(C context, ObjExpr objx, GeneratorAdapter gen)
| 4249 | } |
| 4250 | |
| 4251 | public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){ |
| 4252 | Label onLabel = gen.newLabel(); |
| 4253 | Label callLabel = gen.newLabel(); |
| 4254 | Label endLabel = gen.newLabel(); |
| 4255 | |
| 4256 | Var v = ((VarExpr)fexpr).var; |
| 4257 | |
| 4258 | Expr e = (Expr) args.nth(0); |
| 4259 | e.emit(C.EXPRESSION, objx, gen); |
| 4260 | gen.dup(); //target, target |
| 4261 | gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class |
| 4262 | gen.getStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target,class,cached-class |
| 4263 | gen.visitJumpInsn(IF_ACMPEQ, callLabel); //target |
| 4264 | if(protocolOn != null) |
| 4265 | { |
| 4266 | gen.dup(); //target, target |
| 4267 | gen.instanceOf(Type.getType(protocolOn)); |
| 4268 | gen.ifZCmp(GeneratorAdapter.NE, onLabel); |
| 4269 | } |
| 4270 | |
| 4271 | gen.dup(); //target, target |
| 4272 | gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class |
| 4273 | gen.putStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target |
| 4274 | |
| 4275 | gen.mark(callLabel); //target |
| 4276 | objx.emitVar(gen, v); |
| 4277 | gen.invokeVirtual(VAR_TYPE, Method.getMethod("Object getRawRoot()")); //target, proto-fn |
| 4278 | gen.swap(); |
| 4279 | emitArgsAndCall(1, context,objx,gen); |
| 4280 | gen.goTo(endLabel); |
| 4281 | |
| 4282 | gen.mark(onLabel); //target |
| 4283 | if(protocolOn != null) |
| 4284 | { |
| 4285 | gen.checkCast(Type.getType(protocolOn)); |
| 4286 | MethodExpr.emitTypedArgs(objx, gen, onMethod.getParameterTypes(), RT.subvec(args,1,args.count())); |
| 4287 | if(context == C.RETURN) |
| 4288 | { |
| 4289 | ObjMethod method = (ObjMethod) METHOD.deref(); |
| 4290 | method.emitClearLocals(gen); |
| 4291 | } |
| 4292 | Method m = new Method(onMethod.getName(), Type.getReturnType(onMethod), Type.getArgumentTypes(onMethod)); |
| 4293 | gen.invokeInterface(Type.getType(protocolOn), m); |
| 4294 | HostExpr.emitBoxReturn(objx, gen, onMethod.getReturnType()); |
| 4295 | } |
| 4296 | gen.mark(endLabel); |
| 4297 | } |
| 4298 | |
| 4299 | void emitArgsAndCall(int firstArgToEmit, C context, ObjExpr objx, GeneratorAdapter gen){ |
| 4300 | for(int i = firstArgToEmit; i < Math.min(MAX_POSITIONAL_ARITY, args.count()); i++) |
no test coverage detected