Examples of FunctionLiteral


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

      statementVector.addElement(parseSourceElement());
    }

    readToken(Token.OPERATOR_CLOSEBRACE);

    return new FunctionLiteral(name,
        Util.vectorToIdentifierArray(parameterVector),
        Util.vectorToStatementArray(statementVector)
    );
  }
View Full Code Here

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

  }

  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[] {
                            new IfStatement(
                                new NumberLiteral(0.0),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        new Identifier("c"),
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
                                    )
                                ),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        null,
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
View Full Code Here

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

    // we're need to put the function literals in parenthesis to ensure that
    // they're parsed as function expressions and not function declarations.

    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                null,
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function () {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function foo() {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "(function foo(a) {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            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 ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                    new Identifier("a"),
                    new Identifier("b"),
                    new Identifier("c"),
View Full Code Here

Examples of org.lilystudio.javascript.expression.FunctionLiteral

    case Token.HOOK:
      return new ConditionalExpression(node, root, scope);

    case Token.FUNCTION:
      return new FunctionLiteral(node, root, scope);

    default:
      throw new RuntimeException(node.getType() + "");
    }
  }
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.