/** * Compile the function call and treat as an expression * Update true/false-lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { Type type = Type.Boolean; if (_chosenMethodType != null) type = _chosenMethodType.resultType(); final InstructionList il = methodGen.getInstructionList(); translate(classGen, methodGen); if ((type instanceof BooleanType) || (type instanceof IntType)) { _falseList.add(il.append(new IFEQ(null))); } }
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionIfeq(Element inst) { int id = Integer.parseInt(inst.getAttributeValue("label")); BranchInstruction bi = new IFEQ(null); instructionHandlerManager.registerBranchInstruction(bi, id); return bi; }
public void addBranch( int pc, int branchType, int targetpc ) { switch ( branchType ) { default: case BRANCH_GOTO: branches[pc] = new GOTO(null); break; case BRANCH_IFNE: branches[pc] = new IFNE(null); break; case BRANCH_IFEQ: branches[pc] = new IFEQ(null); break; } targets[pc] = targetpc; append(branches[pc]); }
void generateMain(ClassGen clg, Method origMain) { InstructionList il = new InstructionList(); MethodGen new_main = new MethodGen(Constants.ACC_STATIC | Constants.ACC_PUBLIC, Type.VOID, new Type[] { new ArrayType( Type.STRING, 1) }, new String[] { "argv" }, "main", clg .getClassName(), il, clg.getConstantPool()); il.append(ins_f.createNew(cashmereType)); il.append(new DUP()); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster", Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); BranchHandle ifcmp = il.append(new IFEQ(null)); InstructionHandle origMain_handle = il.append(new ALOAD(0)); InstructionHandle try_start = il.append(ins_f.createInvoke(clg .getClassName(), origMain.getName(), Type.VOID, new Type[] { new ArrayType(Type.STRING, 1) }, Constants.INVOKESTATIC)); BranchHandle try_end = il.append(new GOTO(null)); InstructionHandle e_handler = il.append(getCashmere(ins_f)); il.append(new SWAP()); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit", Type.VOID, new Type[] { new ObjectType("java.lang.Throwable")}, Constants.INVOKEVIRTUAL)); BranchHandle gto2 = il.append(new GOTO(null)); InstructionHandle ifeq_target = il.append(getCashmere(ins_f)); ifcmp.setTarget(ifeq_target); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "client", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.append(getCashmere(ins_f)); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster", Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.append(new IFNE(origMain_handle)); InstructionHandle gto_target = il.append(getCashmere(ins_f)); try_end.setTarget(gto_target); il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); InstructionHandle gto2_target = il.append(new RETURN()); gto2.setTarget(gto2_target); new_main.addExceptionHandler(try_start, try_end, e_handler, new ObjectType("java.lang.Throwable")); new_main.setMaxStack(); new_main.setMaxLocals(); new_main.addLocalVariable("argv", new ArrayType(Type.STRING, 1), 0, origMain_handle, null); removeLocalTypeTables(new_main); Method main = new_main.getMethod(); gen_c.addMethod(main); }
void insertAbortedCheck(MethodGen m, InstructionList il, InstructionHandle pos) { // Generates: // if (cashmere.getParent() != null && cashmere.getParent().aborted) { // throw new ibis.cashmere.impl.aborts.AbortException(); // } InstructionHandle abo = insertThrowAbort(m, il, pos); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); // test for null (root job) il.insert(abo, new IFNULL(pos)); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "aborted", Type.BOOLEAN, Constants.GETFIELD)); il.insert(abo, new IFEQ(pos)); /* ////@@@@@@@@@@2 this needs fixing :-( // Test for parent.eek, if non-null, throw it (exception in inlet). il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek", new ObjectType("java.lang.Throwable"), Constants.GETFIELD)); il.insert(abo, new IFNULL(abo)); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek", new ObjectType("java.lang.Throwable"), Constants.GETFIELD)); il.insert(abo, new ATHROW()); */ }