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

Method _exec

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

Callers 1

execMethod · 0.95

Calls 15

traceMethod · 0.95
load_strMethod · 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

Tested by

no test coverage detected