1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
public static CallSite bsm_binary(Lookup lookup, String name, MethodType mtype) {
//TODO
Class<?> type ;
String message;
switch (name) {
case "SUB":
type = Integer.class;
message = "invalide operation binary SUB on %s" ;
System.out.println();
break;
case "ADD":
type = Integer.class;
message = "invalide operation binary ADD on %s" ;
break;
default: //
type = Boolean.class;
message = "invalide operation binary on %s" ;
break;
}
MethodHandle test = insertArguments(CHECK_TYPE, 1, type);
System.out.println(test);
MethodHandle target = loadStaticMH(name.toLowerCase(),type, type,type).asType(MethodType.methodType(Object.class, Object.class,Object.class));
MethodHandle fallback = insertArguments(REPORT_ERROR, 1, message);
System.out.println(fallback);
MethodHandle guard = guardWithTest(test, target, fallback);
return new ConstantCallSite(guard);
//throw new UnsupportedOperationException();
} |
Partager