示例#1
0
 public BCLInstruction(BCLOpcode opcode, BinaryReader reader) : this(opcode)
 {
     foreach (OSIGenericInstructionArgument arg in this.Arguments)
     {
         arg.ReadValue(reader);
     }
 }
示例#2
0
        public BCLInstruction(BCLOpcode opcode, params object[] arguments)
        {
            this.Opcode = opcode;
            if (opcode == BCLOpcode.LineNumber)
            {
                InitArguments("i16u i16u");
            }
            else if (opcode == BCLOpcode.LineNumberAlt1)
            {
                InitArguments("i16u i16u");
            }
            else if (opcode == BCLOpcode.LineNumberAlt2)
            {
                InitArguments("i16u i16u");
            }
            else if (opcode == BCLOpcode.SetMemberValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.GetMemberValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.GetMemberFunction)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.CreateObject)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.MemberFunctionArgumentCheck)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.SetThisMemberValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.GetThisMemberValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.GetThisMemberFunction)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.GetVariableValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.SetVariableValue)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.CreateStackVariables)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.IncrementVariable)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.DecrementVariable)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.PopN)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.Pull)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.DupN)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.PushConstanti32)
            {
                InitArguments("i32s");
            }
            else if (opcode == BCLOpcode.PushConstanti24)
            {
                InitArguments("i24s");
            }
            else if (opcode == BCLOpcode.PushConstanti16)
            {
                InitArguments("i16s");
            }
            else if (opcode == BCLOpcode.PushConstanti8)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.PushConstantf32)
            {
                InitArguments("f32");
            }
            else if (opcode == BCLOpcode.PushConstantString)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.PushConstantColor8888)
            {
                InitArguments("i32u");
            }
            else if (opcode == BCLOpcode.PushConstantColor5551)
            {
                InitArguments("i16u");
            }
            else if (opcode == BCLOpcode.JumpRelative)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.JumpAbsolute)
            {
                InitArguments("i8s");
            }
            else if (opcode == BCLOpcode.CompareAndBranchIfFalse)
            {
                InitArguments("i16s");
            }
            else if (opcode == BCLOpcode.BranchAlways)
            {
                InitArguments("i16s");
            }
            else if (opcode == BCLOpcode.GetGameVariable)
            {
                InitArguments("i16u i16u");
            }
            else if (opcode == BCLOpcode.SetGameVariable)
            {
                InitArguments("i16u i16u");
            }
            else if (opcode == BCLOpcode.CallGameFunction)
            {
                InitArguments("i16u i16u i8s");
            }
            else if (opcode == BCLOpcode.CallGameFunctionFromString)
            {
                InitArguments("i16u i8s");
            }
            else if (opcode == BCLOpcode.CallGameFunctionDirect)
            {
                InitArguments("i32s i8s");
            }
            else
            {
                this.Arguments = new List <OSIGenericInstructionArgument>();
            }

            if (arguments.Length > this.Arguments.Count)
            {
                throw new ArgumentException("Too many argument values!");
            }

            for (int i = 0; i < arguments.Length; i++)
            {
                this.Arguments[i].Value = arguments[i];
            }
        }