private void processThisCallLocalArgs(ReferenceBinding binding, JMethodCall call) { if (binding.syntheticOuterLocalVariables() != null) { for (SyntheticArgumentBinding arg : binding.syntheticOuterLocalVariables()) { JParameter param = (JParameter) curMethod.locals.get(arg); assert param != null; call.addArg(new JParameterRef(call.getSourceInfo(), param)); } } }
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)); } } }
@Override public JExpression injectMagic(final TreeLogger logger, final JMethodCall methodCall, final JMethod enclosingMethod, final Context context, final UnifyAstView ast) throws UnableToCompleteException { final JExpression ctorProvider = super.injectMagic(logger, methodCall, enclosingMethod, context, ast); // Find the invoker method // call the newInstance method on the result of our ctorProvider final JDeclaredType ctor = ast.searchForTypeBySource(Constructor.class.getName()); for (final JMethod method : ctor.getMethods()) { if (method.getName().equals("newInstance")) { final JMethodCall call = new JMethodCall(methodCall.getSourceInfo().makeChild(), ctorProvider, method); call.addArg(methodCall.getArgs().get(2)); return call; } } logger.log(Type.ERROR, "Unable to implement GwtReflect.construct from "+methodCall.toSource()); throw new UnableToCompleteException(); }
/** * @param ast * @param logger * @param callSite * @return * @throws UnableToCompleteException */ public JExpression throwNotFoundException(final TreeLogger logger, final JMethodCall callSite, final UnifyAstView ast) throws UnableToCompleteException { final SourceInfo sourceInfo = callSite.getSourceInfo().makeChild(); final MemberPoolMethods memberMap = memberPoolMethods.get(); final IsQualified exceptionType = getNotFoundExceptionType(); final JConstructor ctor = memberMap.findConstructor(logger, exceptionType.getQualifiedName(), exceptionType.getSimpleName()+"() <init>", ast); final JNewInstance newThrowable = new JNewInstance(sourceInfo, ctor); final JMethod throwMethod = memberMap.getThrowMethod(logger, ast); return new JMethodCall(sourceInfo, null, throwMethod, newThrowable); }
JGwtCreate.createInstantiationExpression(x.getSourceInfo(), (JClassType) answerType, currentMethod.getEnclosingType()); if (result == null) { return instantiationExpressions.get(0); } else { return new JGwtCreate(x.getSourceInfo(), reqType, answers, program.getTypeJavaLangObject(), instantiationExpressions);
return new JNameOf(x.getSourceInfo(), program.getTypeJavaLangString(), (HasName) node);
private void processSuperCallThisArgs(ReferenceBinding superClass, JMethodCall call, JExpression qualifier, Expression qualification) { // Explicit super calls can only happend inside constructors assert curMethod.scope.isInsideConstructor(); if (superClass.syntheticEnclosingInstanceTypes() != null) { // there can only be ONE immediate enclosing instance. assert superClass.syntheticEnclosingInstanceTypes().length == 1; ReferenceBinding targetType = superClass.syntheticEnclosingInstanceTypes()[0]; if (qualification != null) { // Outer object is the qualifier. call.addArg(qualifier); } else { // Get implicit outer object. call.addArg(makeThisReference(call.getSourceInfo(), targetType, false, curMethod.scope)); } } }
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)); } } }
SourceInfo info = methodCall.getSourceInfo().makeChild(); List<JClassLiteral> classLiterals = Lists.create();
findMethods(ast); final JClassLiteral clazz = ReflectionUtilAst.extractClassLiteral(logger, methodCall, 0, ast, false); final SourceInfo info = methodCall.getSourceInfo().makeChild(); if (clazz == null) {
final SourceInfo info = methodCall.getSourceInfo().makeChild(); JExpression inst = null; for (final JMethod method : uiType.getMethods()) {
if (method.getName().equals("set")) { final SourceInfo info = methodCall.getSourceInfo().makeChild(SourceOrigin.UNKNOWN); final Optional<JNewInstance> result = newInstance(logger, info, ast, answerType); if (result.isPresent()) {
SourceInfo methodSource = methodCall.getSourceInfo().makeChild(SourceOrigin.UNKNOWN);
final SourceInfo methodSource = methodCall.getSourceInfo().makeChild( SourceOrigin.UNKNOWN);
enclosing = method.getEnclosingType(); final Optional<JNewInstance> ctor = newInstance(logger, x.getSourceInfo(), ast, answerType); if (ctor.isPresent()) { instantiationExpressions.add(ctor.get()); } else { return JPermutationDependentValue.createTypeRebind(ast.getProgram(), x.getSourceInfo(), reqType, answers, instantiationExpressions);
index(ast); final SourceInfo info = methodCall.getSourceInfo().makeChild(); final JExpression classArg = methodCall.getArgs().get(0); final JClassLiteral classLit = ReflectionUtilAst.extractClassLiteral(
SourceInfo info = methodCall.getSourceInfo().makeChild(); cur = arrayType; while (cur instanceof JArrayType) {
final Context context, final UnifyAstView ast) throws UnableToCompleteException { final SourceInfo info = methodCall.getSourceInfo().makeChild();
return new JFieldRef(callSite.getSourceInfo().makeChild(), null, field, type);