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

Method _exec

output/java/1.4.14/Interpreter.java:168–483  ·  view source on GitHub ↗
(STWriter out, InstanceScope scope)

Source from the content-addressed store, hash-verified

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