Examples of JsName


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

      errCall.getArguments().add(modName.makeRef(sourceInfo));
    }

    private void generateLongLiterals(JsVars vars) {
      for (Entry<Long, JsName> entry : longLits.entrySet()) {
        JsName jsName = entry.getValue();
        JsExpression longObjectAlloc = longObjects.get(jsName);
        JsVar var = new JsVar(vars.getSourceInfo().makeChild(
            GenerateJavaScriptVisitor.class, "Long literal " + entry.getKey()),
            jsName);
        var.setInitExpr(longObjectAlloc);
View Full Code Here

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

    private void generateSeedFuncAndPrototype(JClassType x,
        List<JsStatement> globalStmts) {
      SourceInfo sourceInfo = x.getSourceInfo().makeChild(
          GenerateJavaScriptVisitor.class, "Seed and function prototype");
      if (x != program.getTypeJavaLangString()) {
        JsName seedFuncName = names.get(x);

        // seed function
        // function com_example_foo_Foo() { }
        JsFunction seedFunc = new JsFunction(sourceInfo, topScope,
            seedFuncName, true);
        seedFuncName.setStaticRef(seedFunc);
        JsBlock body = new JsBlock(sourceInfo);
        seedFunc.setBody(body);
        JsExprStmt seedFuncStmt = seedFunc.makeStmt();
        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);
View Full Code Here

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

        SourceInfo sourceInfo = x.getSourceInfo().makeChild(
            GenerateJavaScriptVisitor.class, "_.toString");
        // _.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,
View Full Code Here

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

    private void generateTypeId(JClassType x, List<JsStatement> globalStmts) {
      int typeId = program.getTypeId(x);
      if (typeId >= 0) {
        JField typeIdField = program.getIndexedField("Object.typeId");
        JsName typeIdName = names.get(typeIdField);
        if (typeIdName == null) {
          // 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);
View Full Code Here

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

      }
    }

    private void generateTypeMarker(List<JsStatement> globalStmts) {
      JField typeMarkerField = program.getIndexedField("Object.typeMarker");
      JsName typeMarkerName = names.get(typeMarkerField);
      if (typeMarkerName == null) {
        // 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);
View Full Code Here

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

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

    @Override
    public void endVisit(JClassLiteral x, Context ctx) {
      JsName classLit = names.get(x.getField());
      push(classLit.makeRef(x.getSourceInfo()));
    }
View Full Code Here

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

        globalStmts.add(vars);
      }

      for (JNode node : x.getArtificialRescues()) {
        if (node instanceof JMethod) {
          JsName jsName = names.get(node);
          if (jsName != null) {
            JsFunction func = (JsFunction) jsName.getStaticRef();
            func.setArtificiallyRescued(true);
          }
        }
      }
    }
View Full Code Here

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

      } else {
        // the variable is setup during clinit, no need to initialize here
        push(null);
      }
      JsExpression rhs = (JsExpression) pop();
      JsName name = names.get(x);

      if (x.isStatic()) {
        // setup a var for the static
        JsVar var = new JsVar(x.getSourceInfo(), name);
        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.JsName

    }

    @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
View Full Code Here

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

        nameString = "N" + nameString.substring(1);
      } else {
        nameString = "P" + nameString;
      }
      nameString += "_longLit";
      JsName longLit = topScope.declareName(nameString);
      longLits.put(x.getValue(), longLit);
      longObjects.put(longLit, longLiteralAllocation);
      push(longLit.makeRef(x.getSourceInfo()));
    }
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.