Examples of JsNameRef


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

        push(null);
        return;
      }

      JsExpression initializer = (JsExpression) pop(); // initializer
      JsNameRef localRef = (JsNameRef) pop(); // localRef

      JVariable target = x.getVariableRef().getTarget();
      if (target instanceof JField
          && ((JField) target).getLiteralInitializer() != null) {
        // Will initialize at top scope; no need to double-initialize.
View Full Code Here

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

        var.setInitExpr(rhs);
        push(var);
      } else {
        // for non-statics, only setup an assignment if needed
        if (rhs != null) {
          JsNameRef fieldRef = name.makeRef(x.getSourceInfo());
          fieldRef.setQualifier(globalTemp.makeRef(x.getSourceInfo()));
          JsExpression asg = createAssignment(fieldRef, rhs);
          push(new JsExprStmt(x.getSourceInfo(), asg));
        } else {
          push(null);
        }
View Full Code Here

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

    @Override
    public void endVisit(JFieldRef x, Context ctx) {
      JField field = x.getField();
      JsName jsFieldName = names.get(field);
      JsNameRef nameRef = jsFieldName.makeRef(x.getSourceInfo());
      JsExpression curExpr = nameRef;

      /*
       * Note: the comma expressions here would cause an illegal tree state if
       * the result expression ended up on the lhs of an assignment. A hack in
       * in endVisit(JBinaryOperation) rectifies the situation.
       */

      // See if we need a clinit
      JsInvocation jsInvocation = maybeCreateClinitCall(field);
      if (jsInvocation != null) {
        curExpr = createCommaExpression(jsInvocation, curExpr);
      }

      if (x.getInstance() != null) {
        JsExpression qualifier = (JsExpression) pop();
        if (field.isStatic()) {
          // unnecessary qualifier, create a comma expression
          curExpr = createCommaExpression(qualifier, curExpr);
        } else {
          // necessary qualifier, qualify the name ref
          nameRef.setQualifier(qualifier);
        }
      }

      push(curExpr);
    }
View Full Code Here

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

      JMethod method = x.getTarget();
      JsInvocation jsInvocation = new JsInvocation(x.getSourceInfo());

      popList(jsInvocation.getArguments(), x.getArgs().size()); // args

      JsNameRef qualifier;
      JsExpression unnecessaryQualifier = null;
      if (method.isStatic()) {
        if (x.getInstance() != null) {
          unnecessaryQualifier = (JsExpression) pop(); // instance
        }
        qualifier = names.get(method).makeRef(x.getSourceInfo());
      } else {
        if (x.isStaticDispatchOnly()) {
          /*
           * Dispatch statically (odd case). This happens when a call that must
           * be static is targeting an instance method that could not be
           * transformed into a static. For example, making a super call into a
           * native method currently causes this, because we cannot currently
           * staticify native methods.
           *
           * Have to use a "call" construct.
           */
          JsName callName = objectScope.declareName("call");
          callName.setObfuscatable(false);
          qualifier = callName.makeRef(x.getSourceInfo());
          qualifier.setQualifier(names.get(method).makeRef(x.getSourceInfo()));
          jsInvocation.getArguments().add(0, (JsExpression) pop()); // instance
        } else {
          // Dispatch polymorphically (normal case).
          qualifier = polymorphicNames.get(method).makeRef(x.getSourceInfo());
          qualifier.setQualifier((JsExpression) pop()); // instance
        }
      }
      jsInvocation.setQualifier(qualifier);
      push(createCommaExpression(unnecessaryQualifier, jsInvocation));
    }
View Full Code Here

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

    }

    @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.JsNameRef

    }

    @Override
    public void endVisit(JsniMethodRef x, Context ctx) {
      JMethod method = x.getTarget();
      JsNameRef nameRef = names.get(method).makeRef(x.getSourceInfo());
      push(nameRef);
    }
View Full Code Here

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

        globalStmts.add(seedFuncStmt);
        typeForStatMap.put(seedFuncStmt, x);

        // setup prototype, assign to temp
        // _ = 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);
        JsExpression tmpAsg = createAssignment(globalTemp.makeRef(sourceInfo),
            protoAsg);
        JsExprStmt tmpAsgStmt = tmpAsg.makeStmt();
        globalStmts.add(tmpAsgStmt);
        typeForStatMap.put(tmpAsgStmt, x);
      } else {
        /*
         * MAGIC: java.lang.String is implemented as a JavaScript String
         * primitive with a modified prototype.
         */
        JsNameRef rhs = prototype.makeRef(sourceInfo);
        rhs.setQualifier(jsProgram.getRootScope().declareName("String").makeRef(
            sourceInfo));
        JsExpression tmpAsg = createAssignment(globalTemp.makeRef(sourceInfo),
            rhs);
        JsExprStmt tmpAsgStmt = tmpAsg.makeStmt();
        globalStmts.add(tmpAsgStmt);
View Full Code Here

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

        // _.toString = function(){return this.java_lang_Object_toString();}

        // lhs
        JsName lhsName = objectScope.declareName("toString");
        lhsName.setObfuscatable(false);
        JsNameRef lhs = lhsName.makeRef(sourceInfo);
        lhs.setQualifier(globalTemp.makeRef(sourceInfo));

        // rhs
        JsInvocation call = new JsInvocation(sourceInfo);
        JsNameRef toStringRef = new JsNameRef(sourceInfo,
            polymorphicNames.get(toStringMeth));
        toStringRef.setQualifier(new JsThisRef(sourceInfo));
        call.setQualifier(toStringRef);
        JsReturn jsReturn = new JsReturn(sourceInfo, call);
        JsFunction rhs = new JsFunction(sourceInfo, topScope);
        JsBlock body = new JsBlock(sourceInfo);
        body.getStatements().add(jsReturn);
View Full Code Here

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

          // Was pruned; this compilation must have no dynamic casts.
          return;
        }
        SourceInfo sourceInfo = x.getSourceInfo().makeChild(
            GenerateJavaScriptVisitor.class, "Type id assignment");
        JsNameRef fieldRef = typeIdName.makeRef(sourceInfo);
        fieldRef.setQualifier(globalTemp.makeRef(sourceInfo));
        JsNumberLiteral typeIdLit = jsProgram.getNumberLiteral(typeId);
        JsExpression asg = createAssignment(fieldRef, typeIdLit);
        JsExprStmt asgStmt = asg.makeStmt();
        globalStmts.add(asgStmt);
        typeForStatMap.put(asgStmt, x);
View Full Code Here

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

        // Was pruned; this compilation must have no JSO instanceof tests.
        return;
      }
      SourceInfo sourceInfo = jsProgram.createSourceInfoSynthetic(
          GenerateJavaScriptAST.class, "Type marker");
      JsNameRef fieldRef = typeMarkerName.makeRef(sourceInfo);
      fieldRef.setQualifier(globalTemp.makeRef(sourceInfo));
      JsExpression asg = createAssignment(fieldRef,
          nullMethodName.makeRef(sourceInfo));
      JsExprStmt stmt = asg.makeStmt();
      globalStmts.add(stmt);
      typeForStatMap.put(stmt, program.getTypeJavaLangObject());
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.