当前位置: 首页>>代码示例>>C#>>正文


C# Heap.GetString方法代码示例

本文整理汇总了C#中Heap.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# Heap.GetString方法的具体用法?C# Heap.GetString怎么用?C# Heap.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Heap的用法示例。


在下文中一共展示了Heap.GetString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);

            switch (val.optype)
            {
                case AddressType.Int:
                    return val.opdata.ToString();
                case AddressType.Double:
                    return val.RawDoubleValue.ToString(runtimeCore.Options.FormatToPrintFloatingPoints);
                case AddressType.Null:
                    return "null";
                case AddressType.Pointer:
                    return GetClassTrace(val, heap, langblock, forPrint);
                case AddressType.ArrayPointer:
                    HashSet<int> pointers = new HashSet<int>{(int)val.opdata};
                    string arrTrace = GetArrayTrace(val, heap, langblock, pointers, forPrint);
                    if (forPrint)
                        return "{" + arrTrace + "}";
                    else
                        return "{ " + arrTrace + " }";
                case AddressType.FunctionPointer:
                    ProcedureNode procNode;
                    if (runtimeCore.DSExecutable.FuncPointerTable.TryGetFunction(val, runtimeCore, out procNode))
                    {
                        string className = String.Empty;
                        if (procNode.classScope != Constants.kGlobalScope)
                        {
                            className = runtimeCore.DSExecutable.classTable.GetTypeName(procNode.classScope).Split('.').Last() + ".";
                        }

                        return "function: " + className + procNode.name; 
                    }
                    return "function: " + val.opdata.ToString();

                case AddressType.Boolean:
                    return (val.opdata == 0) ? "false" : "true";
                case AddressType.String:
                    if (forPrint)
                        return heap.GetString(val);
                    else
                        return "\"" + heap.GetString(val)+ "\"";                    
                case AddressType.Char:
                    Char character = ProtoCore.Utils.EncodingUtils.ConvertInt64ToCharacter(val.opdata);
                    if (forPrint)
                        return character.ToString();
                    else
                        return "'" + character + "'";
                default:
                    return "null"; // "Value not yet supported for tracing";
            }
        }
开发者ID:junmendoza,项目名称:Dynamo,代码行数:53,代码来源:ExecutionMirror.cs

示例2: 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.kTypePointer) 
        {
            Executable exe = runtimeCore.DSExecutable;
            switch (val.optype)
            {
                case AddressType.ArrayPointer:
                    {
                        DsasmArray ret = new DsasmArray();

                        //Pull the item out of the heap


                        HeapElement hs = heap.GetHeapElement(val);

                        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, 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, 
                            Type = exe.TypeSystem.BuildTypeObject(
                                        (ret.members.Length > 0)
                                        ? exe.TypeSystem.GetType(ret.members[0].Type.Name) 
                                        : (int)ProtoCore.PrimitiveType.kTypeVoid, Constants.kArbitraryRank) 
                        };

                        return retO;
                    }
                case AddressType.String:
                    {
                        string str = heap.GetString(val);
                        Obj o = new Obj(val)
                        {
                            Payload = str,
                            Type = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0)
                        };
                        return o;
                    }
                case AddressType.Int:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) 
                        { 
                            Payload = data, 
                            Type = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0) 
                        };
                        return o;
                    }
                case AddressType.Boolean:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) 
                        { 
                            Payload = (data != 0), 
                            Type = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0) 
                        };
                        return o;
                    }

                case AddressType.Null:
                    {
                        Obj o = new Obj(val) 
                        { 
                            Payload = null, 
                            Type = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeNull, 0) 
                        };
                        return o;
                    }
                case AddressType.Char:
                    {
                        Int64 data = val.opdata;
                        Obj o = new Obj(val) 
                        {
                            Payload = data, 
                            Type = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeChar, 0) 
                        };
                        return o;
                    }
                case AddressType.Double:
                    {
                        double data = val.RawDoubleValue;
                        Obj o = new Obj(val) 
                        { 
                            Payload = data, Type =
                            TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0) 
                        };
                        return o;
//.........这里部分代码省略.........
开发者ID:junmendoza,项目名称:Dynamo,代码行数:101,代码来源:ExecutionMirror.cs


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