Examples of FunctionDeclaration


Examples of ast.FunctionDeclaration

 
  /** Generate code for a function call. */
  @Override
  public Value visitCall(Call nd) {
    String calleeName = nd.getCallee().getName();
    FunctionDeclaration calleeDecl = nd.getCallTarget();
    Module calleeModule = calleeDecl.getModule();
    ArrayList<Type> parmTypes = new ArrayList<Type>(calleeDecl.getNumParameter());
    for(Parameter parm : calleeDecl.getParameters())
      parmTypes.add(SootTypeUtil.getSootType(parm.type()));
    Type rettp = SootTypeUtil.getSootType(calleeDecl.getReturnType().getDescriptor());
   
    // compute reference to callee
    SootClass calleeSootClass = fcg.getModuleCodeGenerator().getProgramCodeGenerator().getSootClass(calleeModule);
    SootMethodRef callee = Scene.v().makeMethodRef(calleeSootClass, calleeName, parmTypes, rettp, true);
   
View Full Code Here

Examples of ceylon.language.meta.declaration.FunctionDeclaration

        }
        return result;
    }

    protected FunctionDeclaration makeFunction(Declaration packageOrType, String fn) {
        final FunctionDeclaration result;
        if (packageOrType instanceof Package) {
            result = ((Package)packageOrType).getFunction(fn);
        } else if (packageOrType instanceof ClassOrInterfaceDeclaration) {
            result = ((ClassOrInterfaceDeclaration)packageOrType).<FunctionDeclaration>getMemberDeclaration(FunctionDeclaration.$TypeDescriptor$, fn);
        } else {
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

  }

  public final void testUnmaskableFormals() throws Exception {
    Block b = js(fromString("function NaN(Infinity, arguments) {}"));
    Scope top = fromProgram(b);
    FunctionDeclaration fn = ((FunctionDeclaration) b.children().get(0));
    Scope.fromFunctionConstructor(top, fn.getInitializer());
    assertMessage(
        RewriterMessageType.CANNOT_MASK_IDENTIFIER, MessageLevel.FATAL_ERROR,
        MessagePart.Factory.valueOf("NaN"));
    assertMessage(
        RewriterMessageType.CANNOT_MASK_IDENTIFIER, MessageLevel.FATAL_ERROR,
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

  }

  public final void testUnmaskableFormals() throws Exception {
    Block b = js(fromString("function NaN(Infinity, arguments) {}"));
    Scope top = fromProgram(b);
    FunctionDeclaration fn = ((FunctionDeclaration) b.children().get(0));
    Scope.fromFunctionConstructor(top, fn.getInitializer());
    assertMessage(
        RewriterMessageType.CANNOT_MASK_IDENTIFIER, MessageLevel.FATAL_ERROR,
        MessagePart.Factory.valueOf("NaN"));
    assertMessage(
        RewriterMessageType.CANNOT_MASK_IDENTIFIER, MessageLevel.FATAL_ERROR,
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

                    new Reference(new Identifier(unk, "z")))))));
    checkSucceeds(
        new Block(
            unk,
            Arrays.asList(
                new FunctionDeclaration((FunctionConstructor) fc.clone()))),
        js(fromString(
            ""
            // x and y___ are formals, but z is free to the function.
            + "var dis___ = IMPORTS___;"
            + "{"
            + "  function f(x, y___) {"
            + "    return (x + y___) *"
            + "        (IMPORTS___.z_v___ ?"
            + "        IMPORTS___.z :"
            + "        ___.ri(IMPORTS___, 'z'));"
            + "  }"
            + "  IMPORTS___.w___('f', ___.f(f, 'f'));"
            + "}")));

    SyntheticNodes.s(fc);
    checkSucceeds(
        new Block(
            unk,
            Arrays.asList(
                new FunctionDeclaration((FunctionConstructor) fc.clone()))),
        js(fromString(
            ""
            // x and y___ are formals, but z is free to the function.
            + "var dis___ = IMPORTS___;"
            + "function f(x, y___) {"
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

          reason="function declarations contain function constructors but don't"
              + " have the same discrepencies on IE 6 as function constructors",
          synopsis="")
      public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
        if (node instanceof FunctionDeclaration) {
          FunctionDeclaration decl = ((FunctionDeclaration) node);
          FunctionConstructor ctor = decl.getInitializer();

          Scope s2 = Scope.fromFunctionConstructor(scope, ctor);
          FunctionConstructor rewritten
              = (FunctionConstructor) QuasiBuilder.substV(
                  "function @ident(@formals*) { @stmts*; @body*; }",
                  "ident", ctor.getIdentifier(),
                  "formals", expandAll(
                      new ParseTreeNodeContainer(ctor.getParams()), s2),
                  "stmts", new ParseTreeNodeContainer(s2.getStartStatements()),
                  "body", expandAll(
                      new ParseTreeNodeContainer(ctor.getBody().children()), s2)
                  );
          return new FunctionDeclaration(rewritten);
        }
        return NONE;
      }
    });
    w.addRule(new Rule() {
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

    Block consolidated = new Block();
    MutableParseTreeNode.Mutation mut = consolidated.createMutation();
    FilePosition unk = FilePosition.UNKNOWN;
    for (SafeJsChunk chunk : chunks) {
      Identifier ident = new Identifier(unk, "module");
      mut.appendChild(new FunctionDeclaration(new FunctionConstructor(
          unk, ident, Collections.<FormalParam>emptyList(),
          (Block) chunk.body)));
    }
    mut.execute();
    stripTranslatedCode(consolidated);
View Full Code Here

Examples of com.google.caja.parser.js.FunctionDeclaration

            FunctionConstructor out = (FunctionConstructor) substV(
                "name", rewrittenName,
                "headDecls", optionalDeclarations(headDecls),
                "params", new ParseTreeNodeContainer(newFormals),
                "body", expandAll(bindings.get("body"), newScope));
            return isDeclaration ? new FunctionDeclaration(out) : out;
          }
          return NONE;
        }
      },
View Full Code Here

Examples of com.google.minijoe.compiler.ast.FunctionDeclaration

      return parseStatement();
    }
  }

  private Statement parseFunctionDeclaration() throws CompilerException {
    return new FunctionDeclaration(parseFunctionLiteral(true));
  }
View Full Code Here

Examples of com.google.minijoe.compiler.ast.FunctionDeclaration

    super(name);
  }

  public void testFunctionDeclaration() throws CompilerException {
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "function foo() {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a) {}"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                  new Identifier("b"),
                  new Identifier("c"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a, b, c) {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("a"),
                new Identifier[] {
                },
                new Statement[] {
                  new FunctionDeclaration(
                      new FunctionLiteral(
                          new Identifier("b"),
                          new Identifier[] {
                          },
                          new Statement[] {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.