当前位置: 首页>>代码示例>>C++>>正文


C++ SyntaxTree::right方法代码示例

本文整理汇总了C++中SyntaxTree::right方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxTree::right方法的具体用法?C++ SyntaxTree::right怎么用?C++ SyntaxTree::right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyntaxTree的用法示例。


在下文中一共展示了SyntaxTree::right方法的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.");
}
开发者ID:keebus,项目名称:IonScript,代码行数:14,代码来源:Compiler.cpp

示例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;
}
开发者ID:keebus,项目名称:IonScript,代码行数:22,代码来源:Compiler.cpp

示例3: compile


//.........这里部分代码省略.........
      }

      case SyntaxTree::TYPE_LIST:
      {
         output << OP_LIST_NEW << target;
         std::list<SyntaxTree*>::const_iterator it;
         location_t reg = (target < 0) ? target - 1 : -1;
         for (it = tree.getChildren().begin(); it != tree.getChildren().end(); it++) {
            location_t result = compile(**it, output, reg);
            output << OP_LIST_ADD << target << result;

            if (result < 0)
               max((int) -result, (int) mnRequiredRegisters.top());
         }

         return target;
      }

      case SyntaxTree::TYPE_DICTIONARY:
      {
         output << OP_DICTIONARY_NEW << target;
         std::list<SyntaxTree*>::const_iterator it;

         for (it = tree.getChildren().begin(); it != tree.getChildren().end(); it++) {

            location_t reg = (target < 0) ? target - 1 : -1;

            location_t index = compile(*(*it)->left(), output, reg);

            if (reg < 0 && index == reg) {
               mnRequiredRegisters.top() = max((int) -reg, (int) mnRequiredRegisters.top());
               --reg;
            }
            location_t value = compile(*(*it)->right(), output, reg);

            if (reg < 0 && value == reg)
               mnRequiredRegisters.top() = max((int) -reg, (int) mnRequiredRegisters.top());

            mnRequiredRegisters.top() = max((int) mnRequiredRegisters.top(), (int) -reg);

            output << OP_DICTIONARY_ADD << target << index << value;
         }

         return target;
      }

      case SyntaxTree::TYPE_CONTAINER_ELEMENT:
      {
         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;
         }

         location_t reg = (target < 0) ? target : -1;
         location_t listLoc = compile(*tree.left(), output, reg);
         if (listLoc == reg)
            reg--;
         location_t indexLoc = compile(*tree.right(), output, reg);

         output << OP_GET << target << listLoc << indexLoc;
         return target;
      }

      case SyntaxTree::TYPE_ASSIGNEMENT:
开发者ID:keebus,项目名称:IonScript,代码行数:67,代码来源:Compiler.cpp


注:本文中的SyntaxTree::right方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。