Example #1
0
        internal static void ConvertToCanonicalCode(ref HuffmanTable huffmanTable)
        {
            int newCode = -1; // Para compensar con el incremento inicial dentro del for debajo
            uint prevLength = 1;
            uint newCodeIndex = 0;
            huffmanTable.table = new List<CodeInfo>();

            for (uint i = 0; i < huffmanTable.numSymbols.Length; i++)
            {
                uint codeLength = i + 1;

                for (uint j = 0; j < huffmanTable.numSymbols[i]; j++)
                {
                    CodeInfo code = new CodeInfo();
                    int difLengths = (int)(codeLength - prevLength);

                    newCode = (newCode + 1) << difLengths;
                    prevLength = codeLength;

                    code.code = (uint)newCode;
                    code.length = (byte)codeLength;
                    code.number = (ushort)huffmanTable.codes[newCodeIndex++];

                    huffmanTable.table.Add(code);
                }
            }

            huffmanTable.maxCodeLength = (byte)prevLength;
        }
Example #2
0
        public static void SetSelectedValue(this ListControl control, CodeInfo value)
        {
            if (value == null)
                return;

            control.SetSelectedValue(value.Code);
        }
Example #3
0
        public FormattedCode(string csharpText, int[] strIndexes, byte[] tagValues, int[] lineIndexes)
        {
            UiExceptionHelper.CheckNotNull(csharpText, "csharpText");
            UiExceptionHelper.CheckNotNull(strIndexes, "strIndexes");
            UiExceptionHelper.CheckNotNull(tagValues, "tagValues");
            UiExceptionHelper.CheckNotNull(lineIndexes, "lineIndexes");

            _codeInfo = new CodeInfo();

            _codeInfo.Text = csharpText;

            _codeInfo.IndexArray = new List<int>();
            foreach (int index in strIndexes)
                _codeInfo.IndexArray.Add(index);

            _codeInfo.TagArray = new List<byte>();
            foreach (byte tag in tagValues)
                _codeInfo.TagArray.Add(tag);

            _codeInfo.LineArray = new List<int>();
            foreach (int line in lineIndexes)
                _codeInfo.LineArray.Add(line);

            return;
        }
Example #4
0
        /// <summary>
        /// Builds a new instance of FormattedCode.
        /// </summary>
        public FormattedCode()
        {
            _codeInfo = NewCodeInfo();
            _maxLength = 0;

            return;
        }
Example #5
0
        public unsafe void DecomposeByteArray()
        {
            var ci = new CodeInfo(0x1000, code, DecodeType.Decode32Bits);

              using (var decomposed = DiStorm3.Decompose(ci, 10)) {
            TestInstructionsUnmanaged(decomposed.InstructionsPointer);
            //TestInstructionsManaged(decoded.Instructions);
              }
        }
Example #6
0
        public unsafe void DecodeBytePointer()
        {
            var gch = GCHandle.Alloc(code, GCHandleType.Pinned);

              var ci = new CodeInfo(0x1000, (byte*) gch.AddrOfPinnedObject().ToPointer(), code.Length, DecodeType.Decode32Bits);
              using (var decoded = DiStorm3.Decode(ci, 10)) {
            TestInstructionsUnmanaged(decoded.InstructionsPointer);
            TestInstructionsManaged(decoded.Instructions);
              }
              gch.Free();
        }
Example #7
0
        private static List <int> GetNotUpdateTradingDays(CodeInfo codeInfo, List <int> newTradingDays, List <int> updatedTradingDays, bool isFill)
        {
            int start = codeInfo.Start;
            int end   = codeInfo.End <= 0 ? int.MaxValue : codeInfo.End;

            List <int> notUpdateTradingDays = new List <int>();

            if (isFill)
            {
                HashSet <int> set = new HashSet <int>(updatedTradingDays);
                for (int i = 0; i < newTradingDays.Count; i++)
                {
                    int newTradingDay = newTradingDays[i];
                    if (newTradingDay < start || newTradingDay > end)
                    {
                        continue;
                    }
                    if (set.Contains(newTradingDay))
                    {
                        continue;
                    }
                    notUpdateTradingDays.Add(newTradingDay);
                }
            }
            else
            {
                updatedTradingDays.Sort();
                int lastDay = updatedTradingDays.Count == 0 ? -1 : updatedTradingDays[updatedTradingDays.Count - 1];

                for (int i = 0; i < newTradingDays.Count; i++)
                {
                    int newTradingDay = newTradingDays[i];
                    if (newTradingDay < start || newTradingDay > end)
                    {
                        continue;
                    }
                    if (newTradingDay <= lastDay)
                    {
                        continue;
                    }
                    notUpdateTradingDays.Add(newTradingDay);
                }
            }
            return(notUpdateTradingDays);
        }
Example #8
0
        public void TestGetCodeInfo()
        {
            string             path = @"D:\SCWORK\DEV\SC2\bin\Debug\plugin\cnfutures";
            DataLoader_Variety dataLoader_Variety = new DataLoader_Variety(path);
            CodeInfo           codeInfo           = CodeInfoUtils.GetCodeInfo("m1501", dataLoader_Variety);

            Assert.AreEqual("M1501,豆粕1501,M,豆粕,20140119,20150116,DL,M1501,M01", codeInfo.ToString());

            codeInfo = CodeInfoUtils.GetCodeInfo("mmi", dataLoader_Variety);
            //Console.WriteLine(codeInfo);
            Assert.AreEqual("MMI,豆粕MI,M,豆粕,0,0,DL,MMI,MMI", codeInfo.ToString());

            codeInfo = CodeInfoUtils.GetCodeInfo("m0000", dataLoader_Variety);
            Assert.AreEqual("M0000,豆粕0000,M,豆粕,0,0,DL,M0000,M13", codeInfo.ToString());

            codeInfo = CodeInfoUtils.GetCodeInfo("FG701", dataLoader_Variety);
            Assert.AreEqual("FG1701,玻璃1701,FG,玻璃,20160117,20170120,ZZ,FG701,FG01", codeInfo.ToString());
        }
Example #9
0
        public void Validates_when_only_jump_dest_present(int destination, bool isValid)
        {
            byte[] code =
            {
                (byte)Instruction.JUMPDEST
            };

            CodeInfo codeInfo = new CodeInfo(code);

            if (!isValid)
            {
                Assert.Throws <InvalidJumpDestinationException>(() => codeInfo.ValidateJump(destination));
            }
            else
            {
                codeInfo.ValidateJump(destination);
            }
        }
Example #10
0
 public InstrInfo(EnumValue code, CodeInfo codeInfo, EnumValue encoding, EnumValue flowControl, RflagsBits read, RflagsBits undefined, RflagsBits written, RflagsBits cleared, RflagsBits set, EnumValue[] cpuid, OpInfo[] opInfo, InstrInfoFlags flags)
 {
     Code            = code;
     CodeInfo        = codeInfo;
     Encoding        = encoding;
     FlowControl     = flowControl;
     RflagsRead      = read;
     RflagsUndefined = undefined;
     RflagsWritten   = written;
     RflagsCleared   = cleared;
     RflagsSet       = set;
     RflagsInfo      = null;
     Cpuid           = cpuid;
     CpuidInternal   = null;
     OpInfo          = opInfo;
     OpInfoEnum      = new EnumValue[opInfo.Length];
     Flags           = flags;
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.SetTitleBar(GRIDtitle);

            var connectedAnimation = ConnectedAnimationService.GetForCurrentView().GetAnimation("postAnimation");

            if (connectedAnimation != null)
            {
                connectedAnimation.TryStart(Header, new UIElement[] { });
            }
            info = e.Parameter as CodeInfo;
            if (e.Parameter != null && e.Parameter is CodeInfo)
            {
                var info = e.Parameter as CodeInfo;
                TitleBlock.Text = info.title;
                WEBpreprocess();
            }
        }
Example #12
0
        public AddAttendeesFromTag(int id)
        {
            Id     = id;
            UserId = Util.UserId;
            var i = (from m in DbUtil.Db.Meetings
                     where m.MeetingId == id
                     select new
            {
                m.Organization.OrganizationName,
                m.OrganizationId,
                m.MeetingDate
            }).Single();

            OrgName  = i.OrganizationName;
            OrgId    = i.OrganizationId;
            JoinDate = i.MeetingDate.Value.Date;
            Tag      = new CodeInfo("0", "Tag");
        }
Example #13
0
    protected override void OnFormClosed(FormClosedEventArgs e)
    {
        if (Program.Loaded >= EProgramState.LoadedUI)
        {
            Program.Settings.wndPos = _Hwnd.SavePositionSizeState();
            UacDragDrop.AdminProcess.Enable(false);
        }
        Program.Loaded = EProgramState.Unloading;
        ZCloseReason   = e.CloseReason;

        base.OnFormClosed(e);

        CodeInfo.Stop();
        Panels.Files.ZUnloadOnFormClosed();
        EdTrayIcon.Dispose();
        Program.Loaded = EProgramState.Unloaded;
        Application.Exit();
    }
Example #14
0
        private void init()
        {
            List <CodeInfo> codeInfos = instrumentStore.Load();

            for (int i = 0; i < codeInfos.Count; i++)
            {
                CodeInfo codeInfo = codeInfos[i];
                codes.Add(codeInfo);
                dicCodes.Add(codeInfo.Code.ToUpper(), codeInfo);
                String catelog = codeInfo.Catelog;
                if (!catelogs.Contains(catelog))
                {
                    catelogs.Add(catelog);
                }
                String code = codeInfo.Code;
                AddDicCodeCatelog(code, catelog);
            }
        }
Example #15
0
        public NewExtraValueModel(string table, string name)
        {
            var f = Views.GetStandardExtraValues(DbUtil.Db, table).Single(ee => ee.Name == name);

            ExtraValueType  = new CodeInfo(f.Type, "ExtraValueType");
            ExtraValueName  = name;
            ExtraValueTable = table;
            VisibilityRoles = f.VisibilityRoles;
            ExtraValueLink  = HttpUtility.HtmlDecode(f.Link);
            var codes = string.Join("\n", f.Codes);

            switch (ExtraValueType.Value)
            {
            case "Bits": ExtraValueCheckboxes = codes; break;

            case "Code": ExtraValueCodes = codes; break;
            }
        }
Example #16
0
        public AddToOrgFromTag(Guid id, CMSDataContext db)
        {
            Host            = db.Host;
            CurrentDatabase = db;
            QueryId         = id;
            UserId          = CurrentDatabase.UserId;
            Tag             = new CodeInfo("0", "Tag");

            Filter = filter ?? (filter = db.OrgFilter(id));

            if (Filter.GroupSelect == GroupSelectCode.Previous)
            {
                var org = db.LoadOrganizationById(OrgId);
                OrgName = org.OrganizationName;
            }

            OrgId = Filter.Id;
        }
        /// <summary>
        /// 验证验证码是否正确
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ValidInfo VerificationCodeValid(CodeInfo code)
        {
            ValidInfo valid = new ValidInfo();

            try
            {
                List <SqlParameter> sqllist = new List <SqlParameter>();
                sqllist.Add(new SqlParameter {
                    ParameterName = "@phone", SqlDbType = SqlDbType.VarChar, Value = code.phone
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@code", SqlDbType = SqlDbType.VarChar, Value = code.code
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@codetype", SqlDbType = SqlDbType.Int, Value = code.codetype
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outvalid", SqlDbType = SqlDbType.Bit, Direction = ParameterDirection.Output
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outmsg", SqlDbType = SqlDbType.VarChar, Size = 100, Direction = ParameterDirection.Output
                });
                EPData     ep       = new EPData();
                SqlCommand cmd      = ep.CallProcCommon("cp_EqualVerificationCode", sqllist.ToArray());
                string     outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string     outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(valid);
        }
Example #18
0
        public List <CodeInfo> GetAllCodes()
        {
            string path = this.dataUpdateHelper.GetPath_Code();

            //装载已更新好的股票
            Dictionary <string, CodeInfo> dic_Id_CodeInfo = new Dictionary <string, CodeInfo>();
            List <CodeInfo> updatedCodes = CsvUtils_Code.Load(path);

            if (File.Exists(path))
            {
                for (int i = 0; i < updatedCodes.Count; i++)
                {
                    dic_Id_CodeInfo.Add(updatedCodes[i].Code, updatedCodes[i]);
                }
            }

            //从新的合约中找到之前没有的合约
            List <CodeInfo> codes    = dataUpdateHelper.GetNewCodes();
            List <CodeInfo> newcodes = new List <CodeInfo>(updatedCodes);

            for (int i = 0; i < codes.Count; i++)
            {
                CodeInfo code = codes[i];
                if (dic_Id_CodeInfo.ContainsKey(code.Code))
                {
                    CodeInfo codeInfo = dic_Id_CodeInfo[code.Code];
                    if (codeInfo.Start != 0 && codeInfo.Start < code.Start)
                    {
                        code.Start = codeInfo.Start;
                    }
                    if (codeInfo.Start != 0 && codeInfo.End > code.End)
                    {
                        code.End = codeInfo.End;
                    }
                }
                else
                {
                    newcodes.Add(code);
                }
            }

            newcodes.Sort(new CodeInfoComparer());
            return(newcodes);
        }
Example #19
0
        /// <summary>
        /// 传入代码,品种名称和交易所,得到CodeInfo
        /// </summary>
        /// <param name="codeId"></param>
        /// <param name="varietyName"></param>
        /// <param name="exchange"></param>
        /// <returns></returns>
        //public static CodeInfo GetCodeInfo(string codeId, string varietyName, string exchange)
        //{
        //    return GetCodeInfo(codeId, SplitCodeId(codeId), varietyName, exchange);
        //}

        public static CodeInfo GetCodeInfo(string codeId, string[] codeIdSplit, string varietyName, string exchange)
        {
            if (codeIdSplit[1] != "")
            {
                return(GetTwoYearCodes(codeId, codeIdSplit, varietyName, exchange));
            }
            string   varietyId = codeIdSplit[0];
            string   suffix    = codeIdSplit[2];
            int      year      = 2000 + int.Parse(suffix.Substring(suffix.Length - 4, 2));
            int      month     = int.Parse(suffix.Substring(suffix.Length - 2, 2));
            string   codeName  = varietyName + suffix.Substring(suffix.Length - 4, 4);
            int      start     = GetEndDay(year - 1, month) + 1;
            int      end       = GetEndDay(year, month);
            CodeInfo code      = new CodeInfo(codeId, codeName, varietyId, varietyName, start, end, exchange, "");

            code.ServerCode = GetServerCode(codeId, exchange);
            //code.ShortCode = codeIdSplit[0]
            return(code);
        }
Example #20
0
        private String GetMainCode(String path, List <CodeInfo> codes, int date)
        {
            long   max      = 0;
            String mainCode = null;

            for (int i = 0; i < codes.Count; i++)
            {
                CodeInfo codeInfo = codes[i];
                String   code     = codeInfo.Code;
                if (code.Contains("MI") || code.Contains("0000"))
                {
                    continue;
                }
                //合约截止日期如果早于当日,则肯定不是主合约
                if (codeInfo.End < date)
                {
                    continue;
                }
                String p = GetPath(path, code, date);
                //if (!File.Exists(p))
                //    continue;
                //int hold = GetHold(p);
                //if (hold > maxHold)
                //{
                //    maxHold = hold;
                //    mainCode = code;
                //}

                //以前是按照持仓量来判断,但是有时候持仓量最大的成交量不大,这里还是倾向于用成交量最大的作为主连
                FileInfo f = new FileInfo(p);
                if (!f.Exists)
                {
                    continue;
                }
                long l = f.Length;
                if (l > max)
                {
                    max      = l;
                    mainCode = code;
                }
            }
            return(mainCode);
        }
        /// <summary>
        /// 更新配置文件
        /// </summary>
        public void UpdateConfig()
        {
            if (!m_bIsAllowUpdateConfig)
            {
                return;
            }
            CodeInfo defaultInfo = new CodeInfo();

            defaultInfo = FKDeepObjCopier.Clone(GlobalCH.m_ci);

            defaultInfo.PixelMin         = Convert.ToInt32(textBox3.Text);
            defaultInfo.PixelMax         = Convert.ToInt32(textBox4.Text);
            defaultInfo.NoiseLv          = noiseLvTrackBar.Value;
            defaultInfo.IsAutoSelectRect = true;
            defaultInfo.CodeRectangles.Clear();
            defaultInfo.BinaryValues = Enumerable.Repeat((byte)Convert.ToInt32(textBox2.Text), 1).ToArray();

            GlobalCH.LoadCodeInfo(defaultInfo);
        }
Example #22
0
        public MainForm()
        {
            InitializeComponent();

            CodeInfo defaultInfo = new CodeInfo();

            defaultInfo.ClearCode();
            defaultInfo.Url              = "";
            defaultInfo.ImageTemp        = null;
            defaultInfo.CodeCount        = 0;
            defaultInfo.RectangleCut     = new Rectangle(0, 0, 100, 100);
            defaultInfo.PixelMin         = 8;
            defaultInfo.PixelMax         = 120;
            defaultInfo.IsAutoSelectRect = true;
            defaultInfo.CodeRectangles.Clear();
            defaultInfo.BinaryValues = Enumerable.Repeat((byte)127, 1).ToArray();

            GlobalCH.LoadCodeInfo(defaultInfo);
        }
Example #23
0
        public bool TryGetValue(SourceCodeFile key, out CodeInfo value)
        {
            value = null;
            var id        = new BsonValue(key.FileName.ToLower());
            var cacheItem = CacheItemCollection.FindById(id);

            if (cacheItem != null)
            {
                if (cacheItem.Data.HashCode == key.HashCode)
                {
                    value = cacheItem.Data;
                }
                else
                {
                    CacheItemCollection.Delete(id);
                }
            }
            return(value != null);
        }
        public override void ExecuteCommandImpl(object sender, EventArgs args, IVsUIShell uiShell)
        {
            var project = projectManager.SelectedProject;

            string selectedMethodName     = projectManager.MethodName;
            string serverMethodFolderPath = projectManager.ServerMethodFolderPath;
            string selectedFolderPath     = projectManager.SelectedFolderPath;
            string projectConfigPath      = projectManager.ProjectConfigPath;

            var        projectConfiguration = projectConfigurationManager.Load(projectConfigPath);
            MethodInfo methodInformation    = projectConfiguration.MethodInfos.FirstOrDefault(m => m.MethodName == selectedMethodName);

            if (methodInformation == null)
            {
                throw new Exception($"Configurations for the {selectedMethodName} method not found.");
            }

            var view       = dialogFactory.GetCreatePartialClassView(uiShell, projectConfiguration.UseVSFormatting);
            var viewResult = view.ShowDialog();

            if (viewResult?.DialogOperationResult != true)
            {
                return;
            }

            string partialPath = selectedFolderPath.Substring(serverMethodFolderPath.IndexOf(serverMethodFolderPath) + serverMethodFolderPath.Length);

            partialPath = Path.Combine(partialPath, viewResult.FileName);

            if (methodInformation.PartialClasses.Contains(partialPath, StringComparer.InvariantCultureIgnoreCase))
            {
                throw new Exception($"Partial element already exist.");
            }

            ICodeProvider codeProvider    = codeProviderFactory.GetCodeProvider(project.CodeModel.Language, projectConfiguration);
            CodeInfo      partialCodeInfo = codeProvider.CreatePartialCodeInfo(methodInformation, viewResult.FileName, viewResult.IsUseVSFormattingCode);

            projectManager.AddItemTemplateToProjectNew(partialCodeInfo, true, 0);
            methodInformation.PartialClasses.Add(partialCodeInfo.Path);
            projectConfiguration.UseVSFormatting = viewResult.IsUseVSFormattingCode;
            projectConfigurationManager.Save(projectManager.ProjectConfigPath, projectConfiguration);
        }
Example #25
0
        /// <summary>
        /// 得到未更新的KLine数据
        /// </summary>
        /// <param name="code"></param>
        /// <param name="isFill"></param>
        /// <returns></returns>
        public List <int> GetNotUpdateTradingDays_KLineData(string code, bool isFill)
        {
            CodeInfo   codeInfo       = GetCodeInfo(code);
            List <int> newTradingDays = this.GetNewTradingDays();

            //强制更新SQ的JINSHUYUAN的kline数据
            //if (code.EndsWith("0000") || code.EndsWith("MI"))
            //    return newTradingDays;
            if (newTradingDays.Count == 0)
            {
                return(null);
            }
            if (codeInfo.End < newTradingDays[0])
            {
                return(null);
            }
            List <int> updatedTradingDays = this.GetUpdatedKLineDataTradingDays(code);

            return(GetNotUpdateTradingDays(codeInfo, newTradingDays, updatedTradingDays, isFill));
        }
Example #26
0
        public AddAttendeesFromTag(int id, CMSDataContext db)
        {
            Host      = db.Host;
            QueryId   = Guid.NewGuid();
            MeetingId = id;
            UserId    = Util.UserId;
            var i = (from m in db.Meetings
                     where m.MeetingId == id
                     select new
            {
                m.Organization.OrganizationName,
                m.OrganizationId,
                m.MeetingDate
            }).Single();

            OrgName  = i.OrganizationName;
            OrgId    = i.OrganizationId;
            JoinDate = i.MeetingDate.Value.Date;
            Tag      = new CodeInfo("0", "Tag");
        }
Example #27
0
        public bool ReadNextCode()
        {
            if (_readCodes >= _partitionInfo.codeCount)
            {
                _codeInfo = null;
                return(false);
            }

            var code = _reader.ReadUInt16();

            if (Lists.controlCodes.ContainsKey(code))
            {
                //control code
                try
                {
                    _codeInfo = new CodeInfo
                    {
                        code      = (ushort)(code ^ _header.XORKey),
                        arguments = _reader.ReadMultiple <ushort>(Lists.controlCodes[code].Item2).Select(m => (ushort)(m ^ _header.XORKey)).ToList()
                    };
                }
                catch
                {
                    return(false);
                }

                _readCodes += Lists.controlCodes[code].Item2 + 1;
            }
            else
            {
                //utf16 letter
                _codeInfo = new CodeInfo
                {
                    code = code
                };

                _readCodes++;
            }

            return(true);
        }
Example #28
0
        public List <TradingSession> LoadTradingSessions(string code)
        {
            List <TradingSession> dayStartTimes = this.LoadUpdatedTradingSessions(code);

            CodeInfo          codeInfo       = this.dataLoader_Instrument.GetInstrument(code);
            ITradingDayReader openDateReader = this.LoadTradingDayReader();
            int firstCodeTradingDayIndex;
            int lastCodeTradingDayIndex;
            int lastUpdateTradingDayIndex = GetLastUpdatedIndex(dayStartTimes);

            if (lastUpdateTradingDayIndex < 0)
            {
                firstCodeTradingDayIndex = GetFirstTradingDayIndex(codeInfo, openDateReader);
                lastCodeTradingDayIndex  = GetLastTradingDayIndex(codeInfo, openDateReader);
            }
            else
            {
                lastCodeTradingDayIndex = lastUpdateTradingDayIndex + 1;
                if (lastCodeTradingDayIndex >= openDateReader.GetAllTradingDays().Count)
                {
                    return(null);
                }
                firstCodeTradingDayIndex = GetFirstTradingDayIndex(codeInfo, openDateReader);
            }
            if (firstCodeTradingDayIndex < 0)
            {
                return(null);
            }

            List <int>            openDates        = openDateReader.GetAllTradingDays();
            List <TradingSession> updateStartTimes = CalcDayOpenTime(code, openDates, firstCodeTradingDayIndex, lastCodeTradingDayIndex);

            List <TradingSession> result = new List <TradingSession>();

            if (dayStartTimes != null)
            {
                result.AddRange(dayStartTimes);
            }
            result.AddRange(updateStartTimes);
            return(result);
        }
Example #29
0
        private static CodeInfo GetTwoYearCodes(string codeId, string[] codeIdSplit, string varietyName, string exchange)
        {
            string codeTwoYearTag = codeIdSplit[1];
            bool   isOddContract  = codeTwoYearTag.EndsWith("y") || codeTwoYearTag.EndsWith("Y");
            bool   isEvenContract = codeTwoYearTag.EndsWith("x") || codeTwoYearTag.EndsWith("X");

            if (!isOddContract && !isEvenContract)
            {
                return(null);
            }
            string suffix = codeIdSplit[2];
            int    year   = 2000 + int.Parse(suffix.Substring(suffix.Length - 4, 2));

            if (isOddContract && year % 2 == 0)
            {
                return(null);
            }
            if (isEvenContract && year % 2 == 1)
            {
                return(null);
            }

            int subYear = year - 2000;

            codeTwoYearTag = codeTwoYearTag.Substring(0, codeTwoYearTag.Length - 1);
            string codeSuffix = ((subYear < 10) ? ("0" + subYear.ToString()) : subYear.ToString()) + codeId.Substring(codeId.Length - 2, 2);

            CodeInfo newCode = new CodeInfo();

            newCode.Code        = codeTwoYearTag + codeSuffix;
            newCode.Name        = varietyName + codeSuffix;
            newCode.Catelog     = codeIdSplit[0];
            newCode.CatelogName = varietyName;
            int month = int.Parse(codeId.Substring(codeId.Length - 2, 2));

            newCode.Start      = GetEndDay(year - 2, month) + 1;
            newCode.End        = GetEndDay(year, month);
            newCode.Exchange   = exchange;
            newCode.ServerCode = GetServerCode(codeId, exchange);
            return(newCode);
        }
Example #30
0
        private void AdjustIndex(CodeInfo code, string oldCodeId)
        {
            string        path = GetSrcPath(code.Code);
            DirectoryInfo dir  = new DirectoryInfo(path);

            if (!dir.Exists)
            {
                return;
            }
            FileInfo[] files = dir.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                FileInfo file = files[i];
                int      date = GetDate(file);
                if (date < 0)
                {
                    continue;
                }
                AdjustIndex(code, oldCodeId, date);
            }
        }
Example #31
0
    protected override bool TranslateAcceleratorCore(ref System.Windows.Interop.MSG msg, ModifierKeys mod)
    {
        if (msg.message is Api.WM_KEYDOWN or Api.WM_SYSKEYDOWN)
        {
            var key = (KKey)msg.wParam;
            switch ((key, mod))
            {
            case (KKey.C, ModifierKeys.Control):
                ZCopy();
                return(true);

            case (KKey.V, ModifierKeys.Control):
                ZPaste();
                return(true);

            case (KKey.F12, 0):
                Menus.Edit.Go_to_definition();
                return(true);

            default:
                if (_ImageDeleteKey(key))
                {
                    return(true);
                }
                if (CodeInfo.SciCmdKey(this, key, mod))
                {
                    return(true);
                }
                switch ((key, mod))
                {
                case (KKey.Enter, 0):
                case (KKey.Enter, ModifierKeys.Control | ModifierKeys.Shift):
                    zAddUndoPoint();
                    break;
                }
                break;
            }
        }
        return(base.TranslateAcceleratorCore(ref msg, mod));
    }
Example #32
0
        /// <summary>
        /// ����Դ�ļ�
        /// </summary>
        /// <param name="templdate">ģ������</param>
        /// <returns>�������ɴ���</returns>
        public static List<CodeInfo> Generator(IDatabase database, string templdate)
        {
            string remove = System.Configuration.ConfigurationManager.AppSettings["Filter"];
            if (remove == null) remove = string.Empty;

            string[] removeItem = remove.Split(',');

            List<CodeInfo> codeList = new List<CodeInfo>();
            string templateName = Path.GetFileName(templdate);
            foreach (ITable table in database.Tables)
            {
                foreach (string item in removeItem)
                    if (table.Name.IndexOf(item) == -1) continue;

                Generator(templdate, table, database.Name);
                CodeInfo info = new CodeInfo();
                info.Template = templateName;
                info.FileName = table.PascalCaseName.ToLower();
                info.Code = table.ToString();

                codeList.Add(info);
            }

            foreach (IView view in database.Views)
            {
                foreach (string item in removeItem)
                    if (view.Name.IndexOf(item) == -1) continue;

                Generator(templdate, view, database.Name);

                CodeInfo info = new CodeInfo();
                info.Template = templateName;
                info.FileName = view.PascalCaseName.ToLower();
                info.Code = view.ToString();

                codeList.Add(info);
            }

            return codeList;
        }
Example #33
0
        public static string DecompileCode(GMFileContent content, RefData rdata, CodeInfo code, bool absolute = false)
        {
            if (code.Instructions.Length == 0)
            {
                return(String.Empty);
            }

            var sb = new StringBuilder();

            var stack = new Stack <Expression>();
            var dupts = new List <Expression>();

            var firstI = (long)code.Instructions[0];

            var graph = BuildCFGraph(content, code);

            //TODO: CFG kind recognition stuff (if, if/else, for, while, etc)
            var i = 0;

            foreach (var g in graph)
            {
                var stmts = ParseStatements(content, rdata, code, g.Instructions, stack, absolute: absolute);

                sb.Append(SR.HEX_PRE)
                .Append(((long)g.Instructions[0] - firstI).ToString(SR.HEX_FM6))
                .AppendLine(SR.COLON);

                foreach (var s in stmts)
                {
                    sb.Append(SR.INDENT4).AppendLine(s.ToString());
                }

                i++;
            }

            sb.Append(SR.HEX_PRE).Append(code.Size.ToString(SR.HEX_FM6)).AppendLine(SR.COLON);
            sb.Append(SR.INDENT4).AppendLine(FinalRet.ToString());

            return(sb.ToString());
        }
Example #34
0
        private void MoveCode(CodeInfo code, string oldCodeId, int i)
        {
            string srcPath    = GetSrcPath(code, oldCodeId, i);
            string targetPath = GetTargetPath(code, oldCodeId, i);

            //Console.WriteLine(srcPath + "|" + targetPath);

            if (File.Exists(srcPath))
            {
                FileInfo f = new FileInfo(targetPath);
                if (f.Exists)
                {
                    return;
                }
                DirectoryInfo dir = f.Directory;
                if (!dir.Exists)
                {
                    dir.Create();
                }
                File.Move(srcPath, targetPath);
            }
        }
Example #35
0
        private int GetFirstTradingDayIndex(CodeInfo codeInfo, ITradingDayReader openDateReader)
        {
            int codeFirstDate = codeInfo.Start;

            if (codeFirstDate < 0)
            {
                return(0);
            }
            int firstTradingDay = openDateReader.FirstTradingDay;

            firstTradingDay = codeFirstDate > firstTradingDay ? codeFirstDate : firstTradingDay;

            int index = openDateReader.GetTradingDayIndex(firstTradingDay);

            if (index >= 0)
            {
                return(index);
            }
            int date = openDateReader.GetNextTradingDay(firstTradingDay);

            return(openDateReader.GetTradingDayIndex(date));
        }
Example #36
0
    private static Dictionary <int, string>[] FindLocalVariables(CodeInfo codeInfo, MethodWrapper mw, ClassFile classFile, ClassFile.Method method)
    {
        FindLocalVarState[] state = new FindLocalVarState[method.Instructions.Length];
        state[0].changed = true;
        state[0].sites   = new FindLocalVarStoreSite[method.MaxLocals];
        TypeWrapper[] parameters = mw.GetParameters();
        int           argpos     = 0;

        if (!mw.IsStatic)
        {
            state[0].sites[argpos++].Add(-1);
        }
        for (int i = 0; i < parameters.Length; i++)
        {
            state[0].sites[argpos++].Add(-1);
            if (parameters[i].IsWidePrimitive)
            {
                argpos++;
            }
        }
        return(FindLocalVariablesImpl(codeInfo, classFile, method, state));
    }
Example #37
0
        private int GetLastTradingDayIndex(CodeInfo codeInfo, ITradingDayReader openDateReader)
        {
            int codeLastDate = codeInfo.End;

            if (codeLastDate <= 0)
            {
                return(openDateReader.GetAllTradingDays().Count - 1);
            }
            int lastTradingDay = openDateReader.LastTradingDay;

            lastTradingDay = codeLastDate > lastTradingDay ? lastTradingDay : codeLastDate;

            int index = openDateReader.GetTradingDayIndex(lastTradingDay);

            if (index >= 0)
            {
                return(index);
            }
            int date = openDateReader.GetPrevTradingDay(lastTradingDay);

            return(openDateReader.GetTradingDayIndex(date));
        }
Example #38
0
 public static extern DecodeResult distorm_decompose(
     ref CodeInfo ci, [In, Out] DInst[] result, uint maxInstructions, ref uint usedInstructionsCount);
Example #39
0
        private void TicketInfo(Model.Coupons_CashWhenFee_Code code)
        {
            var info = new CodeInfo
            {
                money = code.Money.Value,
                fee = code.Fee.Value
            };

            var levels = levelDAL.GetEntityList("count desc", new string[] { "userid" }, new object[] { code.SaleManUserID });
            var logs = shareLogDAL.GetEntityList("", new string[] { "codeid" }, new object[] { code.ID });
            info.count = logs.Count();

            //商家没有设置提升
            if (!levels.IsNotNullAndAny())
            {
                ADeeWu.HuoBi3J.Libary.WebUtility.ShowMsg("商家还没有设置提升等级呢!");
                btnConfirm.Visible = false;
            }

            var maxLevel = levels.OrderBy(p => p.Count.ToInt()).LastOrDefault();
            //优惠券抵扣金钱处于顶级时认为爆级
            if (logs.Count() >= maxLevel.Count.ToInt())
            {
                btnConfirm.Visible = false;
                info.nextcount = "爆级";
                info.nextmoney = info.money;
            }
            else
            {
                var nextLevel = levels.Where(p => p.Money > code.Money).OrderBy(p => p.Count.ToInt()).FirstOrDefault();
                if (nextLevel.IsNotNull())
                {
                    if (nextLevel.Count.ToInt() < logs.Count())
                    {
                        nextLevel = levels.Where(p => p.Count.ToInt() > nextLevel.Count.ToInt()).OrderBy(p => p.Count.ToInt()).FirstOrDefault();
                    }

                    info.nextcount = (nextLevel.Count.ToInt() - info.count).ToStr();
                    info.nextmoney = nextLevel.Money.Value;
                }
                else
                {
                    info.nextcount = (maxLevel.Count.ToInt() - logs.Count()).ToStr();
                    info.nextmoney = code.Money.Value;
                }
            }

            rpCode.DataSource = new List<CodeInfo> { info };
            rpCode.DataBind();
        }
Example #40
0
 public void DisposeDecodedResult()
 {
     var ci = new CodeInfo(0x1000, code, DecodeType.Decode32Bits);
       var decoded = DiStorm3.Decode(ci, 10);
       decoded.Dispose();
       Assert.That(decoded._isDisposed);
 }
Example #41
0
        /// <summary>
        /// Builds a new instance of CodeInfo.
        /// </summary>
        public static CodeInfo NewCodeInfo()
        {
            CodeInfo res;

            res = new CodeInfo();
            res.Text = "";
            res.IndexArray = new List<int>();
            res.LineArray = new List<int>();
            res.TagArray = new List<byte>();

            return (res);
        }
            public TestingCSCode(string csharpText, int[] strIndexes, byte[] tagValues, int[] lineIndexes)
            {
                _codeInfo = new CodeInfo();

                _codeInfo.Text = csharpText;

                _codeInfo.IndexArray = new List<int>();
                foreach (int index in strIndexes)
                    _codeInfo.IndexArray.Add(index);

                _codeInfo.TagArray = new List<byte>();
                foreach (byte tag in tagValues)
                    _codeInfo.TagArray.Add(tag);

                _codeInfo.LineArray = new List<int>();
                foreach (int line in lineIndexes)
                    _codeInfo.LineArray.Add(line);

                return;
            }         
Example #43
0
 public static extern void distorm_format(ref CodeInfo ci, ref DInst di, ref DecodedInst result);
Example #44
0
            public InternalCSTokenCollection(CodeInfo info, int lineIndex)
            {
                _info = info;
                _lineIndex = lineIndex;

                return;
            }
Example #45
0
	internal LocalVarInfo(CodeInfo ma, ClassFile classFile, ClassFile.Method method, UntangledExceptionTable exceptions, MethodWrapper mw, ClassLoaderWrapper classLoader)
	{
		Dictionary<int, string>[] localStoreReaders = FindLocalVariables(ma, mw, classFile, method);

		// now that we've done the code flow analysis, we can do a liveness analysis on the local variables
		ClassFile.Method.Instruction[] instructions = method.Instructions;
		Dictionary<long, LocalVar> localByStoreSite = new Dictionary<long, LocalVar>();
		List<LocalVar> locals = new List<LocalVar>();
		for (int i = 0; i < localStoreReaders.Length; i++)
		{
			if (localStoreReaders[i] != null)
			{
				VisitLocalLoads(ma, method, locals, localByStoreSite, localStoreReaders[i], i, classLoader.EmitDebugInfo);
			}
		}
		Dictionary<LocalVar, LocalVar> forwarders = new Dictionary<LocalVar, LocalVar>();
		if (classLoader.EmitDebugInfo)
		{
			InstructionFlags[] flags = MethodAnalyzer.ComputePartialReachability(ma, method.Instructions, exceptions, 0, false);
			// if we're emitting debug info, we need to keep dead stores as well...
			for (int i = 0; i < instructions.Length; i++)
			{
				if ((flags[i] & InstructionFlags.Reachable) != 0
					&& IsStoreLocal(instructions[i].NormalizedOpCode))
				{
					if (!localByStoreSite.ContainsKey(MakeKey(i, instructions[i].NormalizedArg1)))
					{
						LocalVar v = new LocalVar();
						v.local = instructions[i].NormalizedArg1;
						v.type = ma.GetStackTypeWrapper(i, 0);
						FindLvtEntry(v, method, i);
						locals.Add(v);
						localByStoreSite.Add(MakeKey(i, v.local), v);
					}
				}
			}
			// to make the debugging experience better, we have to trust the
			// LocalVariableTable (unless it's clearly bogus) and merge locals
			// together that are the same according to the LVT
			for (int i = 0; i < locals.Count - 1; i++)
			{
				for (int j = i + 1; j < locals.Count; j++)
				{
					LocalVar v1 = (LocalVar)locals[i];
					LocalVar v2 = (LocalVar)locals[j];
					if (v1.name != null && v1.name == v2.name && v1.start_pc == v2.start_pc && v1.end_pc == v2.end_pc)
					{
						// we can only merge if the resulting type is valid (this protects against incorrect
						// LVT data, but is also needed for constructors, where the uninitialized this is a different
						// type from the initialized this)
						TypeWrapper tw = InstructionState.FindCommonBaseType(v1.type, v2.type);
						if (tw != VerifierTypeWrapper.Invalid)
						{
							v1.isArg |= v2.isArg;
							v1.type = tw;
							forwarders.Add(v2, v1);
							locals.RemoveAt(j);
							j--;
						}
					}
				}
			}
		}
		else
		{
			for (int i = 0; i < locals.Count - 1; i++)
			{
				for (int j = i + 1; j < locals.Count; j++)
				{
					LocalVar v1 = (LocalVar)locals[i];
					LocalVar v2 = (LocalVar)locals[j];
					// if the two locals are the same, we merge them, this is a small
					// optimization, it should *not* be required for correctness.
					if (v1.local == v2.local && v1.type == v2.type)
					{
						v1.isArg |= v2.isArg;
						forwarders.Add(v2, v1);
						locals.RemoveAt(j);
						j--;
					}
				}
			}
		}
		invokespecialLocalVars = new LocalVar[instructions.Length][];
		localVars = new LocalVar[instructions.Length];
		for (int i = 0; i < localVars.Length; i++)
		{
			LocalVar v = null;
			if (localStoreReaders[i] != null)
			{
				Debug.Assert(IsLoadLocal(instructions[i].NormalizedOpCode));
				// lame way to look up the local variable for a load
				// (by indirecting through a corresponding store)
				foreach (int store in localStoreReaders[i].Keys)
				{
					v = localByStoreSite[MakeKey(store, instructions[i].NormalizedArg1)];
					break;
				}
			}
			else
			{
				if (instructions[i].NormalizedOpCode == NormalizedByteCode.__invokespecial)
				{
					invokespecialLocalVars[i] = new LocalVar[method.MaxLocals];
					for (int j = 0; j < invokespecialLocalVars[i].Length; j++)
					{
						localByStoreSite.TryGetValue(MakeKey(i, j), out invokespecialLocalVars[i][j]);
					}
				}
				else
				{
					localByStoreSite.TryGetValue(MakeKey(i, instructions[i].NormalizedArg1), out v);
				}
			}
			if (v != null)
			{
				LocalVar fwd;
				if (forwarders.TryGetValue(v, out fwd))
				{
					v = fwd;
				}
				localVars[i] = v;
			}
		}
		this.allLocalVars = locals.ToArray();
	}
Example #46
0
	private static void VisitLocalLoads(CodeInfo codeInfo, ClassFile.Method method, List<LocalVar> locals, Dictionary<long, LocalVar> localByStoreSite, Dictionary<int, string> storeSites, int instructionIndex, bool debug)
	{
		Debug.Assert(IsLoadLocal(method.Instructions[instructionIndex].NormalizedOpCode));
		LocalVar local = null;
		TypeWrapper type = VerifierTypeWrapper.Null;
		int localIndex = method.Instructions[instructionIndex].NormalizedArg1;
		bool isArg = false;
		foreach (int store in storeSites.Keys)
		{
			if (store == -1)
			{
				// it's a method argument, it has no initial store, but the type is simply the parameter type
				type = InstructionState.FindCommonBaseType(type, codeInfo.GetLocalTypeWrapper(0, localIndex));
				isArg = true;
			}
			else
			{
				if (method.Instructions[store].NormalizedOpCode == NormalizedByteCode.__invokespecial)
				{
					type = InstructionState.FindCommonBaseType(type, codeInfo.GetLocalTypeWrapper(store + 1, localIndex));
				}
				else if (method.Instructions[store].NormalizedOpCode == NormalizedByteCode.__static_error)
				{
					// it's an __invokespecial that turned into a __static_error
					// (since a __static_error doesn't continue, we don't need to set type)
				}
				else
				{
					Debug.Assert(IsStoreLocal(method.Instructions[store].NormalizedOpCode));
					type = InstructionState.FindCommonBaseType(type, codeInfo.GetStackTypeWrapper(store, 0));
				}
			}
			// we can't have an invalid type, because that would have failed verification earlier
			Debug.Assert(type != VerifierTypeWrapper.Invalid);

			LocalVar l;
			if (localByStoreSite.TryGetValue(MakeKey(store, localIndex), out l))
			{
				if (local == null)
				{
					local = l;
				}
				else if (local != l)
				{
					// If we've already defined a LocalVar and we find another one, then we merge them
					// together.
					// This happens for the following code fragment:
					//
					// int i = -1;
					// try { i = 0; for(; ; ) System.out.println(i); } catch(Exception x) {}
					// try { i = 0; for(; ; ) System.out.println(i); } catch(Exception x) {}
					// System.out.println(i);
					//
					local = MergeLocals(locals, localByStoreSite, local, l);
				}
			}
		}
		if (local == null)
		{
			local = new LocalVar();
			local.local = localIndex;
			if (VerifierTypeWrapper.IsThis(type))
			{
				local.type = ((VerifierTypeWrapper)type).UnderlyingType;
			}
			else
			{
				local.type = type;
			}
			local.isArg = isArg;
			if (debug)
			{
				FindLvtEntry(local, method, instructionIndex);
			}
			locals.Add(local);
		}
		else
		{
			local.isArg |= isArg;
			local.type = InstructionState.FindCommonBaseType(local.type, type);
			Debug.Assert(local.type != VerifierTypeWrapper.Invalid);
		}
		foreach (int store in storeSites.Keys)
		{
			LocalVar v;
			if (!localByStoreSite.TryGetValue(MakeKey(store, localIndex), out v))
			{
				localByStoreSite[MakeKey(store, localIndex)] = local;
			}
			else if (v != local)
			{
				local = MergeLocals(locals, localByStoreSite, local, v);
			}
		}
	}
Example #47
0
	private static Dictionary<int, string>[] FindLocalVariablesImpl(CodeInfo codeInfo, ClassFile classFile, ClassFile.Method method, FindLocalVarState[] state)
	{
		ClassFile.Method.Instruction[] instructions = method.Instructions;
		ExceptionTableEntry[] exceptions = method.ExceptionTable;
		int maxLocals = method.MaxLocals;
		Dictionary<int, string>[] localStoreReaders = new Dictionary<int, string>[instructions.Length];
		bool done = false;

		while (!done)
		{
			done = true;
			for (int i = 0; i < instructions.Length; i++)
			{
				if (state[i].changed)
				{
					done = false;
					state[i].changed = false;

					FindLocalVarState curr = state[i].Copy();

					for (int j = 0; j < exceptions.Length; j++)
					{
						if (exceptions[j].startIndex <= i && i < exceptions[j].endIndex)
						{
							state[exceptions[j].handlerIndex].Merge(curr);
						}
					}

					if (IsLoadLocal(instructions[i].NormalizedOpCode)
						&& (instructions[i].NormalizedOpCode != NormalizedByteCode.__aload || !VerifierTypeWrapper.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(i + 1, 0))))
					{
						if (localStoreReaders[i] == null)
						{
							localStoreReaders[i] = new Dictionary<int, string>();
						}
						for (int j = 0; j < curr.sites[instructions[i].NormalizedArg1].Count; j++)
						{
							localStoreReaders[i][curr.sites[instructions[i].NormalizedArg1][j]] = "";
						}
					}

					if (IsStoreLocal(instructions[i].NormalizedOpCode)
						&& (instructions[i].NormalizedOpCode != NormalizedByteCode.__astore || !VerifierTypeWrapper.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(i, 0))))
					{
						curr.Store(i, instructions[i].NormalizedArg1);
						// if this is a store at the end of an exception block,
						// we need to propagate the new state to the exception handler
						for (int j = 0; j < exceptions.Length; j++)
						{
							if (exceptions[j].endIndex == i + 1)
							{
								state[exceptions[j].handlerIndex].Merge(curr);
							}
						}
					}

					if (instructions[i].NormalizedOpCode == NormalizedByteCode.__invokespecial)
					{
						ClassFile.ConstantPoolItemMI cpi = classFile.GetMethodref(instructions[i].Arg1);
						if (ReferenceEquals(cpi.Name, StringConstants.INIT))
						{
							TypeWrapper type = codeInfo.GetRawStackTypeWrapper(i, cpi.GetArgTypes().Length);
							// after we've invoked the constructor, the uninitialized references
							// are now initialized
							if (type == VerifierTypeWrapper.UninitializedThis
								|| VerifierTypeWrapper.IsNew(type))
							{
								for (int j = 0; j < maxLocals; j++)
								{
									if (codeInfo.GetLocalTypeWrapper(i, j) == type)
									{
										curr.Store(i, j);
									}
								}
							}
						}
					}
					else if (instructions[i].NormalizedOpCode == NormalizedByteCode.__goto_finally)
					{
						int handler = instructions[i].HandlerIndex;

						// Normally a store at the end of a try block doesn't affect the handler block,
						// but in the case of a finally handler it does, so we need to make sure that
						// we merge here in case the try block ended with a store.
						state[handler].Merge(curr);

						// Now we recursively analyse the handler and afterwards merge the endfault locations back to us
						FindLocalVarState[] handlerState = new FindLocalVarState[instructions.Length];
						handlerState[handler].Merge(curr);
						curr = new FindLocalVarState();
						FindLocalVariablesImpl(codeInfo, classFile, method, handlerState);

						// Merge back to the target of our __goto_finally
						for (int j = 0; j < handlerState.Length; j++)
						{
							if (instructions[j].NormalizedOpCode == NormalizedByteCode.__athrow
								&& codeInfo.HasState(j)
								&& VerifierTypeWrapper.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(j, 0))
								&& ((VerifierTypeWrapper)codeInfo.GetRawStackTypeWrapper(j, 0)).Index == handler)
							{
								curr.Merge(handlerState[j]);
							}
						}
					}

					switch (ByteCodeMetaData.GetFlowControl(instructions[i].NormalizedOpCode))
					{
						case ByteCodeFlowControl.Switch:
							{
								for (int j = 0; j < instructions[i].SwitchEntryCount; j++)
								{
									state[instructions[i].GetSwitchTargetIndex(j)].Merge(curr);
								}
								state[instructions[i].DefaultTarget].Merge(curr);
								break;
							}
						case ByteCodeFlowControl.Branch:
							state[instructions[i].TargetIndex].Merge(curr);
							break;
						case ByteCodeFlowControl.CondBranch:
							state[instructions[i].TargetIndex].Merge(curr);
							state[i + 1].Merge(curr);
							break;
						case ByteCodeFlowControl.Return:
						case ByteCodeFlowControl.Throw:
							break;
						case ByteCodeFlowControl.Next:
							state[i + 1].Merge(curr);
							break;
						default:
							throw new InvalidOperationException();
					}
				}
			}
		}
		return localStoreReaders;
	}
Example #48
0
	private static Dictionary<int, string>[] FindLocalVariables(CodeInfo codeInfo, MethodWrapper mw, ClassFile classFile, ClassFile.Method method)
	{
		FindLocalVarState[] state = new FindLocalVarState[method.Instructions.Length];
		state[0].changed = true;
		state[0].sites = new FindLocalVarStoreSite[method.MaxLocals];
		TypeWrapper[] parameters = mw.GetParameters();
		int argpos = 0;
		if (!mw.IsStatic)
		{
			state[0].sites[argpos++].Add(-1);
		}
		for (int i = 0; i < parameters.Length; i++)
		{
			state[0].sites[argpos++].Add(-1);
			if (parameters[i].IsWidePrimitive)
			{
				argpos++;
			}
		}
		return FindLocalVariablesImpl(codeInfo, classFile, method, state);
	}