make.Apply( null, make.Select(receiver, impl).setType(calltype), translateArgs(make.Idents(md.params), origErasure.getParameterTypes(), null)) .setType(calltype);
make.Apply( null, make.Select(receiver, impl).setType(calltype), translateArgs(make.Idents(md.params), origErasure.getParameterTypes(), null)) .setType(calltype);
make.Select(receiver, impl).setType(calltype), translateArgs(make.Idents(md.params), origErasure.getParameterTypes(), null)) .setType(calltype); JCStatement stat = (origErasure.getReturnType().hasTag(VOID)) ? make.Exec(call)
private void addOverrideBridges(DiagnosticPosition pos, MethodSymbol impl, MethodSymbol member, ClassSymbol c, ListBuffer<JCTree> bridges) { Type implErasure = impl.erasure(types); long flags = (impl.flags() & AccessFlags) | SYNTHETIC | BRIDGE | OVERRIDE_BRIDGE; member = new MethodSymbol(flags, member.name, member.type, c); JCMethodDecl md = make.MethodDef(member, null); JCExpression receiver = make.Super(types.supertype(c.type).tsym.erasure(types), c); Type calltype = erasure(impl.type.getReturnType()); JCExpression call = make.Apply(null, make.Select(receiver, impl).setType(calltype), translateArgs(make.Idents(md.params), implErasure.getParameterTypes(), null)) .setType(calltype); JCStatement stat = (member.getReturnType().hasTag(VOID)) ? make.Exec(call) : make.Return(coerce(call, member.erasure(types).getReturnType())); md.body = make.Block(0, List.of(stat)); c.members().enter(member); bridges.append(md); }
/** * determine the receiver of the bridged method call - the receiver can * be either the synthetic receiver parameter or a type qualifier; the * original qualifier expression is never used here, as it might refer * to symbols not available in the static context of the bridge */ private JCExpression bridgeExpressionInvoke(JCExpression rcvr) { JCExpression qualifier = tree.sym.isStatic() ? make.Type(tree.sym.owner.type) : (rcvr != null) ? rcvr : tree.getQualifierExpression(); //create the qualifier expression JCFieldAccess select = make.Select(qualifier, tree.sym.name); select.sym = tree.sym; select.type = tree.sym.erasure(types); //create the method call expression JCExpression apply = make.Apply(List.<JCExpression>nil(), select, convertArgs(tree.sym, args.toList(), tree.varargsElement)). setType(tree.sym.erasure(types).getReturnType()); apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType()); setVarargsIfNeeded(apply, tree.varargsElement); return apply; }
@Override public void visitBinary( JCBinary tree ) { super.visitBinary( tree ); OperatorMethod foundOpMeth = null; for( OperatorMethod opMeth : ops ) { if( tree.getTag() == opMeth.op && types.isAssignable( opMeth.arg0, tree.lhs.type ) && types.isAssignable( opMeth.arg1, tree.rhs.type ) ) { foundOpMeth = opMeth; break; } } if( foundOpMeth != null ) { result = make.Apply( List.<JCExpression> nil(), make.Select( make.Ident( foundOpMeth.sym.owner ), foundOpMeth.sym ).setType( foundOpMeth.mt ), List.of( tree.lhs, tree.rhs ) ) .setType( foundOpMeth.res ); debug( "Replacing overloaded operator '" + foundOpMeth.op + "' by call to '" + foundOpMeth.sym + "'" ); } }
private void addOverrideBridges(DiagnosticPosition pos, MethodSymbol impl, MethodSymbol member, ClassSymbol c, ListBuffer<JCTree> bridges) { Type implErasure = impl.erasure(types); long flags = (impl.flags() & AccessFlags) | SYNTHETIC | BRIDGE | OVERRIDE_BRIDGE; member = new MethodSymbol(flags, member.name, member.type, c); JCMethodDecl md = make.MethodDef(member, null); JCExpression receiver = make.Super(types.supertype(c.type).tsym.erasure(types), c); Type calltype = erasure(impl.type.getReturnType()); JCExpression call = make.Apply(null, make.Select(receiver, impl).setType(calltype), translateArgs(make.Idents(md.params), implErasure.getParameterTypes(), null)) .setType(calltype); JCStatement stat = (member.getReturnType().hasTag(VOID)) ? make.Exec(call) : make.Return(coerce(call, member.erasure(types).getReturnType())); md.body = make.Block(0, List.of(stat)); c.members().enter(member); bridges.append(md); }
/** * determine the receiver of the method call - the receiver can * be a type qualifier, the synthetic receiver parameter or 'super'. */ private JCExpression expressionInvoke(VarSymbol rcvr) { JCExpression qualifier = (rcvr != null) ? makeReceiver(rcvr) : tree.getQualifierExpression(); //create the qualifier expression JCFieldAccess select = make.Select(qualifier, tree.sym.name); select.sym = tree.sym; select.type = tree.sym.erasure(types); //create the method call expression JCExpression apply = make.Apply(List.<JCExpression>nil(), select, convertArgs(tree.sym, args.toList(), tree.varargsElement)). setType(tree.sym.erasure(types).getReturnType()); apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType()); setVarargsIfNeeded(apply, tree.varargsElement); return apply; }
private JCExpression deserTest(JCExpression prev, String func, String lit) { MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass); Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil()); JCMethodInvocation eqtest = make.Apply( List.<JCExpression>nil(), make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt), List.<JCExpression>of(make.Literal(lit))); eqtest.setType(syms.booleanType); JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest); compound.operator = rs.resolveBinaryOperator(null, JCTree.Tag.AND, attrEnv, syms.booleanType, syms.booleanType); compound.setType(syms.booleanType); return compound; }
private JCExpression deserTest(JCExpression prev, String func, String lit) { MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass); Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil()); JCMethodInvocation eqtest = make.Apply( List.<JCExpression>nil(), make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt), List.<JCExpression>of(make.Literal(lit))); eqtest.setType(syms.booleanType); JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest); compound.operator = rs.resolveBinaryOperator(null, JCTree.Tag.AND, attrEnv, syms.booleanType, syms.booleanType); compound.setType(syms.booleanType); return compound; }
/** * Create a no-arg method invocation from a method tree */ public JCMethodInvocation App(JCExpression meth) { return Apply(null, meth, List.<JCExpression>nil()).setType(meth.type.getReturnType()); }
/** * Create a no-arg method invocation from a method tree */ public JCMethodInvocation App(JCExpression meth) { return Apply(null, meth, List.<JCExpression>nil()).setType(meth.type.getReturnType()); }
/** * Create a method invocation from a method tree and a list of * argument trees. */ public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { return Apply(null, meth, args).setType(meth.type.getReturnType()); }
/** * Create a no-arg method invocation from a method tree */ public JCMethodInvocation App(JCExpression meth) { return Apply(null, meth, List.<JCExpression>nil()).setType(meth.type.getReturnType()); }
private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) { MethodType getmt = new MethodType(argTypes, type, List.<Type>nil(), syms.methodClass); Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.<Type>nil()); return make.Apply( List.<JCExpression>nil(), make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt), args).setType(type); }
/** * Create a no-arg method invocation from a method tree */ public JCMethodInvocation App(JCExpression meth) { return Apply(null, meth, List.<JCExpression>nil()).setType(meth.type.getReturnType()); }
private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) { MethodType getmt = new MethodType(argTypes, type, List.<Type>nil(), syms.methodClass); Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.<Type>nil()); return make.Apply( List.<JCExpression>nil(), make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt), args).setType(type); }
/** * Create a method invocation from a method tree and a list of * argument trees. */ public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { return Apply(null, meth, args).setType(meth.type.getReturnType()); }
/** * Create a method invocation from a method tree and a list of * argument trees. */ public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { return Apply(null, meth, args).setType(meth.type.getReturnType()); }
/** * Create a method invocation from a method tree and a list of * argument trees. */ public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { return Apply(null, meth, args).setType(meth.type.getReturnType()); }