Examples of JsNew


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(names.get(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

      stack.push(toReturn);
    }

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

      List<JsExpression> arguments = toReturn.getArguments();
      for (JsExpression a : x.getArguments()) {
        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

    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

      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

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(names.get(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) {
          if (!x.isJsniReference()) {
            return;
          }

          String ident = x.getIdent();
          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, false);
            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

  private JsNew mapNew(Node newNode) throws JsParserException {
    // Map the constructor expression, which is often just the name of
    // some lambda.
    //
    Node fromCtorExpr = newNode.getFirstChild();
    JsNew newExpr = new JsNew(makeSourceInfo(newNode),
        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

      int size = x.getArguments().size();
      List<JsExpression> arguments = new ArrayList<JsExpression>(size);
      while (size-- > 0) {
        arguments.add(0, stack.pop());
      }
      JsNew toReturn = new JsNew(x.getSourceInfo(), stack.pop());
      toReturn.getArguments().addAll(arguments);
      stack.push(toReturn);
    }
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
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.