public MosaType GetTypeByName(MosaModule module, string @namespace, string name) { if (typeLookup.TryGetValue(Tuple.Create(module, @namespace, name), out MosaType result)) { return(result); } return(null); }
public BuiltInTypes(TypeSystem typeSystem, MosaModule corlib) { Void = typeSystem.GetTypeByName(corlib, "System", "Void"); Boolean = typeSystem.GetTypeByName(corlib, "System", "Boolean"); Char = typeSystem.GetTypeByName(corlib, "System", "Char"); I1 = typeSystem.GetTypeByName(corlib, "System", "SByte"); U1 = typeSystem.GetTypeByName(corlib, "System", "Byte"); I2 = typeSystem.GetTypeByName(corlib, "System", "Int16"); U2 = typeSystem.GetTypeByName(corlib, "System", "UInt16"); I4 = typeSystem.GetTypeByName(corlib, "System", "Int32"); U4 = typeSystem.GetTypeByName(corlib, "System", "UInt32"); I8 = typeSystem.GetTypeByName(corlib, "System", "Int64"); U8 = typeSystem.GetTypeByName(corlib, "System", "UInt64"); R4 = typeSystem.GetTypeByName(corlib, "System", "Single"); R8 = typeSystem.GetTypeByName(corlib, "System", "Double"); String = typeSystem.GetTypeByName(corlib, "System", "String"); Object = typeSystem.GetTypeByName(corlib, "System", "Object"); I = typeSystem.GetTypeByName(corlib, "System", "IntPtr"); U = typeSystem.GetTypeByName(corlib, "System", "UIntPtr"); TypedRef = typeSystem.GetTypeByName(corlib, "System", "TypedReference"); Pointer = Void.ToUnmanagedPointer(); }
private LinkerSymbol CreateAssemblyDefinition(MosaModule module) { // Emit assembly name var assemblyNameSymbol = EmitStringWithLength(module.Assembly + Metadata.NameString, module.Assembly); // Emit assembly table var assemblyTableSymbol = Linker.CreateSymbol(module.Assembly + Metadata.AssemblyDefinition, SectionKind.ROData, TypeLayout.NativePointerAlignment, 0); var writer1 = new EndianAwareBinaryWriter(assemblyTableSymbol.Stream, Architecture.Endianness); // 1. Pointer to Assembly Name Linker.Link(LinkType.AbsoluteAddress, NativePatchType, assemblyTableSymbol, (int)writer1.Position, 0, assemblyNameSymbol, 0); writer1.WriteZeroBytes(TypeLayout.NativePointerSize); // 2. Pointer to Custom Attributes if (module.CustomAttributes.Count > 0) { var customAttributeListSymbol = CreateCustomAttributesTable(module); Linker.Link(LinkType.AbsoluteAddress, NativePatchType, assemblyTableSymbol, (int)writer1.Position, 0, customAttributeListSymbol, 0); } writer1.WriteZeroBytes(TypeLayout.NativePointerSize); // 3. Attributes - IsReflectionOnly (32bit length) uint flags = 0x0; if (module.IsReflectionOnly) flags |= 0x1; writer1.Write(flags, TypeLayout.NativePointerSize); // 4. Number of Types uint count = 0; foreach (var type in module.Types.Values) { if (type.IsModule) continue; count++; } writer1.Write(count, TypeLayout.NativePointerSize); // 5. Pointers to Types // Create the definitions along the way foreach (var type in module.Types.Values) { if (type.IsModule) continue; // Run the type through the TypeLayout system //TypeLayout.ResolveType(type); var typeTableSymbol = CreateTypeDefinition(type, assemblyTableSymbol); // Link Linker.Link(LinkType.AbsoluteAddress, NativePatchType, assemblyTableSymbol, (int)writer1.Position, 0, typeTableSymbol, 0); writer1.WriteZeroBytes(TypeLayout.NativePointerSize); } // Return assemblyTableSymbol return assemblyTableSymbol; }
public void SetCorLib(MosaModule module) { typeSystem.CorLib = module; }
public void AddModule(MosaModule module) { typeSystem.Modules.Add(module); }
public MosaModule.Mutator MutateModule(MosaModule module) { return(new MosaModule.Mutator(module)); }
public string LookupUserString(MosaModule module, uint token) { return(metadata.LookupUserString(module, token)); }
public MosaModule.Mutator MutateModule(MosaModule module) { return new MosaModule.Mutator(module); }
public string LookupUserString(MosaModule module, uint token) { return metadata.LookupUserString(module, token); }
public MosaType GetTypeByName(MosaModule module, string @namespace, string name) { MosaType result; if (typeLookup.TryGetValue(Tuple.Create(module, @namespace, name), out result)) return result; return null; }
internal Mutator(MosaModule module) : base(module) { this.module = module; }