예제 #1
0
        internal MonoType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
            base(GetPrimitiveType(type, arguments))
        {
            string uniqueName = GetUniqueName(type);

            manager.AssemblyManager.AddScriptType(uniqueName, this);
            ComplexType = CreateComplexType(manager, type, arguments);
        }
예제 #2
0
        private static SerializableType GetBaseType(MonoManager manager, MonoTypeContext context)
        {
            MonoTypeContext baseContext     = context.GetBase();
            MonoTypeContext resolvedContext = baseContext.Resolve();
            TypeDefinition  baseDefinition  = resolvedContext.Type.Resolve();

            if (IsObject(baseDefinition))
            {
                return(null);
            }
            return(manager.GetSerializableType(resolvedContext));
        }
예제 #3
0
        private static IEnumerable <IScriptField> CreateFields(MonoManager manager, TypeDefinition type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            List <IScriptField> fields = new List <IScriptField>();

            foreach (FieldDefinition field in type.Fields)
            {
                if (!MonoField.IsSerializable(field, arguments))
                {
                    continue;
                }

                MonoField monoField = new MonoField(manager, field, arguments);
                fields.Add(monoField);
            }
            return(fields);
        }
예제 #4
0
        internal MonoType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
            base(type.Namespace, ToPrimitiveType(type), type.Name, GetBaseType(manager, type, arguments))
        {
            if (type.IsGenericParameter)
            {
                throw new ArgumentException(nameof(type));
            }
            if (MonoField.IsSerializableArray(type))
            {
                throw new ArgumentException(nameof(type));
            }

            string uniqueName = GetUniqueName(type);

            manager.AssemblyManager.AddSerializableType(uniqueName, this);
            Fields = CreateFields(manager, type, arguments);
        }
예제 #5
0
        private static Field[] CreateFields(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            TypeDefinition definition = type.Resolve();
            List <Field>   fields     = new List <Field>();

            foreach (FieldDefinition field in definition.Fields)
            {
                if (MonoField.IsSerializable(field, arguments))
                {
                    TypeReference    fieldType  = GetSerializedElementType(field.FieldType, arguments);
                    SerializableType scriptType = manager.GetSerializableType(fieldType, arguments);
                    bool             isArray    = IsSerializableArray(field.FieldType, arguments);
                    Field            fieldStruc = new Field(scriptType, isArray, field.Name);
                    fields.Add(fieldStruc);
                }
            }
            return(fields.ToArray());
        }
예제 #6
0
        internal MonoType(MonoManager manager, MonoTypeContext context) :
            base(context.Type.Namespace, ToPrimitiveType(context.Type), MonoUtils.GetName(context.Type))
        {
            if (context.Type.ContainsGenericParameter)
            {
                throw new ArgumentException(nameof(context));
            }
            if (MonoField.IsSerializableArray(context.Type))
            {
                throw new ArgumentException(nameof(context));
            }

            string uniqueName = GetUniqueName(context.Type);

            manager.AssemblyManager.AddSerializableType(uniqueName, this);
            Base   = GetBaseType(manager, context);
            Fields = CreateFields(manager, context);
        }
예제 #7
0
        private static Field[] CreateFields(MonoManager manager, MonoTypeContext context)
        {
            List <Field>   fields     = new List <Field>();
            TypeDefinition definition = context.Type.Resolve();
            IReadOnlyDictionary <GenericParameter, TypeReference> arguments = context.GetContextArguments();

            foreach (FieldDefinition field in definition.Fields)
            {
                if (MonoField.IsSerializable(field, arguments))
                {
                    MonoTypeContext  fieldContext    = new MonoTypeContext(field.FieldType, arguments);
                    MonoTypeContext  resolvedContext = fieldContext.Resolve();
                    MonoTypeContext  serFieldContext = GetSerializedElementContext(resolvedContext);
                    SerializableType scriptType      = manager.GetSerializableType(serFieldContext);
                    bool             isArray         = MonoField.IsSerializableArray(resolvedContext.Type);
                    Field            fieldStruc      = new Field(scriptType, isArray, field.Name);
                    fields.Add(fieldStruc);
                }
            }
            return(fields.ToArray());
        }
예제 #8
0
        private static IScriptStructure CreateComplexType(MonoManager manager, TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            if (IsEngineStruct(type))
            {
                return(ScriptStructure.EngineTypeToScriptStructure(type.Name));
            }

            PrimitiveType primType = ToPrimitiveType(type);

            if (primType != PrimitiveType.Complex)
            {
                return(null);
            }

            if (IsEnginePointer(type))
            {
                return(new ScriptPointer(type));
            }
            else
            {
                return(new MonoStructure(manager, type.Resolve(), arguments));
            }
        }
예제 #9
0
 internal MonoField(MonoManager manager, FieldDefinition field, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
     base(manager.GetSerializableType(GetSerializedElementType(field.FieldType, arguments), arguments),
          IsSerializableArray(field.FieldType, arguments), field.Name)
 {
 }
예제 #10
0
 internal MonoType(MonoManager manager, TypeReference type) :
     this(manager, type, s_emptyArguments)
 {
 }
예제 #11
0
 internal MonoField(MonoManager manager, FieldDefinition field, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
     base(manager.GetScriptType(field.FieldType, arguments), IsArrayType(field.FieldType), field.Name)
 {
 }
예제 #12
0
 internal MonoStructure(MonoManager manager, TypeDefinition type) :
     this(manager, type, s_emptyArguments)
 {
 }
예제 #13
0
 internal MonoStructure(MonoManager manager, TypeDefinition type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) :
     base(type.Namespace, type.Name, CreateBase(manager, type, arguments), CreateFields(manager, type, arguments))
 {
 }
예제 #14
0
 internal MonoType(MonoManager manager, TypeReference type) :
     this(manager, new MonoTypeContext(type))
 {
 }