本文整理汇总了C++中ExpressionNode::getIsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionNode::getIsArray方法的具体用法?C++ ExpressionNode::getIsArray怎么用?C++ ExpressionNode::getIsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionNode
的用法示例。
在下文中一共展示了ExpressionNode::getIsArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScopeAndType
void ExpressionNode::ScopeAndType(ostream &out, int &numErrors) {
DeclarationNode *dPtr, *paramPtr, *tempdPtr;
ExpressionNode *argPtr;
int argCounter;
Types lhs_type, rhs_type, lhs_decl, rhs_decl, returnType;
bool isUnary, lhs_isArray, rhs_isArray, foundError;
lhs_type = rhs_type = lhs_decl = rhs_decl = returnType = Undefined; // initialize types to undefined
lhs_isArray = rhs_isArray = foundError = false; // initialize booleans to false
isUnary = true;
string nameToLookup;
switch (subKind) {
case AssignK:
op = "="; // populate the op for assignments with "=" to make Op logic work properly
// intentionally drop through to OpK case...
case OpK:
if (child[0] != NULL) {
child[0]->ScopeAndType(out, numErrors);
lhs_type = ((ExpressionNode *)child[0])->type; // grab lhs type
lhs_isArray = child[0]->getIsArray();
}
if (child[1] != NULL) {
isUnary = false;
child[1]->ScopeAndType(out, numErrors);
rhs_type = ((ExpressionNode *)child[1])->type; // grab lhs type
rhs_isArray = child[1]->getIsArray();
}
lookupTypes(op, lhs_decl, rhs_decl, returnType); // populate the last three variable from the function
//DEBUG
/*if (lineNumber == 26) {
cerr << "op: " << op << "\nlhs_decl: " << PrintType(lhs_decl) << " lhs_type: "
<< PrintType(lhs_type) << "\nrhs_decl: " << PrintType(rhs_decl)
<< " rhs_type: " << PrintType(rhs_type) << "\nlhs_isArray: "
<< boolalpha << lhs_isArray << "\nrhs_isArray: " << rhs_isArray
<< noboolalpha << endl;
}*/
//DEBUG
// unary ops
if (isUnary && lhs_type != Error) {
//check for arrays
if (lhs_isArray) {
++numErrors;
foundError = true;
// Unary operator array check error
PrintError(out, 16, lineNumber, op, "", "", 0, 0);
}
else if (lhs_type != lhs_decl) { // do type check on unary op
++numErrors;
foundError = true;
// Unary operator type check error
PrintError(out, 17, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0);
}
}
// binary ops
else if (!isUnary) {
// check for arrays
if (lhs_type != Error && rhs_type != Error && (lhs_isArray || rhs_isArray)) {
++numErrors;
foundError = true;
// binary operator array check error
PrintError(out, 16, lineNumber, op, "", "", 0, 0);
}
// check for binary ops that can process different types as long as they are the same
else if (lhs_type != Error && rhs_type != Error && lhs_decl == Undefined && rhs_decl == Undefined && lhs_type != rhs_type) {
++numErrors;
foundError = true;
// same type required check error
PrintError(out, 1, lineNumber, op, PrintType(lhs_type), PrintType(rhs_type), 0, 0);
}
// do type check for strict binary operators
/*else {
if (lhs_type != Error && lhs_decl != Undefined && lhs_decl != lhs_type) {
++numErrors;
foundError = true;
// binary lhs type check error
PrintError(out, 2, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0);
}
if (rhs_type != Error && rhs_decl != Undefined && rhs_decl != rhs_type) {
++numErrors;
foundError = true;
// binary rhs type check error
PrintError(out, 3, lineNumber, op, PrintType(rhs_decl), PrintType(rhs_type), 0, 0);
}
}*/
else if (lhs_type != Error && rhs_type != Error) {
if (lhs_decl != Undefined && lhs_decl != lhs_type) {
++numErrors;
foundError = true;
// binary lhs type check error
PrintError(out, 2, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0);
}
if (rhs_decl != Undefined && rhs_decl != rhs_type) {
++numErrors;
foundError = true;
// binary rhs type check error
//.........这里部分代码省略.........