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);
        }
Пример #2
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.ArrayAccessNode Argument = new HighLevel.ArrayAccessNode(ArrayType);
            Argument.SubNodes.Add(Context.ReadStackLocationNode(Context.StackPointer - 1));
            Argument.SubNodes.Add(Context.ReadStackLocationNode(Context.StackPointer));

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer - 1), Argument));
            return(List);
        }
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;
            HighLevel.Node Left = Context.ReadStackLocationNode(Context.StackPointer - 1), Right = Context.ReadStackLocationNode(Context.StackPointer);
            if (Opcode == OpCodes.Add)
            {
                Argument = new HighLevel.AddNode(Left, Right);
            }
            else if (Opcode == OpCodes.Sub)
            {
                Argument = new HighLevel.SubNode(Left, Right);
            }
            else if (Opcode == OpCodes.Mul)
            {
                Argument = new HighLevel.MulNode(Left, Right);
            }
            else if (Opcode == OpCodes.Div)
            {
                Argument = new HighLevel.DivNode(Left, Right);
            }
            else if (Opcode == OpCodes.Rem)
            {
                Argument = new HighLevel.ModNode(Left, Right);
            }
            else
            {
                throw new InvalidOperationException();
            }

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer - 1), Argument));
            return(List);
        }
Пример #4
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            List.Add(new HighLevel.AssignmentInstruction(new HighLevel.DerefNode(Context.ReadStackLocationNode(Context.StackPointer - 1)), Context.ReadStackLocationNode(Context.StackPointer)));
            return(List);
        }
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Result;
            if (FieldInfo.IsStatic)
            {
                Result = new HighLevel.LocationNode(Context.StaticFieldLocation(FieldInfo));
            }
            else
            {
                Result = new HighLevel.InstanceFieldNode(Context.ReadStackLocationNode(Context.StackPointer - 1), FieldInfo);
            }

            List.Add(new HighLevel.AssignmentInstruction(Result, Context.ReadStackLocationNode(Context.StackPointer)));
            return(List);
        }
Пример #6
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.LocationNode Argument = Context.ReadStackLocationNode(Context.StackPointer);
            Context.DefineStackLocationNode(Context.StackPointer, Argument.Location.DataType);

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer + 1), Argument));
            return(List);
        }
Пример #7
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);
        }
Пример #8
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument = Context.ReadStackLocationNode(Context.StackPointer);
            if (Opcode == OpCodes.Brfalse || Opcode == OpCodes.Brfalse_S)
            {
                Argument = new HighLevel.LogicalNotNode(Argument);
            }

            List.Add(new HighLevel.ConditionalBranchInstruction(Argument, Context.GetBlock(m_BranchTargetOffset)));
            return(List);
        }
Пример #9
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;
            if (FieldInfo.IsStatic)
            {
                Argument = new HighLevel.LocationNode(Context.StaticFieldLocation(FieldInfo));
            }
            else
            {
                Argument = new HighLevel.InstanceFieldNode(Context.ReadStackLocationNode(Context.StackPointer), FieldInfo);
            }

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(m_WithoutThis ? Context.StackPointer + 1 : Context.StackPointer), Argument));
            return(List);
        }
Пример #10
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;

            if (StackConsumeCount == 0)
            {
                Argument = null;
            }
            else
            {
                Argument = Context.ReadStackLocationNode(Context.StackPointer);
            }

            List.Add(new HighLevel.ReturnInstruction(Argument));
            return(List);
        }
Пример #11
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Result = null;
            if (StackProduceCount != 0)
            {
                Result = Context.DefineStackLocationNode(Context.StackPointer - StackConsumeCount + 1, MethodInfo.ReturnType);
            }

            HighLevel.Node CallNode = new HighLevel.CallNode(MethodInfo);
            for (int i = StackConsumeCount - 1; i >= 0; i--)
            {
                CallNode.SubNodes.Add(Context.ReadStackLocationNode(Context.StackPointer - i));
            }

            Context.TranslateCallNode(ref Result, ref CallNode);

            List.Add(new HighLevel.AssignmentInstruction(Result, CallNode));
            return(List);
        }
Пример #12
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            HighLevel.Node Argument;
            if (FieldInfo.IsStatic)
            {
                Argument = new HighLevel.LocationNode(Context.StaticFieldLocation(FieldInfo));
            }
            else
            {
                Argument = new HighLevel.InstanceFieldNode(Context.ReadStackLocationNode(Context.StackPointer), FieldInfo);
            }

            bool isStruct = FieldInfo.FieldType.IsValueType && !FieldInfo.FieldType.IsPrimitive && !FieldInfo.FieldType.IsEnum;

            if (!isStruct)
            {
                Argument = new HighLevel.AddressOfNode(Argument);
            }

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer), Argument));
            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);
        }
Пример #14
0
        public override List <HighLevel.Instruction> GetHighLevel(HighLevel.HlGraph Context)
        {
            List <HighLevel.Instruction> List = new List <HighLevel.Instruction>();

            List.Add(new HighLevel.AssignmentInstruction(Context.DefineStackLocationNode(Context.StackPointer), new HighLevel.CastNode(Context.ReadStackLocationNode(Context.StackPointer), Type)));
            return(List);
        }