本文整理汇总了C++中CAstStatement::TypeCheck方法的典型用法代码示例。如果您正苦于以下问题:C++ CAstStatement::TypeCheck方法的具体用法?C++ CAstStatement::TypeCheck怎么用?C++ CAstStatement::TypeCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAstStatement
的用法示例。
在下文中一共展示了CAstStatement::TypeCheck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TypeCheck
bool CAstStatIf::TypeCheck(CToken *t, string *msg) const
{
CAstExpression *cond = GetCondition();
bool result = true;
if (!cond->TypeCheck(t, msg)) return false;
if (cond->GetType() != CTypeManager::Get()->GetBool()) {
if (t != NULL) *t = cond->GetToken();
if (msg != NULL) *msg = "boolean expression expected.";
return false;
}
try {
CAstStatement *ifBody = GetIfBody();
CAstStatement *elseBody = GetElseBody();
while (result && (ifBody != NULL)) {
result = ifBody->TypeCheck(t, msg);
ifBody = ifBody->GetNext();
}
while (result && (elseBody != NULL)) {
result = elseBody->TypeCheck(t, msg);
elseBody = elseBody->GetNext();
}
} catch (...) {
result = false;
}
return result;
}
示例2: TypeCheck
bool CAstStatIf::TypeCheck(CToken *t, string *msg) const
{
if(!_cond->TypeCheck(t, msg)) return false; // Do TypeCheck on condition expression
if(!_cond->GetType()->IsBoolean()) {
if(t != NULL) *t = _cond->GetToken();
if(msg != NULL) *msg = "boolean expression expected.";
return false;
}
bool result = true;
CAstStatement *s = _ifBody;
while(result && (s != NULL)) { // Do TypeCheck on all ifBody-statements
result = s->TypeCheck(t, msg);
s = s->GetNext();
}
s = _elseBody;
while(result && (s != NULL)) { // Do TypeCheck on all elseBody-statements
result = s->TypeCheck(t, msg);
s = s->GetNext();
}
return result;
}