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

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


      this.longType = longType;
    }

    @Override
    public void endVisit(JBinaryOperation x, Context ctx) {
      JType lhsType = x.getLhs().getType();
      JType rhsType = x.getRhs().getType();
      JType resultType = x.getType();
      JBinaryOperator op = x.getOp();

      if (resultType == program.getTypeJavaLangString()) {
        // Don't mess with concat.
        return;
      }

      if (lhsType == JPrimitiveType.BOOLEAN
          && (op == JBinaryOperator.AND || op == JBinaryOperator.OR)) {
        // Don't mess with if rewriter.
        return;
      }

      // Special case: shift operators always coerce a long RHS to int.
      if (op.isShiftOperator()) {
        if (rhsType == longType) {
          rhsType = program.getTypePrimitiveInt();
        }
      } else if (lhsType == longType || rhsType == longType) {
        // We must coerce lhs and rhs to the same type, either long or a float.

        // Assume a long type.
        JType coerceTo = longType;

        // But double / float takes precedence over long.
        JPrimitiveType floatType = program.getTypePrimitiveFloat();
        JPrimitiveType doubleType = program.getTypePrimitiveDouble();
        // See if the lhs can coerce the rhs
View Full Code Here


      }
    }

    @Override
    public void endVisit(JNewArray x, Context ctx) {
      JType elementType = x.getArrayType().getElementType();
      List<JExpression> initializers = x.initializers;
      if (initializers != null) {
        for (int i = 0; i < initializers.size(); ++i) {
          JExpression initializer = initializers.get(i);
          JExpression newInitializer = checkAndReplace(initializer, elementType);
View Full Code Here

        }

        JMethodBody enclosingBody = findEnclosingMethod(scope);
        SourceInfo info = makeSourceInfo(argument, enclosingBody.getMethod());
        LocalVariableBinding b = argument.binding;
        JType localType = (JType) typeMap.get(b.type);
        JLocal newLocal = program.createLocal(info, argument.name, localType,
            b.isFinal(), enclosingBody);
        typeMap.put(b, newLocal);
        return true;
      } catch (Throwable e) {
View Full Code Here

    @Override
    public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
      try {
        LocalVariableBinding b = localDeclaration.binding;
        JType localType = (JType) typeMap.get(localDeclaration.type.resolvedType);
        JMethodBody enclosingBody = findEnclosingMethod(scope);
        SourceInfo info = makeSourceInfo(localDeclaration,
            enclosingBody.getMethod());
        JLocal newLocal = program.createLocal(info, localDeclaration.name,
            localType, b.isFinal(), enclosingBody);
View Full Code Here

      return lines;
    }

    private JField createEnumField(SourceInfo info, FieldBinding binding,
        JReferenceType enclosingType) {
      JType type = (JType) typeMap.get(binding.type);
      JField field = program.createEnumField(info, binding.name,
          (JEnumType) enclosingType, (JClassType) type, binding.original().id);
      info.addCorrelation(program.getCorrelator().by(field));
      typeMap.put(binding, field);
      return field;
View Full Code Here

      return field;
    }

    private JField createField(SourceInfo info, FieldBinding binding,
        JDeclaredType enclosingType) {
      JType type = (JType) typeMap.get(binding.type);

      boolean isCompileTimeConstant = binding.isStatic() && (binding.isFinal())
          && (binding.constant() != Constant.NotAConstant)
          && (binding.type.isBaseType());
      assert (type instanceof JPrimitiveType || !isCompileTimeConstant);
View Full Code Here

      return field;
    }

    private JField createField(SyntheticArgumentBinding binding,
        JDeclaredType enclosingType) {
      JType type = (JType) typeMap.get(binding.type);
      SourceInfo info = enclosingType.getSourceInfo().makeChild(
          BuildDeclMapVisitor.class, "Field " + String.valueOf(binding.name));
      JField field = program.createField(info, binding.name, enclosingType,
          type, false, Disposition.FINAL);
      info.addCorrelation(program.getCorrelator().by(field));
View Full Code Here

      return field;
    }

    private JParameter createParameter(LocalVariableBinding binding,
        JMethod enclosingMethod) {
      JType type = (JType) typeMap.get(binding.type);
      SourceInfo info = makeSourceInfo(binding.declaration, enclosingMethod);
      JParameter param = program.createParameter(info, binding.name, type,
          binding.isFinal(), false, enclosingMethod);
      typeMap.put(binding, param);
      return param;
View Full Code Here

      return param;
    }

    private JParameter createParameter(SyntheticArgumentBinding arg,
        String argName, JMethod enclosingMethod) {
      JType type = (JType) typeMap.get(arg.type);
      JParameter param = program.createParameter(
          enclosingMethod.getSourceInfo().makeChild(BuildTypeMap.class,
              "Parameter " + argName), argName.toCharArray(), type, true,
          false, enclosingMethod);
      return param;
View Full Code Here

      }
    }

    private JMethod processMethodBinding(MethodBinding b,
        JDeclaredType enclosingType, SourceInfo info) {
      JType returnType = (JType) typeMap.get(b.returnType);
      JMethod newMethod = program.createMethod(info, b.selector, enclosingType,
          returnType, b.isAbstract(), b.isStatic(), b.isFinal(), b.isPrivate(),
          b.isNative());

      typeMap.put(b, newMethod);
View Full Code Here

TOP

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

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.