()
| 131 | pc += 4; |
| 132 | } |
| 133 | protected void callFunction() { |
| 134 | Object value = registers[decodeRegister(code[pc + 1])]; |
| 135 | int numOfArgs = code[pc + 2]; |
| 136 | if (value instanceof VmFunction |
| 137 | && ((VmFunction)value).parameters().size() == numOfArgs) { |
| 138 | ret = pc + 3; |
| 139 | pc = ((VmFunction)value).entry(); |
| 140 | } |
| 141 | else if (value instanceof NativeFunction |
| 142 | && ((NativeFunction)value).numOfParameters() == numOfArgs) { |
| 143 | Object[] args = new Object[numOfArgs]; |
| 144 | for (int i = 0; i < numOfArgs; i++) |
| 145 | args[i] = stack[sp + i]; |
| 146 | stack[sp] = ((NativeFunction)value).invoke(args, |
| 147 | new ASTList(new ArrayList<ASTree>())); |
| 148 | pc += 3; |
| 149 | } |
| 150 | else |
| 151 | throw new StoneException("bad function call"); |
| 152 | } |
| 153 | protected void saveRegisters() { |
| 154 | int size = decodeOffset(code[pc + 1]); |
| 155 | int dest = size + sp; |
no test coverage detected