arkanalyzer 1.0.41 → 1.0.43

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 (110) hide show
  1. package/config/arkanalyzer.json +1 -2
  2. package/lib/Scene.d.ts.map +1 -1
  3. package/lib/Scene.js +52 -38
  4. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +11 -5
  5. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  6. package/lib/callgraph/pointerAnalysis/PTAUtils.js +42 -24
  7. package/lib/callgraph/pointerAnalysis/Pag.d.ts +6 -11
  8. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  9. package/lib/callgraph/pointerAnalysis/Pag.js +26 -23
  10. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +11 -63
  11. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  12. package/lib/callgraph/pointerAnalysis/PagBuilder.js +72 -499
  13. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  14. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +4 -2
  15. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts +24 -0
  16. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts.map +1 -0
  17. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.js +167 -0
  18. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts +26 -0
  19. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts.map +1 -0
  20. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.js +151 -0
  21. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts +15 -0
  22. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts.map +1 -0
  23. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.js +16 -0
  24. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts +25 -0
  25. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts.map +1 -0
  26. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.js +66 -0
  27. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts +37 -0
  28. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts.map +1 -0
  29. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.js +160 -0
  30. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts +68 -0
  31. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts.map +1 -0
  32. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.js +288 -0
  33. package/lib/core/base/Expr.d.ts +1 -0
  34. package/lib/core/base/Expr.d.ts.map +1 -1
  35. package/lib/core/base/Expr.js +9 -0
  36. package/lib/core/common/DummyMainCreater.js +1 -1
  37. package/lib/core/common/IRInference.d.ts +1 -1
  38. package/lib/core/common/IRInference.d.ts.map +1 -1
  39. package/lib/core/common/IRInference.js +7 -3
  40. package/lib/core/common/ModelUtils.js +1 -1
  41. package/lib/core/common/SdkUtils.d.ts +3 -2
  42. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  43. package/lib/core/common/SdkUtils.js +30 -30
  44. package/lib/core/common/TypeInference.d.ts.map +1 -1
  45. package/lib/core/common/TypeInference.js +7 -5
  46. package/lib/core/dataflow/DataflowSolver.js +3 -3
  47. package/lib/core/dataflow/UndefinedVariable.js +2 -2
  48. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  49. package/lib/core/graph/BasicBlock.js +9 -4
  50. package/lib/core/graph/Cfg.d.ts.map +1 -1
  51. package/lib/core/graph/Cfg.js +4 -1
  52. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  53. package/lib/core/graph/builder/CfgBuilder.js +4 -4
  54. package/lib/core/graph/builder/ConditionBuilder.d.ts +2 -1
  55. package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
  56. package/lib/core/graph/builder/ConditionBuilder.js +8 -4
  57. package/lib/core/graph/builder/TrapBuilder.d.ts +19 -1
  58. package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
  59. package/lib/core/graph/builder/TrapBuilder.js +195 -68
  60. package/lib/core/model/ArkClass.d.ts.map +1 -1
  61. package/lib/core/model/ArkClass.js +2 -1
  62. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  63. package/lib/core/model/ArkMethod.js +3 -4
  64. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  65. package/lib/core/model/builder/ArkClassBuilder.js +24 -20
  66. package/lib/core/model/builder/ArkImportBuilder.js +28 -25
  67. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  68. package/lib/core/model/builder/ArkMethodBuilder.js +1 -2
  69. package/lib/core/model/builder/BodyBuilder.js +1 -1
  70. package/lib/pass/Context.d.ts +47 -0
  71. package/lib/pass/Context.d.ts.map +1 -0
  72. package/lib/pass/Context.js +72 -0
  73. package/lib/pass/Dispatcher.d.ts +102 -0
  74. package/lib/pass/Dispatcher.d.ts.map +1 -0
  75. package/lib/pass/Dispatcher.js +202 -0
  76. package/lib/pass/Pass.d.ts +83 -0
  77. package/lib/pass/Pass.d.ts.map +1 -0
  78. package/lib/pass/Pass.js +95 -0
  79. package/lib/pass/ScenePassMgr.d.ts +73 -0
  80. package/lib/pass/ScenePassMgr.d.ts.map +1 -0
  81. package/lib/pass/ScenePassMgr.js +156 -0
  82. package/lib/pass/validators/Exprs.d.ts +9 -0
  83. package/lib/pass/validators/Exprs.d.ts.map +1 -0
  84. package/lib/pass/validators/Exprs.js +40 -0
  85. package/lib/pass/validators/Models.d.ts +14 -0
  86. package/lib/pass/validators/Models.d.ts.map +1 -0
  87. package/lib/pass/validators/Models.js +42 -0
  88. package/lib/pass/validators/SceneValidator.d.ts +19 -0
  89. package/lib/pass/validators/SceneValidator.d.ts.map +1 -0
  90. package/lib/pass/validators/SceneValidator.js +77 -0
  91. package/lib/pass/validators/Stmts.d.ts +7 -0
  92. package/lib/pass/validators/Stmts.d.ts.map +1 -0
  93. package/lib/pass/validators/Stmts.js +36 -0
  94. package/lib/pass/validators/Validator.d.ts +207 -0
  95. package/lib/pass/validators/Validator.d.ts.map +1 -0
  96. package/lib/pass/validators/Validator.js +343 -0
  97. package/lib/pass/validators/Values.d.ts +7 -0
  98. package/lib/pass/validators/Values.d.ts.map +1 -0
  99. package/lib/pass/validators/Values.js +34 -0
  100. package/lib/save/JsonPrinter.d.ts.map +1 -1
  101. package/lib/save/JsonPrinter.js +26 -102
  102. package/lib/save/source/SourceStmt.d.ts +1 -0
  103. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  104. package/lib/save/source/SourceStmt.js +5 -8
  105. package/lib/utils/FileUtils.d.ts.map +1 -1
  106. package/lib/utils/FileUtils.js +13 -6
  107. package/lib/utils/ValueAsserts.d.ts +9 -0
  108. package/lib/utils/ValueAsserts.d.ts.map +1 -0
  109. package/lib/utils/ValueAsserts.js +89 -0
  110. package/package.json +2 -2
@@ -0,0 +1,73 @@
1
+ import { AnyKey, Context, CtxArg, UpperRoot } from './Context';
2
+ import { Dispatcher } from './Dispatcher';
3
+ import { ClassPass, FilePass, MethodPass } from './Pass';
4
+ import type { Scene } from '../Scene';
5
+ import type { ArkFile } from '../core/model/ArkFile';
6
+ import type { ArkClass } from '../core/model/ArkClass';
7
+ import type { ArkMethod } from '../core/model/ArkMethod';
8
+ /**
9
+ * Represents a specialized context class that extends the base Context class with specific types.
10
+ * Provides functionality to access the root context within a hierarchical structure.
11
+ * The SceneCtx is bound to a UpperRoot and CtxArg, defining its operational scope.
12
+ * The root method retrieves the top-level SceneCtx itself.
13
+ */
14
+ export declare class SceneCtx extends Context<UpperRoot, CtxArg> {
15
+ constructor();
16
+ root(): SceneCtx;
17
+ }
18
+ /**
19
+ * Represents the properties required for configuring various passes in a system.
20
+ * The PassProps interface is designed to hold arrays of different types of passes,
21
+ * specifically file-level, class-level, and method-level passes. Each pass type
22
+ * is identified by a unique key and associated with specific configurations or rules.
23
+ * These passes are used to define how certain operations or validations should be
24
+ * applied at different levels of granularity within the system.
25
+ */
26
+ export interface PassProps {
27
+ file: AnyKey<FilePass>[];
28
+ klass: AnyKey<ClassPass>[];
29
+ method: AnyKey<MethodPass>[];
30
+ }
31
+ /**
32
+ * Represents the properties for a selector configuration.
33
+ * Provides options to define callback functions for selecting files, classes, and methods.
34
+ * The file property allows specifying a function to select files from a given scene.
35
+ * The klass property allows specifying a function to select classes from a given file.
36
+ * The method property allows specifying a function to select methods from a given class.
37
+ */
38
+ export interface SelectorProps {
39
+ file?: (s: Scene) => ArkFile[];
40
+ klass?: (s: ArkFile) => ArkClass[];
41
+ method?: (s: ArkClass) => ArkMethod[];
42
+ }
43
+ /**
44
+ * Represents the properties for configuring a scene pass manager.
45
+ *
46
+ * The SceneProps interface allows defining optional configurations for a scene,
47
+ * including rendering passes, selector properties, and a dispatcher implementation.
48
+ *
49
+ * The passes property defines the configuration for rendering stages or phases within the scene.
50
+ *
51
+ * The selectors property provides options for selecting elements or components within the scene.
52
+ *
53
+ * The dispatcher property specifies the dispatcher class responsible for handling events or actions
54
+ * within the scene, defaulting to the base Dispatcher type if not provided.
55
+ */
56
+ export interface SceneProps {
57
+ passes?: PassProps;
58
+ selectors?: SelectorProps;
59
+ dispatcher?: typeof Dispatcher;
60
+ }
61
+ export declare class ScenePassMgr {
62
+ private passes;
63
+ private selectors?;
64
+ private dispatcher?;
65
+ private sctx;
66
+ constructor(props: SceneProps);
67
+ sceneContext(): SceneCtx;
68
+ run(scene: Scene): void;
69
+ private iterFile;
70
+ private iterClass;
71
+ private iterMethod;
72
+ }
73
+ //# sourceMappingURL=ScenePassMgr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScenePassMgr.d.ts","sourceRoot":"","sources":["../../src/pass/ScenePassMgr.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAY,SAAS,EAAuB,QAAQ,EAAa,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIzD;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;;IAKpD,IAAI,IAAI,QAAQ;CAGnB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IAEtB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAEzB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;IAE3B,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAA;CAC/B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAE1B,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;IAE/B,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,EAAE,CAAC;IAEnC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,SAAS,EAAE,CAAA;CACxC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACvB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC;CAClC;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,MAAM,CAIZ;IACF,OAAO,CAAC,SAAS,CAAC,CAA4B;IAC9C,OAAO,CAAC,UAAU,CAAC,CAAiC;IACpD,OAAO,CAAC,IAAI,CAA4B;gBAE5B,KAAK,EAAE,UAAU;IAY7B,YAAY,IAAI,QAAQ;IAIxB,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAavB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,UAAU;CAgBrB"}
@@ -0,0 +1,156 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ScenePassMgr = exports.SceneCtx = void 0;
41
+ const Context_1 = require("./Context");
42
+ const logger_1 = __importStar(require("../utils/logger"));
43
+ const Dispatcher_1 = require("./Dispatcher");
44
+ const Pass_1 = require("./Pass");
45
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'SceneMgr');
46
+ /**
47
+ * Represents a specialized context class that extends the base Context class with specific types.
48
+ * Provides functionality to access the root context within a hierarchical structure.
49
+ * The SceneCtx is bound to a UpperRoot and CtxArg, defining its operational scope.
50
+ * The root method retrieves the top-level SceneCtx itself.
51
+ */
52
+ class SceneCtx extends Context_1.Context {
53
+ constructor() {
54
+ super(Context_1.UpperRoot.getInstance());
55
+ }
56
+ root() {
57
+ return this;
58
+ }
59
+ }
60
+ exports.SceneCtx = SceneCtx;
61
+ class ScenePassMgr {
62
+ constructor(props) {
63
+ this.passes = {
64
+ file: [],
65
+ klass: [],
66
+ method: [],
67
+ };
68
+ this.selectors = undefined;
69
+ this.dispatcher = Dispatcher_1.Dispatcher;
70
+ this.sctx = new SceneCtx();
71
+ if (props.passes) {
72
+ this.passes = props.passes;
73
+ }
74
+ if (props.selectors) {
75
+ this.selectors = props.selectors;
76
+ }
77
+ if (props.dispatcher) {
78
+ this.dispatcher = props.dispatcher;
79
+ }
80
+ }
81
+ sceneContext() {
82
+ return this.sctx;
83
+ }
84
+ run(scene) {
85
+ var _a;
86
+ logger.info('run scene');
87
+ let files;
88
+ if ((_a = this.selectors) === null || _a === void 0 ? void 0 : _a.file) {
89
+ files = this.selectors.file(scene);
90
+ }
91
+ else {
92
+ files = scene.getFiles();
93
+ }
94
+ for (let file of files) {
95
+ this.iterFile(file);
96
+ }
97
+ }
98
+ iterFile(file) {
99
+ var _a;
100
+ let fctx = new Pass_1.FileCtx(this.sctx);
101
+ for (let P of this.passes.file) {
102
+ let p = new P();
103
+ if (p.run(file, fctx) === 1 /* FallAction.Break */) {
104
+ break;
105
+ }
106
+ }
107
+ let classes;
108
+ if ((_a = this.selectors) === null || _a === void 0 ? void 0 : _a.klass) {
109
+ classes = this.selectors.klass(file);
110
+ }
111
+ else {
112
+ classes = file.getClasses();
113
+ }
114
+ for (let cls of classes) {
115
+ this.iterClass(cls, fctx);
116
+ }
117
+ }
118
+ iterClass(cls, fctx) {
119
+ var _a;
120
+ let cctx = new Pass_1.ClassCtx(fctx);
121
+ for (let P of this.passes.klass) {
122
+ let p = new P();
123
+ if (p.run(cls, cctx) === 1 /* FallAction.Break */) {
124
+ break;
125
+ }
126
+ }
127
+ let methods;
128
+ if ((_a = this.selectors) === null || _a === void 0 ? void 0 : _a.method) {
129
+ methods = this.selectors.method(cls);
130
+ }
131
+ else {
132
+ methods = cls.getMethods();
133
+ }
134
+ for (let mtd of methods) {
135
+ this.iterMethod(mtd, cctx);
136
+ }
137
+ }
138
+ iterMethod(mtd, cctx) {
139
+ var _a;
140
+ let mctx = new Pass_1.MethodCtx(cctx);
141
+ for (let P of this.passes.method) {
142
+ let p = new P();
143
+ if (p.run(mtd, mctx) === 1 /* FallAction.Break */) {
144
+ break;
145
+ }
146
+ }
147
+ if (this.dispatcher) {
148
+ let stmts = ((_a = mtd.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts()) || [];
149
+ let dispatcher = new this.dispatcher(mctx);
150
+ for (let s of stmts) {
151
+ dispatcher.dispatchStmt(mtd, s);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ exports.ScenePassMgr = ScenePassMgr;
@@ -0,0 +1,9 @@
1
+ import { AbstractInvokeExpr } from '../../core/base/Expr';
2
+ import { SummaryReporter, ValueValidator } from './Validator';
3
+ import { Value } from '../../core/base/Value';
4
+ export declare class AbsInvokeValidator extends ValueValidator<AbstractInvokeExpr> {
5
+ private static readonly INSTANCE;
6
+ validate(value: AbstractInvokeExpr, ctx: SummaryReporter): void;
7
+ checkArg(arg: Value, index: number, ctx: SummaryReporter): void;
8
+ }
9
+ //# sourceMappingURL=Exprs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Exprs.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/Exprs.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAM9C,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,kBAAkB,CAAC;IACtE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IAE5D,QAAQ,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;IAM/D,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAWlE"}
@@ -0,0 +1,40 @@
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.AbsInvokeValidator = void 0;
18
+ const Expr_1 = require("../../core/base/Expr");
19
+ const Validator_1 = require("./Validator");
20
+ const Constant_1 = require("../../core/base/Constant");
21
+ const Local_1 = require("../../core/base/Local");
22
+ class AbsInvokeValidator extends Validator_1.ValueValidator {
23
+ validate(value, ctx) {
24
+ value.getArgs().forEach((arg, i) => {
25
+ this.checkArg(arg, i, ctx);
26
+ });
27
+ }
28
+ checkArg(arg, index, ctx) {
29
+ if (!((arg instanceof Local_1.Local) || (arg instanceof Constant_1.Constant))) {
30
+ ctx.error(`arg ${index} is not local or constant`);
31
+ }
32
+ }
33
+ }
34
+ exports.AbsInvokeValidator = AbsInvokeValidator;
35
+ AbsInvokeValidator.INSTANCE = new AbsInvokeValidator();
36
+ (() => {
37
+ AbsInvokeValidator.register([Expr_1.AbstractInvokeExpr, (v, ctx, mtd) => {
38
+ AbsInvokeValidator.INSTANCE.run(v, ctx, mtd);
39
+ }]);
40
+ })();
@@ -0,0 +1,14 @@
1
+ import { ArkClass } from '../../core/model/ArkClass';
2
+ import { ClassValidator, FileValidator, MethodValidator, SummaryReporter } from './Validator';
3
+ import { ArkFile } from '../../core/model/ArkFile';
4
+ import { ArkMethod } from '../../core/model/ArkMethod';
5
+ export declare class ArkMethodValidator extends MethodValidator {
6
+ validate(mtd: ArkMethod, ctx: SummaryReporter): void;
7
+ }
8
+ export declare class ArkClassValidator extends ClassValidator {
9
+ validate(cls: ArkClass, ctx: SummaryReporter): void;
10
+ }
11
+ export declare class ArkFileValidator extends FileValidator {
12
+ validate(file: ArkFile, ctx: SummaryReporter): void;
13
+ }
14
+ //# sourceMappingURL=Models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/Models.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,qBAAa,kBAAmB,SAAQ,eAAe;IACnD,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAMvD;AAED,qBAAa,iBAAkB,SAAQ,cAAc;IACjD,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAMtD;AAED,qBAAa,gBAAiB,SAAQ,aAAa;IAC/C,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAEtD"}
@@ -0,0 +1,42 @@
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.ArkFileValidator = exports.ArkClassValidator = exports.ArkMethodValidator = void 0;
18
+ const Validator_1 = require("./Validator");
19
+ const ArkError_1 = require("../../core/common/ArkError");
20
+ class ArkMethodValidator extends Validator_1.MethodValidator {
21
+ validate(mtd, ctx) {
22
+ const err = mtd.validate();
23
+ if (err.errCode !== ArkError_1.ArkErrorCode.OK) {
24
+ ctx.error(`code: ${err.errCode} msg: ${err.errMsg}`);
25
+ }
26
+ }
27
+ }
28
+ exports.ArkMethodValidator = ArkMethodValidator;
29
+ class ArkClassValidator extends Validator_1.ClassValidator {
30
+ validate(cls, ctx) {
31
+ const err = cls.validate();
32
+ if (err.errCode !== ArkError_1.ArkErrorCode.OK) {
33
+ ctx.error(`code: ${err.errCode} msg: ${err.errMsg}`);
34
+ }
35
+ }
36
+ }
37
+ exports.ArkClassValidator = ArkClassValidator;
38
+ class ArkFileValidator extends Validator_1.FileValidator {
39
+ validate(file, ctx) {
40
+ }
41
+ }
42
+ exports.ArkFileValidator = ArkFileValidator;
@@ -0,0 +1,19 @@
1
+ import { Scene } from '../../Scene';
2
+ import { SceneSummary } from './Validator';
3
+ import './Exprs';
4
+ import './Stmts';
5
+ import './Values';
6
+ /**
7
+ * The SceneValidator class is responsible for validating a given scene by leveraging the ScenePassMgr.
8
+ * It sets up a context for validation, executes the validation process, and retrieves the summary of the validation.
9
+ *
10
+ * The validate method initializes a new SceneSummary instance, associates it with the current scene context,
11
+ * runs the validation process using the configured manager, and finally returns the generated summary.
12
+ *
13
+ * This class ensures that the validation logic is encapsulated and provides a clean interface for processing scenes.
14
+ */
15
+ export declare class SceneValidator {
16
+ private mgr;
17
+ validate(scene: Scene): SceneSummary;
18
+ }
19
+ //# sourceMappingURL=SceneValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneValidator.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/SceneValidator.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAEH,YAAY,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,SAAS,CAAC;AACjB,OAAO,SAAS,CAAC;AACjB,OAAO,UAAU,CAAC;AAKlB;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,GAAG,CAOR;IAEH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY;CAOvC"}
@@ -0,0 +1,77 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.SceneValidator = void 0;
41
+ const ScenePassMgr_1 = require("../ScenePassMgr");
42
+ const logger_1 = __importStar(require("../../utils/logger"));
43
+ const Validator_1 = require("./Validator");
44
+ const Models_1 = require("./Models");
45
+ require("./Exprs");
46
+ require("./Stmts");
47
+ require("./Values");
48
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'SceneValidator');
49
+ /**
50
+ * The SceneValidator class is responsible for validating a given scene by leveraging the ScenePassMgr.
51
+ * It sets up a context for validation, executes the validation process, and retrieves the summary of the validation.
52
+ *
53
+ * The validate method initializes a new SceneSummary instance, associates it with the current scene context,
54
+ * runs the validation process using the configured manager, and finally returns the generated summary.
55
+ *
56
+ * This class ensures that the validation logic is encapsulated and provides a clean interface for processing scenes.
57
+ */
58
+ class SceneValidator {
59
+ constructor() {
60
+ this.mgr = new ScenePassMgr_1.ScenePassMgr({
61
+ passes: {
62
+ file: [Models_1.ArkFileValidator],
63
+ klass: [Models_1.ArkClassValidator],
64
+ method: [Models_1.ArkMethodValidator],
65
+ },
66
+ dispatcher: Validator_1.ArkValidatorRegistry,
67
+ });
68
+ }
69
+ validate(scene) {
70
+ let summary = new Validator_1.SceneSummary();
71
+ this.mgr.sceneContext().set(Validator_1.SceneSummary, summary);
72
+ this.mgr.run(scene);
73
+ logger.info('validate');
74
+ return this.mgr.sceneContext().remove(Validator_1.SceneSummary);
75
+ }
76
+ }
77
+ exports.SceneValidator = SceneValidator;
@@ -0,0 +1,7 @@
1
+ import { StmtValidator, SummaryReporter } from './Validator';
2
+ import { ArkAssignStmt } from '../../core/base/Stmt';
3
+ export declare class AssignStmtValidator extends StmtValidator<ArkAssignStmt> {
4
+ private static readonly INSTANCE;
5
+ validate(value: ArkAssignStmt, ctx: SummaryReporter): void;
6
+ }
7
+ //# sourceMappingURL=Stmts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stmts.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/Stmts.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,aAAa,CAAC;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAE7D,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAY7D"}
@@ -0,0 +1,36 @@
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.AssignStmtValidator = void 0;
18
+ const Validator_1 = require("./Validator");
19
+ const Stmt_1 = require("../../core/base/Stmt");
20
+ const Ref_1 = require("../../core/base/Ref");
21
+ const Local_1 = require("../../core/base/Local");
22
+ class AssignStmtValidator extends Validator_1.StmtValidator {
23
+ validate(value, ctx) {
24
+ let left = value.getLeftOp();
25
+ if (!((left instanceof Local_1.Local) || (left instanceof Ref_1.AbstractFieldRef))) {
26
+ ctx.error(`must assign to local or field_ref`);
27
+ }
28
+ }
29
+ }
30
+ exports.AssignStmtValidator = AssignStmtValidator;
31
+ AssignStmtValidator.INSTANCE = new AssignStmtValidator();
32
+ (() => {
33
+ AssignStmtValidator.register([Stmt_1.ArkAssignStmt, (v, ctx, mtd) => {
34
+ AssignStmtValidator.INSTANCE.run(v, ctx, mtd);
35
+ }]);
36
+ })();