Examples of JReferenceType


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

    }

    JExpression processExpression(InstanceOfExpression x) {
      SourceInfo info = makeSourceInfo(x);
      JExpression expr = dispProcessExpression(x.expression);
      JReferenceType testType = (JReferenceType) typeMap.get(x.type.resolvedType);
      return new JInstanceOf(info, testType, expr);
    }
View Full Code Here

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

    }

    private JExpression maybeCast(JType expected, JExpression expression) {
      if (expected != expression.getType()) {
        // Must be a generic; insert a cast operation.
        JReferenceType toType = (JReferenceType) expected;
        return new JCastOperation(expression.getSourceInfo(), toType,
            expression);
      } else {
        return expression;
      }
View Full Code Here

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

    }

    private void processArtificialRescue(Annotation rescue) {
      assert rescue != null;

      JReferenceType classType = null;
      String[] fields = Empty.STRINGS;
      boolean instantiable = false;
      String[] methods = Empty.STRINGS;
      String typeName = null;

      for (MemberValuePair pair : rescue.memberValuePairs()) {
        String name = String.valueOf(pair.name);
        Expression value = pair.value;

        if ("className".equals(name)) {
          typeName = value.constant.stringValue();

          // Invalid references should be caught in ArtificialRescueChecker
          classType = (JReferenceType) program.getTypeFromJsniRef(typeName);

        } else if ("fields".equals(name)) {
          if (value instanceof StringLiteral) {
            fields = new String[] {value.constant.stringValue()};
          } else if (value instanceof ArrayInitializer) {
            ArrayInitializer init = (ArrayInitializer) value;
            fields = new String[init.expressions == null ? 0
                : init.expressions.length];
            for (int i = 0, j = fields.length; i < j; i++) {
              fields[i] = init.expressions[i].constant.stringValue();
            }
          }

        } else if ("instantiable".equals(name)) {
          instantiable = value.constant.booleanValue();

        } else if ("methods".equals(name)) {
          if (value instanceof StringLiteral) {
            methods = new String[] {value.constant.stringValue()};
          } else if (value instanceof ArrayInitializer) {
            ArrayInitializer init = (ArrayInitializer) value;
            methods = new String[init.expressions == null ? 0
                : init.expressions.length];
            for (int i = 0, j = methods.length; i < j; i++) {
              methods[i] = init.expressions[i].constant.stringValue();
            }
          }
        } else {
          throw new InternalCompilerException(
              "Unknown Rescue annotation member " + name);
        }
      }

      assert classType != null : "classType " + typeName;
      assert fields != null : "fields";
      assert methods != null : "methods";

      if (instantiable) {
        currentClass.addArtificialRescue(classType);

        // Make sure that a class literal for the type has been allocated
        program.getLiteralClass(classType);
      }

      if (classType instanceof JDeclaredType) {
        List<String> toRescue = new ArrayList<String>();
        Collections.addAll(toRescue, fields);
        Collections.addAll(toRescue, methods);

        for (String name : toRescue) {
          JsniRef ref = JsniRef.parse("@" + classType.getName() + "::" + name);
          final String[] errors = {null};
          HasEnclosingType node = JsniRefLookup.findJsniRefTarget(ref, program,
              new JsniRefLookup.ErrorReporter() {
                public void reportError(String error) {
                  errors[0] = error;
View Full Code Here

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

    List<JsStatement> extractedStats = new ArrayList<JsStatement>();

    /**
     * The type whose vtables can currently be installed.
     */
    JReferenceType currentVtableType = null;

    for (int frag = 0; frag < jsprogram.getFragmentCount(); frag++) {
      List<JsStatement> stats = jsprogram.getFragmentBlock(frag).getStatements();
      for (JsStatement stat : stats) {
        if (isEntryCall(stat)) {
          continue;
        }

        boolean keepIt;

        if (containsRemovableVars(stat)) {
          stat = removeSomeVars((JsVars) stat, livenessPredicate,
              alreadyLoadedPredicate);
          keepIt = !(stat instanceof JsEmpty);
        } else {
          keepIt = isLive(stat, livenessPredicate)
              && !isLive(stat, alreadyLoadedPredicate);
        }

        statementLogger.logStatement(stat, keepIt);

        if (keepIt) {
          if (vtableTypeAssigned(stat) != null) {
            currentVtableType = vtableTypeAssigned(stat);
          }
          JReferenceType vtableType = vtableTypeNeeded(stat);
          if (vtableType != null && vtableType != currentVtableType) {
            extractedStats.add(vtableStatFor(vtableType));
            currentVtableType = vtableType;
          }
          extractedStats.add(stat);
View Full Code Here

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

    }
    return false;
  }

  private boolean isLive(JsStatement stat, LivenessPredicate livenessPredicate) {
    JReferenceType type = map.typeForStatement(stat);
    if (type != null) {
      // This is part of the code only needed once a type is instantiable
      return livenessPredicate.isLive(type);
    }
View Full Code Here

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

          "Unexpected failure to get possible rebind answers for '" + reqType
              + "'");
    }
    List<JClassType> rebindAnswers = new ArrayList<JClassType>();
    for (String answer : answers) {
      JReferenceType result = program.getFromTypeMap(answer);
      assert (result != null);
      rebindAnswers.add((JClassType) result);
    }
    assert rebindAnswers.size() > 0;
    return rebindAnswers;
View Full Code Here

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

    private void replaceGwtCreate(JMethodCall x, Context ctx) {
      assert (x.getArgs().size() == 1);
      JExpression arg = x.getArgs().get(0);
      assert (arg instanceof JClassLiteral);
      JClassLiteral classLiteral = (JClassLiteral) arg;
      JReferenceType sourceType = (JReferenceType) classLiteral.getRefType();
      List<JClassType> allRebindResults = getAllPossibleRebindResults(sourceType);
      JGwtCreate gwtCreate = new JGwtCreate(x.getSourceInfo(), sourceType,
          allRebindResults, program.getTypeJavaLangObject());
      if (allRebindResults.size() == 1) {
        // Just replace with the instantiation expression.
View Full Code Here

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

         * prospective element type of the lhs.
         */
        JTypeOracle typeOracle = program.typeOracle;
        JType rhsType = x.getRhs().getType();
        assert (rhsType instanceof JReferenceType);
        JReferenceType refRhsType = (JReferenceType) rhsType;

        for (JArrayType arrayType : instantiatedArrayTypes) {
          if (typeOracle.canTheoreticallyCast(arrayType, lhsArrayType)) {
            JType itElementType = arrayType.getElementType();
            if (itElementType instanceof JReferenceType) {
View Full Code Here

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

    }

    private void recordCast(JType targetType, JExpression rhs) {
      if (targetType instanceof JReferenceType) {
        // unconditional cast b/c it would've been a semantic error earlier
        JReferenceType rhsType = (JReferenceType) rhs.getType();
        // don't record a type for trivial casts that won't generate code
        if (rhsType instanceof JClassType) {
          if (program.typeOracle.canTriviallyCast(rhsType,
              (JReferenceType) targetType)) {
            return;
View Full Code Here

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

      }
    }

    private void recordCastInternal(JReferenceType targetType,
        JReferenceType rhsType) {
      JReferenceType toType = targetType;
      Set<JReferenceType> querySet = queriedTypes.get(toType);
      if (querySet == null) {
        queryIds.put(toType, nextQueryId++);
        querySet = new HashSet<JReferenceType>();
        queriedTypes.put(toType, querySet);
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.