public ScriptFile(Stream scriptStream, OpcodeSet opCodeSet)
        {
            _file   = scriptStream;
            CodeSet = opCodeSet;

            _codeTable   = new List <byte>();
            Functions    = new List <Function>();
            AggFunctions = new List <Function>();
            FunctionLoc  = new Dictionary <int, FunctionName>();

            Header      = ScriptHeader.Generate(scriptStream);
            StringTable = new StringTable(scriptStream, Header.StringTableOffsets, Header.StringBlocks,
                                          Header.StringsSize);
            X64NativeTable = new X64NativeTable(scriptStream, Header.NativesOffset + Header.Rsc7Offset,
                                                Header.NativesCount, Header.CodeLength);
            Name = Header.ScriptName;

            for (var i = 0; i < Header.CodeBlocks; i++)
            {
                var tablesize = (i + 1) * 0x4000 >= Header.CodeLength ? Header.CodeLength % 0x4000 : 0x4000;
                var working   = new byte[tablesize];
                scriptStream.Position = Header.CodeTableOffsets[i];
                scriptStream.Read(working, 0, tablesize);
                _codeTable.AddRange(working);
            }

            GetStaticInfo();
            GetFunctions();
            foreach (var func in Functions)
            {
                func.PreDecode();
            }
            Statics.Checkvars();

            var dirty = true;

            while (dirty)
            {
                dirty = false;
                foreach (var func in Functions)
                {
                    if (func.Dirty)
                    {
                        dirty      = true;
                        func.Dirty = false;
                        func.DecodeInstructionsForVarInfo();
                    }
                }
            }

            if (Program.AggregateFunctions)
            {
                foreach (var func in AggFunctions)
                {
                    func.PreDecode();
                }
            }
            foreach (var func in Functions)
            {
                func.Decode();
            }
            if (Program.AggregateFunctions)
            {
                foreach (var func in AggFunctions)
                {
                    func.Decode();
                }
            }
        }
        private static void InitializeFields(Options o)
        {
            IsBit32 = SwapEndian = RdrOpcodes = RdrNativeCipher = false;
            switch (o.Opcode.ToLower())
            {
            case "v":
                Codeset = new OpcodeSet();
                break;

            case "vconsole":
                IsBit32 = SwapEndian = true;
                Codeset = new OpcodeSet();
                break;

            case "rdr":
                RdrOpcodes = RdrNativeCipher = true;
                Codeset    = new RdrOpcodeSet();
                break;

            case "rdrconsole":
                RdrOpcodes = true;
                Codeset    = new RdrConsoleOpcodeSet();
                break;

            default:
                throw new ArgumentException("Invalid Opcode Set: " + o.Opcode);
            }

            Console.WriteLine("Loading hashes...");
            Hashbank = new Hashes();

            Console.WriteLine("Loading GXT entries...");
            Gxtbank = new GxtEntries();

            CompressedInput    = o.CompressedInput;
            CompressedOutput   = o.CompressOutput;
            AggregateFunctions = o.Aggregate;
            if (o.AggregateMinLines > 0)
            {
                AggregateMinLines = o.AggregateMinLines;
            }
            if (o.AggregateMinHits > 0)
            {
                AggregateMinHits = o.AggregateMinHits;
            }

            if (!o.Default)
            {
                UseMultiThreading = o.UseMultiThreading;
                UppercaseNatives  = o.UppercaseNatives;
                ShowNamespace     = o.ShowNamespace;
                DeclareVariables  = o.DeclareVariables;
                ShiftVariables    = o.ShiftVariables;
                ReverseHashes     = o.ReverseHashes;
                ShowArraySize     = o.ShowArraySize;
                ShowEntryComments = o.ShowEntryComments;
                HexIndex          = o.HexIndex;
                ShowFuncPosition  = o.ShowFuncPosition;
                switch (o.IntStyle.ToLower())
                {
                case "uint":
                    IntStyle = IntType.Uint;
                    break;

                case "hex":
                    IntStyle = IntType.Hex;
                    break;

                case "int":
                default:
                    IntStyle = IntType.Int;
                    break;
                }
            }
        }