(STWriter out, InstanceScope scope)
| 165 | } |
| 166 | |
| 167 | protected int _exec(STWriter out, InstanceScope scope) { |
| 168 | final ST self = scope.st; |
| 169 | int start = out.index(); // track char we're about to write |
| 170 | int prevOpcode = 0; |
| 171 | int n = 0; // how many char we write out |
| 172 | int nargs; |
| 173 | int nameIndex; |
| 174 | int addr; |
| 175 | String name; |
| 176 | Object o, left, right; |
| 177 | ST st; |
| 178 | Object[] options; |
| 179 | byte[] code = self.impl.instrs; // which code block are we executing |
| 180 | int ip = 0; |
| 181 | while ( ip < self.impl.codeSize ) { |
| 182 | if ( trace || debug ) trace(scope, ip); |
| 183 | short opcode = code[ip]; |
| 184 | //count[opcode]++; |
| 185 | scope.ip = ip; |
| 186 | ip++; //jump to next instruction or first byte of operand |
| 187 | switch ( opcode ) { |
| 188 | case Bytecode.INSTR_LOAD_STR: |
| 189 | // just testing... load_str(self, ip); |
| 190 | ip += Bytecode.OPND_SIZE_IN_BYTES; |
| 191 | break; |
| 192 | case Bytecode.INSTR_LOAD_ATTR: nameIndex = getShort(code, ip); |
| 193 | ip += Bytecode.OPND_SIZE_IN_BYTES; |
| 194 | name = self.impl.strings[nameIndex]; |
| 195 | try { |
| 196 | o = getAttribute(scope, name); |
| 197 | if ( o==ST.EMPTY_ATTR ) o = null; |
| 198 | } |
| 199 | catch (STNoSuchAttributeException nsae) { |
| 200 | errMgr.runTimeError(this, scope, ErrorType.NO_SUCH_ATTRIBUTE, name); |
| 201 | o = null; |
| 202 | } |
| 203 | operands[++sp] = o; |
| 204 | break; |
| 205 | case Bytecode.INSTR_LOAD_LOCAL: |
| 206 | int valueIndex = getShort(code, ip); |
| 207 | ip += Bytecode.OPND_SIZE_IN_BYTES; |
| 208 | o = self.locals[valueIndex]; |
| 209 | if ( o==ST.EMPTY_ATTR ) o = null; |
| 210 | operands[++sp] = o; |
| 211 | break; |
| 212 | case Bytecode.INSTR_LOAD_PROP: nameIndex = getShort(code, ip); |
| 213 | ip += Bytecode.OPND_SIZE_IN_BYTES; |
| 214 | o = operands[sp--]; |
| 215 | name = self.impl.strings[nameIndex]; |
| 216 | operands[++sp] = getObjectProperty(out, scope, o, name); |
| 217 | break; |
| 218 | case Bytecode.INSTR_LOAD_PROP_IND: Object propName = operands[sp--]; |
| 219 | o = operands[sp]; |
| 220 | operands[sp] = getObjectProperty(out, scope, o, propName); |
| 221 | break; |
| 222 | case Bytecode.INSTR_NEW: nameIndex = getShort(code, ip); |
| 223 | ip += Bytecode.OPND_SIZE_IN_BYTES; |
| 224 | name = self.impl.strings[nameIndex]; |
no test coverage detected