Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JMethodCall


        throw new UnableToCompleteException();
      }

      JMethod mainMethod = findMainMethod(mainType);
      if (mainMethod != null && mainMethod.isStatic()) {
        JMethodCall onModuleLoadCall = new JMethodCall(info, null, mainMethod);
        block.addStmt(onModuleLoadCall.makeStatement());
        continue;
      }

      // Couldn't find a static main method; must rebind the class
      String[] resultTypeNames = rpo.getAllPossibleRebindAnswers(logger, mainClassName);
      List<JClassType> resultTypes = new ArrayList<JClassType>();
      List<JExpression> entryCalls = new ArrayList<JExpression>();
      for (String resultTypeName : resultTypeNames) {
        JDeclaredType resultType = program.getFromTypeMap(resultTypeName);
        if (resultType == null) {
          logger.log(TreeLogger.ERROR, "Could not find module entry point class '" + resultTypeName
              + "' after rebinding from '" + mainClassName + "'", null);
          throw new UnableToCompleteException();
        }

        JMethodCall onModuleLoadCall =
            createReboundModuleLoad(logger, info, resultType, mainClassName, bootStrapMethod
                .getEnclosingType());
        resultTypes.add((JClassType) resultType);
        entryCalls.add(onModuleLoadCall);
      }
View Full Code Here


   */
  private static JStatement makeStatsCalls(SourceInfo info, JProgram program, String mainClassName) {
    JMethod isStatsAvailableMethod = program.getIndexedMethod("Stats.isStatsAvailable");
    JMethod onModuleStartMethod = program.getIndexedMethod("Stats.onModuleStart");

    JMethodCall availableCall = new JMethodCall(info, null, isStatsAvailableMethod);
    JMethodCall onModuleStartCall = new JMethodCall(info, null, onModuleStartMethod);
    onModuleStartCall.addArg(program.getLiteralString(info, mainClassName));

    JBinaryOperation amp =
        new JBinaryOperation(info, program.getTypePrimitiveBoolean(), JBinaryOperator.AND,
            availableCall, onModuleStartCall);

View Full Code Here

   * If <code>x</code> is an unbox expression, then return the expression that
   * is being unboxed by it. Otherwise, return <code>null</code>.
   */
  public JExpression undoUnbox(JExpression arg) {
    if (arg instanceof JMethodCall) {
      JMethodCall argMethodCall = (JMethodCall) arg;
      if (unboxMethods.contains(argMethodCall.getTarget())) {
        return argMethodCall.getInstance();
      }
    }
    return null;
  }
View Full Code Here

              + wrapperType.getName() + " valueOf(" + primitiveType.getName()
              + ")'", null);
    }

    // Create the boxing call.
    JMethodCall call = new JMethodCall(program, toBox.getSourceInfo(), null,
        valueOfMethod);
    call.getArgs().add(toBox);
    return call;
  }
View Full Code Here

          oldParam.getType(), true, false, newMethod);
    }
    newMethod.freezeParamTypes();

    // Build from bottom up.
    JMethodCall condition = new JMethodCall(program, sourceInfo, null,
        isJavaObjectMethod);
    condition.getArgs().add(new JParameterRef(program, sourceInfo, thisParam));

    JMethodCall thenValue = new JMethodCall(program, sourceInfo,
        new JParameterRef(program, sourceInfo, thisParam), objectMethod);
    for (JParameter param : newMethod.params) {
      if (param != thisParam) {
        thenValue.getArgs().add(new JParameterRef(program, sourceInfo, param));
      }
    }

    JMethodCall elseValue = new JMethodCall(program, sourceInfo, null, jsoImpl);
    for (JParameter param : newMethod.params) {
      elseValue.getArgs().add(new JParameterRef(program, sourceInfo, param));
    }

    JConditional conditional = new JConditional(program, sourceInfo,
        objectMethod.getType(), condition, thenValue, elseValue);
View Full Code Here

          }

          // Construct a new instance of the class to qualify the non-static
          // call
          JNewInstance newInstance = new JNewInstance(program, null, mainClass);
          qualifier = new JMethodCall(program, null, newInstance, noArgCtor);
        }
      }

      // qualifier will be null if onModuleLoad is static
      JMethodCall onModuleLoadCall = new JMethodCall(program, null, qualifier,
          mainMethod);

      body.getStatements().add(makeStatsCalls(program, mainClassName));
      body.getStatements().add(onModuleLoadCall.makeStatement());
    }
    program.addEntryMethod(bootStrapMethod);
  }
View Full Code Here

  private static JStatement makeStatsCalls(JProgram program,
      String mainClassName) {
    JMethod isStatsAvailableMethod = program.getIndexedMethod("Stats.isStatsAvailable");
    JMethod onModuleStartMethod = program.getIndexedMethod("Stats.onModuleStart");

    JMethodCall availableCall = new JMethodCall(program, null, null,
        isStatsAvailableMethod);
    JMethodCall onModuleStartCall = new JMethodCall(program, null, null,
        onModuleStartMethod);
    onModuleStartCall.getArgs().add(program.getLiteralString(mainClassName));

    JBinaryOperation amp = new JBinaryOperation(program, null,
        program.getTypePrimitiveBoolean(), JBinaryOperator.AND, availableCall,
        onModuleStartCall);
View Full Code Here

      JExpression instance = x.getInstance();
      if (instance != null) {
        multi.exprs.add(instance);
      }

      JMethodCall clinit = maybeCreateClinitCall(x);
      if (clinit != null) {
        multi.exprs.add(clinit);
      }

      if (literal != null) {
View Full Code Here

    private Class<?> mapType(JType type) {
      return typeClassMap.get(type);
    }

    private JMethodCall maybeCreateClinitCall(JFieldRef x) {
      JMethodCall call;
      JField field = x.getField();
      if (field.isStatic()
          && !field.isCompileTimeConstant()
          && program.typeOracle.checkClinit(currentClass,
              field.getEnclosingType())) {
        JMethod clinit = field.getEnclosingType().methods.get(0);
        assert (JProgram.isClinit(clinit));
        call = new JMethodCall(program, x.getSourceInfo(), null, clinit);
      } else {
        call = null;
      }
      return call;
    }
View Full Code Here

      // new Foo() : Create the instance
      JNewInstance newInstance = new JNewInstance(program, null, type);

      // (new Foo()).Foo() : Invoke the constructor method on the instance
      JMethodCall call = new JMethodCall(program, null, newInstance,
          constructor);
      List<JExpression> args = call.getArgs();

      /*
       * If the type isn't static, make the first parameter a reference to the
       * instance of the enclosing class. It's the first instance to allow the
       * JSNI qualifier to be moved without affecting evaluation order.
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JMethodCall

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.