Package com.google.gwt.dev.js.ast

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


   */
  private JClassType vtableTypeAssigned(JsStatement stat) {
    if (!(stat instanceof JsExprStmt)) {
      return null;
    }
    JsExprStmt expr = (JsExprStmt) stat;
    if (expr.getExpression() instanceof JsInvocation) {
      // Handle a defineClass call.
      JsInvocation call = (JsInvocation) expr.getExpression();
      if (!(call.getQualifier() instanceof JsNameRef)) {
        return null;
      }
      JsNameRef func = (JsNameRef) call.getQualifier();
      JsFunction defineClassJsFunc =
          jsprogram.getIndexedFunction("JavaClassHierarchySetupUtil.defineClass");
      JsFunction defineClassJsProtoFunc =
          jsprogram.getIndexedFunction(
              "JavaClassHierarchySetupUtil.defineClassWithPrototype");
      if (func.getName() != defineClassJsFunc.getName() && func.getName() !=
          defineClassJsProtoFunc.getName()) {
        return null;
      }
      return map.typeForStatement(stat);
    }

    // Handle String.
    if (!(expr.getExpression() instanceof JsBinaryOperation)) {
      return null;
    }
    JsBinaryOperation binExpr = (JsBinaryOperation) expr.getExpression();
    if (binExpr.getOperator() != JsBinaryOperator.ASG) {
      return null;
    }
    if (!(binExpr.getArg1() instanceof JsNameRef)) {
      return null;
View Full Code Here


        // 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

      // initializers
      JsExpression initExpr = null;
      List<JsExprStmt> initStmts = popList(x.getInitializers().size());
      for (int i = 0; i < initStmts.size(); ++i) {
        JsExprStmt initStmt = initStmts.get(i);
        if (initStmt != null) {
          initExpr = createCommaExpression(initExpr, initStmt.getExpression());
        }
      }
      jsFor.setInitExpr(initExpr);

      push(jsFor);
View Full Code Here

      JsNameRef ctmRef = castableTypeMapName.makeRef(x.getSourceInfo());

      JsExpression castMapLit = generateCastableTypeMap(x);
      JsExpression ctmAsg = createAssignment(ctmRef,
          castMapLit);
      JsExprStmt ctmAsgStmt = ctmAsg.makeStmt();
      globalStmts.add(ctmAsgStmt);
      typeForStatMap.put(ctmAsgStmt, x);
    }
View Full Code Here

        body.getStatements().add(jsReturn);
        rhs.setBody(body);

        // asg
        JsExpression asg = createAssignment(lhs, rhs);
        JsExprStmt stmt = asg.makeStmt();
        globalStmts.add(stmt);
        typeForStatMap.put(stmt, program.getTypeJavaLangObject());
      }
    }
View Full Code Here

    private void generateVTableAssignment(List<JsStatement> globalStmts, JMethod method,
        JsName lhsName, JsExpression rhs) {
      SourceInfo sourceInfo = method.getSourceInfo();
      JsNameRef lhs = lhsName.makeRef(sourceInfo);
      lhs.setQualifier(globalTemp.makeRef(sourceInfo));
      JsExprStmt polyAssignment = createAssignment(lhs, rhs).makeStmt();
      globalStmts.add(polyAssignment);
      vtableInitForMethodMap.put(polyAssignment, method);
    }
View Full Code Here

    private void createAndAddExportAssignment(JClassType x, List<JsStatement> globalStmts, JsNameRef exportRhs,
                                              Pair<String, String> exportNamespacePair) {
      JsNameRef leaf = new JsNameRef(x.getSourceInfo(), exportNamespacePair.getRight());
      leaf.setQualifier(getExportLhsQualifier(x, exportNamespacePair.getLeft()));
      JsExprStmt astStat = new JsExprStmt(x.getSourceInfo(),
           createAssignment(leaf,
               exportRhs));
      globalStmts.add(astStat);
    }
View Full Code Here

        JsName provideFunc = indexedFunctions.get("JavaClassHierarchySetupUtil.provide").getName();
        JsInvocation provideCall = new JsInvocation(x.getSourceInfo());
        provideCall.setQualifier(provideFunc.makeRef(x.getSourceInfo()));
        provideCall.getArguments().add(new JsStringLiteral(x.getSourceInfo(),
            exportNamespacePair.getLeft()));
        JsExprStmt provideStat = createAssignment(globalTemp.makeRef(x.getSourceInfo()),
            provideCall).makeStmt();
        globalStmts.add(provideStat);
        lastProvidedNamespace = exportNamespacePair.getLeft();
      }
      return lastProvidedNamespace;
View Full Code Here

    private JsName createGlobalJsFunctionFromSource(String functionName, String code) {
      try {
        List<JsStatement> stmts =
            JsParser.parse(SourceOrigin.UNKNOWN, topScope, new StringReader(code));
        assert stmts.size() == 1;
        JsExprStmt stmt = (JsExprStmt) stmts.get(0);
        JsFunction globalFunction =  (JsFunction) stmt.getExpression();

        assert functionName == globalFunction.getName().getIdent();

        List< JsStatement > globalStmts = jsProgram.getGlobalBlock().getStatements();
        globalStmts.add(0, stmt);
View Full Code Here

              + jsniCode);
          try {
            // start at -1 to avoid counting our synthetic header
            // TODO: get the character position start correct
            JsStatements result = jsParser.parse(jsProgram.getScope(), sr, -1);
            JsExprStmt jsExprStmt = (JsExprStmt) result.get(0);
            JsFunction jsFunction = (JsFunction) jsExprStmt.getExpression();
            ((JsniMethodBody) newMethod.getBody()).setFunc(jsFunction);
          } catch (IOException e) {
            throw new InternalCompilerException(
                "Internal error parsing JSNI in method '" + newMethod
                    + "' in type '" + enclosingType.getName() + "'", e);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.js.ast.JsExprStmt

Copyright © 2018 www.massapicom. 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.