本文整理汇总了C#中Mosa.Compiler.MosaTypeSystem.TypeSystem类的典型用法代码示例。如果您正苦于以下问题:C# TypeSystem类的具体用法?C# TypeSystem怎么用?C# TypeSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeSystem类属于Mosa.Compiler.MosaTypeSystem命名空间,在下文中一共展示了TypeSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
/// <summary>
/// Compiles the specified type system.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="compilerTrace">The compiler trace.</param>
/// <param name="compilerOptions">The compiler options.</param>
/// <param name="architecture">The architecture.</param>
/// <param name="simAdapter">The sim adapter.</param>
/// <param name="linker">The linker.</param>
/// <returns></returns>
public static SimCompiler Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, CompilerTrace compilerTrace, CompilerOptions compilerOptions, BaseArchitecture architecture, ISimAdapter simAdapter, BaseLinker linker)
{
var compiler = new SimCompiler(architecture, typeSystem, typeLayout, linker, compilerOptions, compilerTrace, simAdapter);
compiler.Compile();
return compiler;
}
示例2: MosaTypeLayout
/// <summary>
/// Initializes a new instance of the <see cref="MosaTypeLayout" /> class.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="nativePointerSize">Size of the native pointer.</param>
/// <param name="nativePointerAlignment">The native pointer alignment.</param>
public MosaTypeLayout(TypeSystem typeSystem, int nativePointerSize, int nativePointerAlignment)
{
Debug.Assert(nativePointerSize == 4 || nativePointerSize == 8);
NativePointerAlignment = nativePointerAlignment;
NativePointerSize = nativePointerSize;
TypeSystem = typeSystem;
ResolveLayouts();
}
示例3: Compile
/// <summary>
/// Compiles the specified type system.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="internalTrace">The internal trace.</param>
/// <param name="enabledSSA">if set to <c>true</c> [enabled ssa].</param>
/// <param name="architecture">The architecture.</param>
/// <param name="simAdapter">The sim adapter.</param>
/// <param name="linker">The linker.</param>
/// <returns></returns>
public static SimCompiler Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, IInternalTrace internalTrace, bool enabledSSA, BaseArchitecture architecture, ISimAdapter simAdapter, ILinker linker)
{
CompilerOptions compilerOptions = new CompilerOptions();
compilerOptions.EnableSSA = enabledSSA;
compilerOptions.EnableSSAOptimizations = enabledSSA;
SimCompiler compiler = new SimCompiler(architecture, typeSystem, typeLayout, linker, compilerOptions, internalTrace, simAdapter);
compiler.Compile();
return compiler;
}
示例4: CompilationScheduler
public CompilationScheduler(TypeSystem typeSystem, bool compileAllMethods)
{
this.typeSystem = typeSystem;
this.compileAllMethods = compileAllMethods;
if (compileAllMethods)
{
// forces all types to get compiled
foreach (MosaType type in typeSystem.AllTypes)
{
CompileType(type);
}
}
}
示例5: Compile
/// <summary>
/// Compiles the specified type system.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="compilerTrace">The compiler trace.</param>
/// <param name="platform">The platform.</param>
/// <param name="enabledSSA">if set to <c>true</c> [enabled ssa].</param>
/// <param name="enableOptimizations">if set to <c>true</c> [enable ssa optimizations].</param>
/// <param name="emitBinary">if set to <c>true</c> [emit binary].</param>
public static void Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, CompilerTrace compilerTrace, string platform, CompilerOptions compilerOptions, bool emitBinary)
{
BaseArchitecture architecture;
switch (platform.ToLower())
{
case "x86": architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
case "armv6": architecture = Mosa.Platform.ARMv6.Architecture.CreateArchitecture(Mosa.Platform.ARMv6.ArchitectureFeatureFlags.AutoDetect); break;
//case "avr32": architecture = Mosa.Platform.AVR32.Architecture.CreateArchitecture(Mosa.Platform.AVR32.ArchitectureFeatureFlags.AutoDetect); break;
default:
architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
}
var compiler = new ExplorerCompiler(architecture, typeSystem, typeLayout, compilerTrace, compilerOptions, emitBinary);
compiler.Compile();
}
示例6: ExplorerCompiler
/// <summary>
/// Prevents a default instance of the <see cref="ExplorerCompiler" /> class from being created.
/// </summary>
/// <param name="architecture">The compiler target architecture.</param>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="compilerTrace">The internal trace.</param>
/// <param name="compilerOptions">The compiler options.</param>
public ExplorerCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, CompilerTrace compilerTrace, CompilerOptions compilerOptions, bool emitBinary)
: base(architecture, typeSystem, typeLayout, new CompilationScheduler(typeSystem, true), compilerTrace, new ExplorerLinker(), compilerOptions)
{
this.emitBinary = emitBinary;
// Build the assembly compiler pipeline
Pipeline.Add(new ICompilerStage[] {
new PlugStage(),
new MethodCompilerSchedulerStage(),
new TypeInitializerSchedulerStage(),
new MethodLookupTableStage(),
new MethodExceptionLookupTableStage(),
new MetadataStage(),
});
architecture.ExtendCompilerPipeline(Pipeline);
}
示例7: SimCompiler
/// <summary>
/// Prevents a default instance of the <see cref="SimCompiler" /> class from being created.
/// </summary>
/// <param name="architecture">The compiler target architecture.</param>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="linker">The linker.</param>
/// <param name="compilerOptions">The compiler options.</param>
/// <param name="internalTrace">The internal trace.</param>
/// <param name="simAdapter">The sim adapter.</param>
public SimCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, ILinker linker, CompilerOptions compilerOptions, IInternalTrace internalTrace, ISimAdapter simAdapter)
: base(architecture, typeSystem, typeLayout, new CompilationScheduler(typeSystem, true), internalTrace, linker, compilerOptions)
{
this.simAdapter = simAdapter;
// Build the assembly compiler pipeline
Pipeline.Add(new ICompilerStage[] {
new PlugStage(),
new MethodCompilerSchedulerStage(),
new TypeInitializerSchedulerStage(),
new SimPowerUpStage(),
new TypeLayoutStage(),
new MetadataStage(),
new LinkerFinalizationStage(),
});
architecture.ExtendCompilerPipeline(Pipeline);
}
示例8: BaseCompiler
/// <summary>
/// Initializes a new compiler instance.
/// </summary>
/// <param name="architecture">The compiler target architecture.</param>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="compilationScheduler">The compilation scheduler.</param>
/// <param name="compilerTrace">The compiler trace.</param>
/// <param name="linker">The linker.</param>
/// <param name="compilerOptions">The compiler options.</param>
/// <exception cref="System.ArgumentNullException">@Architecture</exception>
protected BaseCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, ICompilationScheduler compilationScheduler, CompilerTrace compilerTrace, BaseLinker linker, CompilerOptions compilerOptions)
{
if (architecture == null)
throw new ArgumentNullException(@"Architecture");
Pipeline = new CompilerPipeline();
Architecture = architecture;
TypeSystem = typeSystem;
TypeLayout = typeLayout;
CompilerTrace = compilerTrace;
CompilerOptions = compilerOptions;
Counters = new Counters();
CompilationScheduler = compilationScheduler;
PlugSystem = new PlugSystem();
Linker = linker;
if (Linker == null)
{
Linker = compilerOptions.LinkerFactory();
Linker.Initialize(compilerOptions.BaseAddress, architecture.Endianness, architecture.ElfMachineType);
}
// Create new dictionary
IntrinsicTypes = new Dictionary<string, Type>();
// Get all the classes that implement the IIntrinsicInternalMethod interface
IEnumerable<Type> types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => typeof(IIntrinsicInternalMethod).IsAssignableFrom(p) && p.IsClass);
// Iterate through all the found types
foreach (var t in types)
{
// Now get all the ReplacementTarget attributes
var attributes = (ReplacementTargetAttribute[])t.GetCustomAttributes(typeof(ReplacementTargetAttribute), true);
for (int i = 0; i < attributes.Length; i++)
{
// Finally add the dictionary entry mapping the target string and the type
IntrinsicTypes.Add(attributes[i].Target, t);
}
}
PlatformInternalRuntimeType = GetPlatformInternalRuntimeType();
}
示例9: Compile
/// <summary>
/// Compiles the specified type system.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="internalTrace">The internal trace.</param>
/// <param name="platform">The platform.</param>
/// <param name="enabledSSA">if set to <c>true</c> [enabled ssa].</param>
/// <param name="emitBinary">if set to <c>true</c> [emit binary].</param>
public static void Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, IInternalTrace internalTrace, string platform, bool enabledSSA, bool emitBinary)
{
BaseArchitecture architecture;
switch (platform.ToLower())
{
case "x86": architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
case "armv6": architecture = Mosa.Platform.ARMv6.Architecture.CreateArchitecture(Mosa.Platform.ARMv6.ArchitectureFeatureFlags.AutoDetect); break;
//case "avr32": architecture = Mosa.Platform.AVR32.Architecture.CreateArchitecture(Mosa.Platform.AVR32.ArchitectureFeatureFlags.AutoDetect); break;
default:
architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
}
CompilerOptions compilerOptions = new CompilerOptions();
compilerOptions.EnableSSA = enabledSSA;
compilerOptions.EnableSSAOptimizations = enabledSSA && enabledSSA;
ExplorerCompiler compiler = new ExplorerCompiler(architecture, typeSystem, typeLayout, internalTrace, compilerOptions, emitBinary);
compiler.Compile();
}
示例10: BaseCompiler
/// <summary>
/// Initializes a new compiler instance.
/// </summary>
/// <param name="architecture">The compiler target architecture.</param>
/// <param name="typeSystem">The type system.</param>
/// <param name="typeLayout">The type layout.</param>
/// <param name="compilationScheduler">The compilation scheduler.</param>
/// <param name="internalTrace">The internal trace.</param>
/// <param name="compilerOptions">The compiler options.</param>
protected BaseCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, ICompilationScheduler compilationScheduler, IInternalTrace internalTrace, ILinker linker, CompilerOptions compilerOptions)
{
if (architecture == null)
throw new ArgumentNullException(@"Architecture");
Pipeline = new CompilerPipeline();
Architecture = architecture;
TypeSystem = typeSystem;
TypeLayout = typeLayout;
InternalTrace = internalTrace;
CompilerOptions = compilerOptions;
Counters = new Counters();
CompilationScheduler = compilationScheduler;
PlugSystem = new PlugSystem();
Linker = linker;
if (Linker == null)
{
Linker = compilerOptions.LinkerFactory();
Linker.Initialize(compilerOptions.OutputFile, architecture.Endianness, architecture.ElfMachineType);
}
}
示例11: GetNull
/// <summary>
/// Gets the null constant <see cref="Operand"/>.
/// </summary>
/// <returns></returns>
public static Operand GetNull(TypeSystem typeSystem)
{
var operand = new Operand(typeSystem.BuiltIn.Object);
operand.IsNull = true;
operand.IsConstant = true;
return operand;
}
示例12: CreateSymbolFromMethod
/// <summary>
/// Creates a new symbol <see cref="Operand" /> for the given symbol name.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="method">The method.</param>
/// <returns></returns>
public static Operand CreateSymbolFromMethod(TypeSystem typeSystem, MosaMethod method)
{
var operand = CreateUnmanagedSymbolPointer(typeSystem, method.FullName);
operand.Method = method;
return operand;
}
示例13: CreateUnmanagedSymbolPointer
/// <summary>
/// Creates the symbol.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="name">The name.</param>
/// <returns></returns>
public static Operand CreateUnmanagedSymbolPointer(TypeSystem typeSystem, string name)
{
var operand = new Operand(typeSystem.BuiltIn.Pointer);
operand.IsSymbol = true;
operand.Name = name;
return operand;
}
示例14: Initialize
public void Initialize(MosaCompiler compiler)
{
if (compiler == null)
throw new ArgumentNullException(@"compiler");
Compiler = compiler;
Architecture = Compiler.CompilerOptions.Architecture;
TypeSystem = Compiler.TypeSystem;
TypeLayout = Compiler.TypeLayout;
CompilerTrace = Compiler.CompilerTrace;
CompilerOptions = Compiler.CompilerOptions;
CompilationScheduler = Compiler.CompilationScheduler;
Linker = compiler.Linker;
PreCompilePipeline = new CompilerPipeline();
PostCompilePipeline = new CompilerPipeline();
GlobalCounters = new Counters();
PlugSystem = new PlugSystem();
CompilerData = new CompilerData();
// Create new dictionary
IntrinsicTypes = new Dictionary<string, Type>();
foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
{
if (type.IsClass && typeof(IIntrinsicInternalMethod).IsAssignableFrom(type))
{
// Now get all the ReplacementTarget attributes
var attributes = (ReplacementTargetAttribute[])type.GetCustomAttributes(typeof(ReplacementTargetAttribute), true);
for (int i = 0; i < attributes.Length; i++)
{
// Finally add the dictionary entry mapping the target string and the type
IntrinsicTypes.Add(attributes[i].Target, type);
}
}
}
PlatformInternalRuntimeType = GetPlatformInternalRuntimeType();
InternalRuntimeType = GeInternalRuntimeType();
// Extended Setup
ExtendCompilerSetup();
// Build the default pre-compiler pipeline
Architecture.ExtendPreCompilerPipeline(PreCompilePipeline);
// Build the default post-compiler pipeline
Architecture.ExtendPostCompilerPipeline(PostCompilePipeline);
}
示例15: CreateStringSymbol
/// <summary>
/// Creates the string symbol with data.
/// </summary>
/// <param name="typeSystem">The type system.</param>
/// <param name="name">The name.</param>
/// <param name="data">The string data.</param>
/// <returns></returns>
public static Operand CreateStringSymbol(TypeSystem typeSystem, string name, string data)
{
Debug.Assert(data != null);
var operand = new Operand(typeSystem.BuiltIn.String);
operand.IsSymbol = true;
operand.Name = name;
operand.StringData = data;
return operand;
}