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

Method _exec

output/java/1.4.13/Interpreter.java:173–480  ·  view source on GitHub ↗
(STWriter out, InstanceScope scope)

Source from the content-addressed store, hash-verified

171 }
172
173 protected int _exec(STWriter out, InstanceScope scope) {
174 final ST self = scope.st;
175 int start = out.index(); // track char we're about to write
176 int prevOpcode = 0;
177 int n = 0; // how many char we write out
178 int nargs;
179 int nameIndex;
180 int addr;
181 String name;
182 Object o, left, right;
183 ST st;
184 Object[] options;
185 byte[] code = self.impl.instrs; // which code block are we executing
186 int ip = 0;
187 while ( ip <self.impl.codeSize ) {
188 if ( trace|| debug ) trace(scope, ip);
189 short opcode = code[ip];
190 //count[opcode]++;
191 scope.ip = ip;
192 ip++; //jump to next instruction or first byte of operand
193 switch ( opcode ) {
194 case Bytecode.INSTR_LOAD_STR:
195 // just testing... 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);
230 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