Examples of JsObjectLiteral


Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

  private JsExpression mapNumber(Node numberNode) {
    return program.getNumberLiteral(numberNode.getDouble());
  }

  private JsExpression mapObjectLit(Node objLitNode) throws JsParserException {
    JsObjectLiteral toLit = new JsObjectLiteral();
    Node fromPropInit = objLitNode.getFirstChild();
    while (fromPropInit != null) {

      Node fromLabelExpr = fromPropInit;
      JsExpression toLabelExpr = mapExpression(fromLabelExpr);

      // Advance to the initializer expression.
      //
      fromPropInit = fromPropInit.getNext();
      Node fromValueExpr = fromPropInit;
      if (fromValueExpr == null) {
        throw createParserException("Expected an init expression for: "
            + toLabelExpr, objLitNode);
      }
      JsExpression toValueExpr = mapExpression(fromValueExpr);

      JsPropertyInitializer toPropInit = new JsPropertyInitializer(toLabelExpr,
          toValueExpr);
      toLit.getPropertyInitializers().add(toPropInit);

      // Begin the next property initializer, if there is one.
      //
      fromPropInit = fromPropInit.getNext();
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

      push(jsArrayLiteral);
    }

    @Override
    public void endVisit(JsonObject x, Context ctx) {
      JsObjectLiteral jsObjectLiteral = new JsObjectLiteral();
      popList(jsObjectLiteral.getPropertyInitializers(), x.propInits.size());
      push(jsObjectLiteral);
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

        if (x.extnds != null) {
          JsNew newExpr = new JsNew();
          newExpr.setConstructorExpression(names.get(x.extnds).makeRef());
          rhs = newExpr;
        } else {
          rhs = new JsObjectLiteral();
        }
        JsExpression protoAsg = createAssignment(lhs, rhs);
        JsExpression tmpAsg = createAssignment(globalTemp.makeRef(), protoAsg);
        globalStmts.add(tmpAsg.makeStmt());
      } else {
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

      stack.push(x);
    }

    @Override
    public void endVisit(JsObjectLiteral x, JsContext<JsExpression> ctx) {
      JsObjectLiteral toReturn = new JsObjectLiteral();
      List<JsPropertyInitializer> inits = toReturn.getPropertyInitializers();

      for (JsPropertyInitializer init : x.getPropertyInitializers()) {
        /*
         * JsPropertyInitializers are the only non-JsExpression objects that we
         * care about, so we just go ahead and create the objects in the loop,
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

  private JsExpression mapNumber(Node numberNode) {
    return program.getNumberLiteral(numberNode.getDouble());
  }

  private JsExpression mapObjectLit(Node objLitNode) throws JsParserException {
    JsObjectLiteral toLit = new JsObjectLiteral(makeSourceInfo(objLitNode));
    Node fromPropInit = objLitNode.getFirstChild();
    while (fromPropInit != null) {

      Node fromLabelExpr = fromPropInit;
      JsExpression toLabelExpr = mapExpression(fromLabelExpr);

      // Advance to the initializer expression.
      //
      fromPropInit = fromPropInit.getNext();
      Node fromValueExpr = fromPropInit;
      if (fromValueExpr == null) {
        throw createParserException("Expected an init expression for: "
            + toLabelExpr, objLitNode);
      }
      JsExpression toValueExpr = mapExpression(fromValueExpr);

      JsPropertyInitializer toPropInit = new JsPropertyInitializer(
          makeSourceInfo(fromLabelExpr), toLabelExpr, toValueExpr);
      toLit.getPropertyInitializers().add(toPropInit);

      // Begin the next property initializer, if there is one.
      //
      fromPropInit = fromPropInit.getNext();
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

    for (int i = 1; i < 6; i++) {
      instrumentableLines.put("A.java", i);
      instrumentableLines.put("B.java", i);
    }

    JsObjectLiteral baseline = CoverageInstrumentor.baselineCoverage(program.getSourceInfo(),
        instrumentableLines);
    assertEquals("{'A.java':{1:0, 2:0, 3:0, 4:0, 5:0}, 'B.java':{1:0, 2:0, 3:0, 4:0, 5:0}}",
        baseline.toSource().trim().replaceAll("\\s+", " "));
  }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

    JsNumberLiteral two = new JsNumberLiteral(sourceInfo, 2);
    JsArrayLiteral arrayOneTwoLiteral = new JsArrayLiteral(sourceInfo, one, two);
    JsArrayLiteral arrayOneTwoLiteral2 = new JsArrayLiteral(sourceInfo, one,two);
    JsArrayLiteral arrayTwoOneLiteral = new JsArrayLiteral(sourceInfo, two, one);

    JsObjectLiteral emptyObject = new JsObjectLiteral(sourceInfo);

    assertEquals(arrayOneTwoLiteral, arrayOneTwoLiteral2);
    assertEquals(arrayOneTwoLiteral2, arrayOneTwoLiteral);
    assertFalse(arrayOneTwoLiteral.equals(arrayTwoOneLiteral));
    assertFalse(arrayTwoOneLiteral.equals(arrayOneTwoLiteral2));
    assertFalse(arrayTwoOneLiteral.equals(emptyObject));
    assertFalse(emptyObject.equals(arrayOneTwoLiteral2));
  }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

      push(jsArrayLiteral);
    }

    @Override
    public void endVisit(JsonObject x, Context ctx) {
      JsObjectLiteral jsObjectLiteral = new JsObjectLiteral();
      popList(jsObjectLiteral.getPropertyInitializers(), x.propInits.size());
      push(jsObjectLiteral);
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

        if (x.extnds != null) {
          JsNew newExpr = new JsNew();
          newExpr.setConstructorExpression(names.get(x.extnds).makeRef());
          rhs = newExpr;
        } else {
          rhs = new JsObjectLiteral();
        }
        JsExpression protoAsg = createAssignment(lhs, rhs);
        JsExpression tmpAsg = createAssignment(globalTemp.makeRef(), protoAsg);
        globalStmts.add(tmpAsg.makeStmt());
      } else {
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsObjectLiteral

   * instrumented line.
   */
  @VisibleForTesting
  static JsObjectLiteral baselineCoverage(SourceInfo info,
      Multimap<String, Integer> instrumentableLines) {
    JsObjectLiteral baseline = new JsObjectLiteral(info);
    List<JsPropertyInitializer> properties = baseline.getPropertyInitializers();
    for (String filename : instrumentableLines.keySet()) {
      JsPropertyInitializer pair = new JsPropertyInitializer(info);
      pair.setLabelExpr(new JsStringLiteral(info, filename));
      JsObjectLiteral lines = new JsObjectLiteral(info);
      List<JsPropertyInitializer> coverage = lines.getPropertyInitializers();
      for (int line : instrumentableLines.get(filename)) {
        coverage.add(new JsPropertyInitializer(info,
            new JsNumberLiteral(info, line), new JsNumberLiteral(info, 0)));
      }
      pair.setValueExpr(lines);
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.