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);
        }
Exemplo n.º 2
0
 public void PushStackFrame(int ptr, 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(StackUtils.BuildPointer(ptr));
     FramePointer = Stack.Count;
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="context"></param>
        /// <param name="dsi"></param>
        /// <returns></returns>
        private StackValue CreateDSObject(object obj, ProtoCore.Runtime.Context context, Interpreter dsi)
        {
            //We are here, because we want to create DS object of user defined type.
            var  core       = dsi.runtime.Core;
            var  classTable = core.DSExecutable.classTable;
            Type objType    = GetPublicType(obj.GetType());
            int  type       = classTable.IndexOf(GetTypeName(objType));

            //Recursively get the base class type if available.
            while (type == -1 && objType != null)
            {
                objType = objType.BaseType;
                if (null != objType)
                {
                    type = classTable.IndexOf(GetTypeName(objType));
                }
            }

            int ptr = ProtoCore.DSASM.Constants.kInvalidPointer;

            lock (core.Heap.cslock)
            {
                ptr = core.Heap.Allocate(classTable.ClassNodes[type].size);
            }

            MetaData metadata;

            metadata.type = type;
            StackValue retval = StackUtils.BuildPointer(ptr, metadata);

            BindObjects(obj, retval);
            dsi.runtime.Core.FFIPropertyChangedMonitor.AddFFIObject(obj);

            //If we are in debug mode, populate primary properties if there is any.
            //if (core.Options.IDEDebugMode)
            //    PopulatePrimaryProperties(obj, retval, context, dsi, type);

            return(retval);
        }