Exemplo n.º 1
0
        public void BuildField(ILConversion conversion, ConvertedTypeDefinition_I input, FieldDefinition field)
        {
            if (!(input is ConvertedTypeDefinitionWithFields_I typeWithFields))
            {
                throw new Exception("Trying to build a field on a type that does not support fields.");
            }

            var fieldAttributes = GetFieldAttributes(field);

            var boundFieldType = Execution.Types.Ensuring.EnsureToType(conversion, field.FieldType, out BoundTypeDefinitionMask_I semanticFieldType);

            var builder = typeWithFields.TypeBuilder.DefineField(field.Name, boundFieldType, fieldAttributes);

            if (field.HasConstant)
            {
                builder.SetConstant(field.Constant);
            }

            var convertedField = new ConvertedField()
            {
                FieldType       = semanticFieldType,
                Conversion      = conversion,
                FieldDefinition = field,
                FieldBuilder    = builder,
                UnderlyingField = builder,
                Name            = field.Name,
            };

            typeWithFields.Fields.ByName.Add(convertedField.Name, convertedField);

            CustomAttributes.BuildCustomAttributes(conversion, input, convertedField);
        }
Exemplo n.º 2
0
        public bool BuildInstructions(ILConversion conversion, ConvertedTypeDefinition_I convertedType)
        {
            if (conversion.Configuration.UseILGenerator)
            {
                //return WithILGenerator.GenerateIL(conversion, convertedType);
                throw new NotSupportedException("The use of the IL generator is  no longer supported.");
            }

            if (!(convertedType is ConvertedTypeWithRoutines_I convertedWithRoutines))
            {
                return(true);
            }

            if (convertedWithRoutines.RoutinesEmitState == null)
            {
                convertedWithRoutines.RoutinesEmitState = new ConvertedRoutinesEmitState();
            }

            var currentRoutineToEmit = convertedWithRoutines.RoutinesEmitState.CurrentRoutineToEmit;

            for (int i = currentRoutineToEmit; i < convertedWithRoutines.Routines.Count; convertedWithRoutines.RoutinesEmitState.CurrentRoutineToEmit = ++i)
            {
                var routine = convertedWithRoutines.Routines[i];

                if (!BuildRoutineBody(conversion, routine))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public void EnsureInterfaces(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            if (!(converted.SupportsInterfaceTypeList() && converted is SemanticTypeWithInterfaceTypeList_I tewii))
            {
                return;
            }

            var typeDefinition = (TypeDefinition)converted.SourceTypeReference;



            var interfaceTypes = typeDefinition.Interfaces;

            for (int i = 0; i < interfaceTypes.Count; i++)
            {
                var interfaceImplementation = interfaceTypes[i];

                var interfaceType = interfaceImplementation.InterfaceType;

                var item = Execution.Types.Ensuring.Ensure(conversion, interfaceType, null, null);

                if (!(item is BoundTypeDefinitionMask_I boundInterface))
                {
                    throw new Exception("When creating a conversion model, the base type needs to be a bound type.");
                }

                converted.TypeBuilder.AddInterfaceImplementation(boundInterface.UnderlyingType);

                var resolutionName = Types.Naming.GetResolutionName(item);

                tewii.Interfaces.ByResolutionName.Add(resolutionName, (SemanticInterfaceTypeMask_I)item);

                Types.Dependencies.Add(converted, item);
            }
        }
Exemplo n.º 4
0
        public void IfPossibleBuildPhase2(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            if (converted.SourceTypeReference.FullName ==
                "Root.Code.Containers.E01D.Runtimic.RuntimicContainerB_I`1"
                )
            {
                // Does get here
            }

            // There is not just building work to be done.  There is actually pre and post being working to be done.  The dependency check is to verify if there is any
            // post build work to be done.
            List <ConvertedTypeDefinition_I> dependencies = CheckForBuildDependencies(conversion, converted, BuildPhaseKind.MembersDefined);

            if (dependencies.Count < 1)
            {
                BuildPhase2AndDependencies(conversion, converted);
            }
            else
            {
                for (int i = 0; i < dependencies.Count; i++)
                {
                    var dependency = dependencies[i];

                    converted.ConversionState.Phase2Dependencies.Add(dependency);

                    dependency.ConversionState.Phase2Dependents.Add(converted);
                }
            }
        }
Exemplo n.º 5
0
        private void BuildPhase2AndDependencies(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
// Build all members
            BuildPhase2(conversion, converted);

            if (converted.SourceTypeReference.FullName ==
                "Root.Code.Containers.E01D.Runtimic.RuntimicContainerB_I`1"
                )
            {
                // Does get here
            }

            // Give a chance for all dependencies to build all members
            var dependents = converted.ConversionState.Phase2Dependents;

            for (int i = 0; i < dependents.Count; i++)
            {
                var dependent = dependents[i];

                dependent.ConversionState.Phase2Dependencies.Remove(converted);

                if (dependent.ConversionState.Phase2Dependencies.Count == 0)
                {
                    BuildPhase2AndDependencies(conversion, dependent);
                }
            }

            converted.ConversionState.Phase2Dependents.Clear();

            BuildPhase3(conversion, converted);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds builds all of the members and adds them to the type.
        /// </summary>
        /// <param name="conversion"></param>
        /// <param name="converted"></param>
        public void Build(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            // DESIGN NOTE:
            // Add all members to the type.



            Members.TypeParameters.Building.EnsureTypeParametersIfAny(conversion, converted);

            Types.Ensuring.Gathering.EnsureBaseType(conversion, converted);

            Types.Ensuring.Gathering.EnsureInterfaces(conversion, converted);

            // FIX: needs to take generic arguments into account
            Types.Ensuring.Gathering.GetNestedTypes(conversion, converted);

            Fields.Building.NonGeneric.BuildFields(conversion, converted);

            Routines.Building.BuildRoutines(conversion, converted);

            Properties.Building.BuildsProperties(conversion, converted);

            Events.Building.BuildEvents(conversion, converted);

            CustomAttributes.BuildCustomAttributes(conversion, converted);

            // DESIGN NOTE:
            // Do not place the building of instructions within this phase.  The instructions can need
            // generic instances of the class being built.  The generic instances need the methods that orginate from
            // this phase.  But they cannot get them till this phase is complete, and they can add their own members.
            //Instructions.Building.BuildInstructions(conversion, converted);
        }
Exemplo n.º 7
0
        private void DefineTypeParameterBuildersIfPresent(ILConversion conversion, ConvertedTypeDefinition_I convertedType)
        {
            if (!convertedType.IsGeneric())
            {
                return;
            }

            var gtd = (ConvertedGenericTypeDefinition_I)convertedType;

            if (!gtd.HasTypeParameters())
            {
                return;
            }

            var ctwtb = (ConvertedTypeDefinitionWithTypeBuilder_I)convertedType;

            var tpList = gtd.TypeParameters.All;

            var names = Types.TypeParameters.GetNames(conversion, gtd);

            var genericParameters = convertedType.TypeBuilder.DefineGenericParameters(names);

            gtd.TypeParameters.Builders = genericParameters;

            for (var i = 0; i < tpList.Count; i++)
            {
                var tp = (ConvertedGenericParameterTypeDefinition)tpList[i];

                tp.Builder = genericParameters[i];

                tp.UnderlyingType = genericParameters[i];
            }
        }
Exemplo n.º 8
0
        public ConvertedMethodMask_I GetMethod(ConvertedTypeDefinition_I convertedType, MethodDefinition methodDefinition)
        {
            if (!(convertedType is ConvertedTypeWithMethods_I withMethods))
            {
                throw new System.Exception("Expecting a type with methods.");
            }

            var collection = withMethods.Methods.ByName.Values.ToList();

            for (int i = 0; i < collection.Count; i++)
            {
                var semanticList = collection[i];

                for (int j = 0; j < semanticList.Count; j++)
                {
                    var semantic = semanticList[j];

                    if (!(semantic is ConvertedMethod bound))
                    {
                        continue;
                    }

                    if (object.ReferenceEquals(bound.MethodReference, methodDefinition))
                    {
                        return(bound);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        private void EnsureNestedTypesAreReadyForBaking(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            var nestedTypes = input.NestedTypes.Values.ToList();

            for (int i = 0; i < nestedTypes.Count; i++)
            {
                var nestedType = nestedTypes[i];
            }
        }
Exemplo n.º 10
0
        //public void BakeTypes(ILConversion conversion, List<ConvertedTypeDefinition_I> list)
        //{
        //    // NEED TO GO THROUGH ALL;
        //    // * Base Types
        //    // * Interface Types
        //    // * Nested Types
        //    // * Generic Type Parameter Constraints

        //    // AND MAKE SURE THEY ARE BAKED FIRST

        //    //for (int i = 0; i < list.Count; i++)
        //    //{
        //    //    var input = list[i];

        //    //    Bake(conversion, input);
        //    //}
        //}



        private void EnsureGenericIsReadyForBaking(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            if (!input.IsGeneric())
            {
                return;
            }

            if (!(input is ConvertedGenericTypeDefinition_I convertedGeneric))
            {
                throw new System.Exception("Expected at least a converted generic.");
            }

            if (convertedGeneric.HasTypeArguments())
            {
                for (int i = 0; i < convertedGeneric.TypeArguments.All.Count; i++)
                {
                    var typeArgument = convertedGeneric.TypeArguments.All[i];



                    //Bake(conversion, convertedTypeArgument);
                }
            }

            if (!convertedGeneric.HasTypeParameters())
            {
                return;
            }

            for (int i = 0; i < convertedGeneric.TypeParameters.All.Count; i++)
            {
                var typeParameter = (ConvertedGenericParameterTypeDefinition)convertedGeneric.TypeParameters.All[i];

                if (typeParameter.BaseTypeConstraint != null)
                {
                    var classConstraint = typeParameter.BaseTypeConstraint.Class;
                }

                if (typeParameter.InterfaceTypeConstraints == null)
                {
                    continue;
                }

                for (int j = 0; j < typeParameter.InterfaceTypeConstraints.Count; j++)
                {
                    var interfaceTypeConstraint = typeParameter.InterfaceTypeConstraints[j];

                    if (interfaceTypeConstraint.Interface == null)
                    {
                        continue;
                    }

                    var interfaceConstraint = interfaceTypeConstraint.Interface;
                }
            }
        }
Exemplo n.º 11
0
        public void BuildCustomAttributes(ILConversion conversion, ConvertedTypeDefinition_I input, ConvertedField convertedField)
        {
            var builders = CreateCustomAttributeList(conversion, convertedField.FieldDefinition.CustomAttributes);

            for (int i = 0; i < builders.Count; i++)
            {
                var builder1 = builders[i];

                convertedField.FieldBuilder.SetCustomAttribute(builder1);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Assigns the generic blueprint and the type arguments to the generic instance type.
        /// </summary>
        /// <param name="conversion"></param>
        /// <param name="converted"></param>
        /// <param name="convertedDeclaringType"></param>
        /// <returns></returns>
        public void Build(ILConversion conversion, ConvertedTypeDefinition_I converted, ConvertedTypeDefinition_I convertedDeclaringType)
        {
            //Done on purpose to find errors
            var typeDefinition = (TypeDefinition)converted.SourceTypeReference;

            System.Reflection.TypeAttributes attributes = Cecil.Metadata.Members.Types.GetTypeAttributes(typeDefinition);

            if (converted is ConvertedTypeDefinitionWithDeclaringType_I withDeclaringType)
            {
                var packingSize = Cecil.GetPackingSize(typeDefinition);

                if (convertedDeclaringType == null)                 // Can occur if passing in a single nested type or if a nested class gets processed before its parents gets
                // processed.
                {
                    if (!(converted.SourceTypeReference is TypeDefinition))
                    {
                        throw new Exception("Expected a type definition");
                    }

                    var semanticDeclaringType = Execution.Types.Ensuring.Ensure(conversion, converted.SourceTypeReference.DeclaringType, null, null);

                    if (!(semanticDeclaringType is ConvertedTypeDefinition_I producedDeclaringType))
                    {
                        throw new Exception($"Expected the declaring type of a nested class to be castable to {typeof(ConvertedTypeDefinition_I)}");
                    }

                    convertedDeclaringType = producedDeclaringType;
                }

                withDeclaringType.DeclaringType = convertedDeclaringType;

                // The plus sign and the parent class name before it needs to be dropped from the full name prior to calling define nested class
                // as the type builder will automatically add them back on based upon the name of the declaring type.
                var fullName = Types.Naming.GetTypeBuilderNestedClassFullName(converted.FullName);

                converted.TypeBuilder = convertedDeclaringType.TypeBuilder.DefineNestedType(fullName, attributes, null, packingSize);
            }
            else
            {
                if (converted.FullName == "<Module>")
                {
                    var x = converted.Module.ModuleBuilder.GetType("<Module>", true);
                }

                converted.TypeBuilder = converted.Module.ModuleBuilder.DefineType(converted.FullName, attributes);
            }

            converted.UnderlyingType = converted.TypeBuilder;

            this.Unified.Types.ExtendWithCrossReference(conversion.RuntimicSystem, converted, converted.UnderlyingType.AssemblyQualifiedName);

            Types.Building.UpdateBuildPhase(converted, BuildPhaseKind.TypeDefined);
        }
Exemplo n.º 13
0
        public void BuildCustomAttributes(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            var typeDefinition = (TypeDefinition)converted.SourceTypeReference;

            var builders = CreateCustomAttributeList(conversion, typeDefinition.CustomAttributes);

            for (int i = 0; i < builders.Count; i++)
            {
                var builder1 = builders[i];

                converted.TypeBuilder.SetCustomAttribute(builder1);
            }
        }
Exemplo n.º 14
0
        private void EnsureInterfacesAreReadyForBaking(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            if (!(input is SemanticTypeWithInterfaceTypeList_I typeWithInterfaceTypeList))
            {
                return;
            }

            var interfaces = typeWithInterfaceTypeList.Interfaces.ByResolutionName.Values.ToList();

            for (int i = 0; i < interfaces.Count; i++)
            {
                var interfaceType = interfaces[i];
            }
        }
Exemplo n.º 15
0
        public BoundTypeDefinitionMask_I EnsureBound(ILConversion conversion, TypeReference typeReference,
                                                     ConvertedTypeDefinition_I declaringType)
        {
            // Done collecting arguments, now use context.
            var context = new ExecutionEnsureContext()
            {
                RuntimicSystem = conversion.RuntimicSystem,
                Conversion     = conversion,
                DeclaringType  = declaringType,
                TypeReference  = typeReference
            };

            return(EnsureBound(context));
        }
Exemplo n.º 16
0
        public void  GetNestedTypes(ILConversion conversion, ConvertedTypeDefinition_I declaringType)
        {
            declaringType.NestedTypes = new Dictionary <string, SemanticTypeMask_I>();

            var typeDefinition = (TypeDefinition)declaringType.SourceTypeReference;

            var nestedTypes = typeDefinition.NestedTypes;

            for (int i = 0; i < nestedTypes.Count; i++)
            {
                var nestedType = nestedTypes[i];

                var boundNestedType = Execution.Types.Ensuring.EnsureBound(conversion, nestedType, declaringType);

                declaringType.NestedTypes.Add(boundNestedType.FullName, boundNestedType);
            }
        }
Exemplo n.º 17
0
        public bool Build(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            // DESIGN NOTE:
            // Need to place this in this phase after members have been created, and after generic instances have been able to get a copy of the methods.
            // The instructions for this converted type can need generic instances of this type, which in turn need to have the methods already added
            // so their methods can be created.

            // The generic instances need the methods that orginate from this phase.
            if (!Instructions.Building.BuildInstructions(conversion, converted))
            {
                return(false);
            }

            Methods.Building.Emitted.AddAllMethodOverrides(conversion, converted);

            return(true);
        }
Exemplo n.º 18
0
        public void BuildFields(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            // Done on purpose to find errors
            var typeDefinition = (TypeDefinition)input.SourceTypeReference;

            if (!typeDefinition.HasFields)
            {
                return;
            }

            for (int i = 0; i < typeDefinition.Fields.Count; i++)
            {
                var field = typeDefinition.Fields[i];

                BuildField(conversion, input, field);
            }
        }
Exemplo n.º 19
0
        public bool GetConstructor(ILConversion conversion, ConvertedTypeDefinition_I callingType, MethodReference methodReference, out MemberInfo memberInfo)
        {
            memberInfo = null;

            // how does the member reference declaring type be resolved?
            var declaringBound = Execution.Types.Ensuring.EnsureBound(conversion, methodReference.DeclaringType);

            if (declaringBound.SourceTypeReference.IsArray)
            {
                memberInfo = Methods.Building.MakeArrayMethod(conversion, callingType, declaringBound, methodReference);

                return(true);
            }

            if (!declaringBound.IsConverted())
            {
                // NOTE - This call can only be used when accessing types that fully built.
                memberInfo = Binding.Metadata.Members.Constructors.FindConstructorBySignature(conversion.Model, declaringBound, methodReference);
            }
            else
            {
                // This method HAS to be used for accessing constructors of types that are not fullying built.
                var withConstructors = (ConvertedTypeDefinitionWithConstructors_I)declaringBound;

                var semanticConstructor = GetConstructor(conversion, withConstructors, methodReference);

                if (semanticConstructor == null)
                {
                    return(false);
                }

                if (!(semanticConstructor is BoundConstructorDefinitionMask_I boundConstructor))
                {
                    throw new Exception("Semantic constructor is not a bound constructor.  Cannot return a constructor info from a non-executive type.");
                }

                memberInfo = boundConstructor.UnderlyingConstructor;
            }

            return(memberInfo != null);
        }
Exemplo n.º 20
0
        public BoundTypeDefinitionMask_I EnsureBaseType(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            var baseTypeReference = Infrastructure.Structural.Cecil.GetBaseType(converted.SourceTypeReference);

            BoundTypeDefinitionMask_I boundBaseType = null;

            if (baseTypeReference != null)
            {
                var result = Execution.Types.Ensuring.Ensure(conversion, baseTypeReference, null, converted);

                if (!(result is BoundTypeDefinitionMask_I boundBaseType1))
                {
                    throw new Exception("When creating a conversion model, the base type needs to be a bound type.");
                }

                boundBaseType = boundBaseType1;

                converted.BaseType = boundBaseType;
            }

            System.Type baseType;

            if (converted.IsStruct())
            {
                baseType = boundBaseType?.UnderlyingType ?? GetValueType(conversion);
            }
            else
            {
                baseType = boundBaseType?.UnderlyingType ?? (converted.IsClassType() ? GetObjectType(conversion) : null);
            }

            if (baseType == null && (converted.IsClassType() || converted.IsStruct()))
            {
                throw new Exception("The bound's undelrying type cannot be null.  The converted type is a class or struct, and in either case requires a base class of either System.Object or System.ValueType.");
            }

            converted.TypeBuilder.SetParent(baseType);

            return(boundBaseType);
        }
Exemplo n.º 21
0
        public void BuildsProperties(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            // Done on purpose to find errors
            var typeDefinition = (TypeDefinition)input.SourceTypeReference;

            if (!typeDefinition.HasProperties)
            {
                return;
            }

            if (!(input is ConvertedTypeDefinitionWithProperties_I inputWithProperties))
            {
                throw new System.Exception("Expected a type that can store properties.");
            }

            for (int i = 0; i < typeDefinition.Properties.Count; i++)
            {
                var property1 = typeDefinition.Properties[i];

                BuildProperty(conversion, inputWithProperties, property1);
            }
        }
Exemplo n.º 22
0
        public void AddAllMethodOverrides(ILConversion conversion, ConvertedTypeDefinition_I input)
        {
            // Done on purpose to find errors
            var typeDefinition = (TypeDefinition)input.SourceTypeReference;

            if (!typeDefinition.HasMethods)
            {
                return;
            }

            if (!(input is ConvertedTypeWithMethods_I convertedTypeWithMethods))
            {
                throw new Exception("Trying to add a method to a type that does not support methods.");
            }

            var methods = Bound.Metadata.Members.Methods.Getting.GetMethods(input);

            for (int i = 0; i < methods.Count; i++)
            {
                var method = methods[i];

                AddMethodOverride(conversion, input, method);
            }
        }
Exemplo n.º 23
0
        public void BuildPhase2(ILConversion conversion, ConvertedTypeDefinition_I converted)
        {
            if (converted.SourceTypeReference.FullName ==
                "Root.Code.Containers.E01D.Runtimic.RuntimicContainer_I`1<TContainer>"
                )
            {
            }

            if (converted.SourceTypeReference.FullName ==
                "Root.Code.Containers.E01D.Runtimic.RuntimicContainer_I`1"
                )
            {
                // Does get here
            }

            if (converted.ConversionState.BuildPhase != BuildPhaseKind.TypeDefined)
            {
                throw new System.Exception("Expecting the current build phase to be phase 1");
            }

            if (converted is ConvertedGenericTypeDefinition_I generic && generic.IsClosedType())
            {
                GenericInstances.Phase2Dependency.Build(conversion, generic);
            }
Exemplo n.º 24
0
 public void MarkAsBaked(ConvertedTypeDefinition_I converted)
 {
     throw new Exception();
 }
Exemplo n.º 25
0
 public void Bake(ILConversion conversion, ConvertedTypeDefinition_I converted)
 {
     throw new Exception();
 }
Exemplo n.º 26
0
 private List <ConvertedTypeDefinition_I> CheckForBakingDependencies(ILConversion conversion, ConvertedTypeDefinition_I converted)
 {
     throw new Exception();
 }
Exemplo n.º 27
0
 public void IfPossibleBuildPhase2(ILConversion conversion, ConvertedTypeDefinition_I converted)
 {
     // There is not just building work to be done.  There is actually pre and post being working to be done.  The dependency check is to verify if there is any
     // post build work to be done.
     throw new Exception();
 }
Exemplo n.º 28
0
 public void AddDependentOrDependency(Dictionary <string, ConvertedTypeDefinition_I> dictionary, ConvertedTypeDefinition_I converted)
 {
     if (!dictionary.ContainsKey(converted.ResolutionName))
     {
         dictionary.Add(converted.ResolutionName, converted);
     }
 }
Exemplo n.º 29
0
        public void EnsureTypes(ILConversion conversion, ConvertedTypeDefinition_I converted, MethodDefinition callingMethodDefinition, Collection <Instruction> instructions)
        {
            for (int i = 0; i < instructions.Count; i++)
            {
                var instructionDefinition = instructions[i];


                switch (instructionDefinition.OpCode.Code)
                {
                case Libs.Mono.Cecil.Cil.Code.Add:
                case Libs.Mono.Cecil.Cil.Code.Add_Ovf:
                case Libs.Mono.Cecil.Cil.Code.Add_Ovf_Un:
                case Libs.Mono.Cecil.Cil.Code.And:
                case Libs.Mono.Cecil.Cil.Code.Arglist:
                case Libs.Mono.Cecil.Cil.Code.Beq:
                case Libs.Mono.Cecil.Cil.Code.Beq_S:
                case Libs.Mono.Cecil.Cil.Code.Bge:
                case Libs.Mono.Cecil.Cil.Code.Bge_S:
                case Libs.Mono.Cecil.Cil.Code.Bge_Un:
                case Libs.Mono.Cecil.Cil.Code.Bge_Un_S:
                case Libs.Mono.Cecil.Cil.Code.Bgt:
                case Libs.Mono.Cecil.Cil.Code.Bgt_S:
                case Libs.Mono.Cecil.Cil.Code.Bgt_Un:
                case Libs.Mono.Cecil.Cil.Code.Bgt_Un_S:
                case Libs.Mono.Cecil.Cil.Code.Ble:
                case Libs.Mono.Cecil.Cil.Code.Ble_S:
                case Libs.Mono.Cecil.Cil.Code.Ble_Un:
                case Libs.Mono.Cecil.Cil.Code.Ble_Un_S:
                case Libs.Mono.Cecil.Cil.Code.Blt:
                case Libs.Mono.Cecil.Cil.Code.Blt_S:
                case Libs.Mono.Cecil.Cil.Code.Blt_Un:
                case Libs.Mono.Cecil.Cil.Code.Blt_Un_S:
                case Libs.Mono.Cecil.Cil.Code.Bne_Un:
                case Libs.Mono.Cecil.Cil.Code.Bne_Un_S:
                // Unconditional Branching - Long Form
                case Libs.Mono.Cecil.Cil.Code.Br:
                // Inserts an breakpoint into the IL stream - takes no parameters; does not touch the evaluation stack
                case Libs.Mono.Cecil.Cil.Code.Break:
                // Conditional Branching - Pop a value from evaluation stack and see if it is 0.  If so, branch.
                case Libs.Mono.Cecil.Cil.Code.Brfalse:
                // Conditional Branching - Pop a value from evaluation stack and see if it is 0.  If so, branch.
                case Libs.Mono.Cecil.Cil.Code.Brfalse_S:
                // Conditional Branching - Pop a value from evaluation stack and see if it is 1.  If so, branch.
                case Libs.Mono.Cecil.Cil.Code.Brtrue:
                // Conditional Branching - Pop a value from evaluation stack and see if it is 1.  If so, branch.
                case Libs.Mono.Cecil.Cil.Code.Brtrue_S:
                // Unconditional Branching - Short Form
                case Libs.Mono.Cecil.Cil.Code.Br_S:

                case Libs.Mono.Cecil.Cil.Code.Ceq:
                case Libs.Mono.Cecil.Cil.Code.Cgt:
                case Libs.Mono.Cecil.Cil.Code.Cgt_Un:
                case Libs.Mono.Cecil.Cil.Code.Ckfinite:
                case Libs.Mono.Cecil.Cil.Code.Clt:
                case Libs.Mono.Cecil.Cil.Code.Clt_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_I:
                case Libs.Mono.Cecil.Cil.Code.Conv_I1:
                case Libs.Mono.Cecil.Cil.Code.Conv_I2:
                case Libs.Mono.Cecil.Cil.Code.Conv_I4:
                case Libs.Mono.Cecil.Cil.Code.Conv_I8:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I1:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I1_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I2:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I2_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I4:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I4_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I8:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I8_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_I_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U1:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U1_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U2:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U2_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U4:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U4_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U8:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U8_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_Ovf_U_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_R4:
                case Libs.Mono.Cecil.Cil.Code.Conv_R8:
                case Libs.Mono.Cecil.Cil.Code.Conv_R_Un:
                case Libs.Mono.Cecil.Cil.Code.Conv_U:
                case Libs.Mono.Cecil.Cil.Code.Conv_U1:
                case Libs.Mono.Cecil.Cil.Code.Conv_U2:
                case Libs.Mono.Cecil.Cil.Code.Conv_U4:
                case Libs.Mono.Cecil.Cil.Code.Conv_U8:
                case Libs.Mono.Cecil.Cil.Code.Cpblk:
                case Libs.Mono.Cecil.Cil.Code.Div:
                case Libs.Mono.Cecil.Cil.Code.Div_Un:
                case Libs.Mono.Cecil.Cil.Code.Dup:
                case Libs.Mono.Cecil.Cil.Code.Endfilter:
                case Libs.Mono.Cecil.Cil.Code.Endfinally:
                case Libs.Mono.Cecil.Cil.Code.Initblk:
                case Libs.Mono.Cecil.Cil.Code.Ldarg:
                case Libs.Mono.Cecil.Cil.Code.Ldarga:
                case Libs.Mono.Cecil.Cil.Code.Ldarga_S:

                case Libs.Mono.Cecil.Cil.Code.Ldarg_0:
                case Libs.Mono.Cecil.Cil.Code.Ldarg_1:
                case Libs.Mono.Cecil.Cil.Code.Ldarg_2:
                case Libs.Mono.Cecil.Cil.Code.Ldarg_3:
                case Libs.Mono.Cecil.Cil.Code.Ldarg_S:
                // Constant Loading - Push the supplied integer value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4:
                // Constant Loading - Push the supplied integer value of 0 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_0:
                // Constant Loading - Push the supplied integer value of 1 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_1:
                // Constant Loading - Push the supplied integer value of 2 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_2:
                // Constant Loading - Push the supplied integer value of 3 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_3:
                // Constant Loading - Push the supplied integer value of 4 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_4:
                // Constant Loading - Push the supplied integer value of 5 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_5:
                // Constant Loading - Push the supplied integer value of 6 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_6:
                // Constant Loading - Push the supplied integer value of 7 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_7:
                // Constant Loading - Push the supplied integer value of 8 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_8:
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_M1:
                case Libs.Mono.Cecil.Cil.Code.Ldc_I4_S:
                case Libs.Mono.Cecil.Cil.Code.Ldc_I8:
                case Libs.Mono.Cecil.Cil.Code.Ldc_R4:
                case Libs.Mono.Cecil.Cil.Code.Ldc_R8:
                case Libs.Mono.Cecil.Cil.Code.Leave:

                case Libs.Mono.Cecil.Cil.Code.Leave_S:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_Any:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_I:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_I1:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_I2:

                case Libs.Mono.Cecil.Cil.Code.Ldelem_I4:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_I8:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_R4:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_R8:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_Ref:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_U1:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_U2:
                case Libs.Mono.Cecil.Cil.Code.Ldelem_U4:
                //case Mono.Cecil.Cil.Code.Ldfld:
                //case Mono.Cecil.Cil.Code.Ldflda:
                //case Mono.Cecil.Cil.Code.Ldftn:
                case Libs.Mono.Cecil.Cil.Code.Ldlen:
                case Libs.Mono.Cecil.Cil.Code.Ldind_I:
                case Libs.Mono.Cecil.Cil.Code.Ldind_I1:
                case Libs.Mono.Cecil.Cil.Code.Ldind_I2:
                case Libs.Mono.Cecil.Cil.Code.Ldind_I4:
                case Libs.Mono.Cecil.Cil.Code.Ldind_I8:
                case Libs.Mono.Cecil.Cil.Code.Ldind_R4:
                case Libs.Mono.Cecil.Cil.Code.Ldind_R8:
                case Libs.Mono.Cecil.Cil.Code.Ldind_Ref:
                case Libs.Mono.Cecil.Cil.Code.Ldind_U1:
                case Libs.Mono.Cecil.Cil.Code.Ldind_U2:
                case Libs.Mono.Cecil.Cil.Code.Ldind_U4:
                // Local Load - Push the local value at the location specified by the supplied short value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc:
                // Local Load - Push the address of the local value at the location specified by the supplied short value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloca:
                // Local Load - Push the address of the local value at the location specified by the supplied byte value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloca_S:
                // Local Load - Push the local value 0 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc_0:
                // Local Load - Push the local value 0 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc_1:
                // Local Load - Push the local value 0 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc_2:
                // Local Load - Push the local value 0 onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc_3:
                // Local Load - Push the local value at the location specified by the supplied byte value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Ldloc_S:
                case Libs.Mono.Cecil.Cil.Code.Ldnull:
                //case Mono.Cecil.Cil.Code.Ldsfld:
                //case Mono.Cecil.Cil.Code.Ldsflda:
                case Libs.Mono.Cecil.Cil.Code.Ldstr:
                case Libs.Mono.Cecil.Cil.Code.Localloc:
                case Libs.Mono.Cecil.Cil.Code.Mul:
                case Libs.Mono.Cecil.Cil.Code.Mul_Ovf:
                case Libs.Mono.Cecil.Cil.Code.Mul_Ovf_Un:
                case Libs.Mono.Cecil.Cil.Code.Neg:

                case Libs.Mono.Cecil.Cil.Code.Nop:
                case Libs.Mono.Cecil.Cil.Code.Not:
                case Libs.Mono.Cecil.Cil.Code.Pop:
                case Libs.Mono.Cecil.Cil.Code.Or:
                case Libs.Mono.Cecil.Cil.Code.Readonly:
                case Libs.Mono.Cecil.Cil.Code.Refanytype:
                case Libs.Mono.Cecil.Cil.Code.Rem:
                case Libs.Mono.Cecil.Cil.Code.Rem_Un:
                case Libs.Mono.Cecil.Cil.Code.Ret:
                case Libs.Mono.Cecil.Cil.Code.Rethrow:
                case Libs.Mono.Cecil.Cil.Code.Starg:
                case Libs.Mono.Cecil.Cil.Code.Starg_S:
                case Libs.Mono.Cecil.Cil.Code.Stelem_Any:
                case Libs.Mono.Cecil.Cil.Code.Stelem_I:
                case Libs.Mono.Cecil.Cil.Code.Stelem_I1:
                case Libs.Mono.Cecil.Cil.Code.Stelem_I2:
                case Libs.Mono.Cecil.Cil.Code.Stelem_I4:
                case Libs.Mono.Cecil.Cil.Code.Stelem_I8:
                case Libs.Mono.Cecil.Cil.Code.Stelem_R4:
                case Libs.Mono.Cecil.Cil.Code.Stelem_R8:
                case Libs.Mono.Cecil.Cil.Code.Stelem_Ref:
                case Libs.Mono.Cecil.Cil.Code.Stind_I:
                case Libs.Mono.Cecil.Cil.Code.Stind_I1:
                case Libs.Mono.Cecil.Cil.Code.Stind_I2:
                case Libs.Mono.Cecil.Cil.Code.Stind_I4:
                case Libs.Mono.Cecil.Cil.Code.Stind_I8:
                case Libs.Mono.Cecil.Cil.Code.Stind_R4:
                case Libs.Mono.Cecil.Cil.Code.Stind_R8:
                case Libs.Mono.Cecil.Cil.Code.Stind_Ref:
                // Local Store - Pops the value on the stack and stores it in local location specified by the supplied short value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Stloc:
                // Local Store - Pops the value on the stack and stores it in local 0
                case Libs.Mono.Cecil.Cil.Code.Stloc_0:
                // Local Store - Pops the value on the stack and stores it in local 1
                case Libs.Mono.Cecil.Cil.Code.Stloc_1:
                // Local Store - Pops the value on the stack and stores it in local 2
                case Libs.Mono.Cecil.Cil.Code.Stloc_2:
                // Local Store - Pops the value on the stack and stores it in local 3
                case Libs.Mono.Cecil.Cil.Code.Stloc_3:
                // Local Store - Pops the value on the stack and stores it in local location specified by the supplied byte value onto the stack
                case Libs.Mono.Cecil.Cil.Code.Stloc_S:
                case Libs.Mono.Cecil.Cil.Code.Shl:
                case Libs.Mono.Cecil.Cil.Code.Shr:
                case Libs.Mono.Cecil.Cil.Code.Shr_Un:
                case Libs.Mono.Cecil.Cil.Code.Sub:
                case Libs.Mono.Cecil.Cil.Code.Sub_Ovf:
                case Libs.Mono.Cecil.Cil.Code.Sub_Ovf_Un:
                case Libs.Mono.Cecil.Cil.Code.Switch:
                case Libs.Mono.Cecil.Cil.Code.Tail:
                case Libs.Mono.Cecil.Cil.Code.Throw:
                case Libs.Mono.Cecil.Cil.Code.Unaligned:
                case Libs.Mono.Cecil.Cil.Code.Volatile:
                case Libs.Mono.Cecil.Cil.Code.Xor:
                {
                    break;
                }

                default:
                {
                    SemanticTypeDefinitionMask_I ensuredType = null;

                    TypeReference typeReferenceToLookup = null;

                    if (instructionDefinition.Operand is TypeReference typeReference)
                    {
                        //ensuredType = Types.Scanning.EnsureType(conversion, typeReference);
                    }
                    else if (instructionDefinition.Operand is FieldReference fieldReference)
                    {
                        //ensuredType = Types.Scanning.EnsureType(conversion, fieldReference.DeclaringType);
                    }
                    else if (instructionDefinition.Operand is MethodReference methodReference)
                    {
                        //if (methodReference is Mono.Cecil.GenericInstanceMethod genericMethodReference)
                        //{
                        // for (int j = 0; j < genericMethodReference.GenericArguments.Count; j++)
                        // {
                        //  var genericArgument = genericMethodReference.GenericArguments[j];

                        //  Types.Scanning.EnsureType(conversion, genericArgument);
                        // }
                        //}

                        //var resolvedMethodReference = Cecil.Metadata.Members.Methods.ResolveSignatureReferenceToFullReference(conversion.Model, converted.SourceTypeReference, callingMethodDefinition, methodReference);

                        //typeReferenceToLookup = resolvedMethodReference.DeclaringType;
                    }
                    else if (instructionDefinition.Operand is MemberReference memberReference)
                    {
                        //ensuredType = Types.Scanning.EnsureType(conversion, memberReference.DeclaringType);
                    }
                    else
                    {
                        throw new Exception("Instruction type scanning not handled.");
                    }

                    if (typeReferenceToLookup != null)
                    {
                        if (typeReferenceToLookup.IsGenericInstance && converted.SourceTypeReference.IsGenericInstance)
                        {
                            if (typeReferenceToLookup.FullName == "System.Collections.Generic.List`1<TOutput>")
                            {
                            }

                            var genericTypeReferenceToLookup = (GenericInstanceType)typeReferenceToLookup;

                            var genericConverted = (GenericInstanceType)converted.SourceTypeReference;

                            if (Cecil.Types.AreSame(genericTypeReferenceToLookup.ElementType, genericConverted.ElementType))
                            {
                                break;
                            }
                        }



                        ensuredType = Types.Scanning.EnsureType(conversion, typeReferenceToLookup);

                        if (ensuredType != null &&
                            ensuredType is ConvertedTypeDefinition_I convertedInstructionReference
                            // do not add if the instruction type is itself
                            && !ReferenceEquals(convertedInstructionReference, converted)
                            // do not add if the instruction type's blueprint is itself
                            && !(convertedInstructionReference is ConvertedGenericTypeDefinition_I genericInstructionType &&
                                 ReferenceEquals(converted, genericInstructionType.Blueprint)) &&
                            convertedInstructionReference.ConversionState.BuildPhase != Code.Models.E01D.Runtimic.Execution.Conversion.Metadata.Members.Types.BuildPhaseKind.TypeCreated)
                        {
                            AddDependentOrDependency(convertedInstructionReference.ConversionState.Phase3Dependents, converted);

                            AddDependentOrDependency(converted.ConversionState.Phase3Dependencies, convertedInstructionReference);
                        }
                    }



                    break;
                }
                }
            }
        }
Exemplo n.º 30
0
 private void EnsureBaseTypeIsReadyForBaking(ILConversion conversion, ConvertedTypeDefinition_I input)
 {
 }