public void execute( Memory memoria, OperandStack pila, ProgramCounter pc, InMethod inm, OutMethod outm) throws InstructionExecutionException { int valor = Integer.parseInt(valor_asociado); if (!pila.getEmpty()) { memoria.guardar(valor, pila.desapilar()); } else { throw new InstructionExecutionException( "error ejecutando " + toString() + ": faltan operandos en la pila (hay " + pila.getSize() + ")"); } }
/** * Ejecutar. * * @throws InstructionExecutionException * @throws DivByZero */ public void execute( Memory mem, OperandStack os, ExecutionManager em, InStrategy ins, OutStrategy outs) throws InstructionExecutionException, DivByZero { if (os.size() > 1) { int cima = os.getCima(); os.pop(); int subcima = os.getCima(); os.pop(); try { execute(cima, subcima, os); } catch (DivByZero dz) { os.push(subcima); os.push(cima); // System.err.println(dz.getMessage());//printea cpu!! // if(ins.getName().equalsIgnoreCase("WINDOWINSTRATEGY") // && outs.getName().equalsIgnoreCase("WINDOWOUTSTRATEGY")){ throw new DivByZero(); // } } } else { throw new InstructionExecutionException(toString(), os.size()); } }