public StackValue Evaluate(List <StackValue> args, StackFrame stackFrame)
        {
            //
            // Build the stackframe
            int        classScopeCaller = (int)stackFrame.GetAt(DSASM.StackFrame.AbsoluteIndex.kClass).opdata;
            int        returnAddr       = (int)stackFrame.GetAt(DSASM.StackFrame.AbsoluteIndex.kReturnAddress).opdata;
            int        blockDecl        = (int)mProcNode.runtimeIndex;
            int        blockCaller      = (int)stackFrame.GetAt(DSASM.StackFrame.AbsoluteIndex.kFunctionCallerBlock).opdata;
            int        framePointer     = mRunTime.runtime.Core.Rmem.FramePointer;
            StackValue thisPtr          = StackUtils.BuildPointer(-1);


            // Comment Jun: the caller type is the current type in the stackframe
            StackFrameType callerType = (StackFrameType)stackFrame.GetAt(StackFrame.AbsoluteIndex.kStackFrameType).opdata;

            StackFrameType    type      = StackFrameType.kTypeFunction;
            int               depth     = 0;
            List <StackValue> registers = new List <StackValue>();

            // Comment Jun: Calling convention data is stored on the TX register
            StackValue svCallconvention = StackUtils.BuildNode(AddressType.CallingConvention, (long)ProtoCore.DSASM.CallingConvention.BounceType.kImplicit);

            mRunTime.runtime.TX = svCallconvention;

            StackValue svBlockDecl = StackUtils.BuildNode(AddressType.BlockIndex, blockDecl);

            mRunTime.runtime.SX = svBlockDecl;

            mRunTime.runtime.SaveRegisters(registers);
            ProtoCore.DSASM.StackFrame newStackFrame = new StackFrame(thisPtr, classScopeCaller, 1, returnAddr, blockDecl, blockCaller, callerType, type, depth, framePointer, registers);

            List <List <int> > replicationGuides = new List <List <int> >();

            if (mRunTime.runtime.Core.Options.IDEDebugMode && mRunTime.runtime.Core.ExecMode != ProtoCore.DSASM.InterpreterMode.kExpressionInterpreter)
            {
                mRunTime.runtime.Core.DebugProps.SetUpCallrForDebug(mRunTime.runtime.Core, mRunTime.runtime, mProcNode, returnAddr - 1,
                                                                    false, mCallSite, args, replicationGuides, newStackFrame);
            }


            StackValue rx = mCallSite.JILDispatchViaNewInterpreter(new Runtime.Context(), args, replicationGuides, newStackFrame, mRunTime.runtime.Core);

            if (mRunTime.runtime.Core.Options.IDEDebugMode && mRunTime.runtime.Core.ExecMode != ProtoCore.DSASM.InterpreterMode.kExpressionInterpreter)
            {
                mRunTime.runtime.Core.DebugProps.RestoreCallrForNoBreak(mRunTime.runtime.Core, mProcNode);
            }

            return(rx);
        }
예제 #2
0
 public void PushStackFrame(StackValue svThisPtr, int classIndex, int funcIndex, int pc, int functionBlockDecl, int functionBlockCaller, StackFrameType callerType, StackFrameType type, int depth, int fp, List <StackValue> registers, int locsize)
 {
     // TODO Jun: Performance
     // Push frame should only require adjusting the frame index instead of pushing dummy elements
     PushFrame(locsize);
     Push(StackUtils.BuildInt(fp));
     PushRegisters(registers);
     Push(StackUtils.BuildNode(AddressType.Int, depth));
     Push(StackUtils.BuildNode(AddressType.FrameType, (int)type));
     Push(StackUtils.BuildNode(AddressType.FrameType, (int)callerType));
     Push(StackUtils.BuildNode(AddressType.BlockIndex, functionBlockCaller));
     Push(StackUtils.BuildNode(AddressType.BlockIndex, functionBlockDecl));
     Push(StackUtils.BuildInt(pc));
     Push(StackUtils.BuildInt(funcIndex));
     Push(StackUtils.BuildInt(classIndex));
     Push(svThisPtr);
     FramePointer = Stack.Count;
 }
예제 #3
0
        private ExecutionMirror Execute(int programCounterToExecuteFrom, List <Instruction> breakpoints, bool fepRun = false)
        {
            ProtoCore.Runtime.Context context = new ProtoCore.Runtime.Context();
            core.Breakpoints = breakpoints;
            resumeBlockID    = core.RunningBlock;

            int locals = 0;

            if (core.DebugProps.FirstStackFrame != null)
            {
                core.DebugProps.FirstStackFrame.SetAt(ProtoCore.DSASM.StackFrame.AbsoluteIndex.kFramePointer, StackUtils.BuildInt(core.GlobOffset));

                // Comment Jun: Tell the new bounce stackframe that this is an implicit bounce
                // Register TX is used for this.
                StackValue svCallConvention = StackUtils.BuildNode(AddressType.CallingConvention, (long)ProtoCore.DSASM.CallingConvention.BounceType.kImplicit);
                core.DebugProps.FirstStackFrame.SetAt(ProtoCore.DSASM.StackFrame.AbsoluteIndex.kRegisterTX, svCallConvention);
            }
            core.Bounce(resumeBlockID, programCounterToExecuteFrom, context, breakpoints, core.DebugProps.FirstStackFrame, locals, null, EventSink, fepRun);

            return(new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core));
        }
예제 #4
0
 public override StackValue Marshal(object obj, ProtoCore.Runtime.Context context, Interpreter dsi, ProtoCore.Type type)
 {
     return(StackUtils.BuildNode(AddressType.Boolean, (bool)obj ? 1 : 0));
 }