Esempio n. 1
0
        public override IValue CreateValueFromRuntime(object obj, CilManagedMemory managedMemory, CilProgram program)
        {
            var runtimeArr = obj as Array;

            if (Dimensions == 1)
            {
                var resultArray = new IValue[runtimeArr.Length];
                for (int i = 0; i < runtimeArr.Length; i++)
                {
                    resultArray[i] = ElementType.CreateValueFromRuntime(runtimeArr.GetValue(i), managedMemory, program);
                }

                var cilArray = new CilArray(resultArray, ElementType);
                var arrayRef = managedMemory.Store(cilArray);
                return(arrayRef);
            }

            var extObj = new CilObjectExternal(obj);
            var objRef = managedMemory.Store(extObj);

            return(objRef);
        }