arkanalyzer 1.0.39 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/config/arkanalyzer.json +6 -2
  2. package/lib/Config.d.ts +1 -0
  3. package/lib/Config.d.ts.map +1 -1
  4. package/lib/Scene.d.ts +6 -5
  5. package/lib/Scene.d.ts.map +1 -1
  6. package/lib/Scene.js +36 -18
  7. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
  8. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +3 -4
  9. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  10. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +7 -8
  11. package/lib/callgraph/model/CallGraph.d.ts +5 -5
  12. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  13. package/lib/callgraph/model/CallGraph.js +18 -21
  14. package/lib/callgraph/model/CallSite.d.ts +16 -6
  15. package/lib/callgraph/model/CallSite.d.ts.map +1 -1
  16. package/lib/callgraph/model/CallSite.js +48 -8
  17. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +0 -1
  18. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
  19. package/lib/callgraph/model/builder/CallGraphBuilder.js +0 -8
  20. package/lib/callgraph/pointerAnalysis/Pag.d.ts +3 -6
  21. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  22. package/lib/callgraph/pointerAnalysis/Pag.js +6 -29
  23. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +6 -15
  24. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  25. package/lib/callgraph/pointerAnalysis/PagBuilder.js +61 -85
  26. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +2 -1
  27. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  28. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +12 -8
  29. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +10 -3
  30. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -1
  31. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +20 -5
  32. package/lib/callgraph/pointerAnalysis/context/Context.d.ts +69 -0
  33. package/lib/callgraph/pointerAnalysis/context/Context.d.ts.map +1 -0
  34. package/lib/callgraph/pointerAnalysis/context/Context.js +202 -0
  35. package/lib/callgraph/pointerAnalysis/context/ContextItem.d.ts +40 -0
  36. package/lib/callgraph/pointerAnalysis/context/ContextItem.d.ts.map +1 -0
  37. package/lib/callgraph/pointerAnalysis/context/ContextItem.js +99 -0
  38. package/lib/callgraph/pointerAnalysis/context/ContextSelector.d.ts +46 -0
  39. package/lib/callgraph/pointerAnalysis/context/ContextSelector.d.ts.map +1 -0
  40. package/lib/callgraph/pointerAnalysis/context/ContextSelector.js +138 -0
  41. package/lib/core/base/Expr.d.ts.map +1 -1
  42. package/lib/core/base/Expr.js +11 -1
  43. package/lib/core/base/Local.js +1 -1
  44. package/lib/core/common/ArkIRTransformer.d.ts +2 -0
  45. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  46. package/lib/core/common/ArkIRTransformer.js +90 -0
  47. package/lib/core/common/ArkValueTransformer.d.ts +1 -1
  48. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  49. package/lib/core/common/ArkValueTransformer.js +48 -33
  50. package/lib/core/common/Builtin.d.ts.map +1 -1
  51. package/lib/core/common/Builtin.js +2 -2
  52. package/lib/core/common/DummyMainCreater.js +1 -1
  53. package/lib/core/common/IRInference.d.ts +1 -0
  54. package/lib/core/common/IRInference.d.ts.map +1 -1
  55. package/lib/core/common/IRInference.js +60 -44
  56. package/lib/core/common/ModelUtils.d.ts +1 -0
  57. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  58. package/lib/core/common/ModelUtils.js +7 -0
  59. package/lib/core/common/SdkUtils.d.ts +14 -1
  60. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  61. package/lib/core/common/SdkUtils.js +118 -24
  62. package/lib/core/common/TypeInference.d.ts +2 -1
  63. package/lib/core/common/TypeInference.d.ts.map +1 -1
  64. package/lib/core/common/TypeInference.js +21 -12
  65. package/lib/core/common/ValueUtil.d.ts +1 -0
  66. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  67. package/lib/core/common/ValueUtil.js +7 -0
  68. package/lib/core/graph/BaseExplicitGraph.d.ts +1 -0
  69. package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
  70. package/lib/core/graph/BaseExplicitGraph.js +3 -0
  71. package/lib/core/graph/Scc.js +1 -1
  72. package/lib/core/graph/builder/CfgBuilder.d.ts +2 -0
  73. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  74. package/lib/core/graph/builder/CfgBuilder.js +59 -7
  75. package/lib/core/model/ArkImport.js +1 -1
  76. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  77. package/lib/core/model/ArkMethod.js +8 -2
  78. package/lib/core/model/builder/ArkClassBuilder.js +21 -1
  79. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  80. package/lib/core/model/builder/ArkMethodBuilder.js +2 -2
  81. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  82. package/lib/core/model/builder/builderUtils.js +2 -1
  83. package/lib/index.d.ts +0 -1
  84. package/lib/index.d.ts.map +1 -1
  85. package/lib/index.js +2 -4
  86. package/lib/save/JsonPrinter.d.ts +1 -0
  87. package/lib/save/JsonPrinter.d.ts.map +1 -1
  88. package/lib/save/JsonPrinter.js +15 -5
  89. package/lib/save/arkir/ArkIRMethodPrinter.d.ts.map +1 -1
  90. package/lib/save/arkir/ArkIRMethodPrinter.js +13 -5
  91. package/lib/save/source/SourceBody.d.ts +1 -1
  92. package/lib/save/source/SourceBody.d.ts.map +1 -1
  93. package/lib/save/source/SourceBody.js +3 -2
  94. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  95. package/lib/save/source/SourceStmt.js +12 -4
  96. package/lib/save/source/SourceTransformer.d.ts +3 -3
  97. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  98. package/lib/save/source/SourceTransformer.js +11 -10
  99. package/lib/transformer/StaticSingleAssignmentFormer.js +1 -1
  100. package/package.json +7 -7
  101. package/lib/callgraph/pointerAnalysis/Context.d.ts +0 -38
  102. package/lib/callgraph/pointerAnalysis/Context.d.ts.map +0 -1
  103. package/lib/callgraph/pointerAnalysis/Context.js +0 -154
@@ -1,154 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.KLimitedContextSensitive = exports.DUMMY_CID = void 0;
18
- exports.DUMMY_CID = 0;
19
- class Context {
20
- constructor(contextElems = []) {
21
- this.contextElems = contextElems;
22
- }
23
- static newEmpty() {
24
- return new Context();
25
- }
26
- static new(contextElems) {
27
- return new Context(contextElems);
28
- }
29
- // use old context and a new element to create a new k-limited Context
30
- static newKLimitedContext(oldCtx, elem, k) {
31
- let elems = [];
32
- if (k > 0) {
33
- elems.push(elem);
34
- if (oldCtx.contextElems.length < k) {
35
- elems = elems.concat(oldCtx.contextElems);
36
- }
37
- else {
38
- elems = elems.concat(oldCtx.contextElems.slice(0, k - 1));
39
- }
40
- }
41
- return new Context(elems);
42
- }
43
- static kLimitedContext(ctx, k) {
44
- if (ctx.length() <= k) {
45
- return new Context(ctx.contextElems);
46
- }
47
- else {
48
- const elems = ctx.contextElems.slice(0, k);
49
- return new Context(elems);
50
- }
51
- }
52
- length() {
53
- return this.contextElems.length;
54
- }
55
- get(index) {
56
- if (index < 0 || index >= this.contextElems.length) {
57
- throw new Error('Index out of bounds');
58
- }
59
- return this.contextElems[index];
60
- }
61
- toString() {
62
- return this.contextElems.join('-');
63
- }
64
- }
65
- Context.sEmptyCtx = new Context([]);
66
- class ContextCache {
67
- constructor() {
68
- this.contextList = [];
69
- this.contextToIDMap = new Map();
70
- this.contextList = [];
71
- this.contextToIDMap = new Map();
72
- }
73
- getOrNewContextID(context) {
74
- let cStr = context.toString();
75
- if (this.contextToIDMap.has(cStr)) {
76
- return this.contextToIDMap.get(cStr);
77
- }
78
- else {
79
- // real cid start from 1
80
- const id = this.contextList.length;
81
- this.contextList.push(context);
82
- this.contextToIDMap.set(cStr, id);
83
- return id;
84
- }
85
- }
86
- updateContext(id, newContext, oldContext) {
87
- if (this.contextList.length < id) {
88
- return false;
89
- }
90
- this.contextList[id] = newContext;
91
- let oldCStr = oldContext.toString();
92
- let newCStr = newContext.toString();
93
- this.contextToIDMap.delete(oldCStr);
94
- this.contextToIDMap.set(newCStr, id);
95
- return true;
96
- }
97
- getContextID(context) {
98
- let cStr = context.toString();
99
- if (this.contextToIDMap.has(cStr)) {
100
- return this.contextToIDMap.get(cStr);
101
- }
102
- return undefined;
103
- }
104
- getContext(id) {
105
- if (id > this.contextList.length) {
106
- return undefined;
107
- }
108
- return this.contextList[id];
109
- }
110
- getContextList() {
111
- return this.contextList;
112
- }
113
- }
114
- class KLimitedContextSensitive {
115
- constructor(k) {
116
- this.k = k;
117
- this.ctxCache = new ContextCache();
118
- // put dummy cid
119
- this.getEmptyContextID();
120
- }
121
- emptyContext() {
122
- return new Context([]);
123
- }
124
- getEmptyContextID() {
125
- return this.getContextID(Context.newEmpty());
126
- }
127
- getContextID(context) {
128
- return this.ctxCache.getOrNewContextID(context);
129
- }
130
- getContextByID(context_id) {
131
- return this.ctxCache.getContext(context_id);
132
- }
133
- getNewContextID(callerFuncId) {
134
- return this.ctxCache.getOrNewContextID(Context.new([callerFuncId]));
135
- }
136
- getOrNewContext(callerCid, calleeFuncId, findCalleeAsTop = false) {
137
- const callerCtx = this.ctxCache.getContext(callerCid);
138
- if (!callerCtx) {
139
- throw new Error(`Context with id ${callerCid} not found.`);
140
- }
141
- const calleeNewCtx = Context.newKLimitedContext(callerCtx, calleeFuncId, this.k);
142
- if (findCalleeAsTop) {
143
- const calleeAsTopCtx = Context.newKLimitedContext(Context.sEmptyCtx, calleeFuncId, this.k);
144
- let topID = this.ctxCache.getContextID(calleeAsTopCtx);
145
- if (topID) {
146
- this.ctxCache.updateContext(topID, calleeNewCtx, calleeAsTopCtx);
147
- return topID;
148
- }
149
- }
150
- const calleeCid = this.ctxCache.getOrNewContextID(calleeNewCtx);
151
- return calleeCid;
152
- }
153
- }
154
- exports.KLimitedContextSensitive = KLimitedContextSensitive;