private void processThisCallThisArgs(ReferenceBinding binding, JMethodCall call) { if (binding.syntheticEnclosingInstanceTypes() != null) { Iterator<JParameter> paramIt = curMethod.method.getParams().iterator(); if (curClass.classType.isEnumOrSubclass() != null) { // Skip past the enum args. paramIt.next(); paramIt.next(); } for (@SuppressWarnings("unused") ReferenceBinding argType : binding.syntheticEnclosingInstanceTypes()) { JParameter param = paramIt.next(); call.addArg(new JParameterRef(call.getSourceInfo(), param)); } } }
private static Optional<JNewInstance> newInstance(final TreeLogger logger, final SourceInfo sourceInfo, final UnifyAstView ast, final JDeclaredType answerType) { final Optional<JMethod> ctor = FluentIterable.from(answerType.getMethods()).firstMatch((m)->m.isConstructor() && m.getParams().size() == 0); if (ctor.isPresent()) { final JNewInstance result = new JNewInstance(sourceInfo, (JConstructor)ctor.get()); return Optional.of(result); } else { return Optional.absent(); } }
@Override public boolean visit(MethodDeclaration x, ClassScope scope) { try { JMethod method = typeMap.get(x.binding); assert !method.isExternal(); JMethodBody body = null; if (!method.isNative()) { body = new JMethodBody(method.getSourceInfo()); method.setBody(body); } pushMethodInfo(new MethodInfo(method, body, x.scope)); // Map user arguments. Iterator<JParameter> it = method.getParams().iterator(); if (x.arguments != null) { for (Argument argument : x.arguments) { curMethod.locals.put(argument.binding, it.next()); } } x.statements = reduceToReachable(x.statements); return true; } catch (Throwable e) { throw translateException(x, e); } }
private void processSuperCallLocalArgs(ReferenceBinding superClass, JMethodCall call) { if (superClass.syntheticOuterLocalVariables() != null) { for (SyntheticArgumentBinding arg : superClass.syntheticOuterLocalVariables()) { // TODO: use emulation path here. // Got to be one of my params JType varType = typeMap.get(arg.type); String varName = intern(arg.name); JParameter param = null; for (JParameter paramIt : curMethod.method.getParams()) { 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(new JParameterRef(call.getSourceInfo(), param)); } } }
bridgeMethod.setSynthetic(); int paramIdx = 0; List<JParameter> implParams = implmeth.getParams(); for (TypeBinding jdtParamType : jdtBridgeMethod.parameters) { JParameter param = implParams.get(paramIdx++); for (int i = 0; i < bridgeMethod.getParams().size(); i++) { JParameter param = bridgeMethod.getParams().get(i); JParameterRef paramRef = new JParameterRef(info, param); call.addArg(maybeCast(implParams.get(i).getType(), paramRef));
JParameterRef nameRef = new JParameterRef(info, method.getParams().get(0)); JMethodCall call = new JMethodCall(info, null, typeMap.get(valueOfBinding)); call.addArgs(mapRef, nameRef);