log.debug("Instruction : DUP");
top = stack.peek();
if(top.getSize() == 1){
setNextPushTypes(top.getType());
}else{
throw new InstructionException("two word value off the operand stack", DUP, (Stack)stack.clone());
}
break;
case DUP_X1 :
if(log.isDebugEnabled())
log.debug("Instruction : DUP_X1");
top = stack.peek();
if(top.getSize() == 1){
stack.insert(2, top);
}else{
throw new InstructionException("two word value off the operand stack", DUP_X1, (Stack)stack.clone());
}
break;
case DUP_X2 :
if(log.isDebugEnabled())
log.debug("Instruction : DUP_X2");
top = stack.peek();
if(top.getSize() == 1){
stack.insert(3, top);
}else{
throw new InstructionException("two word value off the operand stack", DUP_X2, (Stack)stack.clone());
}
break;
case DUP2 :
if(log.isDebugEnabled())
log.debug("Instruction : DUP2");
if(stack.peek().getSize() == 2){
setNextPushTypes(stack.peek().getType());
}else if(stack.peek().getSize() == 1
&& stack.peek(1).getSize() == 1){
setNextPushTypes(stack.peek(1).getType(), stack.peek().getType());
}else{
throw new InstructionException("cannot dup top two from stack", DUP2, (Stack)stack.clone());
}
break;
case DUP2_X1 :
if(log.isDebugEnabled())
log.debug("Instruction : DUP2_X1");
if(stack.peek().getSize() == 2){
stack.insert(2, stack.peek());
}else if(stack.peek().getSize() == 1
&& stack.peek(1).getSize() == 1){
stack.insert(2, stack.peek(1));
stack.insert(2, stack.peek());
}else{
throw new InstructionException("cannot dup top two from stack", DUP2_X1, (Stack)stack.clone());
}
break;
case DUP2_X2 :
if(log.isDebugEnabled()){
log.debug("Instruction : DUP2_X2");
}
if(stack.peek().getSize() == 2){
stack.insert(3, stack.peek());
}else if(stack.peek().getSize() == 1
&& stack.peek(1).getSize() == 1){
stack.insert(3, stack.peek(1));
stack.insert(3, stack.peek());
}else{
throw new InstructionException("cannot dup top two from stack", DUP2_X2, (Stack)stack.clone());
}
break;
case SWAP :
if(log.isDebugEnabled()){
log.debug("Instruction : SWAP");