arkanalyzer 1.0.41 → 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/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +10 -4
- 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/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 +31 -31
- 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/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.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +3 -3
- 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 +24 -20
- 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/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/source/SourceStmt.d.ts +1 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +4 -7
- 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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type AnyKey<T> = {
|
|
2
|
+
new (): T;
|
|
3
|
+
};
|
|
4
|
+
export interface CtxArg {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
export type UniMap<T> = Map<AnyKey<T>, T>;
|
|
8
|
+
interface Upper {
|
|
9
|
+
readonly upper: Upper;
|
|
10
|
+
readonly unreachable: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents the root implementation of the Upper interface.
|
|
14
|
+
* Provides a singleton instance to ensure a single point of access.
|
|
15
|
+
* The class is designed to maintain immutability for its properties.
|
|
16
|
+
* The `getInstance` method allows retrieval of the singleton instance.
|
|
17
|
+
*/
|
|
18
|
+
export declare class UpperRoot implements Upper {
|
|
19
|
+
readonly upper: any;
|
|
20
|
+
readonly unreachable = true;
|
|
21
|
+
private static INSTANCE;
|
|
22
|
+
static getInstance(): UpperRoot;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents a context that manages a map of arguments and provides methods to manipulate them.
|
|
26
|
+
* Implements the Upper interface, allowing for hierarchical structures.
|
|
27
|
+
* The context maintains a reference to its upper context and provides utilities to traverse the hierarchy.
|
|
28
|
+
*
|
|
29
|
+
* The `unreachable` property indicates whether this context is considered unreachable in the hierarchy.
|
|
30
|
+
* The `upper` property refers to the parent or enclosing context.
|
|
31
|
+
* The `args` property is a map that stores key-value pairs specific to this context.
|
|
32
|
+
*
|
|
33
|
+
* Provides methods to retrieve, add, and remove entries from the argument map.
|
|
34
|
+
* Allows traversal to the root context in the hierarchy by following the chain of upper contexts.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Context<U extends Upper, T> implements Upper {
|
|
37
|
+
unreachable: boolean;
|
|
38
|
+
upper: U;
|
|
39
|
+
protected args: UniMap<T>;
|
|
40
|
+
constructor(upper: U);
|
|
41
|
+
get<K extends T>(k: AnyKey<K>): K | undefined;
|
|
42
|
+
set<K extends T>(k: AnyKey<K>, v: K): void;
|
|
43
|
+
remove<K extends T>(k: AnyKey<K>): K | undefined;
|
|
44
|
+
root(): Upper;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/pass/Context.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,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d.
|
|
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.Context = exports.UpperRoot = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Represents the root implementation of the Upper interface.
|
|
20
|
+
* Provides a singleton instance to ensure a single point of access.
|
|
21
|
+
* The class is designed to maintain immutability for its properties.
|
|
22
|
+
* The `getInstance` method allows retrieval of the singleton instance.
|
|
23
|
+
*/
|
|
24
|
+
class UpperRoot {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.unreachable = true;
|
|
27
|
+
}
|
|
28
|
+
static getInstance() {
|
|
29
|
+
return UpperRoot.INSTANCE;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.UpperRoot = UpperRoot;
|
|
33
|
+
UpperRoot.INSTANCE = new UpperRoot();
|
|
34
|
+
/**
|
|
35
|
+
* Represents a context that manages a map of arguments and provides methods to manipulate them.
|
|
36
|
+
* Implements the Upper interface, allowing for hierarchical structures.
|
|
37
|
+
* The context maintains a reference to its upper context and provides utilities to traverse the hierarchy.
|
|
38
|
+
*
|
|
39
|
+
* The `unreachable` property indicates whether this context is considered unreachable in the hierarchy.
|
|
40
|
+
* The `upper` property refers to the parent or enclosing context.
|
|
41
|
+
* The `args` property is a map that stores key-value pairs specific to this context.
|
|
42
|
+
*
|
|
43
|
+
* Provides methods to retrieve, add, and remove entries from the argument map.
|
|
44
|
+
* Allows traversal to the root context in the hierarchy by following the chain of upper contexts.
|
|
45
|
+
*/
|
|
46
|
+
class Context {
|
|
47
|
+
constructor(upper) {
|
|
48
|
+
this.unreachable = false;
|
|
49
|
+
this.upper = upper;
|
|
50
|
+
this.args = new Map();
|
|
51
|
+
}
|
|
52
|
+
get(k) {
|
|
53
|
+
return this.args.get(k);
|
|
54
|
+
}
|
|
55
|
+
set(k, v) {
|
|
56
|
+
this.args.set(k, v);
|
|
57
|
+
}
|
|
58
|
+
remove(k) {
|
|
59
|
+
const v = this.get(k);
|
|
60
|
+
this.args.delete(k);
|
|
61
|
+
return v;
|
|
62
|
+
}
|
|
63
|
+
root() {
|
|
64
|
+
let up = this;
|
|
65
|
+
// upper is root,
|
|
66
|
+
while (!up.upper.unreachable) {
|
|
67
|
+
up = up.upper;
|
|
68
|
+
}
|
|
69
|
+
return up;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Context = Context;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Value } from '../core/base/Value';
|
|
2
|
+
import { ArkAliasTypeDefineStmt, ArkAssignStmt, ArkIfStmt, ArkInvokeStmt, ArkReturnStmt, ArkReturnVoidStmt, ArkThrowStmt, Stmt } from '../core/base/Stmt';
|
|
3
|
+
import { AbstractBinopExpr, AbstractExpr, AbstractInvokeExpr, AliasTypeExpr, ArkAwaitExpr, ArkCastExpr, ArkConditionExpr, ArkDeleteExpr, ArkInstanceInvokeExpr, ArkInstanceOfExpr, ArkNewArrayExpr, ArkNewExpr, ArkNormalBinopExpr, ArkPhiExpr, ArkPtrInvokeExpr, ArkStaticInvokeExpr, ArkTypeOfExpr, ArkUnopExpr, ArkYieldExpr } from '../core/base/Expr';
|
|
4
|
+
import { FallAction, MethodCtx } from './Pass';
|
|
5
|
+
import { BigIntConstant, BooleanConstant, Constant, NullConstant, NumberConstant, StringConstant, UndefinedConstant } from '../core/base/Constant';
|
|
6
|
+
import { ArkMethod } from '../core/model/ArkMethod';
|
|
7
|
+
import { Local } from '../core/base/Local';
|
|
8
|
+
import { AbstractFieldRef, AbstractRef, ArkCaughtExceptionRef, ArkInstanceFieldRef, ArkParameterRef, ArkStaticFieldRef, ArkThisRef, ClosureFieldRef, GlobalRef } from '../core/base/Ref';
|
|
9
|
+
/**
|
|
10
|
+
* Represents a function type that processes a value and context, optionally returning a FallAction to control flow.
|
|
11
|
+
* This function is invoked with a value of type T , a context object and a method object, and it can decide whether to skip subsequent passes.
|
|
12
|
+
|
|
13
|
+
* @param value:T - The inst to be executed
|
|
14
|
+
* @param ctx:MethodCtx - The method context of this inst
|
|
15
|
+
* @param mtd:ArkMethod - The method of this inst
|
|
16
|
+
* @returns If a FallAction is returned, it indicates the action to take regarding skipping or halting further processing.
|
|
17
|
+
* Returning nothing or void implies no special action, allowing the next passes to execute normally.
|
|
18
|
+
*/
|
|
19
|
+
export interface InstPass<T> {
|
|
20
|
+
(value: T, ctx: MethodCtx, mtd: ArkMethod): FallAction | void;
|
|
21
|
+
}
|
|
22
|
+
type IndexOf<T extends readonly any[]> = Extract<keyof T, `${number}`>;
|
|
23
|
+
/**
|
|
24
|
+
* Represents all statement types used within the system.
|
|
25
|
+
*/
|
|
26
|
+
declare const STMTS: readonly [typeof ArkAssignStmt, typeof ArkInvokeStmt, typeof ArkIfStmt, typeof ArkReturnStmt, typeof ArkReturnVoidStmt, typeof ArkThrowStmt, typeof ArkAliasTypeDefineStmt, typeof Stmt];
|
|
27
|
+
/**
|
|
28
|
+
* class of stmts
|
|
29
|
+
*/
|
|
30
|
+
export type StmtClass = typeof STMTS[number];
|
|
31
|
+
/**
|
|
32
|
+
* stmts classes
|
|
33
|
+
*/
|
|
34
|
+
export type StmtTy = {
|
|
35
|
+
[K in IndexOf<typeof STMTS>]: InstanceType<typeof STMTS[K]>;
|
|
36
|
+
}[IndexOf<typeof STMTS>];
|
|
37
|
+
type StmtPass = {
|
|
38
|
+
[K in IndexOf<typeof STMTS>]: InstPass<InstanceType<typeof STMTS[K]>>;
|
|
39
|
+
}[IndexOf<typeof STMTS>];
|
|
40
|
+
type StmtList<S extends StmtClass> = [S, InstPass<InstanceType<S>>[] | InstPass<InstanceType<S>>];
|
|
41
|
+
/**
|
|
42
|
+
* Represents an initialization statement type derived from the `STMTS` constant.
|
|
43
|
+
* This type maps each index of the `STMTS` array to a corresponding `StmtList` type,
|
|
44
|
+
* effectively creating a union of all possible statement list types defined by `STMTS`.
|
|
45
|
+
* It is used to ensure type safety and consistency when working with statement lists
|
|
46
|
+
* associated with the `STMTS` entries.
|
|
47
|
+
*/
|
|
48
|
+
export type StmtInit = {
|
|
49
|
+
[K in IndexOf<typeof STMTS>]: StmtList<typeof STMTS[K]>;
|
|
50
|
+
}[IndexOf<typeof STMTS>];
|
|
51
|
+
/**
|
|
52
|
+
* Represents all values types used within the system.
|
|
53
|
+
*/
|
|
54
|
+
declare const VALUES: readonly [typeof AliasTypeExpr, typeof ArkUnopExpr, typeof ArkPhiExpr, typeof ArkCastExpr, typeof ArkInstanceOfExpr, typeof ArkTypeOfExpr, typeof ArkNormalBinopExpr, typeof ArkConditionExpr, typeof AbstractBinopExpr, typeof ArkYieldExpr, typeof ArkAwaitExpr, typeof ArkDeleteExpr, typeof ArkNewArrayExpr, typeof ArkNewExpr, typeof ArkPtrInvokeExpr, typeof ArkStaticInvokeExpr, typeof ArkInstanceInvokeExpr, typeof AbstractInvokeExpr, typeof AbstractExpr, typeof ClosureFieldRef, typeof GlobalRef, typeof ArkCaughtExceptionRef, typeof ArkThisRef, typeof ArkParameterRef, typeof ArkStaticFieldRef, typeof ArkInstanceFieldRef, typeof AbstractFieldRef, typeof AbstractRef, typeof UndefinedConstant, typeof NullConstant, typeof StringConstant, typeof BigIntConstant, typeof NumberConstant, typeof BooleanConstant, typeof Constant, typeof Local];
|
|
55
|
+
/**
|
|
56
|
+
* class of stmts
|
|
57
|
+
*/
|
|
58
|
+
type ValueClass = typeof VALUES[number];
|
|
59
|
+
/**
|
|
60
|
+
* stmts classes
|
|
61
|
+
*/
|
|
62
|
+
export type ValueTy = {
|
|
63
|
+
[K in IndexOf<typeof VALUES>]: InstanceType<typeof VALUES[K]>;
|
|
64
|
+
}[IndexOf<typeof VALUES>];
|
|
65
|
+
type ValuePass = {
|
|
66
|
+
[K in IndexOf<typeof VALUES>]: InstPass<InstanceType<typeof VALUES[K]>>;
|
|
67
|
+
}[IndexOf<typeof VALUES>];
|
|
68
|
+
type ValuePair<S extends ValueClass> = [S, InstPass<InstanceType<S>>[] | InstPass<InstanceType<S>>];
|
|
69
|
+
/**
|
|
70
|
+
* Represents an initialization value for a specific index in the VALUES array.
|
|
71
|
+
* This type maps each index of the VALUES array to a corresponding ValuePair type,
|
|
72
|
+
* ensuring that only valid initialization values for the given index are allowed.
|
|
73
|
+
* The resulting type is a union of all possible ValuePair types derived from the VALUES array.
|
|
74
|
+
*/
|
|
75
|
+
export type ValueInit = {
|
|
76
|
+
[K in IndexOf<typeof VALUES>]: ValuePair<typeof VALUES[K]>;
|
|
77
|
+
}[IndexOf<typeof VALUES>];
|
|
78
|
+
/**
|
|
79
|
+
* the dispatch table, it can be cached
|
|
80
|
+
*/
|
|
81
|
+
export declare class Dispatch {
|
|
82
|
+
name: string;
|
|
83
|
+
readonly stmts: StmtClass[];
|
|
84
|
+
readonly smap: Map<StmtClass, StmtPass[]>;
|
|
85
|
+
readonly values: ValueClass[];
|
|
86
|
+
readonly vmap: Map<ValueClass, ValuePass[]>;
|
|
87
|
+
constructor(stmts?: StmtInit[], values?: ValueInit[]);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* the ArkIR dispatcher, to dispatch stmts and values actions
|
|
91
|
+
*/
|
|
92
|
+
export declare class Dispatcher {
|
|
93
|
+
private readonly ctx;
|
|
94
|
+
protected fallAction: FallAction;
|
|
95
|
+
private readonly dispatch;
|
|
96
|
+
private cache;
|
|
97
|
+
constructor(ctx: MethodCtx, dispatch?: Dispatch);
|
|
98
|
+
dispatchStmt(mtd: ArkMethod, stmt: Stmt): void;
|
|
99
|
+
dispatchValue(mtd: ArkMethod, value: Value): void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=Dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dispatcher.d.ts","sourceRoot":"","sources":["../../src/pass/Dispatcher.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACH,sBAAsB,EAAE,aAAa,EACrC,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAChF,WAAW,EACX,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,EACtD,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAC9C,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EACrE,aAAa,EAAE,WAAW,EAAE,YAAY,EAC3C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACH,cAAc,EACd,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,cAAc,EAAE,iBAAiB,EACpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,WAAW,EAAE,qBAAqB,EAClC,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAC5D,MAAM,kBAAkB,CAAC;AAK1B;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACvB,CA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AAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAoB;IAEpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IAEpC,OAAO,CAAC,KAAK,CAAuB;gBAExB,GAAG,EAAE,SAAS,EAAE,QAAQ,GAAE,QAAyB;IAK/D,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAmB9C,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CA0BpD"}
|
|
@@ -0,0 +1,202 @@
|
|
|
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.Dispatcher = exports.Dispatch = void 0;
|
|
41
|
+
const Stmt_1 = require("../core/base/Stmt");
|
|
42
|
+
const Expr_1 = require("../core/base/Expr");
|
|
43
|
+
const Constant_1 = require("../core/base/Constant");
|
|
44
|
+
const logger_1 = __importStar(require("../utils/logger"));
|
|
45
|
+
const Local_1 = require("../core/base/Local");
|
|
46
|
+
const Ref_1 = require("../core/base/Ref");
|
|
47
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Inst');
|
|
48
|
+
/**
|
|
49
|
+
* Represents all statement types used within the system.
|
|
50
|
+
*/
|
|
51
|
+
const STMTS = [
|
|
52
|
+
Stmt_1.ArkAssignStmt,
|
|
53
|
+
Stmt_1.ArkInvokeStmt,
|
|
54
|
+
Stmt_1.ArkIfStmt,
|
|
55
|
+
Stmt_1.ArkReturnStmt,
|
|
56
|
+
Stmt_1.ArkReturnVoidStmt,
|
|
57
|
+
Stmt_1.ArkThrowStmt,
|
|
58
|
+
Stmt_1.ArkAliasTypeDefineStmt,
|
|
59
|
+
Stmt_1.Stmt,
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Represents all values types used within the system.
|
|
63
|
+
*/
|
|
64
|
+
const VALUES = [
|
|
65
|
+
// expr
|
|
66
|
+
Expr_1.AliasTypeExpr,
|
|
67
|
+
Expr_1.ArkUnopExpr,
|
|
68
|
+
Expr_1.ArkPhiExpr,
|
|
69
|
+
Expr_1.ArkCastExpr,
|
|
70
|
+
Expr_1.ArkInstanceOfExpr,
|
|
71
|
+
Expr_1.ArkTypeOfExpr,
|
|
72
|
+
Expr_1.ArkNormalBinopExpr,
|
|
73
|
+
Expr_1.ArkConditionExpr,
|
|
74
|
+
Expr_1.AbstractBinopExpr,
|
|
75
|
+
Expr_1.ArkYieldExpr,
|
|
76
|
+
Expr_1.ArkAwaitExpr,
|
|
77
|
+
Expr_1.ArkDeleteExpr,
|
|
78
|
+
Expr_1.ArkNewArrayExpr,
|
|
79
|
+
Expr_1.ArkNewExpr,
|
|
80
|
+
Expr_1.ArkPtrInvokeExpr,
|
|
81
|
+
Expr_1.ArkStaticInvokeExpr,
|
|
82
|
+
Expr_1.ArkInstanceInvokeExpr,
|
|
83
|
+
Expr_1.AbstractInvokeExpr,
|
|
84
|
+
Expr_1.AbstractExpr,
|
|
85
|
+
// ref
|
|
86
|
+
Ref_1.ClosureFieldRef,
|
|
87
|
+
Ref_1.GlobalRef,
|
|
88
|
+
Ref_1.ArkCaughtExceptionRef,
|
|
89
|
+
Ref_1.ArkThisRef,
|
|
90
|
+
Ref_1.ArkParameterRef,
|
|
91
|
+
Ref_1.ArkStaticFieldRef,
|
|
92
|
+
Ref_1.ArkInstanceFieldRef,
|
|
93
|
+
Ref_1.AbstractFieldRef,
|
|
94
|
+
Ref_1.AbstractRef,
|
|
95
|
+
// constant
|
|
96
|
+
Constant_1.UndefinedConstant,
|
|
97
|
+
Constant_1.NullConstant,
|
|
98
|
+
Constant_1.StringConstant,
|
|
99
|
+
Constant_1.BigIntConstant,
|
|
100
|
+
Constant_1.NumberConstant,
|
|
101
|
+
Constant_1.BooleanConstant,
|
|
102
|
+
Constant_1.Constant,
|
|
103
|
+
// local
|
|
104
|
+
Local_1.Local,
|
|
105
|
+
];
|
|
106
|
+
/**
|
|
107
|
+
* the dispatch table, it can be cached
|
|
108
|
+
*/
|
|
109
|
+
class Dispatch {
|
|
110
|
+
constructor(stmts = [], values = []) {
|
|
111
|
+
this.name = 'dispatch';
|
|
112
|
+
this.stmts = [];
|
|
113
|
+
this.smap = new Map();
|
|
114
|
+
this.values = [];
|
|
115
|
+
this.vmap = new Map();
|
|
116
|
+
this.stmts = stmts.map(v => v[0]);
|
|
117
|
+
const smap = new Map();
|
|
118
|
+
for (const [k, v] of stmts) {
|
|
119
|
+
if (Array.isArray(v)) {
|
|
120
|
+
smap.set(k, v);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
smap.set(k, [v]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// replace it, in case of modified
|
|
127
|
+
this.smap = smap;
|
|
128
|
+
this.values = values.map(v => v[0]);
|
|
129
|
+
const vmap = new Map();
|
|
130
|
+
for (const [k, v] of values) {
|
|
131
|
+
if (Array.isArray(v)) {
|
|
132
|
+
vmap.set(k, v);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
vmap.set(k, [v]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// replace it, in case of modified
|
|
139
|
+
this.vmap = vmap;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.Dispatch = Dispatch;
|
|
143
|
+
/**
|
|
144
|
+
* the ArkIR dispatcher, to dispatch stmts and values actions
|
|
145
|
+
*/
|
|
146
|
+
class Dispatcher {
|
|
147
|
+
constructor(ctx, dispatch = new Dispatch()) {
|
|
148
|
+
// action when match stmts
|
|
149
|
+
this.fallAction = 1 /* FallAction.Break */;
|
|
150
|
+
// value cache to prevent cycle dependencies
|
|
151
|
+
this.cache = new Set();
|
|
152
|
+
this.ctx = ctx;
|
|
153
|
+
this.dispatch = dispatch;
|
|
154
|
+
}
|
|
155
|
+
dispatchStmt(mtd, stmt) {
|
|
156
|
+
var _a;
|
|
157
|
+
logger.debug(`dispatch stmt ${stmt}`);
|
|
158
|
+
const tys = this.dispatch.stmts;
|
|
159
|
+
for (let ty of tys) {
|
|
160
|
+
if (stmt instanceof ty) {
|
|
161
|
+
let pass = (_a = this.dispatch.smap.get(ty)) !== null && _a !== void 0 ? _a : [];
|
|
162
|
+
for (const p of pass) {
|
|
163
|
+
p(stmt, this.ctx, mtd);
|
|
164
|
+
}
|
|
165
|
+
if (this.fallAction === 1 /* FallAction.Break */) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (let use of stmt.getUses()) {
|
|
171
|
+
this.dispatchValue(mtd, use);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
dispatchValue(mtd, value) {
|
|
175
|
+
var _a;
|
|
176
|
+
logger.debug(`dispatch value ${value}`);
|
|
177
|
+
// skip uses if there is no value pass
|
|
178
|
+
if (this.dispatch.values.length === 0) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (this.cache.has(value)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.cache.add(value);
|
|
185
|
+
const tys = this.dispatch.values;
|
|
186
|
+
for (let ty of tys) {
|
|
187
|
+
if (value instanceof ty) {
|
|
188
|
+
let pass = (_a = this.dispatch.vmap.get(ty)) !== null && _a !== void 0 ? _a : [];
|
|
189
|
+
for (const p of pass) {
|
|
190
|
+
p(value, this.ctx, mtd);
|
|
191
|
+
}
|
|
192
|
+
if (this.fallAction === 1 /* FallAction.Break */) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (let use of value.getUses()) {
|
|
198
|
+
this.dispatchValue(mtd, use);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.Dispatcher = Dispatcher;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ArkMethod } from '../core/model/ArkMethod';
|
|
2
|
+
import { Context, CtxArg } from './Context';
|
|
3
|
+
import { SceneCtx } from './ScenePassMgr';
|
|
4
|
+
import { ArkFile } from '../core/model/ArkFile';
|
|
5
|
+
import { ArkClass } from '../core/model/ArkClass';
|
|
6
|
+
/**
|
|
7
|
+
fallthrough actions
|
|
8
|
+
Continue: will run next pass
|
|
9
|
+
Break: will break the pass list
|
|
10
|
+
*/
|
|
11
|
+
export declare const enum FallAction {
|
|
12
|
+
Continue = 0,
|
|
13
|
+
Break = 1
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents an abstract file responsible for handling file-related operations.
|
|
17
|
+
* The ClassPass class is designed to define a contract for executing specific logic
|
|
18
|
+
* when processing a given class within a particular context. Implementations of this
|
|
19
|
+
* class are expected to provide concrete behavior for the `run` method.
|
|
20
|
+
*
|
|
21
|
+
* @param cls:ArkFile - The class to be executed
|
|
22
|
+
* @param ctx:FileCtx - The context used in executed
|
|
23
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
24
|
+
*/
|
|
25
|
+
export declare abstract class FilePass {
|
|
26
|
+
abstract run(file: ArkFile, ctx: FileCtx): FallAction | void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
30
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
31
|
+
* The FileCtx is bound to a SceneCtx and CtxArg, defining its operational scope.
|
|
32
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
33
|
+
*/
|
|
34
|
+
export declare class FileCtx extends Context<SceneCtx, CtxArg> {
|
|
35
|
+
root(): SceneCtx;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents an abstract class responsible for handling class-related operations.
|
|
39
|
+
* The ClassPass class is designed to define a contract for executing specific logic
|
|
40
|
+
* when processing a given class within a particular context. Implementations of this
|
|
41
|
+
* class are expected to provide concrete behavior for the `run` method.
|
|
42
|
+
*
|
|
43
|
+
* @param cls:ArkClass - The class to be executed
|
|
44
|
+
* @param ctx:ClassCtx - The context used in executed
|
|
45
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
46
|
+
*/
|
|
47
|
+
export declare abstract class ClassPass {
|
|
48
|
+
abstract run(cls: ArkClass, ctx: ClassCtx): FallAction | void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
52
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
53
|
+
* The ClassCtx is bound to a FileCtx and CtxArg, defining its operational scope.
|
|
54
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
55
|
+
*/
|
|
56
|
+
export declare class ClassCtx extends Context<FileCtx, CtxArg> {
|
|
57
|
+
root(): SceneCtx;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Represents an abstract class for executing a method within a specific context.
|
|
61
|
+
* The MethodPass class is designed to be extended by concrete implementations
|
|
62
|
+
* that define how a given method should be processed or executed.
|
|
63
|
+
*
|
|
64
|
+
* The `run` method must be implemented by subclasses to provide the logic
|
|
65
|
+
* for handling the execution of the provided method using the given context.
|
|
66
|
+
*
|
|
67
|
+
* @param method: ArkMethod - The method to be executed
|
|
68
|
+
* @param ctx: MethodCtx - The context used in executed
|
|
69
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
70
|
+
*/
|
|
71
|
+
export declare abstract class MethodPass {
|
|
72
|
+
abstract run(method: ArkMethod, ctx: MethodCtx): FallAction | void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
76
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
77
|
+
* The MethodCtx is bound to a ClassCtx and CtxArg, defining its operational scope.
|
|
78
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
79
|
+
*/
|
|
80
|
+
export declare class Method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AACH,qBAAa,SAAU,SAAQ,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;IACpD,IAAI,IAAI,QAAQ;CAGnB"}
|
package/lib/pass/Pass.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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.MethodCtx = exports.MethodPass = exports.ClassCtx = exports.ClassPass = exports.FileCtx = exports.FilePass = void 0;
|
|
18
|
+
const Context_1 = require("./Context");
|
|
19
|
+
/**
|
|
20
|
+
* Represents an abstract file responsible for handling file-related operations.
|
|
21
|
+
* The ClassPass class is designed to define a contract for executing specific logic
|
|
22
|
+
* when processing a given class within a particular context. Implementations of this
|
|
23
|
+
* class are expected to provide concrete behavior for the `run` method.
|
|
24
|
+
*
|
|
25
|
+
* @param cls:ArkFile - The class to be executed
|
|
26
|
+
* @param ctx:FileCtx - The context used in executed
|
|
27
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
28
|
+
*/
|
|
29
|
+
class FilePass {
|
|
30
|
+
}
|
|
31
|
+
exports.FilePass = FilePass;
|
|
32
|
+
/**
|
|
33
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
34
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
35
|
+
* The FileCtx is bound to a SceneCtx and CtxArg, defining its operational scope.
|
|
36
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
37
|
+
*/
|
|
38
|
+
class FileCtx extends Context_1.Context {
|
|
39
|
+
root() {
|
|
40
|
+
return this.upper.root();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.FileCtx = FileCtx;
|
|
44
|
+
/**
|
|
45
|
+
* Represents an abstract class responsible for handling class-related operations.
|
|
46
|
+
* The ClassPass class is designed to define a contract for executing specific logic
|
|
47
|
+
* when processing a given class within a particular context. Implementations of this
|
|
48
|
+
* class are expected to provide concrete behavior for the `run` method.
|
|
49
|
+
*
|
|
50
|
+
* @param cls:ArkClass - The class to be executed
|
|
51
|
+
* @param ctx:ClassCtx - The context used in executed
|
|
52
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
53
|
+
*/
|
|
54
|
+
class ClassPass {
|
|
55
|
+
}
|
|
56
|
+
exports.ClassPass = ClassPass;
|
|
57
|
+
/**
|
|
58
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
59
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
60
|
+
* The ClassCtx is bound to a FileCtx and CtxArg, defining its operational scope.
|
|
61
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
62
|
+
*/
|
|
63
|
+
class ClassCtx extends Context_1.Context {
|
|
64
|
+
root() {
|
|
65
|
+
return this.upper.root();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.ClassCtx = ClassCtx;
|
|
69
|
+
/**
|
|
70
|
+
* Represents an abstract class for executing a method within a specific context.
|
|
71
|
+
* The MethodPass class is designed to be extended by concrete implementations
|
|
72
|
+
* that define how a given method should be processed or executed.
|
|
73
|
+
*
|
|
74
|
+
* The `run` method must be implemented by subclasses to provide the logic
|
|
75
|
+
* for handling the execution of the provided method using the given context.
|
|
76
|
+
*
|
|
77
|
+
* @param method: ArkMethod - The method to be executed
|
|
78
|
+
* @param ctx: MethodCtx - The context used in executed
|
|
79
|
+
* @returns The result of the method execution, which can be of FallAction or void.
|
|
80
|
+
*/
|
|
81
|
+
class MethodPass {
|
|
82
|
+
}
|
|
83
|
+
exports.MethodPass = MethodPass;
|
|
84
|
+
/**
|
|
85
|
+
* Represents a specialized context class that extends the base Context class with specific types.
|
|
86
|
+
* Provides functionality to access the root context within a hierarchical structure.
|
|
87
|
+
* The MethodCtx is bound to a ClassCtx and CtxArg, defining its operational scope.
|
|
88
|
+
* The root method retrieves the top-level SceneCtx by traversing the context hierarchy.
|
|
89
|
+
*/
|
|
90
|
+
class MethodCtx extends Context_1.Context {
|
|
91
|
+
root() {
|
|
92
|
+
return this.upper.root();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.MethodCtx = MethodCtx;
|