MCPcopy Create free account
hub / github.com/antlr/codebuff / _exec

Method _exec

output/java/1.4.15/Interpreter.java:172–487  ·  view source on GitHub ↗
(STWriter out, InstanceScope scope)

Source from the content-addressed store, hash-verified

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... load_str(self, ip);
195 ip += Bytecode.OPND_SIZE_IN_BYTES;
196 break;
197 case Bytecode.INSTR_LOAD_ATTR:
198 nameIndex = getShort(code, ip);
199 ip += Bytecode.OPND_SIZE_IN_BYTES;
200 name = self.impl.strings[nameIndex];
201 try {
202 o = getAttribute(scope, name);
203 if ( o== ST.EMPTY_ATTR ) o = null;
204 }
205 catch (STNoSuchAttributeException nsae) {
206 errMgr.runTimeError(this, scope, ErrorType.NO_SUCH_ATTRIBUTE, name);
207 o = null;
208 }
209 operands[++sp] = o;
210 break;
211 case Bytecode.INSTR_LOAD_LOCAL:
212 int valueIndex = getShort(code, ip);
213 ip += Bytecode.OPND_SIZE_IN_BYTES;
214 o = self.locals[valueIndex];
215 if ( o== ST.EMPTY_ATTR ) o = null;
216 operands[++sp] = o;
217 break;
218 case Bytecode.INSTR_LOAD_PROP:
219 nameIndex = getShort(code, ip);
220 ip += Bytecode.OPND_SIZE_IN_BYTES;
221 o = operands[sp--];
222 name = self.impl.strings[nameIndex];
223 operands[++sp] = getObjectProperty(out, scope, o, name);
224 break;
225 case Bytecode.INSTR_LOAD_PROP_IND:
226 Object propName = operands[sp--];
227 o = operands[sp];
228 operands[sp] = getObjectProperty(out, scope, o, propName);
229 break;

Callers 1

execMethod · 0.95

Calls 15

traceMethod · 0.95
getShortMethod · 0.95
getAttributeMethod · 0.95
getObjectPropertyMethod · 0.95
storeArgsMethod · 0.95
super_newMethod · 0.95
writeObjectNoOptionsMethod · 0.95
mapMethod · 0.95
rot_mapMethod · 0.95
zip_mapMethod · 0.95
testAttributeTrueMethod · 0.95

Tested by

no test coverage detected