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); }
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)); }
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); }
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); }
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()); }
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); }
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()); }
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)); } }
internal MonoField(MonoManager manager, FieldDefinition field, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) : base(manager.GetSerializableType(GetSerializedElementType(field.FieldType, arguments), arguments), IsSerializableArray(field.FieldType, arguments), field.Name) { }
internal MonoType(MonoManager manager, TypeReference type) : this(manager, type, s_emptyArguments) { }
internal MonoField(MonoManager manager, FieldDefinition field, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) : base(manager.GetScriptType(field.FieldType, arguments), IsArrayType(field.FieldType), field.Name) { }
internal MonoStructure(MonoManager manager, TypeDefinition type) : this(manager, type, s_emptyArguments) { }
internal MonoStructure(MonoManager manager, TypeDefinition type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments) : base(type.Namespace, type.Name, CreateBase(manager, type, arguments), CreateFields(manager, type, arguments)) { }
internal MonoType(MonoManager manager, TypeReference type) : this(manager, new MonoTypeContext(type)) { }