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

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


    }

    @Override
    public void endVisit(JMethodCall x, Context ctx) {
      JMethod target = x.getTarget();
      JDeclaredType type = target.getEnclosingType();

      if (type instanceof JClassType) {
        JClassType cType = (JClassType) type;
        if (typeInBlacklist(blacklistedEnums, cType)) {
          return;
View Full Code Here


            continue;
          }

          switch (c.getAxis()) {
            case CLASS: {
              JDeclaredType type = c.getType();
              StandardClassMember member = memberFactory.get(type);
              membersByCorrelation.put(c, member);
              classesMutable.add(member);
              break;
            }
            case FIELD: {
              JField field = c.getField();
              JDeclaredType type = c.getType();
              StandardFieldMember member = memberFactory.get(field);
              memberFactory.get(type).addField(member);
              membersByCorrelation.put(c, member);
              break;
            }
            case METHOD: {
              JMethod method = c.getMethod();
              JDeclaredType type = c.getType();
              StandardMethodMember member = memberFactory.get(method);
              memberFactory.get(type).addMethod(member);
              membersByCorrelation.put(c, member);
              break;
            }
View Full Code Here

  }

  @Override
  public boolean visit(JsniMethodRef x, Context ctx) {
    JMethod calledMethod = x.getTarget();
    JDeclaredType enclosingTypeOfCalledMethod = calledMethod.getEnclosingType();

    if (isNonStaticJsoClassDispatch(calledMethod, enclosingTypeOfCalledMethod)) {
      logger.log(TreeLogger.ERROR, "JSNI method " + getSignature(currentJsniMethod)
          + " attempts to call non-static method " + getSignature(calledMethod)
          + " on an instance which is a subclass of JavaScriptObject. "
View Full Code Here

    if (program.isJsTypePrototype(classType)) {
        /*
         * When a Java type extends a JS prototype stub, we make the superclass literal
         * equal to the Js interface.
         */
      JDeclaredType jsInterface = program.typeOracle.getNearestJsType(type, true);
      assert jsInterface != null;
      return createDependentClassLiteral(info, jsInterface);
    }

    return createDependentClassLiteral(info, classType.getSuperClass());
View Full Code Here

  private final Map<JDeclaredType, JMethod> unboxMethods =
      new LinkedHashMap<JDeclaredType, JMethod>();

  public AutoboxUtils(JProgram program) {
    for (JPrimitiveType primType : TYPES) {
      JDeclaredType wrapperType = program.getFromTypeMap(primType.getWrapperTypeName());
      String boxSig =
          "valueOf(" + primType.getJsniSignatureName() + ")" + wrapperType.getJsniSignatureName();
      String unboxSig = primType.getName() + "Value()" + primType.getJsniSignatureName();
      for (JMethod method : wrapperType.getMethods()) {
        if (method.isStatic()) {
          if (method.getSignature().equals(boxSig)) {
            boxMethods.put(primType, method);
          }
        } else {
View Full Code Here

    Queue<JDeclaredType> typesToCheck =
        new ArrayDeque<JDeclaredType>(jprogram.getDeclaredTypes().size());
    typesToCheck.addAll(jprogram.getDeclaredTypes());

    while (!typesToCheck.isEmpty()) {
      JDeclaredType type = typesToCheck.remove();
      if (type.getSuperClass() != null) {
        Fragment typeFrag = getFragment(fragmentForType, type);
        Fragment supertypeFrag = getFragment(fragmentForType, type.getSuperClass());
        if (!fragmentsAreConsistent(typeFrag, supertypeFrag)) {
          numFixups++;
          fragmentForType.put(type.getSuperClass(), NOT_EXCLUSIVE);
          typesToCheck.add(type.getSuperClass());
        }
      }
    }

    logger.log(TreeLogger.DEBUG, "Fixed up load-order dependencies on supertypes by moving "
View Full Code Here

          madeChanges();
        }
      }

      // Normal optimizations.
      JDeclaredType targetType = target.getEnclosingType();
      if (targetType == program.getTypeJavaLangString() ||
          (instance != null &&
              instance.getType().getUnderlyingType() == program.getTypeJavaLangString())) {
        tryOptimizeStringCall(x, ctx, target);
      } else if (JProgram.isClinit(target)) {
        // Eliminate the call if the target is now empty.
        if (!targetType.hasClinit()) {
          ctx.replaceMe(program.getLiteralNull());
        } else if (targetType != targetType.getClinitTarget()) {
          // Tighten the target.
          ctx.replaceMe(createClinitCall(x.getSourceInfo(), targetType.getClinitTarget()));
        }
      } else if (target == isScriptMethod) {
        // optimize out in draftCompiles that don't do inlining
        ctx.replaceMe(JBooleanLiteral.TRUE);
      } else if (target == enumOrdinalMethod) {
View Full Code Here

          continue;
        }

        // Remove redundant clinits
        if (expr instanceof JMethodCall && JProgram.isClinit(((JMethodCall) expr).getTarget())) {
          JDeclaredType enclosingType = ((JMethodCall) expr).getTarget().getEnclosingType();
          // If a clinit of enclosingType or a subclass of enclosingType has already been
          // called as part of this JMultiExpression then this clinit call is noop at runtime
          // and can be statically removed.
          if (enclosingType.findSubtype(clinitsCalled) != null) {
            x.removeExpression(i);
            --i;
            madeChanges();
            continue;
          } else {
View Full Code Here

    public boolean visit(JProgram program, Context ctx) {
      for (JMethod method : program.getEntryMethods()) {
        accept(method);
      }
      for (Iterator<JDeclaredType> it = program.getDeclaredTypes().iterator(); it.hasNext();) {
        JDeclaredType type = it.next();
        if (referencedTypes.contains(type) || program.typeOracle.isInstantiatedType(type)) {
          accept(type);
        } else {
          it.remove();
          madeChanges();
View Full Code Here

         * will get cleaned up by other optimization passes prior to this point,
         * but it's not guaranteed. In this case we need to replace the method
         * call with the replaced clinit, unless the replacement is null, in
         * which case we generate a JsNullLiteral as a place-holder expression.
         */
        JDeclaredType type = method.getEnclosingType();
        JDeclaredType clinitTarget = type.getClinitTarget();
        if (clinitTarget == null || program.isJsTypePrototype(clinitTarget)) {
          if (x.getInstance() != null) {
            pop(); // instance
          }
          // generate a null expression, which will get optimized out
          push(JsNullLiteral.INSTANCE);
          return;
        } else if (type != clinitTarget) {
          // replace the method with its retargeted clinit
          method = clinitTarget.getClinitMethod();
        }
      }

      JsNameRef qualifier = null;
      JsExpression unnecessaryQualifier = null;
      JsExpression result = null;
      boolean isJsProperty = false;
      result = jsInvocation;

      if (method.isStatic()) {
        if (x.getInstance() != null) {
          unnecessaryQualifier = pop(); // instance
        }
        qualifier = names.get(method).makeRef(x.getSourceInfo());
      } else if (x.isStaticDispatchOnly() && method.isConstructor()) {
         /*
         * Constructor calls through {@code this} and {@code super} are always dispatched statically
         * using the constructor function name (constructors are always defined as top level
         * functions).
         *
         * Because constructors are modeled like instance methods they have an implicit {@code this}
         * parameter, hence they are invoked like: "constructor.call(this, ...)".
         */
        JsName callName = objectScope.declareName("call");
        callName.setObfuscatable(false);
        qualifier = callName.makeRef(x.getSourceInfo());
        JsNameRef methodRef = names.get(method).makeRef(x.getSourceInfo());
        qualifier.setQualifier(methodRef);
        jsInvocation.getArguments().add(0, (JsExpression) pop()); // instance
        if (program.isJsTypePrototype(method.getEnclosingType())) {
          result = dispatchToSuperPrototype(x, method, qualifier, methodRef, jsInvocation);
        }
      } else if (x.isStaticDispatchOnly() && !method.isConstructor()) {
        // Regular super call. This calls are always static and optimizations normally statify them.
        // They can appear in completely unoptimized code, hence need to be handled here.

        // Construct JCHSU.getPrototypeFor(type).polyname
        // TODO(rluble): Ideally we would want to construct the inheritance chain the JS way and
        // then we could do Type.prototype.polyname.call(this, ...). Currently prototypes do not
        // have global names instead they are stuck into the prototypesByTypeId array.
        final JDeclaredType superMethodTargetType = method.getEnclosingType();

        JsInvocation getPrototypeCall = constructInvocation(x.getSourceInfo(),
            "JavaClassHierarchySetupUtil.getClassPrototype",
            JjsUtils.translateLiteral(program.getLiteral(typeMapper.get(superMethodTargetType))));

View Full Code Here

TOP

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

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.