當前位置: 首頁>>代碼示例>>C#>>正文


C# DSASM.StackValue類代碼示例

本文整理匯總了C#中ProtoCore.DSASM.StackValue的典型用法代碼示例。如果您正苦於以下問題:C# StackValue類的具體用法?C# StackValue怎麽用?C# StackValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StackValue類屬於ProtoCore.DSASM命名空間,在下文中一共展示了StackValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CompareString

        public static int CompareString(StackValue s1, StackValue s2, Core core)
        {
            if (!StackUtils.IsString(s1) || !StackUtils.IsString(s2))
            {
                return ProtoCore.DSASM.Constants.kInvalidIndex;
            }

            HeapElement he1 = ArrayUtils.GetHeapElement(s1, core);
            HeapElement he2 = ArrayUtils.GetHeapElement(s2, core);

            int len1 = he1.VisibleSize;
            int len2 = he2.VisibleSize;

            int len = len1 > len2 ? len2 : len1;
            int i = 0;
            for (; i < len; ++i)
            {
                if (he1.Stack[i].opdata != he2.Stack[i].opdata)
                {
                    return (he1.Stack[i].opdata > he2.Stack[i].opdata) ? 1 : -1;
                }
            }

            if (len1 > len2)
                return 1;
            else if (len1 == len2)
                return 0;
            else
                return -1;
        }
開發者ID:samuto,項目名稱:designscript,代碼行數:30,代碼來源:StringUtils.cs

示例2: GCRetain

 public static void GCRetain(StackValue sv, Core core)
 {
     if (core.ExecMode != ProtoCore.DSASM.InterpreterMode.kExpressionInterpreter)
     {
         core.Heap.IncRefCount(sv);
     }
 }
開發者ID:RobertiF,項目名稱:Dynamo,代碼行數:7,代碼來源:GCUtils.cs

示例3: CoerceArray

        public static StackValue CoerceArray(StackValue array, Type typ, Core core)
        {
            //@TODO(Luke) handle array rank coersions

            Validity.Assert(IsArray(array), "Argument needs to be an array {99FB71A6-72AD-4C93-8F1E-0B1F419C1A6D}");

            //This is the element on the heap that manages the data structure
            HeapElement heapElement = core.Heap.Heaplist[(int)array.opdata];
            StackValue[] newSVs = new StackValue[heapElement.VisibleSize];

            for (int i = 0; i < heapElement.VisibleSize; ++i)
            {
                StackValue sv = heapElement.Stack[i];
                StackValue coercedValue;

                if (IsArray(sv))
                {
                    Type typ2 = new Type();
                    typ2.UID = typ.UID;
                    typ2.rank = typ.rank - 1;
                    typ2.IsIndexable = (typ2.rank == -1 || typ2.rank > 0);

                    coercedValue = CoerceArray(sv, typ2, core);
                }
                else
                {
                    coercedValue = TypeSystem.Coerce(sv, typ, core);
                }

                GCUtils.GCRetain(coercedValue, core);
                newSVs[i] = coercedValue;
            }

            return HeapUtils.StoreArray(newSVs, core);
        }
開發者ID:junmendoza,項目名稱:designscript,代碼行數:35,代碼來源:ArrayUtils.cs

示例4: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Runtime.RuntimeMemory rmem)
 {
     StackValue[] v1 = (AddressType.String == op1.optype) ? rmem.GetArrayElements(op1) : new StackValue[] { op1 };
     StackValue[] v2 = (AddressType.String == op2.optype) ? rmem.GetArrayElements(op2) : new StackValue[] { op2 };
     StackValue tmp = rmem.BuildArray(v1.Concat(v2).ToArray());
     return StackUtils.BuildString(tmp.opdata);
 }
開發者ID:samuto,項目名稱:designscript,代碼行數:7,代碼來源:StringUtils.cs

示例5: TestNonPointers01

        public void TestNonPointers01()
        {
            var heap = new Heap();
            var values = new StackValue[]
            {
                StackValue.BuildInt(0),
                StackValue.BuildInt(1),
                StackValue.BuildInt(2)
            };

            var array1 = heap.AllocateArray(values);

            var allTypes = new List<StackValue>();
            var rawPointer = (int)array1.RawIntValue;
            for (int i = 0; i < (int)AddressType.ArrayKey; ++i)
            {
                var val = new StackValue()
                {
                    optype = (AddressType)i, 
                    opdata = rawPointer
                };

                if (!val.IsReferenceType)
                {
                    allTypes.Add(val);
                }
            }
            var array2 = heap.AllocateArray(allTypes.ToArray());

            heap.GCMarkAndSweep(new List<StackValue>() { array1}, testExecutive);

            Assert.IsNotNull(heap.ToHeapObject<DSArray>(array1));

            heap.Free();
        }
開發者ID:rafatahmed,項目名稱:Dynamo,代碼行數:35,代碼來源:HeapMarkSweepTests.cs

示例6: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Core core)
 {
     var v1 = op1.IsString ? ArrayUtils.GetValues(op1, core) : new StackValue[] { op1 };
     var v2 = op2.IsString ? ArrayUtils.GetValues(op2, core) : new StackValue[] { op2 };
     StackValue tmp = core.Rmem.BuildArray(v1.Concat(v2).ToArray());
     return StackValue.BuildString(tmp.opdata);
 }
開發者ID:RobertiF,項目名稱:Dynamo,代碼行數:7,代碼來源:StringUtils.cs

示例7: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Runtime.RuntimeMemory rmem)
 {
     StackValue[] v1 = op1.IsString ? rmem.GetArrayElements(op1) : new StackValue[] { op1 };
     StackValue[] v2 = op2.IsString ? rmem.GetArrayElements(op2) : new StackValue[] { op2 };
     StackValue tmp = rmem.BuildArray(v1.Concat(v2).ToArray());
     return StackValue.BuildString(tmp.opdata);
 }
開發者ID:heegwon,項目名稱:Dynamo,代碼行數:7,代碼來源:StringUtils.cs

示例8: GCRelease

 public static void GCRelease(StackValue sv, Core core)
 {
     if (null != core.CurrentExecutive.CurrentDSASMExec)
     {
         core.CurrentExecutive.CurrentDSASMExec.GCRelease(sv);
     }
 }
開發者ID:RobertiF,項目名稱:Dynamo,代碼行數:7,代碼來源:GCUtils.cs

示例9: RemoveKey

        public bool RemoveKey(StackValue key)
        {
            if (key.IsNumeric)
            {
                long index = key.ToInteger().opdata;
                if (index < 0)
                {
                    index = index + VisibleSize;
                }

                if (index >= 0 && index < VisibleSize)
                {
                    SetItemAt((int)index, StackValue.Null);

                    if (index == VisibleSize - 1)
                    {
                        VisibleSize -= 1;
                    }
                    return true;
                }
            }
            else
            {
                if (Dict != null && Dict.ContainsKey(key))
                {
                    Dict.Remove(key);
                    return true;
                }
            }

            return false;
        }
開發者ID:qingemeng,項目名稱:Dynamo,代碼行數:32,代碼來源:HeapObjects.cs

示例10: Init

        private void Init(
            StackValue thisPtr, 
            int classIndex, 
            int functionIndex, 
            int returnAddress, 
            int functionBlockIndex,
            int callerBlockIndex,
            StackFrameType callerStackFrameType,
            StackFrameType stackFrameType,
            int depth,
            int framePointer,
            int blockIndex,
            List<StackValue> registers,
            int execStateSize)
        {
            Frame = new StackValue[StackFrameSize];

            Frame[AbsoluteIndex.ThisPtr] = thisPtr;
            Frame[AbsoluteIndex.ClassIndex] = StackValue.BuildClassIndex(classIndex);
            Frame[AbsoluteIndex.FunctionIndex] = StackValue.BuildFunctionIndex(functionIndex);
            Frame[AbsoluteIndex.ReturnAddress] = StackValue.BuildInt(returnAddress);
            Frame[AbsoluteIndex.FunctionBlockIndex] = StackValue.BuildBlockIndex(functionBlockIndex);
            Frame[AbsoluteIndex.CallerBlockIndex] = StackValue.BuildBlockIndex(callerBlockIndex);
            Frame[AbsoluteIndex.CallerStackFrameType] = StackValue.BuildFrameType((int)callerStackFrameType);
            Frame[AbsoluteIndex.StackFrameType] = StackValue.BuildFrameType((int)stackFrameType);
            Frame[AbsoluteIndex.StackFrameDepth] = StackValue.BuildInt(depth);
            Frame[AbsoluteIndex.LocalVariableCount] = StackValue.BuildInt(0);
            Frame[AbsoluteIndex.ExecutionStates] = StackValue.BuildInt(execStateSize);
            Frame[AbsoluteIndex.BlockIndex] = StackValue.BuildBlockIndex(blockIndex);
            Frame[AbsoluteIndex.RX] = registers[0];
            Frame[AbsoluteIndex.TX] = registers[1];
            Frame[AbsoluteIndex.FramePointer] = StackValue.BuildInt(framePointer);
        }
開發者ID:sh4nnongoh,項目名稱:Dynamo,代碼行數:33,代碼來源:Stack.cs

示例11: ConvertToString

 public static StackValue ConvertToString(StackValue sv, RuntimeCore runtimeCore, ProtoCore.Runtime.RuntimeMemory rmem)
 {
     StackValue returnSV;
     //TODO: Change Execution mirror class to have static methods, so that an instance does not have to be created
     ProtoCore.DSASM.Mirror.ExecutionMirror mirror = new DSASM.Mirror.ExecutionMirror(new ProtoCore.DSASM.Executive(runtimeCore), runtimeCore);
     returnSV = ProtoCore.DSASM.StackValue.BuildString(mirror.GetStringValue(sv, runtimeCore.RuntimeMemory.Heap, 0, true), runtimeCore.RuntimeMemory.Heap);
     return returnSV;
 }
開發者ID:ankushraizada,項目名稱:Dynamo,代碼行數:8,代碼來源:StringUtils.cs

示例12: Print

        internal void Print(StackValue sv, int lineNo, string symbolName, int ci = Constants.kInvalidIndex)
        {
            //TODO: Change Execution mirror class to have static methods, so that an instance does not have to be created
            ProtoCore.DSASM.Mirror.ExecutionMirror mirror = new ProtoCore.DSASM.Mirror.ExecutionMirror(this, RuntimeCore);
            string result = mirror.GetStringValue(sv, RuntimeCore.RuntimeMemory.Heap, 0, true);

            TextOutputStream tStream = RuntimeCore.RuntimeStatus.MessageHandler as TextOutputStream;
            if (tStream != null)
            {
                Dictionary<int, List<string>> map = tStream.Map;

                //foreach(var kv in tStream.Map)

                if (!map.ContainsKey(lineNo))
                    return;

                List<string> expressions = map[lineNo];

                foreach (var exp in expressions)
                {
                    // Get lhs symbol name
                    string lhsName = null;
                    int index = exp.IndexOf('.');
                    if (index != -1)
                    {
                        string[] parts = exp.Split('.');
                        lhsName = parts[parts.Length - 1];
                    }
                    else
                    {
                        Match m = Regex.Match(exp, @"(\w+)");
                        if (m.Success)
                        {
                            lhsName = m.Groups[1].Value;
                        }
                    }

                    if (lhsName.Equals(symbolName))
                    {
                        // Add to map
                        Expression expStruct = new Expression(lineNo, exp, ci);

                        if (ExpressionMap.ContainsKey(expStruct))
                        {
                            List<string> values = ExpressionMap[expStruct];
                            values.Add(result);
                        }
                        else
                        {
                            List<string> values = new List<string>();
                            values.Add(result);

                            ExpressionMap.Add(expStruct, values);
                        }
                    }
                }
            }
        }
開發者ID:norbertzsiros,項目名稱:Dynamo,代碼行數:58,代碼來源:WatchTestFx.cs

示例13: CompareCores

        internal static void CompareCores(Core c1, Core c2)
        {
            Assert.AreEqual(c1.DSExecutable.runtimeSymbols.Length, c2.DSExecutable.runtimeSymbols.Length);

            for (int symTableIndex = 0; symTableIndex < c1.DSExecutable.runtimeSymbols.Length; symTableIndex++)
            {
                foreach (SymbolNode symNode in c1.DSExecutable.runtimeSymbols[symTableIndex].symbolList.Values)
                {

                    ExecutionMirror runExecMirror = new ExecutionMirror(c1.CurrentExecutive.CurrentDSASMExec,
                                                                        c1);
                    ExecutionMirror debugExecMirror =
                        new ExecutionMirror(c2.CurrentExecutive.CurrentDSASMExec, c2);

                    bool lookupOk = false;
                    StackValue runValue = new StackValue();

                    if (symNode.name.StartsWith("%") || symNode.functionIndex != Constants.kInvalidIndex)
                        continue; //Don't care about internal variables

                    try
                    {
                        runValue = runExecMirror.GetGlobalValue(symNode.name);
                        Console.WriteLine(symNode.name + ": " + runValue);
                        lookupOk = true;

                    }
                    catch (NotImplementedException)
                    {

                    }
                    catch (Exception ex)
                    {
                        if ((ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException) &&
                            (c1.RunningBlock != symNode.runtimeTableIndex))
                        {
                            // Quite possible that variables defined in the inner
                            // language block have been garbage collected and
                            // stack frame pointer has been adjusted when return
                            // to the outer block.
                        }
                        else
                        {
                            throw ex;
                        }
                    }

                    if (lookupOk)
                    {
                        StackValue debugValue = debugExecMirror.GetGlobalValue(symNode.name);
                        if (!StackUtils.CompareStackValues(debugValue, runValue, c2, c1))
                        {
                            Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in run mode and in debug mode.\n", symNode.name));
                        }
                    }
                }
            }
        }
開發者ID:Benglin,項目名稱:designscript,代碼行數:58,代碼來源:DebugTestFx.cs

示例14: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, ProtoCore.Core core)
 {
     var v1 = op1.IsString ? ArrayUtils.GetValues(op1, core) : new StackValue[] { op1 };
     var v2 = op2.IsString ? ArrayUtils.GetValues(op2, core) : new StackValue[] { op2 };
     var v = v1.Concat(v2).ToList();
     v.ForEach(x => core.Heap.IncRefCount(x));
     StackValue tmp = core.Heap.AllocateArray(v);
     return StackValue.BuildString(tmp.opdata);
 }
開發者ID:whztt07,項目名稱:Dynamo,代碼行數:9,代碼來源:StringUtils.cs

示例15: StoreArray

        /// <summary>
        /// Take an array of already allocated StackValues and push them into the heap
        /// Returning the stack value that represents the array
        /// </summary>
        /// <param name="arrayElements"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue StoreArray(StackValue[] arrayElements, Core core)
        {
            Heap heap = core.Heap;

            lock (heap.cslock)
            {
                int ptr = heap.Allocate(arrayElements);
                // ++heap.Heaplist[ptr].Refcount;
                StackValue overallSv = StackUtils.BuildArrayPointer(ptr);
                return overallSv;
            }
        }
開發者ID:Benglin,項目名稱:designscript,代碼行數:19,代碼來源:HeapUtils.cs


注:本文中的ProtoCore.DSASM.StackValue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。