Package org.hisrc.jscm.codemodel

Examples of org.hisrc.jscm.codemodel.JSProgram


  @Test
  public void programsFactorial() throws IOException {
    // Instantiate the code model
    JSCodeModel codeModel = new CodeModelImpl();
    // Create the program
    JSProgram program = codeModel.program();
    // Add a function declaration
    JSFunctionDeclaration factorial = program
        .functionDeclaration("factorial");
    // Add a function parameter
    JSVariable x = factorial.parameter("x");
    // Create an integer literal
    JSDecimalIntegerLiteral one = codeModel.integer(1);
View Full Code Here


  public void allExpressions() throws IOException {

    final CodeWriter out = new CodeWriter(System.out);
    JSCodeModel codeModel = new CodeModelImpl();

    JSProgram program = codeModel.program();
   
    program._if(codeModel._boolean(true))._then().block()._return();
    program._if(codeModel._boolean(false))._then().block()._return();
   
    out.program(program);
  }
View Full Code Here

  public void allExpressions() throws IOException {

    final CodeWriter out = new CodeWriter(System.out);
    JSCodeModel codeModel = new CodeModelImpl();

    JSProgram program = codeModel.program();
    JSFunctionDeclaration f = program.functionDeclaration("f");

    JSVariable x = f.parameter("x");
    JSVariable y = f.parameter("y");

    JSFunctionBody body = f.getBody();
View Full Code Here

  public void allExpressions() throws IOException {

    final CodeWriter out = new CodeWriter(System.out);
    JSCodeModel codeModel = new CodeModelImpl();

    JSProgram program = codeModel.program();
    program.empty();
    JSGlobalVariable window = codeModel.globalVariable("window");
    JSGlobalVariable window1 = codeModel.globalVariable("window");
    Assert.assertSame(window, window1);

    JSFunctionDeclaration f = program.functionDeclaration("f");

    JSVariable x = f.parameter("x");
    JSVariable y = f.parameter("y");

    JSFunctionBody body = f.getBody();
View Full Code Here

  private final JSCodeModel codeModel = new CodeModelImpl();

  @Test
  public void programsPrototype() throws IOException {
    JSProgram program = codeModel.program();

    JSGlobalVariable $Object = codeModel.globalVariable("Object");
    JSGlobalVariable $navigator = codeModel.globalVariable("navigator");
    JSGlobalVariable $window = codeModel.globalVariable("window");
    JSGlobalVariable $document = codeModel.globalVariable("document");

    JSObjectLiteral _Prototype = codeModel.object();
    program.var("Prototype", _Prototype);

    {
      _Prototype.append("Version", codeModel.string("1.6.1"));
    }
    {
View Full Code Here

TOP

Related Classes of org.hisrc.jscm.codemodel.JSProgram

Copyright © 2018 www.massapicom. 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.