Skip to content

Commit 8f4cb92

Browse files
committed
1. 默认情况下把所有变量都toString放到变量池中
2. 提供根据变量名搜索,用于定位比较有特征的变量初始化或修改的地方
1 parent f1bcd94 commit 8f4cb92

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/components/global-assign-hook-component/plugins/search-strings-db-plugins.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
// 检索字符串数据库
44

5-
const stringsDB = window.cc11001100_hook.stringsDB;
5+
const cc11001100_hook = window.cc11001100_hook;
6+
const stringsDB = cc11001100_hook.stringsDB;
67

7-
window.cc11001100_hook.search = function (pattern, isEquals = true) {
8+
window.search = cc11001100_hook.search = function (pattern, isEquals = true) {
89
const result = [];
910
for (let s of stringsDB.varValueDb) {
1011
if (isEquals ? s.value === pattern : s.value.indexOf(pattern) !== -1) {
@@ -20,8 +21,29 @@
2021
});
2122
}
2223
}
24+
showResult(result);
25+
}
2326

27+
window.searchByName = cc11001100_hook.searchByName = function (pattern, isEquals=false) {
28+
const result = [];
29+
for (let s of stringsDB.varValueDb) {
30+
if (isEquals ? s.name === pattern : s.name.indexOf(pattern) !== -1) {
31+
const codeInfo = parseCodeLocation(s.codeLocation)
32+
result.push({
33+
name: s.name,
34+
value: abbreviationPattern(pattern, s.value),
35+
type: s.type,
36+
execOrder: s.execOrder,
37+
codeName: codeInfo.codeName,
38+
codeAddress: codeInfo.codeAddress,
39+
execTimes: stringsDB.codeLocationExecuteTimesCount[s.codeLocation]
40+
});
41+
}
42+
}
43+
showResult(result);
44+
}
2445

46+
function showResult(result) {
2547
if (!result.length) {
2648
console.log("没有搜索到结果。");
2749
return;

src/components/global-assign-hook-component/plugins/string-put-to-db-plugins.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414
function stringPutToDB(name, value, type) {
1515

16-
if (typeof value !== "string" || !value) {
16+
// 不止是string
17+
if (!value) {
1718
return;
1819
}
1920

2021
// 获取代码位置
2122
const codeLocation = getCodeLocation();
2223
varValueDb.push({
2324
name,
24-
value,
25+
// 默认情况下把所有变量都toString保存到字符串池子中
26+
value: value + "",
2527
type,
2628
execOrder: execOrderCounter++,
2729
codeLocation

0 commit comments

Comments
 (0)