/// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        void IAssemblyCompilerStage.Run()
        {
            if (!secondStage)
            {
                IntPtr entryPoint = WriteMultibootEntryPoint();
                WriteMultibootHeader(entryPoint);
                secondStage = true;
            }
            else
            {
                ITypeInitializerSchedulerStage typeInitializerSchedulerStage = this.compiler.Pipeline.FindFirst <ITypeInitializerSchedulerStage>();

                SigType         I4  = new SigType(CilElementType.I4);
                RegisterOperand ecx = new RegisterOperand(I4, GeneralPurposeRegister.ECX);
                RegisterOperand eax = new RegisterOperand(I4, GeneralPurposeRegister.EAX);
                RegisterOperand ebx = new RegisterOperand(I4, GeneralPurposeRegister.EBX);

                InstructionSet instructionSet = new InstructionSet(16);
                Context        ctx            = new Context(instructionSet, -1);

                ctx.AppendInstruction(CPUx86.Instruction.MovInstruction, ecx, new ConstantOperand(I4, 0x200000));
                ctx.AppendInstruction(CPUx86.Instruction.MovInstruction, new MemoryOperand(I4, ecx.Register, new IntPtr(0x0)), eax);
                ctx.AppendInstruction(CPUx86.Instruction.MovInstruction, new MemoryOperand(I4, ecx.Register, new IntPtr(0x4)), ebx);

                SymbolOperand entryPoint = SymbolOperand.FromMethod(typeInitializerSchedulerStage.Method);

                ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, null, entryPoint);
                ctx.AppendInstruction(CPUx86.Instruction.RetInstruction);

                LinkerGeneratedMethod method = LinkTimeCodeGenerator.Compile(this.compiler, @"MultibootInit", instructionSet, typeSystem);
                this.linker.EntryPoint = this.linker.GetSymbol(method.ToString());
            }
        }
        void IAssemblyCompilerStage.Setup(AssemblyCompiler compiler)
        {
            base.Setup(compiler);

            typeInitializerSchedulerStage = compiler.Pipeline.FindFirst<ITypeInitializerSchedulerStage>();

            if (typeInitializerSchedulerStage == null)
                throw new InvalidOperationException(@"AssemblyCompilationStage needs a ITypeInitializerSchedulerStage.");

            linker = RetrieveAssemblyLinkerFromCompiler();
        }
 public AotAssemblyCompiler(IArchitecture architecture, IMetadataModule assembly, ITypeInitializerSchedulerStage typeInitializerSchedulerStage, IAssemblyLinker linker)
     : base(architecture, assembly)
 {
     this.Pipeline.AddRange(
             new IAssemblyCompilerStage[]
             {
                 new TypeLayoutStage(),
                 new AssemblyMemberCompilationSchedulerStage(),
                 new MethodCompilerSchedulerStage(),
                 new TypeInitializerSchedulerStageProxy(typeInitializerSchedulerStage),
                 new LinkerProxy(linker)
             });
 }
        void IAssemblyCompilerStage.Setup(AssemblyCompiler compiler)
        {
            base.Setup(compiler);

            typeInitializerSchedulerStage = compiler.Pipeline.FindFirst <ITypeInitializerSchedulerStage>();

            if (typeInitializerSchedulerStage == null)
            {
                throw new InvalidOperationException(@"AssemblyCompilationStage needs a ITypeInitializerSchedulerStage.");
            }

            linker = RetrieveAssemblyLinkerFromCompiler();
        }
Пример #5
0
 public AotAssemblyCompiler(IArchitecture architecture, ITypeInitializerSchedulerStage typeInitializerSchedulerStage, IAssemblyLinker linker, ITypeSystem typeSystem, ITypeLayout typeLayout)
     : base(architecture, typeSystem, typeLayout)
 {
     this.Pipeline.AddRange(
         new IAssemblyCompilerStage[]
     {
         new AssemblyMemberCompilationSchedulerStage(),
         new MethodCompilerSchedulerStage(),
         new TypeInitializerSchedulerStageProxy(typeInitializerSchedulerStage),
         new TypeLayoutStage(),
         new LinkerProxy(linker)
     });
 }
 public void Setup(AssemblyCompiler compiler)
 {
     this.outputAssemblyCompiler = compiler;
     this.typeInitializerSchedulerStage = compiler.Pipeline.FindFirst<ITypeInitializerSchedulerStage>();
     this.linker = compiler.Pipeline.FindFirst<IAssemblyLinker>();
 }
 public TypeInitializerSchedulerStageProxy(ITypeInitializerSchedulerStage realStage)
 {
     this.realStage = realStage;
 }
 public TypeInitializerSchedulerStageProxy(ITypeInitializerSchedulerStage realStage)
 {
     this.realStage = realStage;
 }