Examples of JMethodCall


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

    @SuppressWarnings("unused")
    JMethodCall processSuperConstructorCall(ExplicitConstructorCall x) {
      SourceInfo info = makeSourceInfo(x);
      JMethod ctor = (JMethod) typeMap.get(x.binding);
      JExpression trueQualifier = createThisRef(info, currentClass);
      JMethodCall call = new JMethodCall(info, trueQualifier, ctor);

      addCallArgs(x.arguments, call, x.binding);

      // We have to find and pass through any synthetics our supertype needs
      ReferenceBinding superClass = x.binding.declaringClass;
      if (superClass.isNestedType() && !superClass.isStatic()) {
        ReferenceBinding myBinding = currentClassScope.referenceType().binding;
        ReferenceBinding superBinding = superClass;

        // enclosing types
        if (superBinding.syntheticEnclosingInstanceTypes() != null) {
          JExpression qualifier = dispProcessExpression(x.qualification);
          for (ReferenceBinding arg : superBinding.syntheticEnclosingInstanceTypes()) {
            JClassType classType = (JClassType) typeMap.get(arg);
            if (qualifier == null) {
              /*
               * Got to be one of my params; it would be illegal to use a this
               * ref at this moment-- we would most likely be passing in a
               * supertype field that HASN'T BEEN INITIALIZED YET.
               *
               * Unfortunately, my params might not work as-is, so we have to
               * check each one to see if any will make a suitable this ref.
               */
              List<JExpression> workList = new ArrayList<JExpression>();
              Iterator<JParameter> paramIt = getSyntheticsIterator();
              for (ReferenceBinding b : myBinding.syntheticEnclosingInstanceTypes()) {
                workList.add(createVariableRef(info, paramIt.next()));
              }
              call.addArg(createThisRef(classType, workList));
            } else {
              call.addArg(createThisRef(classType, qualifier));
            }
          }
        }

        // outer locals
        if (superBinding.syntheticOuterLocalVariables() != null) {
          for (SyntheticArgumentBinding arg : superBinding.syntheticOuterLocalVariables()) {
            // Got to be one of my params
            JType varType = (JType) typeMap.get(arg.type);
            String varName = String.valueOf(arg.name);
            JParameter param = null;
            for (int i = 0; i < currentMethod.getParams().size(); ++i) {
              JParameter paramIt = currentMethod.getParams().get(i);
              if (varType == paramIt.getType()
                  && varName.equals(paramIt.getName())) {
                param = paramIt;
              }
            }
            if (param == null) {
              throw new InternalCompilerException(
                  "Could not find matching local arg for explicit super ctor call.");
            }
            call.addArg(createVariableRef(info, param));
          }
        }
      }

      return call;
View Full Code Here

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

    JMethodCall processThisConstructorCall(ExplicitConstructorCall x) {
      SourceInfo info = makeSourceInfo(x);
      JMethod ctor = (JMethod) typeMap.get(x.binding);
      JExpression trueQualifier = createThisRef(info, currentClass);
      JMethodCall call = new JMethodCall(info, trueQualifier, ctor);

      assert (x.qualification == null);

      addCallArgs(x.arguments, call, x.binding);

      // All synthetics must be passed through to the target ctor
      ReferenceBinding declaringClass = x.binding.declaringClass;
      if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
        Iterator<JParameter> paramIt = getSyntheticsIterator();
        NestedTypeBinding nestedBinding = (NestedTypeBinding) erasure(declaringClass);
        if (nestedBinding.enclosingInstances != null) {
          for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
            call.addArg(createVariableRef(info, paramIt.next()));
          }
        }
        if (nestedBinding.outerLocalVariables != null) {
          for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
            call.addArg(createVariableRef(info, paramIt.next()));
          }
        }
      }

      return call;
View Full Code Here

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

            paramName.toCharArray(), paramType, true, false, bridgeMethod);
      }
      bridgeMethod.freezeParamTypes();

      // create a call
      JMethodCall call = new JMethodCall(program.createSourceInfoSynthetic(
          GenerateJavaAST.class, "call to inherited method"),
          program.getExprThisRef(program.createSourceInfoSynthetic(
              GenerateJavaAST.class, "part of a bridge method"), clazz),
          implmeth);

      for (int i = 0; i < bridgeMethod.getParams().size(); i++) {
        JParameter param = bridgeMethod.getParams().get(i);
        JParameterRef paramRef = new JParameterRef(
            program.createSourceInfoSynthetic(GenerateJavaAST.class,
                "part of a bridge method"), param);
        call.addArg(maybeCast(implmeth.getParams().get(i).getType(), paramRef));
      }

      // wrap it in a return if necessary
      JStatement callOrReturn;
      if (bridgeMethod.getType() == program.getTypeVoid()) {
        callOrReturn = call.makeStatement();
      } else {
        callOrReturn = new JReturnStatement(program.createSourceInfoSynthetic(
            GenerateJavaAST.class, "part of a bridge method"), call);
      }
View Full Code Here

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

            "Expected to find a method on '" + wrapperType.getName()
                + "' whose signature matches 'public "
                + primitiveType.getName() + " " + valueMethodName + "()'", null);
      }

      JMethodCall unboxCall = new JMethodCall(toUnbox.getSourceInfo(), toUnbox,
          valueMethod);
      return unboxCall;
    }
View Full Code Here

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

          JavaASTGenerationVisitor.class, "enum accessor method");
      JFieldRef mapRef = new JFieldRef(sourceInfo, null, mapField, type);
      JVariableRef nameRef = createVariableRef(sourceInfo,
          currentMethod.getParams().get(0));
      JMethod delegateTo = program.getIndexedMethod("Enum.valueOf");
      JMethodCall call = new JMethodCall(sourceInfo, null, delegateTo);
      call.addArgs(mapRef, nameRef);
      currentMethodBody.getBlock().addStmt(
          new JReturnStatement(sourceInfo, call));
    }
View Full Code Here

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

      JExpression instance = x.getInstance();
      if (instance != null) {
        multi.exprs.add(instance);
      }

      JMethodCall clinit = maybeCreateClinitCall(x);
      if (clinit != null) {
        multi.exprs.add(clinit);
      }

      if (literal != null) {
View Full Code Here

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

    private JMethodCall maybeCreateClinitCall(JFieldRef x) {
      if (x.hasClinit()) {
        JMethod clinit = x.getField().getEnclosingType().getMethods().get(0);
        assert (JProgram.isClinit(clinit));
        return new JMethodCall(x.getSourceInfo(), null, clinit);
      }
      return null;
    }
View Full Code Here

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

      JNewInstance newInstance = new JNewInstance(
          type.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
              "new instance"), type);

      // (new Foo()).Foo() : Invoke the constructor method on the instance
      JMethodCall call = new JMethodCall(type.getSourceInfo().makeChild(
          BuildDeclMapVisitor.class, "constructor invocation"), newInstance,
          constructor);
      /*
       * If the type isn't static, make the first parameter a reference to the
       * instance of the enclosing class. It's the first instance to allow the
       * JSNI qualifier to be moved without affecting evaluation order.
       */
      JParameter enclosingInstance = null;
      if (!staticClass) {
        enclosingInstance = program.createParameter(
            synthetic.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
                "outer instance"), "this$outer".toCharArray(), enclosingType,
            false, false, synthetic);
      }

      /*
       * In one pass, add the parameters to the synthetic constructor and
       * arguments to the method call.
       */
      for (Iterator<JParameter> i = constructor.getParams().iterator(); i.hasNext();) {
        JParameter param = i.next();
        /*
         * This supports x.new Inner() by passing the enclosing instance
         * implicitly as the last argument to the constructor.
         */
        if (enclosingInstance != null && !i.hasNext()) {
          call.addArg(new JParameterRef(synthetic.getSourceInfo().makeChild(
              BuildDeclMapVisitor.class, "enclosing instance"),
              enclosingInstance));
        } else {
          JParameter syntheticParam = program.createParameter(
              synthetic.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
                  "Argument " + param.getName()),
              param.getName().toCharArray(), param.getType(), true, false,
              synthetic);
          call.addArg(new JParameterRef(
              syntheticParam.getSourceInfo().makeChild(
                  BuildDeclMapVisitor.class, "reference"), syntheticParam));
        }
      }

View Full Code Here

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

                "Expected right operand to be of type long");
          }
      }

      JMethod method = program.getIndexedMethod("LongLib." + methodName);
      JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method,
          x.getType());
      call.addArgs(x.getLhs(), x.getRhs());
      ctx.replaceMe(call);
    }
View Full Code Here

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

        return;
      }

      String methodName = getEmulationMethod(x.getOp());
      JMethod method = program.getIndexedMethod("LongLib." + methodName);
      JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method,
          x.getType());
      call.addArg(x.getArg());
      ctx.replaceMe(call);
    }
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.