arkanalyzer 1.0.40 → 1.0.42
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.
- package/config/arkanalyzer.json +1 -2
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +9 -2
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +3 -4
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +7 -8
- package/lib/callgraph/model/CallGraph.d.ts +5 -5
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +18 -21
- package/lib/callgraph/model/CallSite.d.ts +16 -6
- package/lib/callgraph/model/CallSite.d.ts.map +1 -1
- package/lib/callgraph/model/CallSite.js +48 -8
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +0 -1
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
- package/lib/callgraph/model/builder/CallGraphBuilder.js +0 -8
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +3 -6
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +6 -29
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +6 -15
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +63 -81
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +2 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +12 -8
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +9 -3
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +12 -5
- package/lib/callgraph/pointerAnalysis/context/Context.d.ts +69 -0
- package/lib/callgraph/pointerAnalysis/context/Context.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/context/Context.js +202 -0
- package/lib/callgraph/pointerAnalysis/context/ContextItem.d.ts +40 -0
- package/lib/callgraph/pointerAnalysis/context/ContextItem.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/context/ContextItem.js +99 -0
- package/lib/callgraph/pointerAnalysis/context/ContextSelector.d.ts +46 -0
- package/lib/callgraph/pointerAnalysis/context/ContextSelector.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/context/ContextSelector.js +138 -0
- package/lib/core/base/Expr.d.ts +1 -0
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +9 -0
- package/lib/core/common/ArkIRTransformer.d.ts +1 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +58 -2
- package/lib/core/common/ArkValueTransformer.d.ts +1 -1
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/IRInference.d.ts +1 -1
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +7 -3
- package/lib/core/common/ModelUtils.js +1 -1
- package/lib/core/common/SdkUtils.d.ts +2 -1
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +33 -23
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +5 -3
- package/lib/core/dataflow/DataflowSolver.js +3 -3
- package/lib/core/dataflow/UndefinedVariable.js +2 -2
- package/lib/core/graph/BaseExplicitGraph.d.ts +1 -0
- package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
- package/lib/core/graph/BaseExplicitGraph.js +3 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +9 -4
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +4 -1
- package/lib/core/graph/builder/CfgBuilder.d.ts +2 -1
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +54 -10
- package/lib/core/graph/builder/ConditionBuilder.d.ts +2 -1
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ConditionBuilder.js +7 -3
- package/lib/core/graph/builder/TrapBuilder.d.ts +19 -1
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/TrapBuilder.js +195 -68
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +3 -4
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +42 -21
- package/lib/core/model/builder/ArkImportBuilder.js +28 -25
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +1 -2
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +2 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -4
- package/lib/pass/Context.d.ts +47 -0
- package/lib/pass/Context.d.ts.map +1 -0
- package/lib/pass/Context.js +72 -0
- package/lib/pass/Dispatcher.d.ts +102 -0
- package/lib/pass/Dispatcher.d.ts.map +1 -0
- package/lib/pass/Dispatcher.js +202 -0
- package/lib/pass/Pass.d.ts +83 -0
- package/lib/pass/Pass.d.ts.map +1 -0
- package/lib/pass/Pass.js +95 -0
- package/lib/pass/ScenePassMgr.d.ts +73 -0
- package/lib/pass/ScenePassMgr.d.ts.map +1 -0
- package/lib/pass/ScenePassMgr.js +156 -0
- package/lib/pass/SceneValidator.d.ts +215 -0
- package/lib/pass/SceneValidator.d.ts.map +1 -0
- package/lib/pass/SceneValidator.js +339 -0
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +26 -102
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts.map +1 -1
- package/lib/save/arkir/ArkIRMethodPrinter.js +13 -5
- package/lib/save/source/SourceStmt.d.ts +1 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +13 -8
- package/lib/utils/FileUtils.d.ts.map +1 -1
- package/lib/utils/FileUtils.js +13 -6
- package/lib/utils/ValueAsserts.d.ts +9 -0
- package/lib/utils/ValueAsserts.d.ts.map +1 -0
- package/lib/utils/ValueAsserts.js +89 -0
- package/package.json +2 -2
- package/lib/callgraph/pointerAnalysis/Context.d.ts +0 -38
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +0 -1
- package/lib/callgraph/pointerAnalysis/Context.js +0 -154
|
@@ -0,0 +1,215 @@
|
|
|
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';
|
|
9
|
+
export declare const enum SummaryLevel {
|
|
10
|
+
info = 0,
|
|
11
|
+
warn = 1,
|
|
12
|
+
error = 2
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Abstract class representing a statement validator.
|
|
16
|
+
* Provides a mechanism to validate statements of a specific type within a given context.
|
|
17
|
+
* Implementations must define the `validate` method to perform custom validation logic.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class StmtValidator<S extends StmtTy> {
|
|
20
|
+
/**
|
|
21
|
+
* Validates the given input using the provided context and reports the results.
|
|
22
|
+
*
|
|
23
|
+
* @param s The input value to be validated.
|
|
24
|
+
* @param ctx The context used for validation, which includes reporting mechanisms.
|
|
25
|
+
* @return The result of the validation process.
|
|
26
|
+
*/
|
|
27
|
+
abstract validate(s: S, ctx: SummaryReporter): void;
|
|
28
|
+
run(s: S, ctx: MethodCtx, mtd: ArkMethod): void;
|
|
29
|
+
static register(init: StmtInit): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Abstract class representing a validator for values of a specific type.
|
|
33
|
+
* Provides a mechanism to validate values and report the results through a summary reporter.
|
|
34
|
+
* The validation logic is defined by implementing the `validate` method in derived classes.
|
|
35
|
+
*/
|
|
36
|
+
export declare abstract class ValueValidator<S extends ValueTy> {
|
|
37
|
+
/**
|
|
38
|
+
* Validates the given input against specific criteria and reports the validation status.
|
|
39
|
+
*
|
|
40
|
+
* @param s The input value to be validated. This can be of any type depending on the implementation.
|
|
41
|
+
* @param ctx The context object used for reporting validation results or summaries.
|
|
42
|
+
* @return The result of the validation process.
|
|
43
|
+
*/
|
|
44
|
+
abstract validate(s: S, ctx: SummaryReporter): void;
|
|
45
|
+
run(s: S, ctx: MethodCtx, mtd: ArkMethod): void;
|
|
46
|
+
static register(init: ValueInit): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The ArkValidatorRegistry class is responsible for managing and registering statement and value initializers
|
|
50
|
+
* used in validation processes. It extends the Dispatcher class and provides mechanisms to dynamically
|
|
51
|
+
* register and invalidate dispatch configurations.
|
|
52
|
+
*/
|
|
53
|
+
export declare class ArkValidatorRegistry extends Dispatcher {
|
|
54
|
+
private static readonly stmtsHolder;
|
|
55
|
+
private static readonly valuesHolder;
|
|
56
|
+
private static dispatchHolder?;
|
|
57
|
+
constructor(ctx: MethodCtx);
|
|
58
|
+
static getDispatch(): Dispatch;
|
|
59
|
+
static stmt(init: StmtInit): void;
|
|
60
|
+
static value(init: ValueInit): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
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.
|
|
80
|
+
*/
|
|
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 {
|
|
93
|
+
/**
|
|
94
|
+
* Validates the given class and reports any issues found during validation.
|
|
95
|
+
*
|
|
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.
|
|
99
|
+
*/
|
|
100
|
+
abstract validate(cls: ArkClass, ctx: SummaryReporter): void;
|
|
101
|
+
run(cls: ArkClass, ctx: ClassCtx): FallAction | void;
|
|
102
|
+
}
|
|
103
|
+
export declare abstract class MethodValidator extends MethodPass {
|
|
104
|
+
/**
|
|
105
|
+
* Validates the given method and reports any issues found.
|
|
106
|
+
*
|
|
107
|
+
* @param mtd The method to be validated. This is an instance of ArkMethod.
|
|
108
|
+
* @param ctx The context for reporting validation results or issues. This is an instance of SummaryReporter.
|
|
109
|
+
* @return This method does not return a value.
|
|
110
|
+
*/
|
|
111
|
+
abstract validate(mtd: ArkMethod, ctx: SummaryReporter): void;
|
|
112
|
+
run(mtd: ArkMethod, ctx: MethodCtx): FallAction | void;
|
|
113
|
+
}
|
|
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
|
+
/**
|
|
146
|
+
* Represents a summary of a class, containing its name, associated methods, and messages.
|
|
147
|
+
* Provides functionality to submit messages and retrieve or create a ClassSummary instance.
|
|
148
|
+
* The class maintains a collection of method summaries and tracks messages related to the class.
|
|
149
|
+
* It is designed to be used in the context of a larger system that processes class information.
|
|
150
|
+
*/
|
|
151
|
+
export declare class ClassSummary {
|
|
152
|
+
name: string;
|
|
153
|
+
methods: Map<ArkMethod, MethodSummary>;
|
|
154
|
+
msgList: SummaryMsg[];
|
|
155
|
+
constructor();
|
|
156
|
+
submit(msg: SummaryMsg): void;
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves an existing ClassSummary instance from the given context or creates a new one if it does not exist.
|
|
159
|
+
* If the ClassSummary is not found in the context, it attempts to retrieve or create a FileSummary for the declaring file of the class.
|
|
160
|
+
* Ensures that the ClassSummary is associated with the provided class and context before returning it.
|
|
161
|
+
*
|
|
162
|
+
* @param ctx The context in which to search for or store the ClassSummary instance.
|
|
163
|
+
* @param cls The class for which the ClassSummary is being retrieved or created.
|
|
164
|
+
* @return The existing or newly created ClassSummary instance associated with the provided class and context.
|
|
165
|
+
*/
|
|
166
|
+
static getOrNew(ctx: ClassCtx, cls: ArkClass): ClassSummary;
|
|
167
|
+
}
|
|
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);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
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.
|
|
183
|
+
*/
|
|
184
|
+
export declare class MethodSummary {
|
|
185
|
+
name: string;
|
|
186
|
+
values: Map<Value, SummaryMsg[]>;
|
|
187
|
+
stmts: Map<Stmt, SummaryMsg[]>;
|
|
188
|
+
msgList: SummaryMsg[];
|
|
189
|
+
constructor();
|
|
190
|
+
submit(msg: SummaryMsg): void;
|
|
191
|
+
submitValue(value: Value, msg: SummaryMsg): void;
|
|
192
|
+
submitStmt(stmt: Stmt, msg: SummaryMsg): void;
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
|
|
195
|
+
*
|
|
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.
|
|
199
|
+
*/
|
|
200
|
+
static getOrNew(ctx: MethodCtx, mtd: ArkMethod): MethodSummary;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
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.
|
|
210
|
+
*/
|
|
211
|
+
export declare class SceneValidator {
|
|
212
|
+
private mgr;
|
|
213
|
+
validate(scene: Scene): SceneSummary;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=SceneValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,EAAE,UAAU,EAAE,CAAC,CAAa;IAC7C,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAa;IAC3C,OAAO,EAAE,UAAU,EAAE,CAAM;;IAK3B,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAI7B,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI;IAOhD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI;IAQ7C;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,GAAG,aAAa;CAYjE;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,GAAG,CAAwE;IAEnF,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY;CAMvC"}
|
|
@@ -0,0 +1,339 @@
|
|
|
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 = 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"));
|
|
45
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Validator');
|
|
46
|
+
/**
|
|
47
|
+
* Abstract class representing a statement validator.
|
|
48
|
+
* Provides a mechanism to validate statements of a specific type within a given context.
|
|
49
|
+
* Implementations must define the `validate` method to perform custom validation logic.
|
|
50
|
+
*/
|
|
51
|
+
class StmtValidator {
|
|
52
|
+
run(s, ctx, mtd) {
|
|
53
|
+
let submit = (msg) => {
|
|
54
|
+
let summary = MethodSummary.getOrNew(ctx, mtd);
|
|
55
|
+
summary.submitStmt(s, msg);
|
|
56
|
+
};
|
|
57
|
+
this.validate(s, {
|
|
58
|
+
info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
|
|
59
|
+
warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
|
|
60
|
+
error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
static register(init) {
|
|
64
|
+
ArkValidatorRegistry.stmt(init);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.StmtValidator = StmtValidator;
|
|
68
|
+
/**
|
|
69
|
+
* Abstract class representing a validator for values of a specific type.
|
|
70
|
+
* Provides a mechanism to validate values and report the results through a summary reporter.
|
|
71
|
+
* The validation logic is defined by implementing the `validate` method in derived classes.
|
|
72
|
+
*/
|
|
73
|
+
class ValueValidator {
|
|
74
|
+
run(s, ctx, mtd) {
|
|
75
|
+
let submit = (msg) => {
|
|
76
|
+
let summary = MethodSummary.getOrNew(ctx, mtd);
|
|
77
|
+
summary.submitValue(s, msg);
|
|
78
|
+
};
|
|
79
|
+
this.validate(s, {
|
|
80
|
+
info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
|
|
81
|
+
warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
|
|
82
|
+
error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
static register(init) {
|
|
86
|
+
ArkValidatorRegistry.value(init);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ValueValidator = ValueValidator;
|
|
90
|
+
/**
|
|
91
|
+
* The ArkValidatorRegistry class is responsible for managing and registering statement and value initializers
|
|
92
|
+
* used in validation processes. It extends the Dispatcher class and provides mechanisms to dynamically
|
|
93
|
+
* register and invalidate dispatch configurations.
|
|
94
|
+
*/
|
|
95
|
+
class ArkValidatorRegistry extends Dispatcher_1.Dispatcher {
|
|
96
|
+
constructor(ctx) {
|
|
97
|
+
super(ctx, ArkValidatorRegistry.getDispatch());
|
|
98
|
+
this.fallAction = 0 /* FallAction.Continue */;
|
|
99
|
+
}
|
|
100
|
+
static getDispatch() {
|
|
101
|
+
if (ArkValidatorRegistry.dispatchHolder) {
|
|
102
|
+
return ArkValidatorRegistry.dispatchHolder;
|
|
103
|
+
}
|
|
104
|
+
ArkValidatorRegistry.dispatchHolder = new Dispatcher_1.Dispatch(this.stmtsHolder, this.valuesHolder);
|
|
105
|
+
return ArkValidatorRegistry.dispatchHolder;
|
|
106
|
+
}
|
|
107
|
+
static stmt(init) {
|
|
108
|
+
this.stmtsHolder.push(init);
|
|
109
|
+
// invalidate holder
|
|
110
|
+
ArkValidatorRegistry.dispatchHolder = undefined;
|
|
111
|
+
}
|
|
112
|
+
static value(init) {
|
|
113
|
+
this.valuesHolder.push(init);
|
|
114
|
+
// invalidate holder
|
|
115
|
+
ArkValidatorRegistry.dispatchHolder = undefined;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.ArkValidatorRegistry = ArkValidatorRegistry;
|
|
119
|
+
ArkValidatorRegistry.stmtsHolder = [];
|
|
120
|
+
ArkValidatorRegistry.valuesHolder = [];
|
|
121
|
+
/**
|
|
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.
|
|
127
|
+
*/
|
|
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
|
+
});
|
|
139
|
+
}
|
|
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
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.ClassValidator = ClassValidator;
|
|
156
|
+
class MethodValidator extends Pass_1.MethodPass {
|
|
157
|
+
run(mtd, ctx) {
|
|
158
|
+
let submit = (msg) => {
|
|
159
|
+
let summary = MethodSummary.getOrNew(ctx, mtd);
|
|
160
|
+
summary.submit(msg);
|
|
161
|
+
};
|
|
162
|
+
this.validate(mtd, {
|
|
163
|
+
info: (msg) => submit(new SummaryMsg(0 /* SummaryLevel.info */, msg)),
|
|
164
|
+
warn: (msg) => submit(new SummaryMsg(1 /* SummaryLevel.warn */, msg)),
|
|
165
|
+
error: (msg) => submit(new SummaryMsg(2 /* SummaryLevel.error */, msg)),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
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
|
+
/**
|
|
220
|
+
* Represents a summary of a class, containing its name, associated methods, and messages.
|
|
221
|
+
* Provides functionality to submit messages and retrieve or create a ClassSummary instance.
|
|
222
|
+
* The class maintains a collection of method summaries and tracks messages related to the class.
|
|
223
|
+
* It is designed to be used in the context of a larger system that processes class information.
|
|
224
|
+
*/
|
|
225
|
+
class ClassSummary {
|
|
226
|
+
constructor() {
|
|
227
|
+
this.name = 'class summary';
|
|
228
|
+
this.methods = new Map();
|
|
229
|
+
this.msgList = [];
|
|
230
|
+
}
|
|
231
|
+
submit(msg) {
|
|
232
|
+
this.msgList.push(msg);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Retrieves an existing ClassSummary instance from the given context or creates a new one if it does not exist.
|
|
236
|
+
* If the ClassSummary is not found in the context, it attempts to retrieve or create a FileSummary for the declaring file of the class.
|
|
237
|
+
* Ensures that the ClassSummary is associated with the provided class and context before returning it.
|
|
238
|
+
*
|
|
239
|
+
* @param ctx The context in which to search for or store the ClassSummary instance.
|
|
240
|
+
* @param cls The class for which the ClassSummary is being retrieved or created.
|
|
241
|
+
* @return The existing or newly created ClassSummary instance associated with the provided class and context.
|
|
242
|
+
*/
|
|
243
|
+
static getOrNew(ctx, cls) {
|
|
244
|
+
if (ctx.get(ClassSummary)) {
|
|
245
|
+
return ctx.get(ClassSummary);
|
|
246
|
+
}
|
|
247
|
+
let file = FileSummary.getOrNew(ctx.upper, cls.getDeclaringArkFile());
|
|
248
|
+
if (!file.classes.get(cls)) {
|
|
249
|
+
file.classes.set(cls, new ClassSummary());
|
|
250
|
+
}
|
|
251
|
+
let summary = file.classes.get(cls);
|
|
252
|
+
ctx.set(ClassSummary, summary);
|
|
253
|
+
return summary;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
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;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.SummaryMsg = SummaryMsg;
|
|
270
|
+
/**
|
|
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.
|
|
274
|
+
*/
|
|
275
|
+
class MethodSummary {
|
|
276
|
+
constructor() {
|
|
277
|
+
this.name = 'method summary';
|
|
278
|
+
this.values = new Map();
|
|
279
|
+
this.stmts = new Map();
|
|
280
|
+
this.msgList = [];
|
|
281
|
+
}
|
|
282
|
+
submit(msg) {
|
|
283
|
+
this.msgList.push(msg);
|
|
284
|
+
}
|
|
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
|
+
/**
|
|
299
|
+
* Retrieves an existing MethodSummary from the context or creates a new one if it does not exist.
|
|
300
|
+
*
|
|
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.
|
|
304
|
+
*/
|
|
305
|
+
static getOrNew(ctx, mtd) {
|
|
306
|
+
if (ctx.get(MethodSummary)) {
|
|
307
|
+
return ctx.get(MethodSummary);
|
|
308
|
+
}
|
|
309
|
+
let cls = ClassSummary.getOrNew(ctx.upper, mtd.getDeclaringArkClass());
|
|
310
|
+
if (!cls.methods.get(mtd)) {
|
|
311
|
+
cls.methods.set(mtd, new MethodSummary());
|
|
312
|
+
}
|
|
313
|
+
let summary = cls.methods.get(mtd);
|
|
314
|
+
ctx.set(MethodSummary, summary);
|
|
315
|
+
return summary;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.MethodSummary = MethodSummary;
|
|
319
|
+
/**
|
|
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.
|
|
327
|
+
*/
|
|
328
|
+
class SceneValidator {
|
|
329
|
+
constructor() {
|
|
330
|
+
this.mgr = new ScenePassMgr_1.ScenePassMgr({ dispatcher: ArkValidatorRegistry });
|
|
331
|
+
}
|
|
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);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
exports.SceneValidator = SceneValidator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonPrinter.d.ts","sourceRoot":"","sources":["../../src/save/JsonPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAuEhD,qBAAa,WAAY,SAAQ,OAAO;IACxB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAI7B,IAAI,IAAI,MAAM;IAKrB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"JsonPrinter.d.ts","sourceRoot":"","sources":["../../src/save/JsonPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAuEhD,qBAAa,WAAY,SAAQ,OAAO;IACxB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAI7B,IAAI,IAAI,MAAM;IAKrB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,aAAa;IAgHrB,OAAO,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