コード例 #1
0
ファイル: RangeIterator.java プロジェクト: peter-maday/patus
  /** @param idLoopIndex */
  public void setLoopIndex(Identifier idLoopIndex) {
    if (idLoopIndex == null) {
      //			VariableDeclarator decl = new VariableDeclarator (new NameID ("i"));
      ////			addDeclaration (new VariableDeclaration (Globals.SPECIFIER_INDEX, decl))
      /// *
      //			Traversable t = this;
      //			while (!(t instanceof SymbolTable))
      //				t = t.getParent ();
      //			((SymbolTable) t).addDeclaration (new VariableDeclaration (Globals.SPECIFIER_INDEX,
      // decl));
      // */
      //			super.addDeclaration (new VariableDeclaration (Globals.SPECIFIER_INDEX, decl));
      //
      //			m_idLoopIndex = SymbolTools.getTemp (new Identifier (decl));

      //			m_idLoopIndex = CodeGeneratorUtil.createIdentifier (Globals.SPECIFIER_INDEX, "i__",
      // RangeIterator.m_nAnonymousLoopsCount++);

      VariableDeclarator decl =
          new VariableDeclarator(
              CodeGeneratorUtil.createNameID("i__", RangeIterator.m_nAnonymousLoopsCount++));
      m_idLoopIndex = new Identifier(decl);
      // TODO: add VariableDeclaration(...)
    } else {
      /*
      m_idLoopIndex = (Identifier) idLoopIndex.clone ();
      if (m_idLoopIndex.getSymbol () == null)
      	addDeclaration (new VariableDeclaration (Globals.SPECIFIER_INDEX, new VariableDeclarator (m_idLoopIndex)));
      */
      m_idLoopIndex = idLoopIndex;
    }

    m_idLoopIndex.setParent(this);
  }
コード例 #2
0
ファイル: Parser.java プロジェクト: peter-maday/patus
  public Expression processFunctionCall(Expression id, List<Expression> listArgs) {
    if (id instanceof NameID) {
      String strFunctionName = ((NameID) id).getName();

      // special function to be replaced with other operations
      if ("mod".equals(strFunctionName)) {
        assertParamCount(2, strFunctionName, listArgs);
        return new BinaryExpression(listArgs.get(0), BinaryOperator.MODULUS, listArgs.get(1));
      }
      if ("floor".equals(strFunctionName)) {
        assertParamCount(1, strFunctionName, listArgs);
        return new Typecast(CodeGeneratorUtil.specifiers(Globals.SPECIFIER_INDEX), listArgs.get(0));
      }

      // function names to replace
      if ("ceiling".equals(strFunctionName)) id = new NameID("ceil");

      return new FunctionCall(id, listArgs);
    }

    return id;
  }