• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StackValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中StackValue的典型用法代码示例。如果您正苦于以下问题:C# StackValue类的具体用法?C# StackValue怎么用?C# StackValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StackValue类属于命名空间,在下文中一共展示了StackValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CopyIsACopy

        public void CopyIsACopy()
        {
            var stack = new StackValue();

            var zedObject = new object();
            InvokeDelegate(stack, "PUSH", zedObject);
            var firstObject = new object();
            InvokeDelegate(stack, "PUSH", firstObject);
            var secondObject = new object();
            InvokeDelegate(stack, "PUSH", secondObject);
            var thirdObject = "third";
            InvokeDelegate(stack, "PUSH", thirdObject);

            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(4,length);

            var copy = InvokeDelegate(stack, "COPY") as StackValue;
            Assert.AreNotSame(stack, copy);

            var copyLength = InvokeDelegate(copy, "LENGTH");
            Assert.AreEqual(4,copyLength);

            object popped = InvokeDelegate(copy, "POP");
            Assert.AreEqual(thirdObject, popped);

            InvokeDelegate(copy, "CLEAR");

            copyLength = InvokeDelegate(copy, "LENGTH");
            Assert.AreEqual(0,copyLength);

            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(4,length);
        }
开发者ID:Whitecaribou,项目名称:KOS,代码行数:33,代码来源:StackValueTest.cs


示例2: Repack

        public static StackValue Repack(Obj obj, ProtoCore.DSASM.Heap heap)
        {
            if (obj.Type.IsIndexable)
            {
                //Unpack each of the elements
                DsasmArray arr = (DsasmArray)obj.Payload;

                StackValue[] sv = new StackValue[arr.members.Length];

                //recurse over the array
                for (int i = 0; i < sv.Length; i++)
                    sv[i] = Repack(arr.members[i], heap);

                int size = sv.Length;

                lock (heap.cslock)
                {
                    int ptr = heap.Allocate(size);
                    ++heap.Heaplist[ptr].Refcount;
                    for (int n = size - 1; n >= 0; --n)
                    {
                        heap.Heaplist[ptr].Stack[n] = sv[n];
                    }

                    StackValue overallSv = StackUtils.BuildArrayPointer(ptr);

                    return overallSv;
                }
            }

            // For non-arrays, there is nothing to repack so just return the original stackvalue
            return obj.DsasmValue;
        }
开发者ID:Benglin,项目名称:designscript,代码行数:33,代码来源:ExecutionMirror.cs


示例3: CanClear

        public void CanClear()
        {
            var stack = new StackValue();

            InvokeDelegate(stack, "PUSH", new ScalarIntValue(1));
            InvokeDelegate(stack, "PUSH", new ScalarIntValue(2));

            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(new ScalarIntValue(2),length);
            InvokeDelegate(stack, "CLEAR");
            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(new ScalarIntValue(0),length);
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:13,代码来源:StackValueTest.cs


示例4: CanClear

        public void CanClear()
        {
            var stack = new StackValue();

            InvokeDelegate(stack, "PUSH", 1);
            InvokeDelegate(stack, "PUSH", new object());

            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(2,length);
            InvokeDelegate(stack, "CLEAR");
            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(0,length);
        }
开发者ID:Whitecaribou,项目名称:KOS,代码行数:13,代码来源:StackValueTest.cs


示例5: StackValueDeref

        public StackValueDeref(StackValue pointer)
        {
            ValueType = StackValueType.Unknown;
            ProcessedValue = false;

            if (pointer is StackValuePointerBase)
            {
                Pointer = pointer as StackValuePointerBase;
            }
            else
            {
                UnknownPointer = pointer;
            }
        }
开发者ID:tjhorner,项目名称:gtaivtools,代码行数:14,代码来源:StackValueDeref.cs


示例6: CanSerializeStacks

        public void CanSerializeStacks()
        {
            var stack = new StackValue();
            var nested = new StackValue();

            stack.Push(new StringValue("item1"));
            stack.Push(new ScalarIntValue(2));
            stack.Push(nested);

            nested.Push(new StringValue("nested1"));

            StackValue deserialized = Deserialize(Serialize(stack)) as StackValue;

            Assert.AreEqual(new StringValue("nested1"), (deserialized.Pop() as StackValue).Pop());
            Assert.AreEqual(new ScalarIntValue(2), deserialized.Pop());
            Assert.AreEqual(new StringValue("item1"), deserialized.Pop());
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:17,代码来源:JSONFormatterTest.cs


示例7: CanTestContains

        public void CanTestContains()
        {
            var stack = new StackValue();

            var zedObject = new StringValue("abc");
            InvokeDelegate(stack, "PUSH", zedObject);
            var firstObject = ScalarIntValue.One;
            InvokeDelegate(stack, "PUSH", firstObject);
            var secondObject = ScalarIntValue.Two;
            var thirdObject = new ScalarIntValue(4);

            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(ScalarIntValue.Two, length);

            Assert.IsTrue((BooleanValue)InvokeDelegate(stack, "CONTAINS", zedObject));
            Assert.IsTrue((BooleanValue)InvokeDelegate(stack, "CONTAINS", firstObject));
            Assert.IsFalse((BooleanValue)InvokeDelegate(stack, "CONTAINS", secondObject));
            Assert.IsFalse((BooleanValue)InvokeDelegate(stack, "CONTAINS", thirdObject));
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:19,代码来源:StackValueTest.cs


示例8: CanPushPopItem

        public void CanPushPopItem()
        {
            var stack = new StackValue();
            Assert.IsNotNull(stack);
            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(new ScalarIntValue(0), length);

            InvokeDelegate(stack, "PUSH", new StringValue("value1"));
            InvokeDelegate(stack, "PUSH", new StringValue("value2"));

            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(ScalarIntValue.Two, length);

            object popped = InvokeDelegate(stack, "POP");
            Assert.AreEqual(new StringValue("value2"), popped);

            popped = InvokeDelegate(stack, "POP");
            Assert.AreEqual(new StringValue("value1"), popped);

            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(ScalarIntValue.Zero, length);
        }
开发者ID:CalebJ2,项目名称:KOS,代码行数:22,代码来源:StackValueTest.cs


示例9: CanPushPopItem

        public void CanPushPopItem()
        {
            var stack = new StackValue();
            Assert.IsNotNull(stack);
            var length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(0,length);

            InvokeDelegate(stack, "PUSH", "value1");
            InvokeDelegate(stack, "PUSH", "value2");

            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(2,length);

            object popped = InvokeDelegate(stack, "POP");
            Assert.AreEqual("value2", popped);

            popped = InvokeDelegate(stack, "POP");
            Assert.AreEqual("value1", popped);

            length = InvokeDelegate(stack, "LENGTH");
            Assert.AreEqual(0, length);
        }
开发者ID:Whitecaribou,项目名称:KOS,代码行数:22,代码来源:StackValueTest.cs


示例10: GetFirstNameFromValue

        public string GetFirstNameFromValue(StackValue v)
        {
            if (v.optype != AddressType.Pointer)
                throw new ArgumentException("SV to highlight must be a pointer");

            ProtoCore.DSASM.Executable exe = MirrorTarget.rmem.Executable;

            List<SymbolNode> symNodes = new List<SymbolNode>();

            foreach (SymbolTable symTable in exe.runtimeSymbols)
            {
                foreach (SymbolNode symNode in symTable.symbolList.Values)
                {
                    symNodes.Add(symNode);
                }

            }

            int index = MirrorTarget.rmem.Stack.FindIndex(0, value => value.opdata == v.opdata);

            List<SymbolNode> matchingNodes = symNodes.FindAll(value => value.index == index);

            if (matchingNodes.Count > 0)
                return matchingNodes[0].name;
            else
            {
                return null;
            }
        }
开发者ID:Benglin,项目名称:designscript,代码行数:29,代码来源:ExecutionMirror.cs


示例11: GetStringValue

 public string GetStringValue(StackValue val, Heap heap, int langblock, bool forPrint = false)
 {
     return GetStringValue(val, heap, langblock, -1, -1, forPrint);
 }
开发者ID:Benglin,项目名称:designscript,代码行数:4,代码来源:ExecutionMirror.cs


示例12: GetClassTrace

        public string GetClassTrace(StackValue val, Heap heap, int langblock, bool forPrint)
        {
            if (!formatParams.ContinueOutputTrace())
                return "...";

            ClassTable classTable = MirrorTarget.rmem.Executable.classTable;

            int classtype = (int)val.metaData.type;
            if (classtype < 0 || (classtype >= classTable.ClassNodes.Count))
            {
                formatParams.RestoreOutputTraceDepth();
                return string.Empty;
            }

            ClassNode classnode = classTable.ClassNodes[classtype];
            if (classnode.IsImportedClass)
            {
                var helper = DLLFFIHandler.GetModuleHelper(FFILanguage.CSharp);
                var marshaller = helper.GetMarshaller(core);
                var strRep = marshaller.GetStringValue(val);
                formatParams.RestoreOutputTraceDepth();
                return strRep;
            }
            else
            {
                int ptr = (int)val.opdata;
                HeapElement hs = heap.Heaplist[ptr];

                List<string> visibleProperties = null;
                if (null != propertyFilter)
                {
                    if (!propertyFilter.TryGetValue(classnode.name, out visibleProperties))
                        visibleProperties = null;
                }

                StringBuilder classtrace = new StringBuilder();
                if (classnode.symbols != null && classnode.symbols.symbolList.Count > 0)
                {
                    bool firstPropertyDisplayed = false;
                    for (int n = 0; n < hs.VisibleSize; ++n)
                    {
                        SymbolNode symbol = classnode.symbols.symbolList[n];
                        string propName = symbol.name;

                        if ((null != visibleProperties) && visibleProperties.Contains(propName) == false)
                            continue; // This property is not to be displayed.

                        if (false != firstPropertyDisplayed)
                            classtrace.Append(", ");

                        string propValue = "";
                        if (symbol.isStatic)
                        {
                            StackValue opSymbol = new StackValue();
                            opSymbol.opdata = symbol.symbolTableIndex;
                            opSymbol.optype = AddressType.StaticMemVarIndex;

                            StackValue staticProp = this.core.Rmem.GetStackData(langblock, (int)opSymbol.opdata, Constants.kGlobalScope);
                            propValue = GetStringValue(staticProp, heap, langblock, forPrint);
                        }
                        else
                        {
                            propValue = GetStringValue(hs.Stack[symbol.index], heap, langblock, forPrint);
                        }
                        classtrace.Append(string.Format("{0} = {1}", propName, propValue));
                        firstPropertyDisplayed = true;
                    }
                }
                else
                {
                    for (int n = 0; n < hs.VisibleSize; ++n)
                    {
                        if (0 != n)
                            classtrace.Append(", ");

                        classtrace.Append(GetStringValue(hs.Stack[n], heap, langblock, forPrint));
                    }
                }

                formatParams.RestoreOutputTraceDepth();
                if (classtype >= (int)ProtoCore.PrimitiveType.kMaxPrimitives)
                    if (forPrint)
                        return (string.Format("{0}{{{1}}}", classnode.name, classtrace.ToString()));
                    else
                    {
                        string tempstr =  (string.Format("{0}({1})", classnode.name, classtrace.ToString()));
                        return tempstr;
                    }

                return classtrace.ToString();
            }
        }
开发者ID:Benglin,项目名称:designscript,代码行数:92,代码来源:ExecutionMirror.cs


示例13: GetDebugValue

        public Obj GetDebugValue(string name)
        {
            int classcope;
            int block = core.GetCurrentBlockId();

            RuntimeMemory rmem = core.Rmem;
            SymbolNode symbol;
            int index = GetSymbolIndex(name, out classcope, ref block, out symbol);
            StackValue sv = new StackValue();
            if (symbol.functionIndex == -1 && classcope != Constants.kInvalidIndex)
                sv = rmem.GetMemberData(index, classcope);
            else
                sv = rmem.GetStackData(block, index, classcope);

            if (sv.optype == AddressType.Invalid)
                throw new UninitializedVariableException { Name = name };

            return Unpack(sv);
        }
开发者ID:Benglin,项目名称:designscript,代码行数:19,代码来源:ExecutionMirror.cs


示例14: Unpack

        //@TODO(Luke): Add in the methods here that correspond to each of the internal datastructures in use by the executive
        //@TODO(Jun): if this method stays static, then the Heap needs to be referenced from a parameter
        /// <summary>
        /// Do the recursive unpacking of the data structure into mirror objects
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static Obj Unpack(StackValue val, Heap heap, Core core, int type = (int)PrimitiveType.kTypePointer)
        {
            switch (val.optype)
            {
                case AddressType.ArrayPointer:
                case AddressType.String:
                    {
                        //It was a pointer that we pulled, so the value lives on the heap
                        Int64 ptr = val.opdata;

                        DsasmArray ret = new DsasmArray();

                        //Pull the item out of the heap

                        HeapElement hs = heap.Heaplist[(int)ptr];

                        StackValue[] nodes = hs.Stack;
                        ret.members = new Obj[hs.VisibleSize];

                        for (int i = 0; i < ret.members.Length; i++)
                        {
                            ret.members[i] = Unpack(nodes[i], heap, core, type);
                        }

                        // TODO Jun: ret.members[0] is hardcoded  and means we are assuming a homogenous collection
                        // How to handle mixed-type arrays?
                        Obj retO = new Obj(val) { Payload = ret, Type = core.TypeSystem.BuildTypeObject((ret.members.Length > 0) ? core.TypeSystem.GetType(ret.members[0].Type.Name) : (int)ProtoCore.PrimitiveType.kTypeVoid, true) };

                        return retO;
                    }
                case AddressType.Int:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = data, Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeInt, false) };
                        return o;
                    }
                case AddressType.Boolean:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = (data != 0), Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeBool, false) };
                        return o;
                    }

                case AddressType.Null:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = null, Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeNull, false) };
                        return o;
                    }
                case AddressType.Char:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = data, Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeChar, false) };
                        return o;
                    }
                case AddressType.Double:
                    {
                        double data = val.opdata_d;
                        Obj o = new Obj(val) { Payload = data, Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeDouble, false) };
                        return o;
                    }
                case AddressType.Pointer:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = data, Type = core.TypeSystem.BuildTypeObject(type, false) };
                        return o;
                    }
                case AddressType.FunctionPointer:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) { Payload = data, Type = core.TypeSystem.BuildTypeObject(PrimitiveType.kTypeFunctionPointer, false) };
                        return o;
                    }
                case AddressType.Invalid:
                    {
                        return new Obj(val) {Payload = null};
                    }
                default:
                    {
                        throw new NotImplementedException(string.Format("unknown datatype {0}", val.optype.ToString()));
                    }
            }
        }
开发者ID:Benglin,项目名称:designscript,代码行数:90,代码来源:ExecutionMirror.cs


示例15: GetClassTrace

        public string GetClassTrace(StackValue val, Heap heap, int langblock, bool forPrint)
        {
            if (!formatParams.ContinueOutputTrace())
                return "...";

            RuntimeMemory rmem = MirrorTarget.rmem;
            Executable exe = MirrorTarget.exe;
            ClassTable classTable = MirrorTarget.RuntimeCore.DSExecutable.classTable;

            int classtype = val.metaData.type;
            if (classtype < 0 || (classtype >= classTable.ClassNodes.Count))
            {
                formatParams.RestoreOutputTraceDepth();
                return string.Empty;
            }

            ClassNode classnode = classTable.ClassNodes[classtype];
            if (classnode.IsImportedClass)
            {
                var helper = DLLFFIHandler.GetModuleHelper(FFILanguage.CSharp);
                var marshaller = helper.GetMarshaller(runtimeCore);
                var strRep = marshaller.GetStringValue(val);
                formatParams.RestoreOutputTraceDepth();
                return strRep;
            }
            else
            {
                var obj = heap.ToHeapObject<DSObject>(val);

                List<string> visibleProperties = null;
                if (null != propertyFilter)
                {
                    if (!propertyFilter.TryGetValue(classnode.Name, out visibleProperties))
                        visibleProperties = null;
                }

                StringBuilder classtrace = new StringBuilder();
                if (classnode.Symbols != null && classnode.Symbols.symbolList.Count > 0)
                {
                    bool firstPropertyDisplayed = false;
                    for (int n = 0; n < obj.Count; ++n)
                    {
                        SymbolNode symbol = classnode.Symbols.symbolList[n];
                        string propName = symbol.name;

                        if ((null != visibleProperties) && visibleProperties.Contains(propName) == false)
                            continue; // This property is not to be displayed.

                        if (firstPropertyDisplayed)
                            classtrace.Append(", ");

                        string propValue = "";
                        if (symbol.isStatic)
                        {
                            var staticSymbol = exe.runtimeSymbols[langblock].symbolList[symbol.symbolTableIndex];
                            StackValue staticProp = rmem.GetSymbolValue(staticSymbol);
                            propValue = GetStringValue(staticProp, heap, langblock, forPrint);
                        }
                        else
                        {
                            propValue = GetStringValue(obj.GetValueFromIndex(symbol.index, runtimeCore), heap, langblock, forPrint);
                        }
                        classtrace.Append(string.Format("{0} = {1}", propName, propValue));
                        firstPropertyDisplayed = true;
                    }
                }
                else
                {
                    var stringValues = obj.Values.Select(x => GetStringValue(x, heap, langblock, forPrint))
                                                      .ToList();

                    for (int n = 0; n < stringValues.Count(); ++n)
                    {
                        if (0 != n)
                            classtrace.Append(", ");

                        classtrace.Append(stringValues[n]);
                    }
                }

                formatParams.RestoreOutputTraceDepth();
                if (classtype >= (int)ProtoCore.PrimitiveType.MaxPrimitive)
                    if (forPrint)
                        return (string.Format("{0}{{{1}}}", classnode.Name, classtrace.ToString()));
                    else
                    {
                        string tempstr =  (string.Format("{0}({1})", classnode.Name, classtrace.ToString()));
                        return tempstr;
                    }

                return classtrace.ToString();
            }
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:93,代码来源:ExecutionMirror.cs


示例16: PrintClass

 public string PrintClass(StackValue val, Heap heap, int langblock, bool forPrint)
 {
     return PrintClass(val, heap, langblock, -1, -1, forPrint);
 }
开发者ID:Benglin,项目名称:designscript,代码行数:4,代码来源:ExecutionMirror.cs


示例17: Unpack

        //@TODO(Luke): Add in the methods here that correspond to each of the internal datastructures in use by the executive
        //@TODO(Jun): if this method stays static, then the Heap needs to be referenced from a parameter
        /// <summary>
        /// Do the recursive unpacking of the data structure into mirror objects
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static Obj Unpack(StackValue val, Heap heap, RuntimeCore runtimeCore, int type = (int)PrimitiveType.Pointer) 
        {
            Executable exe = runtimeCore.DSExecutable;
            switch (val.optype)
            {
                case AddressType.ArrayPointer:
                    {
                        DsasmArray ret = new DsasmArray();

                        //Pull the item out of the heap


                        var array = heap.ToHeapObject<DSArray>(val);

                        StackValue[] nodes = array.Values.ToArray();
                        ret.members = new Obj[array.Count];
                        for (int i = 0; i < ret.members.Length; i++)
                        {
                            ret.members[i] = Unpack(nodes[i], heap, runtimeCore, type);
                        }

                        // TODO Jun: ret.members[0] is hardcoded  and means we are assuming a homogenous collection
                        // How to handle mixed-type arrays?
                        Obj retO = new Obj(val) 
                        { 
                            Payload = ret, 
                        };

                        return retO;
                    }
                case AddressType.String:
                    {
                        string str = heap.ToHeapObject<DSString>(val).Value;
                        Obj o = new Obj(val)
                        {
                            Payload = str,
                        };
                        return o;
                    }
                case AddressType.Int:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = val.IntegerValue, 
                        };
                        return o;
                    }
                case AddressType.Boolean:
                    {
                        Obj o = new Obj(val)
                        {
                            Payload = val.BooleanValue,
                        };
                        return o;
                    }

                case AddressType.Null:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = null, 
                        };
                        return o;
                    }
                case AddressType.Char:
                    {
                        Obj o = new Obj(val) 
                        {
                            Payload = val.CharValue, 
                        };
                        return o;
                    }
                case AddressType.Double:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = val.DoubleValue,
                        };
                        return o;
                    }
                case AddressType.Pointer:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = val.Pointer,
                        };
                        return o;
                    }
                case AddressType.FunctionPointer:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = val.FunctionPointer, 
//.........这里部分代码省略.........
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:101,代码来源:ExecutionMirror.cs


示例18: GetStringValue

        public string GetStringValue(StackValue val, Heap heap, int langblock, int maxArraySize, int maxOutputDepth, bool forPrint = false)
        {
            if (formatParams == null)
                formatParams = new OutputFormatParameters(maxArraySize, maxOutputDepth);

            if (val.IsInteger)
            {
                return val.IntegerValue.ToString();
            }
            else if (val.IsDouble)
            {
                return val.DoubleValue.ToString("F6");
            }
            else if (val.IsNull)
            {
                return "null";
            }
            else if (val.IsPointer)
            {
                return GetClassTrace(val, heap, langblock, forPrint);
            }
            else if (val.IsArray)
            {
                HashSet<int> pointers = new HashSet<int> { val.ArrayPointer };
                string arrTrace = GetArrayTrace(val, heap, langblock, pointers, forPrint);
                if (forPrint)
                    return "{" + arrTrace + "}";
                else
                    return "{ " + arrTrace + " }";
            }
            else if (val.IsFunctionPointer)
            {
                ProcedureNode procNode;
                if (runtimeCore.DSExecutable.FuncPointerTable.TryGetFunction(val, runtimeCore, out procNode))
                {
                    string className = String.Empty;
                    if (procNode.ClassID != Constants.kGlobalScope)
                    {
                        className = runtimeCore.DSExecutable.classTable.GetTypeName(procNode.ClassID).Split('.').Last() + ".";
                    }

                    return "function: " + className + procNode.Name;
                }
                return "function: " + val.FunctionPointer.ToString();
            }
            else if (val.IsBoolean)
            {
                return val.BooleanValue ? "true" : "false";
            }
            else if (val.IsString)
            {
                if (forPrint)
                    return heap.ToHeapObject<DSString>(val).Value;
                else
                    return "\"" + heap.ToHeapObject<DSString>(val).Value + "\"";
            }
            else if (val.IsChar)
            {
                Char character = Convert.ToChar(val.CharValue);
                if (forPrint)
                    return character.ToString();
                else
                    return "'" + character + "'";
            }
            else
            {
                return "null"; // "Value not yet supported for tracing";
            }
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:69,代码来源:ExecutionMirror.cs


示例19: GetArrayTrace

        private string GetArrayTrace(StackValue svArray, Heap heap, int langblock, HashSet<int> pointers, bool forPrint)
        {
            if (!formatParams.ContinueOutputTrace())
                return "...";

            StringBuilder arrayElements = new StringBuilder();
            var array = heap.ToHeapObject<DSArray>(svArray);

            int halfArraySize = -1;
            if (formatParams.MaxArraySize > 0) // If the caller did specify a max value...
            {
                // And our array is larger than that max value...
                if (array.Count > formatParams.MaxArraySize)
                    halfArraySize = (int)Math.Floor(formatParams.MaxArraySize * 0.5);
            }

            int totalElementCount = array.Count; 
            if (svArray.IsArray)
            {
                totalElementCount = heap.ToHeapObject<DSArray>(svArray).Values.Count();
            }

            for (int n = 0; n < array.Count; ++n)
            {
                // As we try to output the next element in the array, there 
                // should be a comma if there were previously output element.
                if (arrayElements.Length > 0)
                    if(forPrint)
                        arrayElements.Append(",");
                    else
                        arrayElements.Append(", ");

                StackValue sv = array.GetValueFromIndex(n, runtimeCore);
                if (sv.IsArray)
                {
                    arrayElements.Append(GetPointerTrace(sv, heap, langblock, pointers, forPrint));
                }
                else
                {
                    arrayElements.Append(GetStringValue(array.GetValueFromIndex(n, runtimeCore), heap, langblock, forPrint));
                }

                // If we need to truncate this array (halfArraySize > 0), and we have 
                // already reached the first half of it, then offset the loop counter 
                // to the next half of the array.
                if (halfArraySize > 0 && (n == halfArraySize - 1))
                {
                    arrayElements.Append(", ...");
                    n = totalElementCount - halfArraySize - 1;
                }
            }

            formatParams.RestoreOutputTraceDepth();
            return arrayElements.ToString();
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:55,代码来源:ExecutionMirror.cs


示例20: GetPointerTrace

        private string GetPointerTrace(StackValue ptr, Heap heap, int langblock, HashSet<int> pointers, bool forPrint)
        {
            if (pointers.Contains(ptr.ArrayPointer))
            {
                return "{ ... }";
            }
            else
            {
                pointers.Add(ptr.ArrayPointer);

                if (forPrint)
                {
                    return "{" + GetArrayTrace(ptr, heap, langblock, pointers, forPrint) + "}";
                }
                else
                {
                    return "{ " + GetArrayTrace(ptr, heap, langblock, pointers, forPrint) + " }";
                }
            }
        }
开发者ID:YanmengLi,项目名称:Dynamo,代码行数:20,代码来源:ExecutionMirror.cs



注:本文中的StackValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Staff类代码示例发布时间:2022-05-24
下一篇:
C# StackTracePolicy类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap