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

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


        System.out.println("|                     (new permuation)                     |");
        System.out.println("------------------------------------------------------------");
      }

      AST ast = unifiedAst.getFreshAst();
      JProgram jprogram = ast.getJProgram();
      JsProgram jsProgram = ast.getJsProgram();
      JJSOptions options = unifiedAst.getOptions();
      Map<StandardSymbolData, JsName> symbolTable = new TreeMap<StandardSymbolData, JsName>(
          new SymbolData.ClassIdentComparator());
View Full Code Here


    checkForErrors(logger, goldenCuds, false);

    PerfLogger.start("Build AST");
    CorrelationFactory correlator = options.isSoycExtra()
        ? new RealCorrelationFactory() : new DummyCorrelationFactory();
    JProgram jprogram = new JProgram(correlator);
    JsProgram jsProgram = new JsProgram(correlator);

    try {
      /*
       * (1) Build a flattened map of TypeDeclarations => JType. The resulting
View Full Code Here

      //

      // Note that all reference types (even nested and local ones) are in the
      // resulting type map. BuildTypeMap also parses all JSNI.
      //
      JProgram jprogram = new JProgram(logger, rebindOracle);
      TypeMap typeMap = new TypeMap(jprogram);
      JsProgram jsProgram = new JsProgram();
      TypeDeclaration[] allTypeDeclarations = BuildTypeMap.exec(typeMap,
          goldenCuds, jsProgram);
View Full Code Here

   *
   * @throws IllegalArgumentException if the type of the object does not have a java literal form.
   */
  public static String asLiteral(Object value) throws IllegalArgumentException {
    Class<?> clazz = value.getClass();
    JProgram jProgram = new JProgram();

    if (clazz.isArray()) {
      StringBuilder sb = new StringBuilder();
      Object[] array = (Object[]) value;

      sb.append("new " + clazz.getComponentType().getCanonicalName() + "[] ");
      sb.append("{");
      boolean first = true;
      for (Object object : array) {
        if (first) {
          first = false;
        } else {
          sb.append(",");
        }
        sb.append(asLiteral(object));
      }
      sb.append("}");
      return sb.toString();
    }

    if (value instanceof Boolean) {
      return jProgram.getLiteralBoolean(((Boolean) value).booleanValue())
          .toSource();
    } else if (value instanceof Byte) {
      return jProgram.getLiteralInt(((Byte) value).byteValue()).toSource();
    } else if (value instanceof Character) {
      return jProgram.getLiteralChar(((Character) value).charValue())
          .toSource();
    } else if (value instanceof Class<?>) {
      return ((Class<?>) ((Class<?>) value)).getCanonicalName() + ".class";
    } else if (value instanceof Double) {
      return jProgram.getLiteralDouble(((Double) value).doubleValue())
          .toSource();
    } else if (value instanceof Enum) {
      return value.getClass().getCanonicalName() + "."
          + ((Enum<?>) value).name();
    } else if (value instanceof Float) {
      return jProgram.getLiteralFloat(((Float) value).floatValue()).toSource();
    } else if (value instanceof Integer) {
      return jProgram.getLiteralInt(((Integer) value).intValue()).toSource();
    } else if (value instanceof Long) {
      return jProgram.getLiteralLong(((Long) value).intValue()).toSource();
    } else if (value instanceof String) {
      return '"' + Generator.escape((String) value) + '"';
    } else {
      // TODO(nchalko) handle Annotation types
      throw new IllegalArgumentException(value.getClass()
View Full Code Here

      // Library construction does not need to care whether their are or are not any entry points.
    }

    @Override
    protected void createJProgram() {
      jprogram = new JProgram(false);
    }
View Full Code Here

      public StandardGeneratorContext getGeneratorContext() {
        return null;
      }
    };

    JProgram jprogram = new JProgram();
    JsProgram jsProgram = new JsProgram();
    UnifyAst unifyAst = new UnifyAst(logger, compilerContext, jprogram, jsProgram, rpo);
    unifyAst.buildEverything();

    // Compute all super type/sub type info
View Full Code Here

      }
    }

    @Override
    protected void createJProgram() {
      jprogram = new JProgram();
    }
View Full Code Here

   */
  public String compile(TreeLogger logger, RebindOracle rebindOracle, final PropertyOracle propertyOracle ) throws UnableToCompleteException {

    try {

      JProgram jprogram = new JProgram(logger, rebindOracle);
      JsProgram jsProgram = new JsProgram();

      if (JProgram.isTracingEnabled()) {
        System.out.println("------------------------------------------------------------");
        System.out.println("|                     (new permuation)                     |");
        System.out.println("------------------------------------------------------------");
      }

      {
        /*
         * (1) Build a flattened map of TypeDeclarations => JType. The resulting
         * map contains entries for all reference types. BuildTypeMap also
         * parses all JSNI.
         */
        TypeMap typeMap = new TypeMap(jprogram);
        TypeDeclaration[] allTypeDeclarations = BuildTypeMap.exec(typeMap,
            goldenCuds, jsProgram);

        // BuildTypeMap can uncover syntactic JSNI errors; report & abort
        checkForErrors(logger, true);

        // Compute all super type/sub type info
        jprogram.typeOracle.computeBeforeAST();

        // (2) Create our own Java AST from the JDT AST.
        GenerateJavaAST.exec(allTypeDeclarations, typeMap, jprogram, jsProgram,
            options.isEnableAssertions());

        // GenerateJavaAST can uncover semantic JSNI errors; report & abort
        checkForErrors(logger, true);

        // Enable GC.
        typeMap = null;
        allTypeDeclarations = null;
      }

      // (3) Perform Java AST normalizations.
      FixAssignmentToUnbox.exec(jprogram);

      /*
       * TODO: If we defer this until later, we could maybe use the results of
       * the assertions to enable more optimizations.
       */
      if (options.isEnableAssertions()) {
        // Turn into assertion checking calls.
        AssertionNormalizer.exec(jprogram);
      } else {
        // Remove all assert statements.
        AssertionRemover.exec(jprogram);
      }

      // ROCKET reapply changes when upgrading
    final LoggerOptimiser loggerOptimiser = this.getLoggerOptimiser(jprogram, propertyOracle, logger);
    loggerOptimiser.execute();     
     
      // Resolve all rebinds through GWT.create().
      ReplaceRebinds.exec(jprogram);

      if (options.isValidateOnly()) {
        // That's it, we're done.
        return null;
      }

      // Also rebind all non-static entry points.
      findEntryPoints(logger, rebindOracle, declEntryPoints, jprogram);

      // Replace references to JSO subtypes with JSO itself.
      JavaScriptObjectNormalizer.exec(jprogram);

      /*
       * Record the beginning of optimations; this turns on certain checks that
       * guard against problematic late construction of things like class
       * literals.
       */
      jprogram.beginOptimizations();

      // (4) Optimize the normalized Java AST
      boolean didChange;
      do {
        // Recompute clinits each time, they can become empty.
View Full Code Here

    final JClassType logger = this.getNoneLevelLogger();
    final JMethod loggerConstructor = this.findLevelLoggerConstructorMethod(logger);
    log("loggerConstructor -> " + loggerConstructor);

    // inserts a new xxxLevelLogger( Logger )
    final JProgram program = this.getProgram();
    final JNewInstance noneLevelLogger = new JNewInstance(program, methodCall.getSourceInfo(), logger);
    JMethodCall call = new JMethodCall(program, methodCall.getSourceInfo(), noneLevelLogger, loggerConstructor);

    context.replaceMe(call);
  }
View Full Code Here

    if (null == targetLoggerConstructor) {
      throw new IllegalStateException("Unable to find constructor for type: " + targetLogger);
    }

    // havent built new wrapped expression!
    final JProgram program = this.getProgram();

    final JNewInstance newTargetInstance = new JNewInstance(program, methodCall.getSourceInfo(), targetLogger);
    final JMethodCall callNewTargetInstance = new JMethodCall(program, methodCall.getSourceInfo(), newTargetInstance,
        targetLoggerConstructor);
    callNewTargetInstance.getArgs().add(program.getLiteralString(name));

    // inserts a new xxxLevelLogger( Logger )
    final JNewInstance newLevelLoggerInstance = new JNewInstance(program, methodCall.getSourceInfo(), logger);
    JMethodCall call = new JMethodCall(program, methodCall.getSourceInfo(), newLevelLoggerInstance, loggerConstructor);
    call.getArgs().add(callNewTargetInstance);
View Full Code Here

TOP

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

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.