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