Examples of JsNew


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

    return new JsNameRef(makeSourceInfo(node), ident);
  }

  private JsNew mapNew(Node newNode) throws JsParserException {

    JsNew newExpr = new JsNew(makeSourceInfo(newNode));

    // Map the constructor expression, which is often just the name of
    // some lambda.
    //
    Node fromCtorExpr = newNode.getFirstChild();
    newExpr.setConstructorExpression(mapExpression(fromCtorExpr));

    // Iterate over and map the arguments.
    //
    List<JsExpression> args = newExpr.getArguments();
    Node fromArg = fromCtorExpr.getNext();
    while (fromArg != null) {
      args.add(mapExpression(fromArg));
      fromArg = fromArg.getNext();
    }
View Full Code Here

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

      stack.push(toReturn);
    }

    @Override
    public void endVisit(JsNew x, JsContext<JsExpression> ctx) {
      JsNew toReturn = new JsNew(x.getSourceInfo());

      List<JsExpression> arguments = toReturn.getArguments();
      int size = x.getArguments().size();
      while (size-- > 0) {
        arguments.add(0, stack.pop());
      }
      toReturn.setConstructorExpression(stack.pop());
      stack.push(toReturn);
    }
View Full Code Here

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

      throw new InternalCompilerException("Should not get here.");
    }

    @Override
    public void endVisit(JNewInstance x, Context ctx) {
      JsNew newOp = new JsNew(x.getSourceInfo());
      JsNameRef nameRef = names.get(x.getType()).makeRef(x.getSourceInfo());
      newOp.setConstructorExpression(nameRef);
      push(newOp);
    }
View Full Code Here

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

        // _ = com_example_foo_Foo.prototype = new com_example_foo_FooSuper();
        JsNameRef lhs = prototype.makeRef(sourceInfo);
        lhs.setQualifier(seedFuncName.makeRef(sourceInfo));
        JsExpression rhs;
        if (x.getSuperClass() != null) {
          JsNew newExpr = new JsNew(sourceInfo);
          JsNameRef superPrototypeRef = names.get(x.getSuperClass()).makeRef(
              sourceInfo);
          newExpr.setConstructorExpression(superPrototypeRef);
          rhs = newExpr;
        } else {
          rhs = new JsObjectLiteral(sourceInfo);
        }
        JsExpression protoAsg = createAssignment(lhs, rhs);
View Full Code Here

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

      throw new InternalCompilerException("Should not get here.");
    }

    // @Override
    public void endVisit(JNewInstance x, Context ctx) {
      JsNew newOp = new JsNew();
      JsNameRef nameRef = getName(x.getType()).makeRef();
      newOp.setConstructorExpression(nameRef);
      push(newOp);
    }
View Full Code Here

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

        // _ = com_example_foo_Foo.prototype = new com_example_foo_FooSuper();
        JsNameRef lhs = prototype.makeRef();
        lhs.setQualifier(seedFuncName.makeRef());
        JsExpression rhs;
        if (x.extnds != null) {
          JsNew newExpr = new JsNew();
          newExpr.setConstructorExpression(getName(x.extnds).makeRef());
          rhs = newExpr;
        } else {
          rhs = new JsObjectLiteral();
        }
        JsExpression protoAsg = createAssignment(lhs, rhs);
View Full Code Here

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

    }

    @Override
    public void endVisit(JNewInstance x, Context ctx) {
      JsNameRef nameRef = names.get(x.getTarget()).makeRef(x.getSourceInfo());
      JsNew newOp = new JsNew(x.getSourceInfo(), nameRef);
      popList(newOp.getArguments(), x.getArgs().size()); // args
      push(newOp);
    }
View Full Code Here

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

              assert node instanceof JConstructor;
              assert ref.getQualifier() == null;
              JsName jsName = names.get(node);
              assert (jsName != null);
              ref.resolve(jsName);
              JsNew jsNew = new JsNew(x.getSourceInfo(), ref);
              jsNew.getArguments().addAll(x.getArguments());
              ctx.replaceMe(jsNew);
            }
          }
        }

        @Override
        public void endVisit(JsNameRef x, JsContext ctx) {
          String ident = x.getIdent();
          if (isJsniIdent(ident)) {
            JNode node = jsniMap.get(ident);
            assert (node != null);
            if (node instanceof JField) {
              JField field = (JField) node;
              JsName jsName = names.get(field);
              assert (jsName != null);
              x.resolve(jsName);

              // See if we need to add a clinit call to a static field ref
              JsInvocation clinitCall = maybeCreateClinitCall(field);
              if (clinitCall != null) {
                JsExpression commaExpr = createCommaExpression(clinitCall, x);
                ctx.replaceMe(commaExpr);
              }
            } else if (node instanceof JConstructor) {
              if (x == dontReplaceCtor) {
                // Do nothing, parent will handle.
              } else {
                // Replace with a local closure function.
                // function(a,b,c){return new Obj(a,b,c);}
                JConstructor ctor = (JConstructor) node;
                JsName jsName = names.get(ctor);
                assert (jsName != null);
                x.resolve(jsName);
                SourceInfo info = x.getSourceInfo();
                JsFunction closureFunc = new JsFunction(info, jsFunc.getScope());
                for (JParameter p : ctor.getParams()) {
                  JsName name = closureFunc.getScope().declareName(p.getName());
                  closureFunc.getParameters().add(new JsParameter(info, name));
                }
                JsNew jsNew = new JsNew(info, x);
                for (JsParameter p : closureFunc.getParameters()) {
                  jsNew.getArguments().add(p.getName().makeRef(info));
                }
                JsBlock block = new JsBlock(info);
                block.getStatements().add(new JsReturn(info, jsNew));
                closureFunc.setBody(block);
                ctx.replaceMe(closureFunc);
View Full Code Here

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

    return new JsNameRef(ident);
  }

  private JsNew mapNew(Node newNode) throws JsParserException {

    JsNew newExpr = new JsNew();

    // Map the constructor expression, which is often just the name of
    // some lambda.
    //
    Node fromCtorExpr = newNode.getFirstChild();
    newExpr.setConstructorExpression(mapExpression(fromCtorExpr));

    // Iterate over and map the arguments.
    //
    List<JsExpression> args = newExpr.getArguments();
    Node fromArg = fromCtorExpr.getNext();
    while (fromArg != null) {
      args.add(mapExpression(fromArg));
      fromArg = fromArg.getNext();
    }
View Full Code Here

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

      throw new InternalCompilerException("Should not get here.");
    }

    @Override
    public void endVisit(JNewInstance x, Context ctx) {
      JsNew newOp = new JsNew();
      JsNameRef nameRef = names.get(x.getType()).makeRef();
      newOp.setConstructorExpression(nameRef);
      push(newOp);
    }
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.