Examples of JSObjectLiteral


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

  private void defineJsLink() {
    SourceInfo info = jsProgram.createSourceInfoSynthetic(HandleCrossFragmentReferences.class);
    jslink = jsProgram.getScope().declareName("jslink");
    JsVars vars = new JsVars(info);
    JsVar var = new JsVar(info, jslink);
    var.setInitExpr(new JsObjectLiteral(info));
    vars.add(var);
    jsProgram.getFragmentBlock(0).getStatements().add(0, vars);
  }
View Full Code Here

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

      return false;
    }

    private JsObjectLiteral buildJsCastMapLiteral(List<JsExpression> runtimeTypeIdLiterals,
        SourceInfo sourceInfo) {
      JsObjectLiteral objLit = new JsObjectLiteral(sourceInfo);
      objLit.setInternable();
      List<JsPropertyInitializer> propInitializers = objLit.getPropertyInitializers();
      JsNumberLiteral one = new JsNumberLiteral(sourceInfo, 1);
      for (JsExpression runtimeTypeIdLiteral : runtimeTypeIdLiterals) {
        JsPropertyInitializer propInitializer = new JsPropertyInitializer(sourceInfo,
            runtimeTypeIdLiteral, one);
        propInitializers.add(propInitializer);
View Full Code Here

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

      if (castMap != null) {
        JField castableTypeMapField = program.getIndexedField("Object.castableTypeMap");
        JsName castableTypeMapName = names.get(castableTypeMapField);
        if (castableTypeMapName == null) {
          // Was pruned; this compilation must have no dynamic casts.
          return new JsObjectLiteral(SourceOrigin.UNKNOWN);
        }

        accept(castMap);
        return pop();
      }
      return new JsObjectLiteral(SourceOrigin.UNKNOWN);
    }
View Full Code Here

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

            if (init.getType() == program.getJavaScriptObject()) {
              assert init instanceof JMethodCall;
              JMethod meth = ((JMethodCall) init).getTarget();
              // immortal types can only have non-primitive literal initializers of createArray,createObject
              if (meth == createObjMethod) {
                fieldVar.setInitExpr(new JsObjectLiteral(init.getSourceInfo()));
              } else if (meth == createArrMethod) {
                fieldVar.setInitExpr(new JsArrayLiteral(init.getSourceInfo()));
              } else {
                assert false : "Illegal initializer expression for immortal field " + field;
              }
View Full Code Here

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

          // so write foo.bar.Baz = foo.bar.Baz || {}
          if (x.getEnclosingType() != null) {
            JsNameRef lhs = getExportLhsQualifier(x, x.getQualifiedExportName());
            JsNameRef rhsRef = getExportLhsQualifier(x, x.getQualifiedExportName());
            globalStmts.add(createAssignment(lhs, new JsBinaryOperation(x.getSourceInfo(),
                JsBinaryOperator.OR, rhsRef, new JsObjectLiteral(x.getSourceInfo()))).makeStmt());
          }
        }

        lastProvidedNamespace = exportNamespacePair.getLeft();
      }
View Full Code Here

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

    return new JsNumberLiteral(makeSourceInfo(numberNode),
        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

      stack.push(x);
    }

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

      int size = x.getPropertyInitializers().size();
      if (x.isInternable()) {
        toReturn.setInternable();
      }

      while (size-- > 0) {
        /*
         * JsPropertyInitializers are the only non-JsExpression objects that we
View Full Code Here

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

  private List<JsStatement> createNamespaceInitializers(Collection<JsName> namespaces) {
    // Let's list them vertically for readability.
    List<JsStatement> inits = Lists.newArrayList();
    for (JsName name : namespaces) {
      JsVar var = new JsVar(SourceOrigin.UNKNOWN, name);
      var.setInitExpr(new JsObjectLiteral(SourceOrigin.UNKNOWN));
      JsVars vars = new JsVars(SourceOrigin.UNKNOWN);
      vars.add(var);
      inits.add(vars);
    }
    return inits;
View Full Code Here

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

  @Override
  public void endVisit(JLongLiteral x, Context ctx) {
    SourceInfo sourceInfo = x.getSourceInfo();
    int[] intArray = LongLib.getAsIntArray(x.getValue());
    JsObjectLiteral objectLit = new JsObjectLiteral(sourceInfo);
    List<JsPropertyInitializer> inits = objectLit.getPropertyInitializers();
    JsExpression label0 = new JsNameRef(sourceInfo, "l");
    JsExpression label1 = new JsNameRef(sourceInfo, "m");
    JsExpression label2 = new JsNameRef(sourceInfo, "h");
    JsExpression value0 = new JsNumberLiteral(sourceInfo, intArray[0]);
    JsExpression value1 = new JsNumberLiteral(sourceInfo, intArray[1]);
View Full Code Here

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

  private void defineJsLink() {
    SourceInfo info = jsProgram.createSourceInfoSynthetic(HandleCrossFragmentReferences.class);
    jslink = jsProgram.getScope().declareName("jslink");
    JsVars vars = new JsVars(info);
    JsVar var = new JsVar(info, jslink);
    var.setInitExpr(new JsObjectLiteral(info));
    vars.add(var);
    jsProgram.getFragmentBlock(0).getStatements().add(0, vars);
  }
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.