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

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


        List<JExpression> list) {
      LinkedList<JExpression> workList = new LinkedList<JExpression>();
      workList.addAll(list);
      while (!workList.isEmpty()) {
        JExpression expr = workList.removeFirst();
        JClassType classType = (JClassType) expr.getType();
        for (; classType != null; classType = classType.getSuperClass()) {
          // prefer myself or myself-as-supertype over any of my this$ fields
          // that may have already been added to the work list
          if (program.typeOracle.canTriviallyCast(classType, qualType)) {
            return expr;
          }
View Full Code Here


        return new JParameterRef(info, parameter);
      } else if (variable instanceof JField) {
        JField field = (JField) variable;
        JExpression instance = null;
        if (!field.isStatic()) {
          JClassType fieldEnclosingType = (JClassType) field.getEnclosingType();
          instance = createThisRef(info, fieldEnclosingType);
          if (!program.typeOracle.canTriviallyCast(
              (JClassType) instance.getType(), fieldEnclosingType)) {
            throw new InternalCompilerException(
                "FieldRef referencing field in a different type.");
View Full Code Here

    JExpression lhs = x.getLhs();
    JExpression boxed = autoboxUtils.undoUnbox(lhs);
    if (boxed != null) {
      // Assignment-to-unbox, e.g.
      // unbox(x) = foo -> x = box(foo)
      JClassType boxedType = (JClassType) boxed.getType();

      ctx.replaceMe(new JBinaryOperation(x.getSourceInfo(), boxedType,
          JBinaryOperator.ASG, boxed, autoboxUtils.box(x.getRhs(), boxedType)));
      return;
    }
View Full Code Here

      // pass our info to JProgram
      program.initTypeInfo(instantiableTypes, jsonObjects);

      // JSO's maker queryId is -1 (used for array stores).
      JClassType jsoType = program.getJavaScriptObject();
      if (jsoType != null) {
        queryIds.put(jsoType, -1);
      }
      program.recordQueryIds(queryIds);
    }
View Full Code Here

            throw new InternalCompilerException(
                "runAsync call found with neither 1 nor 2 arguments: " + x);
        }

        int entryNumber = entryCount++;
        JClassType loader = getFragmentLoader(entryNumber);
        JMethod loadMethod = getRunAsyncMethod(loader);
        assert loadMethod != null;
        runAsyncReplacements.put(entryNumber, new RunAsyncReplacement(
            entryNumber, currentMethod, loadMethod, name));
View Full Code Here

      /*
       * Search myself and all my super types to find a tighter implementation
       * of the called method, if possible.
       */
      JMethod foundMethod = null;
      JClassType type;
      outer : for (type = (JClassType) instanceType; type != null
          && type != enclosingType; type = type.getSuperClass()) {
        for (JMethod methodIt : type.getMethods()) {
          if (methodOverrides(methodIt, method)) {
            foundMethod = methodIt;
            break outer;
          }
        }
View Full Code Here

    /**
     * Handle special rescues needed implicitly to support concat.
     */
    private void rescueByConcat(JType type) {
      JClassType stringType = program.getTypeJavaLangString();
      JPrimitiveType charType = program.getTypePrimitiveChar();
      if (type instanceof JReferenceType && type != stringType
          && type != program.getTypeNull()) {
        /*
         * Any reference types (except String, which works by default) that take
         * part in a concat must rescue java.lang.Object.toString().
         *
         * TODO: can we narrow the focus by walking up the type hierarchy or
         * doing explicit toString calls?
         */
        JMethod toStringMethod = program.getIndexedMethod("Object.toString");
        rescue(toStringMethod);
      } else if (type == charType) {
        /*
         * Characters must rescue String.valueOf(char)
         */
        if (stringValueOfChar == null) {
          for (JMethod meth : stringType.getMethods()) {
            if (meth.getName().equals("valueOf")) {
              List<JType> params = meth.getOriginalParamTypes();
              if (params.size() == 1) {
                if (params.get(0) == charType) {
                  stringValueOfChar = meth;
View Full Code Here

      return null;
    }

    private JMethod findJsoMethod(JMethod interfaceMethod) {
      JClassType jsoClass = jsoSingleImpls.get(interfaceMethod.getEnclosingType());
      assert program.isJavaScriptObject(jsoClass);
      assert jsoClass != null;

      JMethod toReturn = findConcreteImplementation(interfaceMethod, jsoClass);
      assert toReturn != null;
      assert !toReturn.isAbstract();
      assert jsoClass.isFinal() || toReturn.isFinal();

      return toReturn;
    }
View Full Code Here

public class ResolveRebinds {

  private class RebindVisitor extends JModVisitor {
    @Override
    public void endVisit(JGwtCreate x, Context ctx) {
      JClassType rebindResult = rebind(x.getSourceType());
      List<JClassType> rebindResults = x.getResultTypes();
      for (int i = 0; i < rebindResults.size(); ++i) {
        // Find the matching rebound type.
        if (rebindResult == rebindResults.get(i)) {
          // Replace with the associated instantiation expression.
View Full Code Here

          "No matching rebind result in all rebind results!");
    }

    @Override
    public void endVisit(JReboundEntryPoint x, Context ctx) {
      JClassType rebindResult = rebind(x.getSourceType());
      List<JClassType> rebindResults = x.getResultTypes();
      for (int i = 0; i < rebindResults.size(); ++i) {
        // Find the matching rebound type.
        if (rebindResult == rebindResults.get(i)) {
          // Replace with the associated instantiation expression.
View Full Code Here

TOP

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

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.