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

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


      if (!(x.getCastType() instanceof JReferenceType)
          || !(argType instanceof JReferenceType)) {
        return;
      }

      JReferenceType toType = (JReferenceType) x.getCastType();
      JReferenceType fromType = (JReferenceType) argType;

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
View Full Code Here


      if (!(argType instanceof JReferenceType)) {
        // TODO: is this even possible? Replace with assert maybe.
        return;
      }

      JReferenceType toType = x.getTestType();
      JReferenceType fromType = (JReferenceType) argType;

      boolean triviallyTrue = false;
      boolean triviallyFalse = false;

      JTypeOracle typeOracle = program.typeOracle;
View Full Code Here

    public void endVisit(JMethod x, Context ctx) {

      if (!(x.getType() instanceof JReferenceType)) {
        return;
      }
      JReferenceType refType = (JReferenceType) x.getType();

      if (refType == typeNull) {
        return;
      }

      // tighten based on non-instantiability
      if (!program.typeOracle.isInstantiatedType(refType)) {
        x.setType(typeNull);
        myDidChange = true;
        return;
      }

      // tighten based on both returned types and possible overrides
      List/* <JReferenceType> */typeList = new ArrayList/* <JReferenceType> */();

      /*
       * Always assume at least one null assignment; if there really aren't any
       * other assignments, then this variable will get the null type. If there
       * are, it won't hurt anything because null type will always lose.
       */
      typeList.add(typeNull);

      Set/* <JExpression> */myReturns = (Set) returns.get(x);
      if (myReturns != null) {
        for (Iterator iter = myReturns.iterator(); iter.hasNext();) {
          JExpression expr = (JExpression) iter.next();
          typeList.add(expr.getType());
        }
      }
      Set/* <JMethod> */myOverriders = (Set) overriders.get(x);
      if (myOverriders != null) {
        for (Iterator iter = myOverriders.iterator(); iter.hasNext();) {
          JMethod method = (JMethod) iter.next();
          typeList.add(method.getType());
        }
      }

      JReferenceType resultType = program.generalizeTypes(typeList);
      resultType = program.strongerType(refType, resultType);
      if (refType != resultType) {
        x.setType(resultType);
        myDidChange = true;
      }
View Full Code Here

     */
    private void tighten(JVariable x) {
      if (!(x.getType() instanceof JReferenceType)) {
        return;
      }
      JReferenceType refType = (JReferenceType) x.getType();

      if (refType == typeNull) {
        return;
      }

      // tighten based on non-instantiability
      if (!program.typeOracle.isInstantiatedType(refType)) {
        x.setType(typeNull);
        myDidChange = true;
        return;
      }

      // tighten based on assignment
      List/* <JReferenceType> */typeList = new ArrayList/* <JReferenceType> */();

      /*
       * For non-parameters, always assume at least one null assignment; if
       * there really aren't any other assignments, then this variable will get
       * the null type. If there are, it won't hurt anything because null type
       * will always lose.
       *
       * For parameters, don't perform any tightening if we can't find any
       * actual assignments. The method should eventually get pruned.
       */
      if (!(x instanceof JParameter)) {
        typeList.add(typeNull);
      }

      Set/* <JExpression> */myAssignments = (Set) assignments.get(x);
      if (myAssignments != null) {
        for (Iterator iter = myAssignments.iterator(); iter.hasNext();) {
          JExpression expr = (JExpression) iter.next();
          JType type = expr.getType();
          if (!(type instanceof JReferenceType)) {
            return; // something fishy is going on, just abort
          }
          typeList.add(type);
        }
      }

      if (x instanceof JParameter) {
        Set/* <JParameter> */myParams = (Set) paramUpRefs.get(x);
        if (myParams != null) {
          for (Iterator iter = myParams.iterator(); iter.hasNext();) {
            JParameter param = (JParameter) iter.next();
            typeList.add(param.getType());
          }
        }
      }

      if (typeList.isEmpty()) {
        return;
      }

      JReferenceType resultType = program.generalizeTypes(typeList);
      resultType = program.strongerType(refType, resultType);
      if (refType != resultType) {
        x.setType(resultType);
        myDidChange = true;
      }
View Full Code Here

         * prospective element type of the lhs.
         */
        JTypeOracle typeOracle = program.typeOracle;
        JType rhsType = x.getRhs().getType();
        assert (rhsType instanceof JReferenceType);
        JReferenceType refRhsType = (JReferenceType) rhsType;
        for (Iterator it = instantiatedArrayTypes.iterator(); it.hasNext();) {
          JArrayType arrayType = (JArrayType) it.next();
          if (typeOracle.canTheoreticallyCast(arrayType, lhsArrayType)) {
            JType itElementType = arrayType.getElementType();
            if (itElementType instanceof JReferenceType) {
View Full Code Here

      }

      // Find all possible query types which I can satisfy
      Set/* <JReferenceType> */yesSet = null;
      for (Iterator iter = queriedTypes.keySet().iterator(); iter.hasNext();) {
        JReferenceType qType = (JReferenceType) iter.next();
        Set/* <JReferenceType> */querySet = (Set) queriedTypes.get(qType);
        if (program.typeOracle.canTriviallyCast(type, qType)) {
          for (Iterator it = querySet.iterator(); it.hasNext();) {
            JReferenceType argType = (JReferenceType) it.next();
            if (program.typeOracle.canTriviallyCast(type, argType)) {
              if (yesSet == null) {
                yesSet = new HashSet/* <JReferenceType> */();
              }
              yesSet.add(qType);
              break;
            }
          }
        }
      }

      /*
       * Weird: JavaScriptObjects MUST have a typeId, the implementation of
       * Cast.wrapJSO depends on it.
       */
      if (yesSet == null && !program.isJavaScriptObject(type)) {
        return; // won't satisfy anything
      }

      // use an array to sort my yes set
      JReferenceType[] yesArray = new JReferenceType[nextQueryId];
      if (yesSet != null) {
        for (Iterator it = yesSet.iterator(); it.hasNext();) {
          JReferenceType yesType = (JReferenceType) it.next();
          Integer boxedInt = (Integer) queryIds.get(yesType);
          yesArray[boxedInt.intValue()] = yesType;
        }
      }

View Full Code Here

    }

    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

      }
    }

    private void recordCastInternal(JReferenceType targetType,
        JReferenceType rhsType) {
      JReferenceType toType = targetType;
      Set/* <JReferenceType> */querySet = (Set) queriedTypes.get(toType);
      if (querySet == null) {
        queryIds.put(toType, new Integer(nextQueryId++));
        querySet = new HashSet/* <JReferenceType> */();
        queriedTypes.put(toType, querySet);
View Full Code Here

            method, program.getTypeNull());
        call.getArgs().add(x.getExpr());
        replaceExpr = call;
      } else if (toType instanceof JReferenceType) {
        JExpression curExpr = x.getExpr();
        JReferenceType refType = (JReferenceType) toType;
        JType argType = x.getExpr().getType();
        if (program.isJavaScriptObject(argType)) {
          /*
           * A JSO-derived class that is about to be cast must be "wrapped"
           * first. Since a JSO was never constructed, it may not have an
View Full Code Here

    bootStrapMethod.freezeParamTypes();

    JMethodBody body = (JMethodBody) bootStrapMethod.getBody();
    for (int i = 0; i < mainClassNames.length; ++i) {
      String mainClassName = mainClassNames[i];
      JReferenceType referenceType = program.getFromTypeMap(mainClassName);

      if (referenceType == null) {
        logger.log(TreeLogger.ERROR,
            "Could not find module entry point class '" + mainClassName + "'",
            null);
View Full Code Here

TOP

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

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.