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

C# RuntimeCore类代码示例

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

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



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

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


示例2: CompareString

        public static int CompareString(StackValue s1, StackValue s2, RuntimeCore runtimeCore)
        {
            if (!s1.IsString || !s2.IsString)
                return Constants.kInvalidIndex;

            if (s1.Equals(s2))
                return 0;

            string str1 = runtimeCore.RuntimeMemory.Heap.ToHeapObject<DSString>(s1).Value;
            string str2 = runtimeCore.RuntimeMemory.Heap.ToHeapObject<DSString>(s2).Value;
            return string.Compare(str1, str2);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:12,代码来源:StringUtils.cs


示例3: GetUpcastCountTo

        /// <summary>
        /// Returns the number of upcasts that need to be performed to turn a class into another class in its upcast chain
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static int GetUpcastCountTo(ClassNode from, ClassNode to, RuntimeCore runtimeCore)
        {
            int toID = runtimeCore.DSExecutable.classTable.ClassNodes.IndexOf(to);

            List<int> upcastChain = GetClassUpcastChain(from, runtimeCore);

            if (!upcastChain.Contains(toID))
                return int.MaxValue;

            return upcastChain.IndexOf(toID);


        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:20,代码来源:ClassUtils.cs


示例4: GetElementsAtLevel

        private static List<ElementAtLevel> GetElementsAtLevel(StackValue argument, int level, List<int> indices, bool recordIndices, RuntimeCore runtimeCore)
        {
            var array = runtimeCore.Heap.ToHeapObject<DSArray>(argument);
            if (array == null)
            {
                return new List<ElementAtLevel>();
            }

            int count = array.Values.Count();
            if (level == 0)
            {
                return array.Values.Zip(Enumerable.Range(0, count), (v, i) =>
                {
                    if (recordIndices)
                    {
                        var newIndices = new List<int>(indices);
                        newIndices.Add(i);
                        return new ElementAtLevel(v, newIndices);
                    }
                    else
                    { 
                        return new ElementAtLevel(v);
                    }
               }).ToList();
            }
            else
            {
                return array.Values.Zip(Enumerable.Range(0, count), (v, i) =>
                {
                    if (recordIndices)
                    {
                        var newIndices = new List<int>(indices);
                        newIndices.Add(i);
                        return GetElementsAtLevel(v, level - 1, newIndices, recordIndices, runtimeCore);
                    }
                    else
                    {
                        return GetElementsAtLevel(v, level - 1, new List<int>(), recordIndices, runtimeCore);
                    }
                }).SelectMany(vs => vs).ToList();
            }
        }
开发者ID:limrzx,项目名称:Dynamo,代码行数:42,代码来源:ArgumentAtLevel.cs


示例5: GetClassUpcastChain

        /// <summary>
        /// Returns the list of classes that this can be upcast to
        /// It includes the class itself
        /// </summary>
        /// <param name="cn"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static List<int> GetClassUpcastChain(ClassNode cn, RuntimeCore runtimeCore)
        {
            List<int> ret = new List<int>();

            //@TODO: Replace this with an ID
            ret.Add(runtimeCore.DSExecutable.classTable.ClassNodes.IndexOf(cn));

            ClassNode target = cn;
            while (target.Base != Constants.kInvalidIndex)
            {
                ret.Add(target.Base);
                target = runtimeCore.DSExecutable.classTable.ClassNodes[target.Base];
            }

            if (!ret.Contains((int)(PrimitiveType.Var)))
                ret.Add((int)PrimitiveType.Var);


            return ret;
        }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:27,代码来源:ClassUtils.cs


示例6: GetClassUpcastChain

        /// <summary>
        /// Returns the list of classes that this can be upcast to
        /// It includes the class itself
        /// </summary>
        /// <param name="cn"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static List<int> GetClassUpcastChain(ClassNode cn, RuntimeCore runtimeCore)
        {
            List<int> ret = new List<int>();

            //@TODO: Replace this with an ID
            ret.Add(runtimeCore.DSExecutable.classTable.ClassNodes.IndexOf(cn));

            ClassNode target = cn;
            while (target.Bases.Count > 0)
            {
                Validity.Assert(target.Bases.Count == 1, "Multiple Inheritence not yet supported, {F5DDC58D-F721-4319-854A-622175AC43F8}");
                ret.Add(target.Bases[0]);

                target = runtimeCore.DSExecutable.classTable.ClassNodes[target.Bases[0]];
            }

            if (!ret.Contains((int)(PrimitiveType.Var)))
                ret.Add((int)PrimitiveType.Var);


            return ret;
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:29,代码来源:ClassUtils.cs


示例7: Executive

        public Executive(RuntimeCore runtimeCore, bool isFep = false)
        {
            IsExplicitCall = false;
            Validity.Assert(runtimeCore != null);

            this.runtimeCore = runtimeCore;
            enableLogging = runtimeCore.Options.Verbose;

            exe = runtimeCore.DSExecutable;
            istream = null;

            fepRun = isFep;
            Properties = new InterpreterProperties();

            rmem = runtimeCore.RuntimeMemory;

            // Execute DS View VM Log
            //
            debugFlags = (int)DebugFlags.ENABLE_LOG;

            bounceType = CallingConvention.BounceType.Implicit;

            deferedGraphNodes = new List<AssociativeGraph.GraphNode>();
        }
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:24,代码来源:Executive.cs


示例8: RecursiveProtectGetMaxReductionDepth

        /// <summary>
        /// This computes the max depth to which the element can be reduced
        /// It contains a protected envelope 
        /// </summary>
        /// <param name="sv"></param>
        /// <param name="core"></param>
        /// <param name="depthCount"></param>
        /// <returns></returns>
        private static int RecursiveProtectGetMaxReductionDepth(StackValue sv, RuntimeCore runtimeCore, int depthCount)
        {
            Validity.Assert(depthCount < 1000, 
                "StackOverflow protection trap. This is almost certainly a VM cycle-in-array bug. {0B530165-2E38-431D-88D9-56B0636364CD}");

            //PERF(Luke): Could be non-recursive
            if (!sv.IsArray)
                return 0;

            int maxReduction = 0;

            //De-ref the sv
            var array = runtimeCore.Heap.ToHeapObject<DSArray>(sv);
            foreach (var subSv in array.VisibleItems)
            {
                maxReduction = Math.Max(maxReduction, RecursiveProtectGetMaxReductionDepth(subSv, runtimeCore, depthCount + 1));
            }

            return 1 + maxReduction;   
        }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:28,代码来源:Replicator.cs


示例9: BuildReplicationCombinations

        public static List<List<ReplicationInstruction>> BuildReplicationCombinations(List<ReplicationInstruction> providedControl, List<StackValue> formalParams, RuntimeCore runtimeCore)
        {

            
            //@TODO: Performance hint - this should really be done with a yield-generator unless the parrallelism is useful
            //@ROSO: This is not generating a minimal set


            //First build a list of reducible parameters

            List<int> reducibles = new List<int>();

            int maxDepth = 0;

            for (int i = 0; i < formalParams.Count; i++)
            {
                int itemMaxDepth = GetMaxReductionDepth(formalParams[i], runtimeCore);

                if (itemMaxDepth > 0)
                    reducibles.Add(i);

                maxDepth = maxDepth + itemMaxDepth;
            }

            if (providedControl.Count > maxDepth)
            {
                throw new ReplicationCaseNotCurrentlySupported(
                    string.Format(Resources.MaxDimensionExceeded, "{1EC8AF3C-48D6-4582-999E-ADBCBF9155D1}"));
            }
            else
            {
                //Reduce the available reducions by the amount that we've been instructed to
                maxDepth -= providedControl.Count;
            }


            List<List<int>> cleanedReductions = new List<List<int>>();

            if (maxDepth > 0)
            {
                List<List<int>> reductions = new List<List<int>>();

                for (int i = 0; i <= maxDepth; i++)
                    reductions.AddRange(BuildAllocation(formalParams.Count, maxDepth));

                if (providedControl.Count > 0)
                {
                    //The add in the reductions associated with the provided controls.
                    //The silly copy-ctoring here is to avoid the issues of modifying a collection with an iterator on it
                    List<List<int>> completedReductions = new List<List<int>>();
                    
                    List<ReplicationInstruction> reversedControl = new List<ReplicationInstruction>();
                    reversedControl.AddRange(providedControl);
                    reversedControl.Reverse();

                    foreach (List<int> reduction in reductions)
                    {
                        List<int> reducitonList = new List<int>();
                        reducitonList.AddRange(reduction);

                        foreach (ReplicationInstruction ri in reversedControl)
                        {
                            if (!ri.Zipped)
                                reducitonList[ri.CartesianIndex] = reducitonList[ri.CartesianIndex] + 1;
                            else
                            {
                                foreach (int i in ri.ZipIndecies)
                                    reducitonList[i] = reducitonList[i] + 1;
                            }

                        }

                        completedReductions.Add(reducitonList);
                    }

                    reductions = completedReductions;

                }
                




                foreach (List<int> list in reductions)
                {
                    bool append = true;
                    for (int i = 0; i < list.Count; i++)
                        if (list[i] > GetMaxReductionDepth(formalParams[i], runtimeCore))
                        {
                            append = false;
                            break;
                        }

                    int acc = 0;
                    for (int i = 0; i < list.Count; i++)
                        acc += list[i];

                    //We must be reducing something
                    if (acc == 0)
                        append = false;
//.........这里部分代码省略.........
开发者ID:qingemeng,项目名称:Dynamo,代码行数:101,代码来源:Replicator.cs


示例10: ComputeReducedParamsSuperset

        public static List<List<StackValue>> ComputeReducedParamsSuperset(List<StackValue> formalParams, List<ReplicationInstruction> replicationInstructions, RuntimeCore runtimeCore)
        {
            //Compute the reduced Type args
            List<List<StackValue>> reducedParams = new List<List<StackValue>>();

            List<StackValue> basicList = new List<StackValue>();

            //Copy the types so unaffected ones get copied back directly
            foreach (StackValue sv in formalParams)
                basicList.Add(sv);

            reducedParams.Add(basicList);


            foreach (ReplicationInstruction ri in replicationInstructions)
                if (ri.Zipped)
                {
                    foreach (int index in ri.ZipIndecies)
                    {
                        //This should generally be a collection, so we need to do a one phase unboxing
                        StackValue target = basicList[index];
                        StackValue reducedSV = StackValue.Null;

                        if (target.IsArray)
                        {

                            //Array arr = formalParams[index].Payload as Array;
                            var array = runtimeCore.Heap.ToHeapObject<DSArray>(basicList[index]);

                            //The elements of the array are still type structures
                            if (array.VisibleSize == 0)
                                reducedSV = StackValue.Null;
                            else
                            {
                                var arrayStats = ArrayUtils.GetTypeExamplesForLayer(basicList[index], runtimeCore).Values;

                                List<List<StackValue>> clonedList = new List<List<StackValue>>();

                                foreach (List<StackValue> list in reducedParams)
                                    clonedList.Add(list);

                                reducedParams.Clear();

                                foreach (StackValue sv in arrayStats)
                                {
                                    foreach (List<StackValue> lst in clonedList)
                                    {
                                        List<StackValue> newArgs = new List<StackValue>();
                                        
                                        newArgs.AddRange(lst);
                                        newArgs[index] = sv;

                                        reducedParams.Add(newArgs);
                                    }
                                    
                                }

                            }
                        }
                        else
                        {
                            System.Console.WriteLine("WARNING: Replication unbox requested on Singleton. Trap: 437AD20D-9422-40A3-BFFD-DA4BAD7F3E5F");
                            reducedSV = target;
                        }

                        //reducedType.IsIndexable = false;
                        //reducedParamTypes[index] = reducedSV;
                    }
                }
                else
                {
                    //This should generally be a collection, so we need to do a one phase unboxing
                    int index = ri.CartesianIndex;
                    //This should generally be a collection, so we need to do a one phase unboxing
                    StackValue target = basicList[index];
                    StackValue reducedSV = StackValue.Null;

                    if (target.IsArray)
                    {

                        //Array arr = formalParams[index].Payload as Array;
                        var array = runtimeCore.Heap.ToHeapObject<DSArray>(basicList[index]);



                        //It is a collection, so cast it to an array and pull the type of the first element
                        //@TODO(luke): Deal with sparse arrays, if the first element is null this will explode

                        //The elements of the array are still type structures
                        if (array.VisibleSize == 0)
                            reducedSV = StackValue.Null;
                        else
                        {
                            var arrayStats = ArrayUtils.GetTypeExamplesForLayer(basicList[index], runtimeCore).Values;

                            List<List<StackValue>> clonedList = new List<List<StackValue>>();

                            foreach (List<StackValue> list in reducedParams)
                                clonedList.Add(list);

//.........这里部分代码省略.........
开发者ID:qingemeng,项目名称:Dynamo,代码行数:101,代码来源:Replicator.cs


示例11: AddStackValueString

        /// <summary>
        /// Performs addition on 2 StackValues
        /// This is used by the VM when adding strings
        /// </summary>
        /// <param name="sv1"></param>
        /// <param name="sv2"></param>
        /// <returns></returns>
        public static StackValue AddStackValueString(StackValue sv1, StackValue sv2, RuntimeCore runtimeCore)
        {
            Validity.Assert(sv1.IsString || sv2.IsString);

            if (sv1.IsString && sv2.IsString)
            {
                return StringUtils.ConcatString(sv2, sv1, runtimeCore);
            }
            else if (sv1.IsString || sv2.IsString)
            {
                StackValue newSV;
                if (sv1.IsNull || sv2.IsNull)
                {
                    return StackValue.BuildNull();
                }
                else if (sv1.IsString)
                {
                    newSV = StringUtils.ConvertToString(sv2, runtimeCore, runtimeCore.RuntimeMemory);
                    return StringUtils.ConcatString(newSV, sv1, runtimeCore);
                }
                else if (sv2.IsString)
                {
                    newSV = StringUtils.ConvertToString(sv1, runtimeCore, runtimeCore.RuntimeMemory);
                    return StringUtils.ConcatString(sv2, newSV, runtimeCore);
                }
            }
            return StackValue.BuildNull();
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:35,代码来源:CoreUtils.cs


示例12: GetTypeStatisticsForArray

        /// <summary>
        /// Generate type statistics for the whole array
        /// </summary>
        /// <param name="array"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static Dictionary<ClassNode, int> GetTypeStatisticsForArray(StackValue array, RuntimeCore runtimeCore)
        {
            if (!array.IsArray)
            {
                Dictionary<ClassNode, int> ret = new Dictionary<ClassNode, int>();
                ret.Add(runtimeCore.DSExecutable.classTable.ClassNodes[array.metaData.type], 1);
                return ret;
            }

            Dictionary<ClassNode, int> usageFreq = new Dictionary<ClassNode, int>();

            //This is the element on the heap that manages the data structure
            var dsArray = runtimeCore.Heap.ToHeapObject<DSArray>(array);
            foreach (var sv in dsArray.Values)
            {
                if (sv.IsArray)
                {
                    //Recurse
                    Dictionary<ClassNode, int> subLayer = GetTypeStatisticsForArray(sv, runtimeCore);
                    foreach (ClassNode cn in subLayer.Keys)
                    {
                        if (!usageFreq.ContainsKey(cn))
                            usageFreq.Add(cn, 0);

                        usageFreq[cn] = usageFreq[cn] + subLayer[cn];

                    }
                }
                else
                {

                    ClassNode cn = runtimeCore.DSExecutable.classTable.ClassNodes[sv.metaData.type];
                    if (!usageFreq.ContainsKey(cn))
                        usageFreq.Add(cn, 0);

                    usageFreq[cn] = usageFreq[cn] + 1;
                }
            }

            return usageFreq;
        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:47,代码来源:ArrayUtils.cs


示例13: GetGreatestCommonSubclassForArray

        /// <summary>
        /// If an empty array is passed, the result will be null
        /// if there are instances, but they share no common supertype the result will be var
        /// </summary>
        /// <param name="array"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static ClassNode GetGreatestCommonSubclassForArray(StackValue array, RuntimeCore runtimeCore)
        {
            if (!array.IsArray)
                throw new ArgumentException("The stack value provided was not an array");

            Dictionary<ClassNode, int> typeStats = GetTypeStatisticsForArray(array, runtimeCore);


            //@PERF: This could be improved with a 
            List<List<int>> chains = new List<List<int>>();
            HashSet<int> commonTypeIDs = new HashSet<int>();

            foreach (ClassNode cn in typeStats.Keys)
            {
                List<int> chain = ClassUtils.GetClassUpcastChain(cn, runtimeCore);

                //Now add in the other conversions - as we don't have a common superclass yet
                //@TODO(Jun): Remove this hack when we have a proper casting structure
                foreach (int id in cn.CoerceTypes.Keys)
                    if (!chain.Contains(id))
                        chain.Add((id));

                chains.Add(chain);

                foreach (int nodeId in chain)
                    commonTypeIDs.Add(nodeId);

 

            }

            //Remove nulls if they exist
            {
 
            if (commonTypeIDs.Contains(
                (int)PrimitiveType.kTypeNull))
                commonTypeIDs.Remove((int)PrimitiveType.kTypeNull);

                List<List<int>> nonNullChains = new List<List<int>>();

                foreach (List<int> chain in chains)
                {
                    if (chain.Contains((int)PrimitiveType.kTypeNull))
                        chain.Remove((int)PrimitiveType.kTypeNull);

                    if (chain.Count > 0)
                        nonNullChains.Add(chain);
                }

                chains = nonNullChains;
                    
            }


            //Contract the hashset so that it contains only the nodes present in all chains
            //@PERF: this is very inefficent
            {
                foreach (List<int> chain in chains)
                {
                    commonTypeIDs.IntersectWith(chain);
                    

                }
            }

            //No common subtypes
            if (commonTypeIDs.Count == 0)
                return null;

            if (commonTypeIDs.Count == 1)
                return runtimeCore.DSExecutable.classTable.ClassNodes[commonTypeIDs.First()];


            List<int> lookupChain = chains[0];

            
            //Insertion sort the IDs, we may only have a partial ordering on them.
            List<int> orderedTypes = new List<int>();

            foreach (int typeToInsert in commonTypeIDs)
            {
                bool inserted = false;

                for (int i = 0; i < orderedTypes.Count; i++)
                {
                    int orderedType = orderedTypes[i];

                    if (lookupChain.IndexOf(typeToInsert) < lookupChain.IndexOf(orderedType))
                    {
                        inserted = true;
                        orderedTypes.Insert(i, typeToInsert);
                        break;
                    }
//.........这里部分代码省略.........
开发者ID:joespiff,项目名称:Dynamo,代码行数:101,代码来源:ArrayUtils.cs


示例14: GetTypeExamplesForLayer

        public static Dictionary<int, StackValue> GetTypeExamplesForLayer(StackValue array, RuntimeCore runtimeCore)
        {
            if (!array.IsArray)
            {
                Dictionary<int, StackValue> ret = new Dictionary<int, StackValue>();
                ret.Add(array.metaData.type, array);
                return ret;
            }

            Dictionary<int, StackValue> usageFreq = new Dictionary<int, StackValue>();

            //This is the element on the heap that manages the data structure
            var dsArray = runtimeCore.Heap.ToHeapObject<DSArray>(array);
            foreach (var sv in dsArray.Values)
            {
                if (!usageFreq.ContainsKey(sv.metaData.type))
                    usageFreq.Add(sv.metaData.type, sv);
            }

            return usageFreq;
        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:21,代码来源:ArrayUtils.cs


示例15: GetConversionChain

        /// <summary>
        /// For a class node using single inheritence, get the chain of inheritences
        /// </summary>
        /// <param name="cn"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static List<int> GetConversionChain(ClassNode cn, RuntimeCore runtimeCore)
        {
            List<int> ret = new List<int>();
            /*
            //@TODO: Replace this with an ID
            ret.Add(core.classTable.list.IndexOf(cn));

            ClassNode target = cn;
            while (target.baseList.Count > 0)
            {
                Validity.Assert(target.baseList.Count == 1, "Multiple Inheritence not yet supported, {F5DDC58D-F721-4319-854A-622175AC43F8}");
                ret.Add(cn.baseList[0]);

                target = core.classTable.list[cn.baseList[0]];
            }
            */

            List<int> coercableTypes = new List<int>();

            foreach (int typeID in cn.CoerceTypes.Keys)
            {
                bool inserted = false;

                for (int i = 0; i < coercableTypes.Count; i++)
                {
                    if (cn.CoerceTypes[typeID] < cn.CoerceTypes[coercableTypes[i]])
                    {
                        inserted = true;
                        coercableTypes.Insert(typeID, i);
                        break;
                    }
                }
                if (!inserted)
                    coercableTypes.Add(typeID);
            }
            coercableTypes.Add(runtimeCore.DSExecutable.classTable.ClassNodes.IndexOf(cn));



            ret.AddRange(coercableTypes);
            return ret;

        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:49,代码来源:ArrayUtils.cs


示例16: GetZippedIndices

        /// <summary>
        /// For an array we supporting zipped replicaiton for array indexing as 
        /// well. I.e., for the following expression:
        /// 
        ///     a[1..3][2..4] = x;
        /// 
        /// It will be expanded to 
        /// 
        ///     a[1][2] = x;
        ///     a[2][3] = x;
        ///     a[3][4] = x;
        ///     
        /// So here we need to calculate zipped indices. The length of returned 
        /// indices is decided by the shortest length of index that used in 
        /// array indexing. E.g.,
        /// 
        /// For array indexing
        /// 
        ///     [{1, 2, 3}][{"x", "y"}][{6, 7, 8}], i.e., 
        ///     
        ///     1 -> "x" -> 6
        ///     2 -> "y" -> 7
        ///     3 ->     -> 8
        /// 
        /// The shortest length of index is 2 ({"x", "y"}), so function will 
        /// returns:
        /// 
        ///     {{1, "x", 6}, {2, "y", 7}}
        ///     
        /// </summary>
        /// <param name="indices"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue[][] GetZippedIndices(List<StackValue> indices, RuntimeCore runtimeCore)
        {
            List<StackValue[]> allFlattenValues = new List<StackValue[]>();

            int zipLength = System.Int32.MaxValue;
            foreach (var index in indices)
            {
                int length = 1;
                if (index.IsArray)
                {
                    StackValue[] flattenValues = GetFlattenValue(index, runtimeCore);
                    allFlattenValues.Add(flattenValues);
                    length = flattenValues.Count();
                }
                else
                {
                    allFlattenValues.Add(null);
                }

                if (zipLength > length)
                {
                    zipLength = length;
                }
            }

            if (zipLength == 0)
            {
                return null;
            }
            else
            {
                int dims = indices.Count;
                StackValue[][] zippedIndices = new StackValue[zipLength][];
                for (int i = 0; i < zipLength; ++i)
                {
                    zippedIndices[i] = new StackValue[dims];
                }

                for (int i = 0; i < dims; ++i)
                {
                    StackValue index = indices[i];
                    StackValue[] values = null;
                    if (index.IsArray)
                    {
                        values = allFlattenValues[i];
                    }

                    if (1 == zipLength)
                    {
                        if (index.IsArray)
                        {
                            zippedIndices[0][i] = values[0];
                        }
                        else
                        {
                            zippedIndices[0][i] = index;
                        }
                    }
                    else
                    {
                        for (int j = 0; j < zipLength; ++j)
                        {
                            zippedIndices[j][i] = values[j];
                        }
                    }
                }

//.........这里部分代码省略.........
开发者ID:joespiff,项目名称:Dynamo,代码行数:101,代码来源:ArrayUtils.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: GetMaxRankForArray

        private static int GetMaxRankForArray(StackValue array, RuntimeCore runtimeCore, int tracer)
        {
            if (tracer > RECURSION_LIMIT)
                throw new CompilerInternalException("Internal Recursion limit exceeded in Rank Check - Possible heap corruption {3317D4F6-4758-4C19-9680-75B68DA0436D}");

            if (!array.IsArray)
                return 0;
            //throw new ArgumentException("The stack value provided was not an array");

            int ret = 1;

            int largestSub = 0;

            //This is the element on the heap that manages the data structure
            foreach (var sv in runtimeCore.Heap.ToHeapObject<DSArray>(array).Values)
            {
                if (sv.IsArray)
                {
                    int subArrayRank = GetMaxRankForArray(sv, runtimeCore, tracer + 1);
                    largestSub = Math.Max(subArrayRank, largestSub);
                }
            }

            return largestSub + ret;
        }
开发者ID:joespiff,项目名称:Dynamo,代码行数:25,代码来源:ArrayUtils.cs


示例19: GetStringValue

 public static string GetStringValue(StackValue sv, RuntimeCore runtimeCore)
 {
     ProtoCore.DSASM.Mirror.ExecutionMirror mirror = new DSASM.Mirror.ExecutionMirror(new ProtoCore.DSASM.Executive(runtimeCore), runtimeCore);
     return mirror.GetStringValue(sv, runtimeCore.RuntimeMemory.Heap, 0, true);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:5,代码来源:StringUtils.cs


示例20: ConcatString

 public static StackValue ConcatString(StackValue op1, StackValue op2, RuntimeCore runtimeCore)
 {
     var v1 = runtimeCore.RuntimeMemory.Heap.ToHeapObject<DSString>(op1).Value;
     var v2 = runtimeCore.RuntimeMemory.Heap.ToHeapObject<DSString>(op2).Value;
     return StackValue.BuildString(v1 + v2, runtimeCore.RuntimeMemory.Heap);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:6,代码来源:StringUtils.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# RuntimeDefinedParameterDictionary类代码示例发布时间:2022-05-24
下一篇:
C# RuntimeAssembly类代码示例发布时间: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