public override void execute(StackFrame frame) { ClassFile clazz = ToyVMClassLoader.loadClass(method.GetClassInfo().getClassName()); ConstantPoolInfo_NameAndType nameAndType = method.GetMethodNameAndType(); if (log.IsDebugEnabled) log.DebugFormat("Will be executing {0} on {1}",nameAndType,clazz.GetName()); MethodInfo methodInfo = clazz.getMethod(nameAndType); // TODO: Need better way of handling access to the method if (methodInfo == null){ throw new ToyVMException("Unable to locate method " + nameAndType + " on " + clazz,frame); } StackFrame frame2 = new StackFrame(frame); int paramCount = method.getParameterCount(); frame2.setMethod(clazz,methodInfo,paramCount); if (log.IsDebugEnabled) log.DebugFormat("Have {0} parameters",paramCount); // Store the parameters from the operand stack // into the local variables of the outgoing frame for (int i = paramCount; i > 0; i--){ frame2.getLocalVariables()[i-1]=frame.popOperand(); if (log.IsDebugEnabled) log.DebugFormat("Parameter {0} = {1}",i,frame2.getLocalVariables()[i-1]); } clazz.execute(nameAndType,frame2); /*methodInfo.execute(frame2); if (methodInfo != null){ } else { throw new Exception("Unable to locate " + nameAndType.ToString()); } */ }
/** * * Operand stack * ..., objectref, [arg1, [arg2 ...]] ... */ public override void execute(StackFrame frame) { ClassFile clazz = ToyVMClassLoader.loadClass(method.GetClassInfo().getClassName()); ConstantPoolInfo_NameAndType nameAndType = method.GetMethodNameAndType(); if (log.IsDebugEnabled) log.DebugFormat("Will be executing {0} on {1}",nameAndType,clazz.GetName()); MethodInfo methodInfo = clazz.getMethod(nameAndType); StackFrame frame2 = new StackFrame(frame); int paramCount = method.getParameterCount(); frame2.setMethod(clazz,methodInfo,paramCount); if (log.IsDebugEnabled) log.DebugFormat("Have {0} parameters",paramCount); if (log.IsDebugEnabled) log.DebugFormat("Max Locals: {0}",methodInfo.getMaxLocals()); // push "this" as local variable 0 //frame2.setThis((ToyVMObject)(frame2.getLocalVariables()[0])); // Store the parameters from the operand stack // into the local variables of the outgoing frame for (int i = paramCount;i >= 0; i--){ frame2.getLocalVariables()[i]=frame.popOperand(); if (log.IsDebugEnabled) log.DebugFormat("Set variable {0}={1}",(i),frame2.getLocalVariables()[i]); } clazz.execute(nameAndType,frame2); //Environment.Exit(0); }
public override void execute(StackFrame frame) { try { frame.pushOperand((int) frame.getLocalVariables()[index]); } catch (InvalidCastException e){ foreach (Object o in frame.getLocalVariables()){ if (log.IsDebugEnabled) log.DebugFormat("Var:{0}",o); } throw new ToyVMException("Wanted int at " + index + " but got " + frame.getLocalVariables()[index],e,frame); } }
public override void execute(StackFrame frame) { try { //if (log.IsDebugEnabled) log.DebugFormat("Local variable {0} is {1}",index,frame.getLocalVariables()[index]); frame.pushOperand(frame.getLocalVariables()[index]); } catch (Exception e){ throw new ToyVMException("Index is " + index,e,frame); } }
/** * * Operand stack * ..., objectref, [arg1, [arg2 ...]] ... */ public override void execute(StackFrame frame) { //ClassFile clazz = ToyVMClassLoader.loadClass(method.GetClassInfo().getClassName()); ConstantPoolInfo_NameAndType nameAndType = method.GetMethodNameAndType(); if (log.IsDebugEnabled) log.DebugFormat("Will be executing {0} on interface {1}",nameAndType,method.GetClassInfo().getClassName()); int paramCount = method.getParameterCount(); ArrayList locals = new ArrayList(); for (int i = 0; i <= paramCount; i++){ locals.Add(0); } // create temp version of the variables // so that we can get to the object // on the stack for (int i = paramCount; i >= 0; i--){ locals[i] = frame.popOperand(); } ClassFile clazz = ((Heap.HeapReference)locals[0]).type; StackFrame frame2 = new StackFrame(frame); frame2.setMethod(clazz,clazz.getMethod(nameAndType)); if (log.IsDebugEnabled) log.DebugFormat("Have {0} parameters",paramCount); for (int i = 0;i <= paramCount; i++){ frame2.getLocalVariables()[i] = locals[i]; } clazz.execute(nameAndType,frame2); //Environment.Exit(0); }
/** * * Operand stack * ..., objectref, [arg1, [arg2 ...]] ... */ public override void execute(StackFrame frame) { ConstantPoolInfo_NameAndType nameAndType = method.GetMethodNameAndType(); if (log.IsDebugEnabled) log.DebugFormat("Will be executing {0} on class {1}",nameAndType,method.GetClassInfo().getClassName()); int paramCount = method.getParameterCount(); ArrayList locals = new ArrayList(); for (int i = 0; i <= paramCount; i++){ locals.Add(0); } // create temp version of the variables // so that we can get to the object // on the stack for (int i = paramCount; i >= 0; i--){ locals[i] = frame.popOperand(); if (log.IsDebugEnabled) log.DebugFormat("Parameter {0} is {1}",i,locals[i]); } ClassFile clazz = null; // for Object::getClass we actually // push the ClassFile onto the stack if (locals[0] is Heap.HeapReference){ clazz = ((Heap.HeapReference)locals[0]).type; } else if (locals[0] is ClassFile){ clazz = (ClassFile) locals[0]; } StackFrame frame2 = new StackFrame(frame); frame2.setMethod(clazz,clazz.getMethod(nameAndType)); if (log.IsDebugEnabled) log.DebugFormat("Have {0} parameters",paramCount); for (int i = 0;i <= paramCount; i++){ frame2.getLocalVariables()[i] = locals[i]; } clazz.execute(nameAndType,frame2); /* ClassFile clazz = ToyVMClassLoader.loadClass(method.GetClassInfo().getClassName()); ConstantPoolInfo_NameAndType nameAndType = method.GetMethodNameAndType(); if (log.IsDebugEnabled) log.DebugFormat("Will be executing {0} on {1}",nameAndType,clazz.GetName()); StackFrame frame2 = new StackFrame(frame); frame2.setMethod(clazz,clazz.getMethod(nameAndType)); int paramCount = method.getParameterCount(); if (log.IsDebugEnabled) log.DebugFormat("Have {0} parameters",paramCount); // push "this" as local variable 0 // Store the parameters from the operand stack // into the local variables of the outgoing frame for (int i = paramCount;i >= 0; i--){ frame2.getLocalVariables()[i]=frame.popOperand(); if (log.IsDebugEnabled) log.DebugFormat("Set variable {0}={1}",(i),frame2.getLocalVariables()[i]); } //frame2.getLocalVariables().Insert(0,frame.popOperand()); clazz.execute(nameAndType,frame2); */ //Environment.Exit(0); }
public override void execute(StackFrame frame) { frame.getLocalVariables().Insert(index,frame.popOperand()); }
public override void execute(StackFrame frame) { int old = (int)frame.getLocalVariables()[index]; frame.getLocalVariables()[index] = old + constant; }
/** * Value at index should be of type returnAddress, but we just use int */ public override void execute(StackFrame frame) { int pc = (int) frame.getLocalVariables()[index]; frame.setProgramCounter(pc - size); // we have to decrement because executor will add }