本文整理汇总了C++中SyntaxTree::left方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxTree::left方法的具体用法?C++ SyntaxTree::left怎么用?C++ SyntaxTree::left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree::left方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkComparisonConsistency
void Compiler::checkComparisonConsistency(const SyntaxTree& tree) const {
if (tree.left()->type == SyntaxTree::TYPE_NIL ||
tree.right()->type == SyntaxTree::TYPE_NIL)
error(tree.sourceLineNumber, "cannot compare disequality of a nil value.");
else if (tree.left()->type == SyntaxTree::TYPE_BOOLEAN ||
tree.right()->type == SyntaxTree::TYPE_BOOLEAN)
error(tree.sourceLineNumber, "cannot compare disequality of a boolean.");
else if ((tree.left()->type == SyntaxTree::TYPE_NUMBER ||
tree.left()->type == SyntaxTree::TYPE_STRING) && (
tree.right()->type == SyntaxTree::TYPE_NUMBER ||
tree.right()->type == SyntaxTree::TYPE_STRING) &&
tree.left()->type != tree.right()->type)
error(tree.sourceLineNumber, "disequality involves operands of different type.");
}
示例2: compileExpressionNodeChildren
void Compiler::compileExpressionNodeChildren(const SyntaxTree& node, BytecodeWriter& output, location_t target, OpCode op) {
location_t reg, left, right;
reg = (target < 0) ? target : -1;
left = compile(*node.left(), output, reg);
if (reg < 0 && left == reg) {
mnRequiredRegisters.top() = max((int) -reg, (int) mnRequiredRegisters.top());
--reg;
}
right = compile(*node.right(), output, reg);
if (reg < 0 && right == reg)
mnRequiredRegisters.top() = max((int) -reg, (int) mnRequiredRegisters.top());
if (target < 0)
mnRequiredRegisters.top() = max((int) -target, (int) mnRequiredRegisters.top());
if (!mDeclareOnly.top())
output << op << target << left << right;
}
示例3: compile
//.........这里部分代码省略.........
output.set(storeIndex, (index_t) output.getSize());
mActivationFramePointer.push(mNamesStack.size());
mnRequiredRegisters.push(0);
std::list<SyntaxTree*>::const_iterator it;
for (it = tree.getChildren().begin(); it != tree.getChildren().end(); it++) {
if ((*it)->type == SyntaxTree::TYPE_ARGUMENT)
mNamesStack.push_back((*it)->str);
else {// BLOCK
compile(**it, output, target);
output.set(regIndex, mnRequiredRegisters.top());
}
}
// return nil (Rollback)
output << OP_RETURN_NIL;
output.set(jumpPos, (index_t) output.getSize());
while (mNamesStack.size() > mActivationFramePointer.top())
mNamesStack.pop_back();
mnRequiredRegisters.pop();
mActivationFramePointer.pop();
return loc;
}
case SyntaxTree::TYPE_RETURN:
{
if (mDeclareOnly.top()) {
compile(*tree.left(), output, 0);
return target;
}
if (tree.hasChildren()) {
location_t result = compile(*tree.left(), output, target);
output << OP_RETURN << result;
return result;
} else {
output << OP_RETURN_NIL;
return target;
}
}
case SyntaxTree::TYPE_FUNCTION_CALL:
{
if (mDeclareOnly.top()) {
std::list<SyntaxTree*>::const_iterator it;
for (it = tree.getChildren().begin(); it != tree.getChildren().end(); it++)
compile(**it, output, -1);
return target;
}
// Lookup for the callable in the names stack
OpCode callOp = OP_CALL_SF_G;
location_t loc = 0; // useless initialization
HostFunctionGroupID hfgID = 0;
FunctionID fID = 0;
if (findLocalName(tree.str, loc))
callOp = OP_CALL_SF_L;
else {
map<string, location_t>::const_iterator sfit = mScriptFunctionsLocations.find(tree.str);