Ejemplo n.º 1
0
        public void NewObject(MethodBase constructorInfo)
        {
            if (constructorInfo.DeclaringType == typeof(object))
            {
                return;
            }

            constructorInfo.Register();
            var result = SetNewVReg();

            result.FixedType = new TypeDescription(constructorInfo.DeclaringType);
            var constructedObject = new NewConstructedObject
            {
                AssignedTo = result,
                Info       = constructorInfo
            };

            AddOperation(constructedObject);

            var interpreter = new CilMethodInterpreter(constructedObject.Info);
            var methodData  = new CallMethodStatic(interpreter);

            CallMethodData(constructedObject.Info, methodData);
            var vreg = SetNewVReg();

            vreg.FixedType = new TypeDescription(methodData.Info.DeclaringType);
            var assign = new Assignment
            {
                AssignedTo = vreg,
                Right      = methodData.Parameters.First()
            };

            AddOperation(assign);
        }
Ejemplo n.º 2
0
        public void NewObject(ConstructorInfo constructorInfo, CrRuntimeLibrary crRuntime)
        {
            if (constructorInfo.DeclaringType == typeof(object))
            {
                return;
            }
            var mappedType = crRuntime.GetMappedType(constructorInfo.DeclaringType);

            if (mappedType != null && mappedType != constructorInfo.DeclaringType)
            {
                constructorInfo = crRuntime.GetMappedConstructor(constructorInfo);
            }
            constructorInfo.Register();
            var result = SetNewVReg();

            result.FixedType = new TypeDescription(constructorInfo.DeclaringType);
            var constructedObject = new NewConstructedObject(constructorInfo);
            var assignment        = new Assignment
            {
                AssignedTo = result,
                Right      = constructedObject
            };

            AddOperation(OperationKind.NewObject, assignment);

            var interpreter = constructedObject.Info.Register(crRuntime);
            var methodData  = new MethodData(interpreter);

            CallMethodData(constructedObject.Info, methodData, OperationKind.Call, crRuntime);
            var vreg = SetNewVReg();

            vreg.FixedType = new TypeDescription(methodData.Info.DeclaringType);
            var assign = new Assignment
            {
                AssignedTo = vreg,
                Right      = methodData.Parameters.First()
            };

            AddOperation(OperationKind.Assignment, assign);
        }