Example #1
0
File: cfg.cpp Project: cmj0121/Zerg
size_t CFG::_varcnt_(void) {
	size_t cnt = 0;

	for (ssize_t i = 0; i < this->length(); ++i) {
		AST *child = (AST *)this->child(i);

		switch(child->type()) {
			case AST_ASSIGN:
				if (0 != child->length() && 0 == child->child(0)->length()) {
					cnt ++;
				}
				break;
			case AST_FUNC:
				if (0 != child->length() && 0 != child->child(0)->length()) {
					cnt += child->child(0)->child(0)->length();
				}
				break;
			default:
				_D(LOG_DEBUG, "Need NOT count on %s", child->data().c_str());
				break;
		}
	}

	cnt += (NULL == this->nextCFG(true)  ? 0 : this->nextCFG(true)->_varcnt_());
	cnt += (NULL == this->nextCFG(false) ? 0 : this->nextCFG(false)->_varcnt_());

	return cnt;
}