public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;
            if (Opcode == OpCodes.Ceq)
            {
                Argument = new HighLevel.EqualsNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Cgt || Opcode == OpCodes.Cgt_Un)
            {
                Argument = new HighLevel.GreaterNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Clt || Opcode == OpCodes.Clt_Un)
            {
                Argument = new HighLevel.LessNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else
            {
                throw new InvalidOperationException();
            }

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer - 1, typeof(int)), Argument));
            return(List);
        }
Ejemplo n.º 2
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            for (int i = 0; i < m_BranchTargetOffsets.Count; i++) // Add all conditional branches
            {
                HighLevel.Node Argument = new HighLevel.EqualsNode(Context.ReadStackLocationNode(Context.StackPointer), new HighLevel.IntegerConstantNode(i));
                List.Add(new HighLevel.ConditionalBranchInstruction(Argument, Context.GetBlock(m_BranchTargetOffsets[i])));
            }

            return(List);
        }
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;
            if (Opcode == OpCodes.Beq || Opcode == OpCodes.Beq_S)
            {
                Argument = new HighLevel.EqualsNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Bne_Un || Opcode == OpCodes.Bne_Un_S)
            {
                Argument = new HighLevel.NotEqualsNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Bge || Opcode == OpCodes.Bge_S || Opcode == OpCodes.Bge_Un || Opcode == OpCodes.Bge_Un_S)
            {
                Argument = new HighLevel.GreaterEqualsNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Bgt || Opcode == OpCodes.Bgt_S || Opcode == OpCodes.Bgt_Un || Opcode == OpCodes.Bgt_Un_S)
            {
                Argument = new HighLevel.GreaterNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Ble || Opcode == OpCodes.Ble_S || Opcode == OpCodes.Ble_Un || Opcode == OpCodes.Ble_Un_S)
            {
                Argument = new HighLevel.LessEqualsNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else if (Opcode == OpCodes.Blt || Opcode == OpCodes.Blt_S || Opcode == OpCodes.Blt_Un || Opcode == OpCodes.Blt_Un_S)
            {
                Argument = new HighLevel.LessNode(Context.ReadStackLocationNode(Context.StackPointer - 1), Context.ReadStackLocationNode(Context.StackPointer));
            }
            else
            {
                throw new InvalidOperationException();
            }

            List.Add(new HighLevel.ConditionalBranchInstruction(Argument, Context.GetBlock(m_BranchTargetOffset)));
            return(List);
        }