1 package jrre.unittests;
2
3 import jrre.*;
4 import jrre.types.*;
5 import jrre.api.java.lang.reflect.*;
6 import jrre.instructionset.Instruction;
7
8 public class JRRERunner {
9
10 public void loadClass(String className){
11 JRRE runtime = new JRRE(className);
12 }
13
14 public Type callMethod(String method, Type [] args){
15
16 StackFrame initialStackFrame = new StackFrame();
17 Stack.pushInitial(initialStackFrame, "initial stack frame");
18
19 jrre.api.java.lang.Class rootClass = JRRE.getRootClass();
20
21 // push method stack frame.
22 MethodEntry mainMethod = rootClass.getMethod(method);
23 Stack.push(mainMethod.getStackFrame(), method);
24
25 // Init local variables from arguments.
26 Stack.setLocalVariable(0, new ReferenceType(rootClass.instanceOf()));
27
28 if(args != null)
29 for(int i=1;i <= args.length;i++)
30 Stack.setLocalVariable(i, args[i-1]);
31
32 // Execute method.
33 Instruction instruction = Stack.getNextInstruction();
34 while(Stack.getStackPointer() != initialStackFrame){
35
36 //System.out.println(instruction);
37 instruction.execute();
38 instruction = Stack.getNextInstruction();
39 }
40
41 // Return result.
42 return Stack.popOperand();
43 }
44 }
This page was automatically generated by Maven