public static void PopOperand(this ILTranslator tr, IIROperand operand)
 {
     if (operand is IRRegister)
     {
         var reg = ILRegister.LookupRegister(((IRRegister)operand).Register);
         tr.Instructions.Add(new ILInstruction(ILOpCode.POP, reg));
     }
     else if (operand is IRPointer pointer)
     {
         var reg = ILRegister.LookupRegister(pointer.Register.Register);
         tr.Instructions.Add(new ILInstruction(pointer.Register.GetPUSHR(), reg));
         if (pointer.Offset != 0)
         {
             tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, ILImmediate.Create(pointer.Offset, ASTType.I4)));
             if (pointer.Register.Type == ASTType.I4)
             {
                 tr.Instructions.Add(new ILInstruction(ILOpCode.ADD_DWORD));
             }
             else
             {
                 tr.Instructions.Add(new ILInstruction(ILOpCode.ADD_QWORD));
             }
         }
         tr.Instructions.Add(new ILInstruction(pointer.GetSIND()));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
        public static void PushOperand(this ILTranslator tr, IIROperand operand)
        {
            if (operand is IRRegister)
            {
                var reg = ILRegister.LookupRegister(((IRRegister)operand).Register);
                tr.Instructions.Add(new ILInstruction(((IRRegister)operand).GetPUSHR(), reg));
            }
            else if (operand is IRPointer pointer)
            {
                var reg = ILRegister.LookupRegister(pointer.Register.Register);
                tr.Instructions.Add(new ILInstruction(pointer.Register.GetPUSHR(), reg));
                if (pointer.Offset != 0)
                {
                    tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, ILImmediate.Create(pointer.Offset, ASTType.I4)));
                    switch (pointer.Register.Type)
                    {
                    case ASTType.I4:
                        tr.Instructions.Add(new ILInstruction(ILOpCode.ADD_DWORD));
                        break;

                    default:
                        tr.Instructions.Add(new ILInstruction(ILOpCode.ADD_QWORD));
                        break;
                    }
                }
                tr.Instructions.Add(new ILInstruction(pointer.GetLIND()));
            }
            else if (operand is IRConstant constant)
            {
                if (constant.Value != null)
                {
                    tr.Instructions.Add(new ILInstruction(constant.Type.Value.GetPUSHI(),
                                                          ILImmediate.Create(constant.Value, constant.Type.Value)));
                }
                else
                {
                    tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, ILImmediate.Create(0, ASTType.O)));
                }
            }
            else if (operand is IRMetaTarget)
            {
                var method = (MethodDef)((IRMetaTarget)operand).MetadataItem;
                tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, new ILMethodTarget(method)));
            }
            else if (operand is IRBlockTarget)
            {
                CFG.IBasicBlock target = ((IRBlockTarget)operand).Target;
                tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, new ILBlockTarget(target)));
            }
            else if (operand is IRJumpTable)
            {
                CFG.IBasicBlock[] targets = ((IRJumpTable)operand).Targets;
                tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, new ILJumpTable(targets)));
            }
            else if (operand is IRDataTarget)
            {
                RT.BinaryChunk target = ((IRDataTarget)operand).Target;
                tr.Instructions.Add(new ILInstruction(ILOpCode.PUSHI_DWORD, new ILDataTarget(target)));
            }
            else
            {
                throw new NotSupportedException();
            }
        }