/// <summary>
        /// Get all keys from an array
        /// </summary>
        /// <param name="array"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue[] GetKeys(StackValue array, Core core)
        {
            Validity.Assert(StackUtils.IsArray(array));
            if (!StackUtils.IsArray(array))
            {
                return(null);
            }

            HeapElement       he   = GetHeapElement(array, core);
            List <StackValue> keys = new List <StackValue>();

            for (int i = 0; i < he.VisibleSize; ++i)
            {
                keys.Add(StackUtils.BuildInt(i));
            }

            if (he.Dict != null)
            {
                foreach (var key in he.Dict.Keys)
                {
                    keys.Add(key);
                }
            }

            return(keys.ToArray());
        }
Exemple #2
0
            public StackValue GetData(int blockId, int symbolindex, int scope)
            {
                MemoryRegion region = DSASM.MemoryRegion.kInvalidRegion;

                if (Constants.kGlobalScope == scope)
                {
                    region = Executable.runtimeSymbols[blockId].symbolList[symbolindex].memregion;
                }
                else
                {
                    region = ClassTable.ClassNodes[scope].symbols.symbolList[symbolindex].memregion;
                }

                if (MemoryRegion.kMemStack == region)
                {
                    return(GetStackData(blockId, symbolindex, scope));
                }
                else if (MemoryRegion.kMemHeap == region)
                {
                    //return GetHeapData(symbolindex);
                    throw new NotImplementedException("{69604961-DE03-440A-97EB-0390B1B0E510}");
                }
                else if (MemoryRegion.kMemStatic == region)
                {
                    Validity.Assert(false, "static region not yet supported, {63EA5434-D2E2-40B6-A816-0046F573236F}");
                }

                Validity.Assert(false, "unsupported memory region, {DCA48F13-EEE1-4374-B301-C96870D44C6B}");
                return(StackUtils.BuildInt(0));
            }
Exemple #3
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;
 }
Exemple #4
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));
        }
 public override StackValue Marshal(object obj, ProtoCore.Runtime.Context context, Interpreter dsi, ProtoCore.Type type)
 {
     return(StackUtils.BuildInt(System.Convert.ToInt64(obj)));
 }