Examples of JsExprStmt


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

        }
        JsNameRef fieldRef = typeIdName.makeRef();
        fieldRef.setQualifier(globalTemp.makeRef());
        JsNumberLiteral typeIdLit = jsProgram.getNumberLiteral(typeId);
        JsExpression asg = createAssignment(fieldRef, typeIdLit);
        globalStmts.add(new JsExprStmt(asg));
      }
    }
View Full Code Here

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

        return;
      }
      JsNameRef fieldRef = typeMarkerName.makeRef();
      fieldRef.setQualifier(globalTemp.makeRef());
      JsExpression asg = createAssignment(fieldRef, nullMethodName.makeRef());
      globalStmts.add(new JsExprStmt(asg));
    }
View Full Code Here

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

        if (!method.isStatic() && !method.isAbstract()) {
          JsNameRef lhs = polymorphicNames.get(method).makeRef();
          lhs.setQualifier(globalTemp.makeRef());
          JsNameRef rhs = names.get(method).makeRef();
          JsExpression asg = createAssignment(lhs, rhs);
          globalStmts.add(new JsExprStmt(asg));
        }
      }
    }
View Full Code Here

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

      StringReader sr = new StringReader(syntheticFnHeader + '\n' + jsniCode);
      try {
        // start at -1 to avoid counting our synthetic header
        // TODO: get the character position start correct
        List<JsStatement> result = jsParser.parse(jsProgram.getScope(), sr, -1);
        JsExprStmt jsExprStmt = (JsExprStmt) result.get(0);
        JsFunction jsFunction = (JsFunction) jsExprStmt.getExpression();
        jsFunction.setFromJava(true);
        ((JsniMethodBody) newMethod.getBody()).setFunc(jsFunction);

        // Ensure that we've resolved the parameter and local references within
        // the JSNI method for later pruning.
View Full Code Here

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

  private static JsExpression hoistedExpression(JsProgram program,
      JsStatement statement, List<JsName> localVariableNames) {
    JsExpression expression;
    if (statement instanceof JsExprStmt) {
      // Extract the expression
      JsExprStmt exprStmt = (JsExprStmt) statement;
      expression = exprStmt.getExpression();

    } else if (statement instanceof JsReturn) {
      // Extract the return value
      JsReturn ret = (JsReturn) statement;
      expression = ret.getExpr();
View Full Code Here

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

        /*
         * We can ignore intermediate expressions as long as they have no
         * side-effects.
         */
        if (op.getArg2().hasSideEffects()) {
          statements.add(0, new JsExprStmt(op.getArg2()));
        }

        e = op.getArg1();
      }

      /*
       * We know the return value from the original invocation was ignored, so
       * it may be possible to ignore the final expressions as long as it has no
       * side-effects.
       */
      if (e.hasSideEffects()) {
        statements.add(0, new JsExprStmt(e));
      }

      if (statements.size() == 0) {
        // The expression contained no side effects at all.
        if (ctx.canRemove()) {
View Full Code Here

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

    SourceInfo jsInfo = SourceOrigin.create(jsStartPos, jsEndPos, jsLine,
        info.getFileName());
    try {
      List<JsStatement> result = JsParser.parse(jsInfo, jsProgram.getScope(),
          sr);
      JsExprStmt jsExprStmt = (JsExprStmt) result.get(0);
      return (JsFunction) jsExprStmt.getExpression();
    } catch (IOException e) {
      throw new InternalCompilerException("Internal error parsing JSNI in '"
          + enclosingType + '.' + method.toString() + '\'', e);
    } catch (JsParserException e) {
      int problemCharPos = computeAbsoluteProblemPosition(indexes,
View Full Code Here

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

      String functionSource,
      SourceInfo jsInfo,
      JsProgram jsProgram) throws Exception {
    List<JsStatement> result =
        JsParser.parse(jsInfo, jsProgram.getScope(), new StringReader(functionSource));
    JsExprStmt jsExprStmt = (JsExprStmt) result.get(0);
    JsFunction func = (JsFunction) jsExprStmt.getExpression();
    return func != null ? new JsniMethodImpl(name, func) : null;
  }
View Full Code Here

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

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

      final JConstructor barConstructor = new JConstructor(nullSourceInfo, barType);
      Map<String, JsFunction> functionsByName = new HashMap<String, JsFunction>();
      functionsByName.put("JavaClassHierarchySetupUtil.defineClass",
          new JsFunction(nullSourceInfo, new JsRootScope(), DEFINE_CLASS_FUNCTION_NAME));

      final JsExprStmt defineClassStatement = createDefineClassStatement(barConstructorName);

      JsProgram jsProgram = new JsProgram();
      jsProgram.setIndexedFunctions(functionsByName);
      // Defines the entirety of the JS program being split, to be the one defineClass statement.
      jsProgram.getGlobalBlock().getStatements().add(defineClassStatement);

      JavaToJavaScriptMap map = new MockJavaToJavaScriptMap() {
          @Override
        public JMethod nameToMethod(JsName name) {
          if (name == barConstructorName) {
            // Finds the Bar constructor by name.
            return barConstructor;
          }
          return null;
        }

          @Override
        public JClassType typeForStatement(JsStatement statement) {
          if (statement == defineClassStatement) {
            // Indicates that Bar is the type associated with the defineClass statement.
            return barType;
          }
          return null;
        }
      };
      fragmentExtractor = new FragmentExtractor(null, jsProgram, map);
      constructorLivePredicate = new MockLivenessPredicate() {
          @Override
        public boolean isLive(JDeclaredType type) {
          // Claims that Bar is not made live by the current fragment.
          return false;
        }

          @Override
        public boolean isLive(JMethod method) {
          // Claims that the bar Constructor *is* made live by the current fragment.
          return method == barConstructor;
        }
      };
    }

    List<JsStatement> extractedStatements =
        fragmentExtractor.extractStatements(constructorLivePredicate, new NothingAlivePredicate());

    // Asserts that the single defineClass statement was included in the extraction output.
    assertEquals(1, extractedStatements.size());
    JsStatement defineClassStatement = extractedStatements.get(0);
    assertTrue(defineClassStatement.toString().contains("defineClass"));
  }
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.