// // used for instructions that take a word as a parameter // (e.g. branches, newarray, invokemethod) // void plant(String name, String val) throws jasError { InsnInfo insn = InsnInfo.get(name); CodeAttr code = _getCode(); autoNumber(); flushInsnBuffer(); if (insn.args.equals("method")) { String split[] = ScannerUtils.splitClassMethodSignature(val); bufferInsn(new Insn(insn.opcode, new MethodCP(split[0], split[1], split[2]))); } else if (insn.args.equals("interface")) { String split[] = ScannerUtils.splitClassMethodSignature(val); bufferInsn( new InvokeinterfaceInsn( new InterfaceCP(split[0], split[1], split[2]), ScannerUtils.getArgumentsAndReturnSizes(split[2]) >> 2)); } else if (name.startsWith("ldc")) { bufferInsn(new Insn(insn.opcode, new ClassCP(val))); } else if (insn.args.equals("atype")) { int atype = 0; if (val.equals("boolean")) { atype = 4; } else if (val.equals("char")) { atype = 5; } else if (val.equals("float")) { atype = 6; } else if (val.equals("double")) { atype = 7; } else if (val.equals("byte")) { atype = 8; } else if (val.equals("short")) { atype = 9; } else if (val.equals("int")) { atype = 10; } else if (val.equals("long")) { atype = 11; } else { throw new jasError("Bad array type: " + name); } bufferInsn(new Insn(insn.opcode, atype, false)); } else if (insn.args.indexOf("label") >= 0) { bufferInsn(new Insn(insn.opcode, getLabel(val), scanner.line_num)); } else if (insn.args.equals("class")) { bufferInsn(new Insn(insn.opcode, new ClassCP(val))); } else { throw new jasError("(gloups)Bad arguments for instruction " + name); } }
// // called by the .enclosing directive // void setEnclosingMethod(String str) { try { if (str.indexOf("(") != -1) { // full method description String[] split = ScannerUtils.splitClassMethodSignature(str); class_env.setEnclosingMethod(split[0], split[1], split[2]); } else // just a class name class_env.setEnclosingMethod(str, null, null); } catch (IllegalArgumentException e) { report_error(e.toString()); } }
// // used for invokeinterface and multianewarray // void plant(String name, String val, int nargs) throws jasError { InsnInfo insn = InsnInfo.get(name); CodeAttr code = _getCode(); autoNumber(); flushInsnBuffer(); if (insn.args.equals("interface")) { String split[] = ScannerUtils.splitClassMethodSignature(val); bufferInsn( new InvokeinterfaceInsn( new InterfaceCP(split[0], split[1], split[2]), ScannerUtils.getArgumentsAndReturnSizes(split[2]) >> 2)); } else if (insn.args.equals("marray")) { bufferInsn(new MultiarrayInsn(new ClassCP(val), nargs)); } else { throw new jasError("Bad arguments for instruction " + name); } }