Exemplo n.º 1
0
        public void Update(RuntimicSystemModel semanticModel, SemanticTypeDefinitionMask_I semanticType)
        {
            if (semanticType == null || semanticType.Module == null || semanticType.Module.Assembly == null)
            {
                throw new System.ArgumentNullException();
            }

            var resolutionName = Execution.Conversion.Metadata.Members.Types.Naming.GetResolutionName(semanticType);

            //var resolutionName2 = resolutionName.Replace("+", "/");

            var node = Get(semanticModel, resolutionName);

            //var node2 = Get(semanticModel, resolutionName2);

            if (node == null)
            {
                throw new Exception("Expected an existing node.");
            }

            //if (node.SemanticType != null)
            //{
            //	throw new Exception("More than one add called.");
            //}

            //node.SemanticType = semanticType;

            throw new System.NotImplementedException();
        }
Exemplo n.º 2
0
        public System.Type EnsureToType(ILConversion conversion, SemanticTypeDefinitionMask_I semanticType)
        {
            if (!(semanticType is BoundTypeDefinitionMask_I bound))
            {
                throw new Exception("A semantic type must be a bound type to be resolved to a runtime type.");
            }

            return(EnsureToType(conversion, bound));
        }
Exemplo n.º 3
0
        private bool IfAlreadyCreatedReturn(SemanticTypeDefinitionMask_I elementType, int rank, out SemanticArrayTypeDefinitionMask_I existing)
        {
            if (elementType.Arrays.TryGetValue(rank, out existing))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public System.Type EnsureToType(SemanticTypeDefinitionMask_I semanticType, out BoundTypeDefinitionMask_I resultingBound)
        {
            // Can only build and bake types that are definitions.  References cannot be turned into full types.
            if (!(semanticType is BoundTypeDefinitionMask_I bound))
            {
                throw new Exception("A semantic type must be a bound type to be resolved to a runtime type.");
            }

            resultingBound = bound;

            return(EnsureToType(bound));
        }
Exemplo n.º 5
0
        public SemanticFieldMask_I Get(InfrastructureRuntimicModelMask_I model, SemanticTypeDefinitionMask_I declaringType, string fieldName)
        {
            if (!(declaringType is SemanticTypeDefinitionWithFieldsMask_I typeWithFields))
            {
                throw new Exception("Trying to build a field on a type that does not support fields.");
            }

            if (typeWithFields.Fields.ByName.TryGetValue(fieldName, out SemanticFieldMask_I field))
            {
                return(field);
            }

            return(null);
        }
Exemplo n.º 6
0
        public void Add(BoundRuntimicModelMask_I model, SemanticTypeDefinitionMask_I semantic, int arrayTypeRank)
        {
            throw new System.Exception("Debug");
            //var resolutionName = Cecil.Types.Naming.GetResolutionName(semantic.SourceTypeReference);

            //if (!model.Unified.Arrays.TryGetValue(resolutionName, out UnifiedArrayInstanceNodeSet set))
            //{
            //	set = new UnifiedArrayInstanceNodeSet();

            //	model.Unified.Arrays.Add(resolutionName, set);
            //}

            //         set.Instances.Add(new UnifiedArrayInstanceNode()
            //         {
            //          ElementResolutionName = resolutionName,
            //             Rank = arrayTypeRank,
            //	SemanticType = semantic
            //         });
        }
Exemplo n.º 7
0
        public BoundTypeDefinitionMask_I Resolve(RuntimicSystemModel model, SemanticTypeDefinitionMask_I declaringType, GenericParameter parameter)
        {
            if (!declaringType.IsGeneric())
            {
                throw new Exception("Expected the resolved semantic type to be a generic type.");
            }

            SemanticGenericTypeDefinitionMask_I generic = (SemanticGenericTypeDefinitionMask_I)declaringType;

            if (!generic.TypeParameters.ByName.TryGetValue(parameter.Name, out SemanticGenericParameterTypeDefinitionMask_I semanticTypeParameter))
            {
                throw new Exception($"Expected the generic type to have a type parameter named {parameter.Name}.");
            }

            if (!semanticTypeParameter.IsBound())
            {
                throw new Exception("Expected the generic parameter type to be a bound type.");
            }

            return((BoundTypeDefinitionMask_I)semanticTypeParameter);
        }
Exemplo n.º 8
0
        public void ExtendWithCrossReference(RuntimicSystemModel model, SemanticTypeDefinitionMask_I semanticType, string assemblyQualifiedNameCrossReferenceKey)
        {
            var resolutionName = Execution.Conversion.Metadata.Members.Types.Naming.GetResolutionName(semanticType);

            var orginalNode = Get(model, resolutionName);

            if (orginalNode == null)
            {
                throw new Exception("Could not find orginal node.  Could not add cross reference.");
            }

            //var entry = new UnifiedTypeNode()
            //{
            //	ResolutionName = assemblyQualifiedNameCrossReferenceKey,
            //	SourceTypeReference = semanticType.SourceTypeReference,
            //	AssemblyNode = orginalNode.AssemblyNode,
            //	ModuleNode = orginalNode.ModuleNode,
            //	SemanticType = semanticType,
            //};

            //Add(model, entry);
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="input"></param>
        /// <param name="semanticType"></param>
        /// <returns></returns>
        /// <remarks>Used when ensuring a bound type and it needs to get the semanticType from the type reference as soon as it resolves the type to the type reference.</remarks>
        public TypeReference GetTypeReference(RuntimicSystemModel model, Type input, out SemanticTypeDefinitionMask_I semanticType)
        {
            throw new System.Exception("Debug");
            //      string resolutionName = Binding.Metadata.Members.Types.Naming.GetResolutionName(input);

            //         TypeReference typeDefinition = Cecil.Types.Getting.GetStoredTypeReference(model, resolutionName, out UnifiedTypeNode basicNode);

            //      semanticType = basicNode?.SemanticType;

            //if (typeDefinition != null) return typeDefinition;

            //         if (!input.IsGenericType)
            //         {
            //             throw new Exception($"Type definition for {input.AssemblyQualifiedName} is not loaded.");
            //         }

            //         var genericArguments = input.GenericTypeArguments;

            //         if (genericArguments.Length < 1)
            //         {
            //             throw new Exception($"Type definition for {input.AssemblyQualifiedName} is not loaded.");
            //         }

            //         var genericTypeDefinition = input.GetGenericTypeDefinition();

            //         var genericTypeDefinition1 = GetTypeReference(model, genericTypeDefinition);

            //         var genericArgumentReferences = new TypeReference[genericArguments.Length];

            //         for (int i = 0; i < genericArguments.Length; i++)
            //         {
            //             genericArgumentReferences[i] = GetTypeReference(model, genericArguments[i]);
            //         }

            //         var result = genericTypeDefinition1.MakeGenericInstanceType(genericArgumentReferences);

            //         return result;
        }
Exemplo n.º 10
0
        public void Ensure(RuntimicSystemModel semanticModel, SemanticTypeDefinitionMask_I semanticType)
        {
            throw new System.Exception("Debug");

            //         if (semanticType == null)
            //         {
            //             throw new Exception("Cannot add a semantic type that is null");
            //         }

            //string resolutionName = Types.Naming.GetResolutionName(semanticType);

            //         if (semanticType.Module.Assembly == null)
            //         {
            //             throw new Exception("Every semantic module should have a semantic assembly assigned to it.");
            //         }

            //         var entry = Unified.Types.Get(semanticModel, resolutionName);

            //         if (entry?.SemanticType == null)
            //         {
            //	Unified.Types.Update(semanticModel, semanticType);
            //         }
        }
Exemplo n.º 11
0
        public BoundTypeDefinitionMask_I Resolve(RuntimicSystemModel model, SemanticTypeDefinitionMask_I declaringType,
                                                 MethodDefinition methodDefinition, GenericParameter parameter)
        {
            if (!(declaringType is BoundTypeDefinitionWithMethodsMask_I boundTypeWithMethods))
            {
                throw new Exception("Trying to add a method to a type that does not support methods.");
            }

            var method = Methods.FindMethodByDefinition(model, boundTypeWithMethods, methodDefinition);

            if (!method.TypeParameters.ByName.TryGetValue(parameter.Name, out SemanticGenericParameterTypeDefinitionMask_I semanticTypeParameter))
            {
                throw new Exception(
                          $"Expected the generic method to have a type parameter named {parameter.Name}.");
            }

            if (!semanticTypeParameter.IsBound())
            {
                throw new Exception("Expected the generic parameter type to be a bound type.");
            }

            return((BoundTypeDefinitionMask_I)semanticTypeParameter);
        }
Exemplo n.º 12
0
        public FieldInfo GetFieldInfo(InfrastructureRuntimicModelMask_I model, SemanticTypeDefinitionMask_I declaringType, string fieldName)
        {
            // 1) First check the current type for the field.
            var result = Get(model, declaringType, fieldName);

            // 2.a) If not found, and is generic...
            if (result == null && declaringType is BoundGenericTypeDefinitionMask_I bound)
            {
                // 2.b) Check the blueprint for the field as it might take generic parameters.
                result = Get(model, bound.Blueprint, fieldName);
            }

            if (result == null)
            {
                return(null);
            }

            if (!(result is BoundFieldDefinitionMask_I field))
            {
                throw new Exception("Cannot get a field info from a field hat is not convertible to a BoundFieldMask_I.");
            }

            return(field.UnderlyingField);
        }
Exemplo n.º 13
0
        public SemanticTypeMask_I Add(RuntimicSystemModel semanticModel, SemanticModuleMask_I module, SemanticTypeDefinitionMask_I entry)
        {
            Add(module.Types.ByResolutionName, entry);

            Models.Types.Collection.Add(semanticModel, entry);

            if (entry.IsDefinition() && entry is SemanticTypeDefinitionMask_I definitionMask)
            {
                Add(module.Types.DefinitionsByName, definitionMask);

                //Models.Types.Ensure(semanticModel, definitionMask);
            }

            if (entry.IsReference() && entry is TypeReferenceMask_I referenceMask)
            {
                Add(module.Types.ReferencesByName, referenceMask);
            }



            return(entry);
        }
Exemplo n.º 14
0
 public System.Type EnsureToType(SemanticTypeDefinitionMask_I semanticType)
 {
     return(EnsureToType(semanticType, out BoundTypeDefinitionMask_I resultingBound));
 }
Exemplo n.º 15
0
        public bool TryGet(RuntimicSystemModel model, string resolutionName, out SemanticTypeDefinitionMask_I typeEntry)
        {
            typeEntry = Get(model, resolutionName);

            return(typeEntry != null);
        }
Exemplo n.º 16
0
        public bool TryGet(RuntimicSystemModel model, TypeReference input, out SemanticTypeDefinitionMask_I typeEntry)
        {
            string resolutionName = Types.Naming.GetResolutionName(input);

            return(TryGet(model, resolutionName, out typeEntry));
        }
Exemplo n.º 17
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.º 18
0
 public void Add(RuntimicSystemModel semanticModel, SemanticTypeDefinitionMask_I semanticType)
 {
     Unified.Types.Update(semanticModel, semanticType);
 }
Exemplo n.º 19
0
 public TypeReference GetTypeReference(RuntimicSystemModel model, Type input, out SemanticTypeDefinitionMask_I possibleSemanticType)
 {
     return(Infrastructure.Models.Semantic.Types.GetTypeReference(model, input, out possibleSemanticType));
 }
Exemplo n.º 20
0
 public TypeReference GetTypeReference(ILConversion conversion, Type input, out SemanticTypeDefinitionMask_I possibleSemanticType)
 {
     return(Bound.Models.Types.GetTypeReference(conversion.RuntimicSystem, input, out possibleSemanticType));
 }
Exemplo n.º 21
0
        public SemanticTypeDefinitionMask_I Ensure(ILConversion conversion, GenericInstanceType input, SemanticTypeDefinitionMask_I declaringType)
        {
            var typeArguments = Bound.Metadata.Members.TypeArguments.Building.Build(conversion.RuntimicSystem, input);

            var blueprint = (BoundGenericTypeDefinitionMask_I)Execution.Types.Ensuring.EnsureBound(conversion, input.ElementType, null);

            if (IfAlreadyCreatedReturn(blueprint, typeArguments, out SemanticTypeDefinitionMask_I ensure))
            {
                return(ensure);
            }

            var typeArgumentTypes = GetTypes(typeArguments, out bool hasGenericParameters);

            var underlyingType = Bound.MakeGenericType(blueprint, typeArgumentTypes);

            var converted = (ConvertedGenericTypeDefinition_I)Types.Creation.Create(conversion.RuntimicSystem, input);

            converted.Blueprint = blueprint;

            blueprint.Instances.Add(converted);

            converted.UnderlyingType = underlyingType;

            for (var j = 0; j < typeArguments.Length; j++)
            {
                var currentTypeArgument = typeArguments[j];

                converted.TypeArguments.All.Add(currentTypeArgument);
            }

            Types.Building.UpdateBuildPhase(converted, BuildPhaseKind.TypeDefined);

            Types.Building.IfPossibleBuildPhase2(conversion, converted);

            return(converted);
        }
Exemplo n.º 22
0
        private bool IfAlreadyCreatedReturn(BoundGenericTypeDefinitionMask_I genericBlueprint, BoundTypeDefinitionMask_I[] typeArgumentTypes, out SemanticTypeDefinitionMask_I ensure)
        {
            for (int i = 0; i < genericBlueprint.Instances.Count; i++)
            {
                var instance = genericBlueprint.Instances[i];

                var currentInstance = (BoundGenericTypeDefinitionMask_I)instance;

                var found = true;

                for (var j = 0; j < currentInstance.TypeArguments.All.Count; j++)
                {
                    var currentTypeArgument = currentInstance.TypeArguments.All[j];

                    if (ReferenceEquals(currentTypeArgument, typeArgumentTypes[j]))
                    {
                        continue;
                    }

                    found = false;

                    break;
                }

                if (found)
                {
                    ensure = currentInstance;
                    return(true);
                }
            }
            ensure = null;
            return(false);
        }
Exemplo n.º 23
0
        public TypeDefinition GetElementType(RuntimicSystemModel semanticModel, SemanticTypeDefinitionMask_I bound)
        {
            var genericInstanceType = (GenericInstanceType)bound.SourceTypeReference;

            return(GetElementType(semanticModel, genericInstanceType));
        }
Exemplo n.º 24
0
        public SemanticTypeDefinitionMask_I Ensure(ILConversion conversion, TypeReference input, SemanticTypeDefinitionMask_I declaringType)
        {
            ArrayType arrayType = (ArrayType)input;

            var elementType = Execution.Types.Ensuring.Ensure(conversion.Model, arrayType.ElementType, null, null);

            if (IfAlreadyCreatedReturn(elementType, arrayType.Rank, out SemanticArrayTypeDefinitionMask_I existing))
            {
                return(existing);
            }

            ConvertedTypeDefinition converted = Types.Creation.Create(conversion, input);

            var arrayDef = (ConvertedArrayTypeDefinition_I)converted;

            elementType.Arrays.Add(arrayType.Rank, arrayDef);

            arrayDef.ElementType = elementType;

            converted.BaseType = (BoundTypeDefinitionMask_I)Execution.Types.Ensuring.Ensure(conversion.Model, typeof(System.Array));

            if (!(arrayDef.ElementType is BoundTypeDefinitionMask_I boundElementType))
            {
                throw new Exception("The element type is not a BoundTypeDefinitionMask_I. ");
            }

            if (arrayType.Rank == 1)
            {
                // Makes a vector
                converted.UnderlyingType = boundElementType.UnderlyingType.MakeArrayType();
            }
            else
            {
                // Makes an multi-dimensional array
                converted.UnderlyingType = boundElementType.UnderlyingType.MakeArrayType(arrayType.Rank);
            }



            Types.Building.UpdateBuildPhase(converted, BuildPhaseKind.TypeCreated);

            return(converted);
        }
Exemplo n.º 25
0
        //public TypeReference GetTypeReference(InfrastructureRuntimicModelMask_I model, Type input)
        //{
        // string resolutionName = Binding.Metadata.Members.Types.Naming.GetResolutionName(input);

        //    TypeReference typeDefinition = Collection.GetStoredTypeReference(model, resolutionName);

        //    if (typeDefinition != null) return typeDefinition;

        //    if (!input.IsGenericType)
        //    {
        //        throw new Exception($"Type definition for {input.AssemblyQualifiedName} is not loaded.");
        //    }

        //    var genericArguments = input.GenericTypeArguments;

        //    if (genericArguments.Length < 1)
        //    {
        //        throw new Exception($"Type definition for {input.AssemblyQualifiedName} is not loaded.");
        //    }

        //    var genericTypeDefinition = input.GetGenericTypeDefinition();

        //    var genericTypeDefinition1 = GetTypeReference(model, genericTypeDefinition);

        //    var genericArgumentReferences = new TypeReference[genericArguments.Length];

        //    for (int i = 0; i < genericArguments.Length; i++)
        //    {
        //        genericArgumentReferences[i] = GetTypeReference(model, genericArguments[i]);
        //    }

        //    var result = genericTypeDefinition1.MakeGenericInstanceType(genericArgumentReferences);

        //    return result;
        //}

        public Type ResolveToType(InfrastructureRuntimicModelMask_I model, SemanticTypeDefinitionMask_I semanticType)
        {
            throw new Exception("resolving a semantic type to a run time is not supported.  A semantic type is designed to be used to create runtime type.  Right now automatic" +
                                "compile support is not present.");
        }
Exemplo n.º 26
0
 public SemanticFieldMask_I Get(InfrastructureRuntimicModelMask_I model, SemanticTypeDefinitionMask_I declaringType, string fieldName)
 {
     return(Semantic.Metadata.Members.Fields.Get(model, declaringType, fieldName));
 }
Exemplo n.º 27
0
        public SemanticTypeMask_I Add(RuntimicSystemModel model, SemanticModuleMask_I module, SemanticTypeDefinitionMask_I entry)
        {
            // 1.) Add the semantic type to the module

            // 1.a)  Add by resolution name
            Add(module.Types.ByResolutionName, entry);
            // 1.b) Add by defintion name
            Add(module.Types.DefinitionsByName, entry);

            // 2) Add the semantic to type to the base class
            // nothin to do right now

            // 3) Add semantic type to model
            Infrastructure.Models.Semantic.Types.Ensure(model, entry);

            return(entry);
        }
Exemplo n.º 28
0
 public FieldInfo GetFieldInfo(ILConversion conversion, SemanticTypeDefinitionMask_I declaringType, string fieldReferenceName)
 {
     // There is nothing that is conversion specific.  Shoot the call downstream.
     return(Bound.Metadata.Members.Fields.GetFieldInfo(conversion.Model, declaringType, fieldReferenceName));
 }
Exemplo n.º 29
0
 public void AssignGenericBlueprint(ConvertedTypeDefinition createdType, SemanticTypeDefinitionMask_I genericBlueprint)
 {
 }