arkanalyzer 1.0.42 → 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 (70) hide show
  1. package/lib/Scene.d.ts.map +1 -1
  2. package/lib/Scene.js +44 -37
  3. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +11 -5
  4. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  5. package/lib/callgraph/pointerAnalysis/PTAUtils.js +42 -24
  6. package/lib/callgraph/pointerAnalysis/Pag.d.ts +6 -11
  7. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  8. package/lib/callgraph/pointerAnalysis/Pag.js +26 -23
  9. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +11 -63
  10. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  11. package/lib/callgraph/pointerAnalysis/PagBuilder.js +62 -495
  12. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  13. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +4 -2
  14. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts +24 -0
  15. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.d.ts.map +1 -0
  16. package/lib/callgraph/pointerAnalysis/plugins/ContainerPlugin.js +167 -0
  17. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts +26 -0
  18. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.d.ts.map +1 -0
  19. package/lib/callgraph/pointerAnalysis/plugins/FunctionPlugin.js +151 -0
  20. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts +15 -0
  21. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.d.ts.map +1 -0
  22. package/lib/callgraph/pointerAnalysis/plugins/IPagPlugin.js +16 -0
  23. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts +25 -0
  24. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.d.ts.map +1 -0
  25. package/lib/callgraph/pointerAnalysis/plugins/PluginManager.js +66 -0
  26. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts +37 -0
  27. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts.map +1 -0
  28. package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.js +160 -0
  29. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts +68 -0
  30. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.d.ts.map +1 -0
  31. package/lib/callgraph/pointerAnalysis/plugins/StoragePlugin.js +288 -0
  32. package/lib/core/common/DummyMainCreater.js +1 -1
  33. package/lib/core/common/SdkUtils.d.ts +1 -1
  34. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  35. package/lib/core/common/SdkUtils.js +18 -18
  36. package/lib/core/common/TypeInference.d.ts.map +1 -1
  37. package/lib/core/common/TypeInference.js +2 -2
  38. package/lib/core/graph/builder/CfgBuilder.js +1 -1
  39. package/lib/core/graph/builder/ConditionBuilder.js +1 -1
  40. package/lib/core/model/ArkClass.d.ts.map +1 -1
  41. package/lib/core/model/ArkClass.js +2 -1
  42. package/lib/core/model/builder/BodyBuilder.js +1 -1
  43. package/lib/pass/Dispatcher.d.ts +2 -2
  44. package/lib/pass/Dispatcher.d.ts.map +1 -1
  45. package/lib/pass/Pass.d.ts +3 -3
  46. package/lib/pass/Pass.d.ts.map +1 -1
  47. package/lib/pass/ScenePassMgr.d.ts +4 -4
  48. package/lib/pass/ScenePassMgr.d.ts.map +1 -1
  49. package/lib/pass/validators/Exprs.d.ts +9 -0
  50. package/lib/pass/validators/Exprs.d.ts.map +1 -0
  51. package/lib/pass/validators/Exprs.js +40 -0
  52. package/lib/pass/validators/Models.d.ts +14 -0
  53. package/lib/pass/validators/Models.d.ts.map +1 -0
  54. package/lib/pass/validators/Models.js +42 -0
  55. package/lib/pass/validators/SceneValidator.d.ts +19 -0
  56. package/lib/pass/validators/SceneValidator.d.ts.map +1 -0
  57. package/lib/pass/validators/SceneValidator.js +77 -0
  58. package/lib/pass/validators/Stmts.d.ts +7 -0
  59. package/lib/pass/validators/Stmts.d.ts.map +1 -0
  60. package/lib/pass/validators/Stmts.js +36 -0
  61. package/lib/pass/{SceneValidator.d.ts → validators/Validator.d.ts} +100 -108
  62. package/lib/pass/validators/Validator.d.ts.map +1 -0
  63. package/lib/pass/{SceneValidator.js → validators/Validator.js} +147 -143
  64. package/lib/pass/validators/Values.d.ts +7 -0
  65. package/lib/pass/validators/Values.d.ts.map +1 -0
  66. package/lib/pass/validators/Values.js +34 -0
  67. package/lib/save/source/SourceStmt.js +1 -1
  68. package/lib/utils/FileUtils.js +1 -1
  69. package/package.json +2 -2
  70. package/lib/pass/SceneValidator.d.ts.map +0 -1
@@ -1,16 +1,39 @@
1
- import { Scene } from '../Scene';
2
- import { Dispatch, Dispatcher, StmtInit, StmtTy, ValueInit, ValueTy } from './Dispatcher';
3
- import { ClassCtx, ClassPass, FallAction, FileCtx, FilePass, MethodCtx, MethodPass } from './Pass';
4
- import { ArkFile } from '../core/model/ArkFile';
5
- import { ArkClass } from '../core/model/ArkClass';
6
- import { ArkMethod } from '../core/model/ArkMethod';
7
- import { Value } from '../core/base/Value';
8
- import { Stmt } from '../core/base/Stmt';
1
+ import { ClassCtx, ClassPass, FallAction, FileCtx, FilePass, MethodCtx, MethodPass } from '../Pass';
2
+ import type { ArkFile } from '../../core/model/ArkFile';
3
+ import type { ArkClass } from '../../core/model/ArkClass';
4
+ import type { ArkMethod } from '../../core/model/ArkMethod';
5
+ import type { Value } from '../../core/base/Value';
6
+ import type { Stmt } from '../../core/base/Stmt';
7
+ import type { StmtInit, StmtTy, ValueInit, ValueTy } from '../Dispatcher';
8
+ import { Dispatch, Dispatcher } from '../Dispatcher';
9
9
  export declare const enum SummaryLevel {
10
10
  info = 0,
11
11
  warn = 1,
12
12
  error = 2
13
13
  }
14
+ /**
15
+ * Represents a summary message with an associated level and content.
16
+ * The SummaryMsg class is used to encapsulate messages that have a specific severity or importance level.
17
+ * It provides a way to associate a textual message with a defined level, making it suitable for logging, notifications, or summaries.
18
+ * The constructor initializes the message and its level, ensuring both are explicitly defined at creation.
19
+ */
20
+ export declare class SummaryMsg {
21
+ level: SummaryLevel;
22
+ msg: string;
23
+ constructor(level: SummaryLevel, msg: string);
24
+ }
25
+ /**
26
+ * Interface representing a summary reporter for logging messages with different severity levels.
27
+ * Provides methods to log informational, warning, and error messages.
28
+ * The `info` method is used to log general informational messages.
29
+ * The `warn` method is used to log warning messages that indicate potential issues.
30
+ * The `error` method is used to log error messages that represent critical problems.
31
+ */
32
+ export interface SummaryReporter {
33
+ info(msg: string): void;
34
+ warn(msg: string): void;
35
+ error(msg: string): void;
36
+ }
14
37
  /**
15
38
  * Abstract class representing a statement validator.
16
39
  * Provides a mechanism to validate statements of a specific type within a given context.
@@ -60,45 +83,27 @@ export declare class ArkValidatorRegistry extends Dispatcher {
60
83
  static value(init: ValueInit): void;
61
84
  }
62
85
  /**
63
- * Interface representing a summary reporter for logging messages with different severity levels.
64
- * Provides methods to log informational, warning, and error messages.
65
- * The `info` method is used to log general informational messages.
66
- * The `warn` method is used to log warning messages that indicate potential issues.
67
- * The `error` method is used to log error messages that represent critical problems.
68
- */
69
- export interface SummaryReporter {
70
- info(msg: string): void;
71
- warn(msg: string): void;
72
- error(msg: string): void;
73
- }
74
- /**
75
- * An abstract class that extends FilePass and provides a framework for validating files.
76
- * The FileValidator class is designed to be subclassed with specific validation logic
77
- * implemented in the `validate` method. It provides a default implementation of the `run`
78
- * method, which processes a file and submits validation results (info, warning, or error)
79
- * to a summary object associated with the file context.
86
+ * Represents a summary of a method, capturing various messages and associations with values and statements.
87
+ * This class provides methods to submit messages and associate them with specific values or statements.
88
+ * It also supports retrieving or creating a method summary within a given context.
80
89
  */
81
- export declare abstract class FileValidator extends FilePass {
82
- /**
83
- * Validates the given file and reports the results through the provided context.
84
- *
85
- * @param file The file to be validated, represented as an ArkFile object.
86
- * @param ctx The context used for reporting validation results, implemented as a SummaryReporter.
87
- * @return The result of the validation process.
88
- */
89
- abstract validate(file: ArkFile, ctx: SummaryReporter): void;
90
- run(file: ArkFile, ctx: FileCtx): void;
91
- }
92
- export declare abstract class ClassValidator extends ClassPass {
90
+ export declare class MethodSummary {
91
+ name: string;
92
+ values: Map<Value, SummaryMsg[]>;
93
+ stmts: Map<Stmt, SummaryMsg[]>;
94
+ msgList: SummaryMsg[];
95
+ constructor();
96
+ submit(msg: SummaryMsg): void;
97
+ submitValue(value: Value, msg: SummaryMsg): void;
98
+ submitStmt(stmt: Stmt, msg: SummaryMsg): void;
93
99
  /**
94
- * Validates the given class and reports any issues found during validation.
100
+ * Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
95
101
  *
96
- * @param cls The class to be validated. This should be an instance of ArkClass.
97
- * @param ctx The context used for reporting validation results or issues. This should be an instance of SummaryReporter.
98
- * @return This method does not return any value.
102
+ * @param ctx The method context in which the MethodSummary is stored or will be created.
103
+ * @param mtd The ArkMethod for which the MethodSummary is being retrieved or created.
104
+ * @return The existing or newly created MethodSummary associated with the provided context and method.
99
105
  */
100
- abstract validate(cls: ArkClass, ctx: SummaryReporter): void;
101
- run(cls: ArkClass, ctx: ClassCtx): FallAction | void;
106
+ static getOrNew(ctx: MethodCtx, mtd: ArkMethod): MethodSummary;
102
107
  }
103
108
  export declare abstract class MethodValidator extends MethodPass {
104
109
  /**
@@ -111,37 +116,6 @@ export declare abstract class MethodValidator extends MethodPass {
111
116
  abstract validate(mtd: ArkMethod, ctx: SummaryReporter): void;
112
117
  run(mtd: ArkMethod, ctx: MethodCtx): FallAction | void;
113
118
  }
114
- /**
115
- * Represents a summary of a scene, containing metadata and associated file summaries.
116
- * The name property provides a default identifier for the scene summary.
117
- * The files property maintains a mapping of ArkFile instances to their corresponding FileSummary objects.
118
- * This class is used to encapsulate and manage information about a scene and its related files.
119
- */
120
- export declare class SceneSummary {
121
- name: string;
122
- files: Map<ArkFile, FileSummary>;
123
- }
124
- /**
125
- * Represents a summary of a file containing information about classes and messages.
126
- * Provides methods to manage and retrieve file summaries within a given context.
127
- * The class maintains a collection of messages and a mapping of classes to their summaries.
128
- * It supports operations to submit new messages and retrieve or create summaries for files.
129
- */
130
- export declare class FileSummary {
131
- name: string;
132
- classes: Map<ArkClass, ClassSummary>;
133
- msgList: SummaryMsg[];
134
- constructor();
135
- submit(msg: SummaryMsg): void;
136
- /**
137
- * Retrieves an existing FileSummary instance from the given context or creates a new one if it does not exist.
138
- *
139
- * @param ctx The context object that holds the FileSummary instance. It is used to check if a FileSummary already exists.
140
- * @param file The ArkFile object for which the FileSummary is being retrieved or created.
141
- * @return The existing or newly created FileSummary instance associated with the provided file.
142
- */
143
- static getOrNew(ctx: FileCtx, file: ArkFile): FileSummary;
144
- }
145
119
  /**
146
120
  * Represents a summary of a class, containing its name, associated methods, and messages.
147
121
  * Provides functionality to submit messages and retrieve or create a ClassSummary instance.
@@ -165,51 +139,69 @@ export declare class ClassSummary {
165
139
  */
166
140
  static getOrNew(ctx: ClassCtx, cls: ArkClass): ClassSummary;
167
141
  }
168
- /**
169
- * Represents a summary message with an associated level and content.
170
- * The SummaryMsg class is used to encapsulate messages that have a specific severity or importance level.
171
- * It provides a way to associate a textual message with a defined level, making it suitable for logging, notifications, or summaries.
172
- * The constructor initializes the message and its level, ensuring both are explicitly defined at creation.
173
- */
174
- export declare class SummaryMsg {
175
- level: SummaryLevel;
176
- msg: string;
177
- constructor(level: SummaryLevel, msg: string);
142
+ export declare abstract class ClassValidator extends ClassPass {
143
+ /**
144
+ * Validates the given class and reports any issues found during validation.
145
+ *
146
+ * @param cls The class to be validated. This should be an instance of ArkClass.
147
+ * @param ctx The context used for reporting validation results or issues. This should be an instance of SummaryReporter.
148
+ * @return This method does not return any value.
149
+ */
150
+ abstract validate(cls: ArkClass, ctx: SummaryReporter): void;
151
+ run(cls: ArkClass, ctx: ClassCtx): FallAction | void;
178
152
  }
179
153
  /**
180
- * Represents a summary of a method, capturing various messages and associations with values and statements.
181
- * This class provides methods to submit messages and associate them with specific values or statements.
182
- * It also supports retrieving or creating a method summary within a given context.
154
+ * Represents a summary of a file containing information about classes and messages.
155
+ * Provides methods to manage and retrieve file summaries within a given context.
156
+ * The class maintains a collection of messages and a mapping of classes to their summaries.
157
+ * It supports operations to submit new messages and retrieve or create summaries for files.
183
158
  */
184
- export declare class MethodSummary {
159
+ export declare class FileSummary {
185
160
  name: string;
186
- values: Map<Value, SummaryMsg[]>;
187
- stmts: Map<Stmt, SummaryMsg[]>;
161
+ classes: Map<ArkClass, ClassSummary>;
188
162
  msgList: SummaryMsg[];
189
163
  constructor();
190
164
  submit(msg: SummaryMsg): void;
191
- submitValue(value: Value, msg: SummaryMsg): void;
192
- submitStmt(stmt: Stmt, msg: SummaryMsg): void;
193
165
  /**
194
- * Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
166
+ * Retrieves an existing FileSummary instance from the given context or creates a new one if it does not exist.
195
167
  *
196
- * @param ctx The method context in which the MethodSummary is stored or will be created.
197
- * @param mtd The ArkMethod for which the MethodSummary is being retrieved or created.
198
- * @return The existing or newly created MethodSummary associated with the provided context and method.
168
+ * @param ctx The context object that holds the FileSummary instance. It is used to check if a FileSummary already exists.
169
+ * @param file The ArkFile object for which the FileSummary is being retrieved or created.
170
+ * @return The existing or newly created FileSummary instance associated with the provided file.
199
171
  */
200
- static getOrNew(ctx: MethodCtx, mtd: ArkMethod): MethodSummary;
172
+ static getOrNew(ctx: FileCtx, file: ArkFile): FileSummary;
173
+ }
174
+ export declare abstract class FileValidator extends FilePass {
175
+ /**
176
+ * Validates the given file and reports the results through the provided context.
177
+ *
178
+ * @param file The file to be validated, represented as an ArkFile object.
179
+ * @param ctx The context used for reporting validation results, implemented as a SummaryReporter.
180
+ * @return The result of the validation process.
181
+ */
182
+ abstract validate(file: ArkFile, ctx: SummaryReporter): void;
183
+ run(file: ArkFile, ctx: FileCtx): void;
201
184
  }
202
185
  /**
203
- * The SceneValidator class is responsible for validating a given scene by leveraging the ScenePassMgr.
204
- * It sets up a context for validation, executes the validation process, and retrieves the summary of the validation.
205
- *
206
- * The validate method initializes a new SceneSummary instance, associates it with the current scene context,
207
- * runs the validation process using the configured manager, and finally returns the generated summary.
208
- *
209
- * This class ensures that the validation logic is encapsulated and provides a clean interface for processing scenes.
186
+ * Represents a summary of a scene, containing metadata and associated file summaries.
187
+ * The name property provides a default identifier for the scene summary.
188
+ * The files property maintains a mapping of ArkFile instances to their corresponding FileSummary objects.
189
+ * This class is used to encapsulate and manage information about a scene and its related files.
210
190
  */
211
- export declare class SceneValidator {
212
- private mgr;
213
- validate(scene: Scene): SceneSummary;
191
+ export declare class SceneSummary {
192
+ name: string;
193
+ files: Map<ArkFile, FileSummary>;
194
+ /**
195
+ * Checks if the current instance is in an acceptable state.
196
+ * @return {boolean} - Returns true if the files collection is empty, indicating an acceptable state; otherwise, false.
197
+ */
198
+ isOk(): boolean;
199
+ /**
200
+ * Dumps the scene summary and details to the log based on the specified level.
201
+ * @param {SummaryLevel} [level=SummaryLevel.info] - The minimum level of messages to include in the log. Defaults to SummaryLevel.info.
202
+ * @return {void}
203
+ */
204
+ dump2log(level?: SummaryLevel): void;
205
+ private classDump;
214
206
  }
215
- //# sourceMappingURL=SceneValidator.d.ts.map
207
+ //# sourceMappingURL=Validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/Validator.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CA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IAAI,EAAE,MAAM,CAAsB;IAClC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;IAE7C;;;OAGG;IACH,IAAI,IAAI,OAAO;IAIf;;;;OAIG;IACH,QAAQ,CAAC,KAAK,GAAE,YAAgC,GAAG,IAAI;IAUvD,OAAO,CAAC,SAAS;CAYpB"}
@@ -37,12 +37,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  return result;
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.SceneValidator = exports.MethodSummary = exports.SummaryMsg = exports.ClassSummary = exports.FileSummary = exports.SceneSummary = exports.MethodValidator = exports.ClassValidator = exports.FileValidator = exports.ArkValidatorRegistry = exports.ValueValidator = exports.StmtValidator = void 0;
41
- const ScenePassMgr_1 = require("./ScenePassMgr");
42
- const Dispatcher_1 = require("./Dispatcher");
43
- const Pass_1 = require("./Pass");
44
- const logger_1 = __importStar(require("../utils/logger"));
40
+ exports.SceneSummary = exports.FileValidator = exports.FileSummary = exports.ClassValidator = exports.ClassSummary = exports.MethodValidator = exports.MethodSummary = exports.ArkValidatorRegistry = exports.ValueValidator = exports.StmtValidator = exports.SummaryMsg = void 0;
41
+ const Pass_1 = require("../Pass");
42
+ const Dispatcher_1 = require("../Dispatcher");
43
+ const logger_1 = __importStar(require("../../utils/logger"));
45
44
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Validator');
45
+ /**
46
+ * Represents a summary message with an associated level and content.
47
+ * The SummaryMsg class is used to encapsulate messages that have a specific severity or importance level.
48
+ * It provides a way to associate a textual message with a defined level, making it suitable for logging, notifications, or summaries.
49
+ * The constructor initializes the message and its level, ensuring both are explicitly defined at creation.
50
+ */
51
+ class SummaryMsg {
52
+ constructor(level, msg) {
53
+ this.level = level;
54
+ this.msg = msg;
55
+ }
56
+ }
57
+ exports.SummaryMsg = SummaryMsg;
46
58
  /**
47
59
  * Abstract class representing a statement validator.
48
60
  * Provides a mechanism to validate statements of a specific type within a given context.
@@ -119,40 +131,54 @@ exports.ArkValidatorRegistry = ArkValidatorRegistry;
119
131
  ArkValidatorRegistry.stmtsHolder = [];
120
132
  ArkValidatorRegistry.valuesHolder = [];
121
133
  /**
122
- * An abstract class that extends FilePass and provides a framework for validating files.
123
- * The FileValidator class is designed to be subclassed with specific validation logic
124
- * implemented in the `validate` method. It provides a default implementation of the `run`
125
- * method, which processes a file and submits validation results (info, warning, or error)
126
- * to a summary object associated with the file context.
134
+ * Represents a summary of a method, capturing various messages and associations with values and statements.
135
+ * This class provides methods to submit messages and associate them with specific values or statements.
136
+ * It also supports retrieving or creating a method summary within a given context.
127
137
  */
128
- class FileValidator extends Pass_1.FilePass {
129
- run(file, ctx) {
130
- let submit = (msg) => {
131
- let summary = FileSummary.getOrNew(ctx, file);
132
- summary.submit(msg);
133
- };
134
- this.validate(file, {
135
- info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
136
- warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
137
- error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
138
- });
138
+ class MethodSummary {
139
+ constructor() {
140
+ this.name = 'method summary';
141
+ this.values = new Map();
142
+ this.stmts = new Map();
143
+ this.msgList = [];
139
144
  }
140
- }
141
- exports.FileValidator = FileValidator;
142
- class ClassValidator extends Pass_1.ClassPass {
143
- run(cls, ctx) {
144
- let submit = (msg) => {
145
- let summary = ClassSummary.getOrNew(ctx, cls);
146
- summary.submit(msg);
147
- };
148
- this.validate(cls, {
149
- info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
150
- warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
151
- error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
152
- });
145
+ submit(msg) {
146
+ this.msgList.push(msg);
147
+ }
148
+ submitValue(value, msg) {
149
+ if (!this.values.get(value)) {
150
+ this.values.set(value, []);
151
+ }
152
+ this.values.get(value).push(msg);
153
+ }
154
+ submitStmt(stmt, msg) {
155
+ if (this.stmts.get(stmt) === undefined) {
156
+ this.stmts.set(stmt, []);
157
+ }
158
+ logger.info(`submit ${JSON.stringify(msg)}`);
159
+ this.stmts.get(stmt).push(msg);
160
+ }
161
+ /**
162
+ * Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
163
+ *
164
+ * @param ctx The method context in which the MethodSummary is stored or will be created.
165
+ * @param mtd The ArkMethod for which the MethodSummary is being retrieved or created.
166
+ * @return The existing or newly created MethodSummary associated with the provided context and method.
167
+ */
168
+ static getOrNew(ctx, mtd) {
169
+ if (ctx.get(MethodSummary)) {
170
+ return ctx.get(MethodSummary);
171
+ }
172
+ let cls = ClassSummary.getOrNew(ctx.upper, mtd.getDeclaringArkClass());
173
+ if (!cls.methods.get(mtd)) {
174
+ cls.methods.set(mtd, new MethodSummary());
175
+ }
176
+ let summary = cls.methods.get(mtd);
177
+ ctx.set(MethodSummary, summary);
178
+ return summary;
153
179
  }
154
180
  }
155
- exports.ClassValidator = ClassValidator;
181
+ exports.MethodSummary = MethodSummary;
156
182
  class MethodValidator extends Pass_1.MethodPass {
157
183
  run(mtd, ctx) {
158
184
  let submit = (msg) => {
@@ -167,55 +193,6 @@ class MethodValidator extends Pass_1.MethodPass {
167
193
  }
168
194
  }
169
195
  exports.MethodValidator = MethodValidator;
170
- /**
171
- * Represents a summary of a scene, containing metadata and associated file summaries.
172
- * The name property provides a default identifier for the scene summary.
173
- * The files property maintains a mapping of ArkFile instances to their corresponding FileSummary objects.
174
- * This class is used to encapsulate and manage information about a scene and its related files.
175
- */
176
- class SceneSummary {
177
- constructor() {
178
- this.name = 'validate summary';
179
- this.files = new Map();
180
- }
181
- }
182
- exports.SceneSummary = SceneSummary;
183
- /**
184
- * Represents a summary of a file containing information about classes and messages.
185
- * Provides methods to manage and retrieve file summaries within a given context.
186
- * The class maintains a collection of messages and a mapping of classes to their summaries.
187
- * It supports operations to submit new messages and retrieve or create summaries for files.
188
- */
189
- class FileSummary {
190
- constructor() {
191
- this.name = 'file summary';
192
- this.classes = new Map();
193
- this.msgList = [];
194
- }
195
- submit(msg) {
196
- this.msgList.push(msg);
197
- }
198
- /**
199
- * Retrieves an existing FileSummary instance from the given context or creates a new one if it does not exist.
200
- *
201
- * @param ctx The context object that holds the FileSummary instance. It is used to check if a FileSummary already exists.
202
- * @param file The ArkFile object for which the FileSummary is being retrieved or created.
203
- * @return The existing or newly created FileSummary instance associated with the provided file.
204
- */
205
- static getOrNew(ctx, file) {
206
- if (ctx.get(FileSummary)) {
207
- return ctx.get(FileSummary);
208
- }
209
- let validate = ctx.upper.get(SceneSummary);
210
- if (!validate.files.get(file)) {
211
- validate.files.set(file, new FileSummary());
212
- }
213
- let summary = validate.files.get(file);
214
- ctx.set(FileSummary, summary);
215
- return summary;
216
- }
217
- }
218
- exports.FileSummary = FileSummary;
219
196
  /**
220
197
  * Represents a summary of a class, containing its name, associated methods, and messages.
221
198
  * Provides functionality to submit messages and retrieve or create a ClassSummary instance.
@@ -254,86 +231,113 @@ class ClassSummary {
254
231
  }
255
232
  }
256
233
  exports.ClassSummary = ClassSummary;
257
- /**
258
- * Represents a summary message with an associated level and content.
259
- * The SummaryMsg class is used to encapsulate messages that have a specific severity or importance level.
260
- * It provides a way to associate a textual message with a defined level, making it suitable for logging, notifications, or summaries.
261
- * The constructor initializes the message and its level, ensuring both are explicitly defined at creation.
262
- */
263
- class SummaryMsg {
264
- constructor(level, msg) {
265
- this.level = level;
266
- this.msg = msg;
234
+ class ClassValidator extends Pass_1.ClassPass {
235
+ run(cls, ctx) {
236
+ let submit = (msg) => {
237
+ let summary = ClassSummary.getOrNew(ctx, cls);
238
+ summary.submit(msg);
239
+ };
240
+ this.validate(cls, {
241
+ info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
242
+ warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
243
+ error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
244
+ });
267
245
  }
268
246
  }
269
- exports.SummaryMsg = SummaryMsg;
247
+ exports.ClassValidator = ClassValidator;
270
248
  /**
271
- * Represents a summary of a method, capturing various messages and associations with values and statements.
272
- * This class provides methods to submit messages and associate them with specific values or statements.
273
- * It also supports retrieving or creating a method summary within a given context.
249
+ * Represents a summary of a file containing information about classes and messages.
250
+ * Provides methods to manage and retrieve file summaries within a given context.
251
+ * The class maintains a collection of messages and a mapping of classes to their summaries.
252
+ * It supports operations to submit new messages and retrieve or create summaries for files.
274
253
  */
275
- class MethodSummary {
254
+ class FileSummary {
276
255
  constructor() {
277
- this.name = 'method summary';
278
- this.values = new Map();
279
- this.stmts = new Map();
256
+ this.name = 'file summary';
257
+ this.classes = new Map();
280
258
  this.msgList = [];
281
259
  }
282
260
  submit(msg) {
283
261
  this.msgList.push(msg);
284
262
  }
285
- submitValue(value, msg) {
286
- if (!this.values.get(value)) {
287
- this.values.set(value, []);
288
- }
289
- this.values.get(value).push(msg);
290
- }
291
- submitStmt(stmt, msg) {
292
- if (this.stmts.get(stmt) === undefined) {
293
- this.stmts.set(stmt, []);
294
- }
295
- logger.info(`submit ${JSON.stringify(msg)}`);
296
- this.stmts.get(stmt).push(msg);
297
- }
298
263
  /**
299
- * Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
264
+ * Retrieves an existing FileSummary instance from the given context or creates a new one if it does not exist.
300
265
  *
301
- * @param ctx The method context in which the MethodSummary is stored or will be created.
302
- * @param mtd The ArkMethod for which the MethodSummary is being retrieved or created.
303
- * @return The existing or newly created MethodSummary associated with the provided context and method.
266
+ * @param ctx The context object that holds the FileSummary instance. It is used to check if a FileSummary already exists.
267
+ * @param file The ArkFile object for which the FileSummary is being retrieved or created.
268
+ * @return The existing or newly created FileSummary instance associated with the provided file.
304
269
  */
305
- static getOrNew(ctx, mtd) {
306
- if (ctx.get(MethodSummary)) {
307
- return ctx.get(MethodSummary);
270
+ static getOrNew(ctx, file) {
271
+ if (ctx.get(FileSummary)) {
272
+ return ctx.get(FileSummary);
308
273
  }
309
- let cls = ClassSummary.getOrNew(ctx.upper, mtd.getDeclaringArkClass());
310
- if (!cls.methods.get(mtd)) {
311
- cls.methods.set(mtd, new MethodSummary());
274
+ let validate = ctx.upper.get(SceneSummary);
275
+ if (!validate.files.get(file)) {
276
+ validate.files.set(file, new FileSummary());
312
277
  }
313
- let summary = cls.methods.get(mtd);
314
- ctx.set(MethodSummary, summary);
278
+ let summary = validate.files.get(file);
279
+ ctx.set(FileSummary, summary);
315
280
  return summary;
316
281
  }
317
282
  }
318
- exports.MethodSummary = MethodSummary;
283
+ exports.FileSummary = FileSummary;
284
+ class FileValidator extends Pass_1.FilePass {
285
+ run(file, ctx) {
286
+ let submit = (msg) => {
287
+ let summary = FileSummary.getOrNew(ctx, file);
288
+ summary.submit(msg);
289
+ };
290
+ this.validate(file, {
291
+ info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
292
+ warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
293
+ error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
294
+ });
295
+ }
296
+ }
297
+ exports.FileValidator = FileValidator;
319
298
  /**
320
- * The SceneValidator class is responsible for validating a given scene by leveraging the ScenePassMgr.
321
- * It sets up a context for validation, executes the validation process, and retrieves the summary of the validation.
322
- *
323
- * The validate method initializes a new SceneSummary instance, associates it with the current scene context,
324
- * runs the validation process using the configured manager, and finally returns the generated summary.
325
- *
326
- * This class ensures that the validation logic is encapsulated and provides a clean interface for processing scenes.
299
+ * Represents a summary of a scene, containing metadata and associated file summaries.
300
+ * The name property provides a default identifier for the scene summary.
301
+ * The files property maintains a mapping of ArkFile instances to their corresponding FileSummary objects.
302
+ * This class is used to encapsulate and manage information about a scene and its related files.
327
303
  */
328
- class SceneValidator {
304
+ class SceneSummary {
329
305
  constructor() {
330
- this.mgr = new ScenePassMgr_1.ScenePassMgr({ dispatcher: ArkValidatorRegistry });
306
+ this.name = 'validate summary';
307
+ this.files = new Map();
308
+ }
309
+ /**
310
+ * Checks if the current instance is in an acceptable state.
311
+ * @return {boolean} - Returns true if the files collection is empty, indicating an acceptable state; otherwise, false.
312
+ */
313
+ isOk() {
314
+ return this.files.size === 0;
331
315
  }
332
- validate(scene) {
333
- let summary = new SceneSummary();
334
- this.mgr.sceneContext().set(SceneSummary, summary);
335
- this.mgr.run(scene);
336
- return this.mgr.sceneContext().remove(SceneSummary);
316
+ /**
317
+ * Dumps the scene summary and details to the log based on the specified level.
318
+ * @param {SummaryLevel} [level=SummaryLevel.info] - The minimum level of messages to include in the log. Defaults to SummaryLevel.info.
319
+ * @return {void}
320
+ */
321
+ dump2log(level = 0 /* SummaryLevel.info */) {
322
+ logger.info(`scene summary`);
323
+ for (const [file, fs] of this.files) {
324
+ logger.info(`file ${file.getName()} msg ${JSON.stringify(fs.msgList.filter((v) => v.level >= level))}`);
325
+ for (const [cls, cs] of fs.classes) {
326
+ this.classDump(cls, cs, level);
327
+ }
328
+ }
329
+ }
330
+ classDump(cls, cs, level = 0 /* SummaryLevel.info */) {
331
+ logger.info(`class ${cls.getName()} msg ${JSON.stringify(cs.msgList.filter((v) => v.level >= level))}`);
332
+ for (const [mtd, ms] of cs.methods) {
333
+ logger.info(`method ${mtd.getName()} msg ${JSON.stringify(ms.msgList.filter((v) => v.level >= level))}`);
334
+ for (let [s, ss] of ms.stmts) {
335
+ logger.info(`stmt ${s} ${JSON.stringify(ss.filter((v) => v.level >= level))}`);
336
+ }
337
+ for (let [v, vs] of ms.values) {
338
+ logger.info(`value ${v} ${JSON.stringify(vs.filter((v) => v.level >= level))}`);
339
+ }
340
+ }
337
341
  }
338
342
  }
339
- exports.SceneValidator = SceneValidator;
343
+ exports.SceneSummary = SceneSummary;
@@ -0,0 +1,7 @@
1
+ import { SummaryReporter, ValueValidator } from './Validator';
2
+ import { Local } from '../../core/base/Local';
3
+ export declare class LocalValidator extends ValueValidator<Local> {
4
+ private static readonly INSTANCE;
5
+ validate(value: Local, ctx: SummaryReporter): void;
6
+ }
7
+ //# sourceMappingURL=Values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Values.d.ts","sourceRoot":"","sources":["../../../src/pass/validators/Values.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C,qBAAa,cAAe,SAAQ,cAAc,CAAC,KAAK,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IAExD,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI;CAWrD"}