当前位置: 首页>>代码示例>>C#>>正文


C# CompilerFramework.Context类代码示例

本文整理汇总了C#中Mosa.Runtime.CompilerFramework.Context的典型用法代码示例。如果您正苦于以下问题:C# Context类的具体用法?C# Context怎么用?C# Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于Mosa.Runtime.CompilerFramework命名空间,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Emit

 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 /// <param name="emitter">The emitter.</param>
 protected override void Emit(Context ctx, MachineCodeEmitter emitter)
 {
     if (ctx.Operand1 is ConstantOperand)
     {
         if (IsByte(ctx.Operand1))
             emitter.Emit(CONST8, ctx.Operand1, null);
         else if (IsShort(ctx.Operand1) || IsChar(ctx.Operand1))
             emitter.Emit(CONST16, ctx.Operand1, null);
         else if (IsInt(ctx.Operand1))
             emitter.Emit(CONST32, ctx.Operand1, null);
         return;
     }
     if (ctx.Operand1 is RegisterOperand)
     {
         if ((ctx.Operand1 as RegisterOperand).Register is SegmentRegister)
             switch (((ctx.Operand1 as RegisterOperand).Register as SegmentRegister).Segment)
             {
                 case SegmentRegister.SegmentType.CS: emitter.Emit(PUSH_CS, null, null); return;
                 case SegmentRegister.SegmentType.SS: emitter.Emit(PUSH_SS, null, null); return;
                 case SegmentRegister.SegmentType.DS: emitter.Emit(PUSH_DS, null, null); return;
                 case SegmentRegister.SegmentType.ES: emitter.Emit(PUSH_ES, null, null); return;
                 case SegmentRegister.SegmentType.FS: emitter.Emit(PUSH_FS, null, null); return;
                 case SegmentRegister.SegmentType.GS: emitter.Emit(PUSH_GS, null, null); return;
                 default: throw new InvalidOperationException(@"unable to emit opcode for segment register");
             }
     }
     emitter.Emit(PUSH, ctx.Operand1, null, null);
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:33,代码来源:PushInstruction.cs

示例2: Emit

 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 /// <param name="emitter">The emitter.</param>
 protected override void Emit(Context ctx, MachineCodeEmitter emitter)
 {
     if (ctx.Result is RegisterOperand)
         emitter.WriteByte ((byte)(0x58 + (ctx.Result as RegisterOperand).Register.RegisterCode));
     else
         emitter.Emit (POP.Code, 0, ctx.Result, null);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:12,代码来源:PopInstruction.cs

示例3: HandleMemoryToMemoryOperation

        private void HandleMemoryToMemoryOperation(Context ctx, Operand register, bool useStack)
        {
            Operand destination = ctx.Result;
            Operand source = ctx.Operand1;

            Debug.Assert (destination is MemoryOperand && source is MemoryOperand);

            if (register == null)
                register = new RegisterOperand (destination.Type, GeneralPurposeRegister.EDX);

            ctx.Operand1 = register;

            Context before = ctx.InsertBefore ();

            if (useStack)
            {
                before.SetInstruction (CPUx86.Instruction.PushInstruction, null, register);
                before.AppendInstruction (CPUx86.Instruction.MovInstruction, register, source);
            }

            else
                before.SetInstruction (CPUx86.Instruction.MovInstruction, register, source);

            if (useStack)
                ctx.AppendInstruction (CPUx86.Instruction.PopInstruction, register);
        }
开发者ID:54616E6E6572,项目名称:Mosa,代码行数:26,代码来源:MemToMemConversionStage.cs

示例4: Emit

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="emitter"></param>
        protected override void Emit(Context ctx, MachineCodeEmitter emitter)
        {
            RegisterOperand rop = (RegisterOperand)ctx.Result;
            MemoryOperand mop = (MemoryOperand)ctx.Operand1;
            byte[] code;

            if (null != mop.Base)
            {
                code = new byte[] {
                    0x8d,
                    0x84,
                    (4 << 3)
                };
                code[1] |= (byte)((rop.Register.RegisterCode & 0x7));
                code[2] |= (byte)((mop.Base.RegisterCode & 0x7));
            }

            else
            {
                code = new byte[] { 0xb8 };
            }

            emitter.Write (code, 0, code.Length);
            emitter.EmitImmediate (mop);
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:30,代码来源:LeaInstruction.cs

示例5: Emit

 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 /// <param name="emitter">The emitter.</param>
 protected override void Emit(Context ctx, MachineCodeEmitter emitter)
 {
     if (ctx.Operand1 is RegisterOperand)
         emitter.Emit(JmpReg, ctx.Operand1);
     else
         emitter.EmitBranch(JMP, ctx.Branch.Targets[0]);
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:12,代码来源:JmpInstruction.cs

示例6: Emit

        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context ctx, MachineCodeEmitter emitter)
        {
            OpCode opcode;

            switch (ctx.ConditionCode)
            {
                case IR.ConditionCode.Equal: opcode = E; break;
                case IR.ConditionCode.LessThan: opcode = LT; break;
                case IR.ConditionCode.LessOrEqual: opcode = LE; break;
                case IR.ConditionCode.GreaterOrEqual: opcode = GE; break;
                case IR.ConditionCode.GreaterThan: opcode = GT; break;
                case IR.ConditionCode.NotEqual: opcode = NE; break;
                case IR.ConditionCode.UnsignedGreaterOrEqual: opcode = UGE; break;
                case IR.ConditionCode.UnsignedGreaterThan: opcode = UGT; break;
                case IR.ConditionCode.UnsignedLessOrEqual: opcode = ULE; break;
                case IR.ConditionCode.UnsignedLessThan: opcode = ULT; break;
                case IR.ConditionCode.Parity: opcode = P; break;
                case IR.ConditionCode.NoParity: opcode = NP; break;
                case IR.ConditionCode.NoCarry: opcode = NC; break;
                case IR.ConditionCode.Carry: opcode = C; break;
                case IR.ConditionCode.Zero: opcode = Z; break;
                case IR.ConditionCode.NoZero: opcode = NZ; break;
                default: throw new NotSupportedException();
            }

            emitter.Emit(opcode, ctx.Result, null);
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:32,代码来源:SetccInstruction.cs

示例7: CreateISRMethods

        /// <summary>
        /// Creates the ISR methods.
        /// </summary>
        /// <param name="compiler">The compiler.</param>
        private void CreateISRMethods(AssemblyCompiler compiler)
        {
            // Create Interrupt Service Routines (ISR)
            RuntimeMethod InterruptMethod = compiler.Assembly.EntryPoint; // TODO: replace with another entry point

            SigType I1 = new SigType(CilElementType.I1);
            SigType I4 = new SigType(CilElementType.I4);
            RegisterOperand eax = new RegisterOperand(I4, GeneralPurposeRegister.EAX);

            for (int i = 0; i <= 256; i++) {
                InstructionSet set = new InstructionSet(100);
                Context ctx = new Context(set, -1);

                ctx.SetInstruction(CPUx86.Instruction.CliInstruction);
                if ((i != 8) && (i < 10 || i > 14)) // For IRQ 8, 10, 11, 12, 13, 14 the cpu automatically pushed the error code
                    ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I4, 0x0));
                ctx.AppendInstruction(CPUx86.Instruction.PushadInstruction);
                ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I4, i));
                // TODO: Set method parameters
                ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, InterruptMethod);
                ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, eax);
                ctx.AppendInstruction(CPUx86.Instruction.PopadInstruction);
                ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, eax);
                ctx.AppendInstruction(CPUx86.Instruction.StiInstruction);
                //ctx.AppendInstruction(CPUx86.Instruction.IRetdInstruction);

                CompilerGeneratedMethod method = LinkTimeCodeGenerator.Compile(compiler, @"InterruptISR" + i.ToString(), set);
            }
        }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:33,代码来源:InterruptStage.cs

示例8: Run

 /// <summary>
 /// Performs stage specific processing on the compiler context.
 /// </summary>
 public virtual void Run()
 {
     for (int index = 0; index < BasicBlocks.Count; index++)
         for (Context ctx = new Context (InstructionSet, BasicBlocks[index]); !ctx.EndOfInstruction; ctx.GotoNext ())
             if (ctx.Instruction != null)
                 ctx.Clone ().Visit (this);
 }
开发者ID:54616E6E6572,项目名称:Mosa,代码行数:10,代码来源:CodeTransformationStage.cs

示例9: Run

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public void Run()
        {
            // Create the prologue block
            Context ctx = new Context(InstructionSet, -1);
            // Add a jump instruction to the first block from the prologue
            ctx.AppendInstruction(IR.Instruction.JmpInstruction);
            //ctx.AppendInstruction(CIL.Instruction.Get(CIL.OpCode.Br));
            ctx.SetBranch(0);
            ctx.Label = -1;
            _prologue = CreateBlock(-1, ctx.Index);

            SplitIntoBlocks(0);

            // Create the epilogue block
            ctx = new Context(InstructionSet, -1);
            // Add null instruction, necessary to generate a block index
            ctx.AppendInstruction(null);
            ctx.Ignore = true;
            ctx.Label = Int32.MaxValue;
            _epilogue = CreateBlock(Int32.MaxValue, ctx.Index);

            // Link all the blocks together
            BuildBlockLinks(_prologue);

            // Link Exception Header Clauses
            LinkExceptionHeaderClauses();
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:30,代码来源:BasicBlockBuilderStage.cs

示例10: Emit

 /// <summary>
 /// 
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="emitter"></param>
 protected override void Emit(Context ctx, MachineCodeEmitter emitter)
 {
     emitter.Emit (new OpCode (new byte[] {
         0xf,
         0xa2
     }), null, null);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:12,代码来源:CpuIdEcxInstruction.cs

示例11: TypeInitializerSchedulerStage

        /// <summary>
        /// Initializes a new instance of the <see cref="TypeInitializerSchedulerStage"/> class.
        /// </summary>
        public TypeInitializerSchedulerStage()
        {
            InstructionSet = new InstructionSet(1024);
            _ctx = CreateContext(-1);

            _ctx.AppendInstruction(IR.Instruction.PrologueInstruction);
            _ctx.Other = 0; // stacksize
        }
开发者ID:hj1980,项目名称:MOSA-Project,代码行数:11,代码来源:TypeInitializerSchedulerStage.cs

示例12: ReplaceIntrinsicCall

        /// <summary>
        /// Replaces the instrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        public void ReplaceIntrinsicCall(Context context)
        {
            Operand operand1 = context.Operand1;

            RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);

            context.SetInstruction(IR.Instruction.MoveInstruction, imm, operand1);
            context.AppendInstruction(IR.Instruction.MoveInstruction, new RegisterOperand(new SigType(CilElementType.U4), _control), imm);
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:13,代码来源:SetControlRegisterBase.cs

示例13: RegisterOperand

 /// <summary>
 /// Visitation function for <see cref="IR.IIRVisitor.AddressOfInstruction"/> instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 void IR.IIRVisitor.AddressOfInstruction(Context ctx)
 {
     Operand opRes = ctx.Result;
     RegisterOperand eax = new RegisterOperand (opRes.Type, GeneralPurposeRegister.EAX);
     ctx.Result = eax;
     ctx.ReplaceInstructionOnly (CPUx86.Instruction.LeaInstruction);
     //            ctx.Ignore = true;
     ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, opRes, eax);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:13,代码来源:IRTransformationStage.cs

示例14: ReplaceIntrinsicCall

        /// <summary>
        /// Replaces the instrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
        {
            Operand result = context.Result;

            RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);

            context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(new SigType(CilElementType.U4), _control));
            context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm);
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:14,代码来源:GetControlRegisterBase.cs

示例15: Emit

 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 /// <param name="emitter">The emitter.</param>
 protected override void Emit(Context ctx, MachineCodeEmitter emitter)
 {
     emitter.WriteByte(0xE8);
     emitter.WriteByte(0x00);
     emitter.WriteByte(0x00);
     emitter.WriteByte(0x00);
     emitter.WriteByte(0x00);
     emitter.Call(ctx.InvokeTarget);
 }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:14,代码来源:CallInstruction.cs


注:本文中的Mosa.Runtime.CompilerFramework.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。