arkanalyzer 1.0.87 → 1.0.89

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 (143) hide show
  1. package/config/arkanalyzer.json +11 -0
  2. package/lib/Config.d.ts +27 -2
  3. package/lib/Config.d.ts.map +1 -1
  4. package/lib/Config.js +65 -2
  5. package/lib/Scene.d.ts +5 -2
  6. package/lib/Scene.d.ts.map +1 -1
  7. package/lib/Scene.js +34 -67
  8. package/lib/callgraph/pointerAnalysis/context/Context.d.ts.map +1 -1
  9. package/lib/callgraph/pointerAnalysis/context/Context.js +10 -12
  10. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +1 -1
  11. package/lib/cli/commands/cg.d.ts +27 -6
  12. package/lib/cli/commands/cg.d.ts.map +1 -1
  13. package/lib/cli/commands/cg.js +9 -6
  14. package/lib/core/base/Expr.js +3 -3
  15. package/lib/core/base/Position.d.ts +1 -1
  16. package/lib/core/base/Position.d.ts.map +1 -1
  17. package/lib/core/base/Position.js +2 -2
  18. package/lib/core/base/Type.d.ts.map +1 -1
  19. package/lib/core/base/Type.js +1 -2
  20. package/lib/core/common/Const.d.ts +1 -0
  21. package/lib/core/common/Const.d.ts.map +1 -1
  22. package/lib/core/common/Const.js +2 -1
  23. package/lib/core/common/IRInference.d.ts.map +1 -1
  24. package/lib/core/common/IRInference.js +1 -1
  25. package/lib/core/common/IRUtils.d.ts.map +1 -1
  26. package/lib/core/common/IRUtils.js +3 -33
  27. package/lib/core/common/ModelUtils.d.ts +6 -0
  28. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  29. package/lib/core/common/ModelUtils.js +30 -0
  30. package/lib/core/common/SdkUtils.js +1 -1
  31. package/lib/core/common/TypeInference.d.ts +13 -0
  32. package/lib/core/common/TypeInference.d.ts.map +1 -1
  33. package/lib/core/common/TypeInference.js +44 -0
  34. package/lib/core/common/ValueUtil.d.ts +1 -1
  35. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  36. package/lib/core/common/ValueUtil.js +28 -12
  37. package/lib/core/graph/Cfg.d.ts.map +1 -1
  38. package/lib/core/graph/Cfg.js +0 -2
  39. package/lib/core/graph/DominanceFinder.d.ts +3 -0
  40. package/lib/core/graph/DominanceFinder.d.ts.map +1 -1
  41. package/lib/core/graph/DominanceFinder.js +42 -36
  42. package/lib/core/graph/DominanceTree.d.ts.map +1 -1
  43. package/lib/core/graph/DominanceTree.js +0 -4
  44. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  45. package/lib/core/inference/ValueInference.js +3 -2
  46. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  47. package/lib/core/inference/abc/AbcInference.js +2 -1
  48. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  49. package/lib/core/inference/arkts/ArkTsInference.js +3 -2
  50. package/lib/core/model/ArkClass.d.ts +3 -0
  51. package/lib/core/model/ArkClass.d.ts.map +1 -1
  52. package/lib/core/model/ArkClass.js +32 -6
  53. package/lib/core/model/ArkFile.d.ts.map +1 -1
  54. package/lib/core/model/ArkFile.js +0 -1
  55. package/lib/core/model/ArkMetadata.d.ts +32 -1
  56. package/lib/core/model/ArkMetadata.d.ts.map +1 -1
  57. package/lib/core/model/ArkMetadata.js +28 -3
  58. package/lib/core/model/builder/ArkMetadataBuilder.d.ts +21 -0
  59. package/lib/core/model/builder/ArkMetadataBuilder.d.ts.map +1 -0
  60. package/lib/core/model/builder/ArkMetadataBuilder.js +160 -0
  61. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  62. package/lib/core/model/builder/ArkMethodBuilder.js +32 -26
  63. package/lib/frontend/FrontendBuilder.d.ts +26 -0
  64. package/lib/frontend/FrontendBuilder.d.ts.map +1 -0
  65. package/lib/frontend/FrontendBuilder.js +108 -0
  66. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +16 -0
  67. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -0
  68. package/lib/frontend/arktsFrontend/ArktsFrontend.js +52 -0
  69. package/lib/frontend/cppFrontend/CppFrontend.d.ts +13 -0
  70. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -0
  71. package/lib/frontend/cppFrontend/CppFrontend.js +85 -0
  72. package/lib/frontend/cppFrontend/ast/index.d.ts +5 -0
  73. package/lib/frontend/cppFrontend/ast/index.d.ts.map +1 -0
  74. package/lib/frontend/cppFrontend/ast/index.js +31 -0
  75. package/lib/frontend/cppFrontend/ast/ts/ArkCxxAstNode.d.ts.map +1 -0
  76. package/lib/frontend/cppFrontend/ast/ts/astParser.d.ts +25 -0
  77. package/lib/frontend/cppFrontend/ast/ts/astParser.d.ts.map +1 -0
  78. package/lib/frontend/cppFrontend/ast/ts/astParser.js +280 -0
  79. package/lib/frontend/cppFrontend/ast/ts/astUtils.d.ts +18 -0
  80. package/lib/frontend/cppFrontend/ast/ts/astUtils.d.ts.map +1 -0
  81. package/lib/frontend/cppFrontend/ast/ts/astUtils.js +158 -0
  82. package/lib/frontend/cppFrontend/ast/{const.d.ts → ts/const.d.ts} +0 -13
  83. package/lib/frontend/cppFrontend/ast/ts/const.d.ts.map +1 -0
  84. package/lib/frontend/cppFrontend/ast/ts/const.js +58 -0
  85. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.d.ts +8 -0
  86. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.d.ts.map +1 -0
  87. package/lib/frontend/cppFrontend/ast/ts/napi/napiApi.js +90 -0
  88. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.d.ts +8 -0
  89. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.d.ts.map +1 -0
  90. package/lib/frontend/cppFrontend/ast/ts/napi/napiRunner.js +180 -0
  91. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts +1 -1
  92. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
  93. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +55 -55
  94. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
  95. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
  96. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +151 -151
  97. package/lib/frontend/cppFrontend/common/IRInference.js +2 -2
  98. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -1
  99. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
  100. package/lib/frontend/cppFrontend/common/IRUtils.js +2 -2
  101. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts +1 -1
  102. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
  103. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +74 -74
  104. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts +1 -1
  105. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
  106. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +3 -3
  107. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts +1 -1
  108. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  109. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +1 -1
  110. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  111. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +16 -17
  112. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts +1 -1
  113. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts.map +1 -1
  114. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts +1 -1
  115. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  116. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +2 -2
  117. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +1 -1
  118. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  119. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +2 -2
  120. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -1
  121. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
  122. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts +1 -1
  123. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
  124. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +3 -3
  125. package/lib/index.d.ts +5 -2
  126. package/lib/index.d.ts.map +1 -1
  127. package/lib/index.js +14 -6
  128. package/lib/pass/Dispatcher.d.ts.map +1 -1
  129. package/lib/pass/Dispatcher.js +0 -4
  130. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  131. package/lib/save/source/SourceStmt.js +3 -1
  132. package/lib/utils/FileUtils.d.ts +1 -0
  133. package/lib/utils/FileUtils.d.ts.map +1 -1
  134. package/lib/utils/FileUtils.js +11 -3
  135. package/package.json +9 -4
  136. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts.map +0 -1
  137. package/lib/frontend/cppFrontend/ast/astUtils.d.ts +0 -51
  138. package/lib/frontend/cppFrontend/ast/astUtils.d.ts.map +0 -1
  139. package/lib/frontend/cppFrontend/ast/astUtils.js +0 -470
  140. package/lib/frontend/cppFrontend/ast/const.d.ts.map +0 -1
  141. package/lib/frontend/cppFrontend/ast/const.js +0 -134
  142. /package/lib/frontend/cppFrontend/ast/{ArkCxxAstNode.d.ts → ts/ArkCxxAstNode.d.ts} +0 -0
  143. /package/lib/frontend/cppFrontend/ast/{ArkCxxAstNode.js → ts/ArkCxxAstNode.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArkCxxAstNode.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/ast/ts/ArkCxxAstNode.ts"],"names":[],"mappings":"AAgBA,uDAAuD;AACvD,MAAM,WAAW,W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zC,OAAO,YAAY;IACnB,SAAS,cAAc;CAC1B"}
@@ -0,0 +1,25 @@
1
+ import { CxxAstNode, CxxAstNodeLite } from './ArkCxxAstNode';
2
+ export type GetParentFn = {
3
+ (isNeedInner: true): CxxAstNode;
4
+ (isNeedInner?: false): CxxAstNodeLite;
5
+ };
6
+ export declare class AstParser {
7
+ private static currentAccess;
8
+ private static deleteFileSync;
9
+ static parse(sourceFile: string, ccJsonPath: string | null, includeDirs: string[] | null, llvmPath: string, cppAstPath: string): CxxAstNode;
10
+ private static resolveProjectRoot;
11
+ private static getWorkingDir;
12
+ private static processAstFile;
13
+ private static createEmptyNode;
14
+ private static updateInner;
15
+ private static filter;
16
+ private static filterChildren;
17
+ private static makeGetParent;
18
+ private static fullInfo;
19
+ private static processAccess;
20
+ private static getCodeForExtractModifiers;
21
+ private static stripFucntionParams;
22
+ private static getAstOutputPath;
23
+ private static ensureOutputDir;
24
+ }
25
+ //# sourceMappingURL=astParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astParser.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/ast/ts/astParser.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAW,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMtE,MAAM,MAAM,WAAW,GAAG;IACtB,CAAC,WAAW,EAAE,IAAI,GAAG,UAAU,CAAC;IAChC,CAAC,WAAW,CAAC,EAAE,KAAK,GAAG,cAAc,CAAC;CACzC,CAAC;AAEF,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAc;IAE1C,OAAO,CAAC,MAAM,CAAC,cAAc;WAQf,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU;IA4BlJ,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAoBjC,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,cAAc;IAqB7B,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,OAAO,CAAC,MAAM,CAAC,WAAW;IAY1B,OAAO,CAAC,MAAM,CAAC,MAAM;IAYrB,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,QAAQ;IA8BvB,OAAO,CAAC,MAAM,CAAC,aAAa;IAgB5B,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAUzC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAyBlC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAQ/B,OAAO,CAAC,MAAM,CAAC,eAAe;CAKjC"}
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 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
+ var __rest = (this && this.__rest) || function (s, e) {
40
+ var t = {};
41
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
42
+ t[p] = s[p];
43
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
44
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
45
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
46
+ t[p[i]] = s[p[i]];
47
+ }
48
+ return t;
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.AstParser = void 0;
52
+ const fs = __importStar(require("fs"));
53
+ const path = __importStar(require("path"));
54
+ const logger_1 = __importStar(require("../../../../utils/logger"));
55
+ const ArkCxxAstNode_1 = require("./ArkCxxAstNode");
56
+ const napiApi_1 = require("./napi/napiApi");
57
+ const astUtils_1 = require("./astUtils");
58
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'astParser');
59
+ class AstParser {
60
+ static deleteFileSync(filePath) {
61
+ try {
62
+ fs.unlinkSync(filePath);
63
+ }
64
+ catch (_a) {
65
+ logger.warn('delete file failed:', filePath);
66
+ }
67
+ }
68
+ static parse(sourceFile, ccJsonPath, includeDirs, llvmPath, cppAstPath) {
69
+ logger.info(`[Debug] Parsing File: ${sourceFile}`);
70
+ if (!fs.existsSync(sourceFile)) {
71
+ logger.warn('parse file is not exists');
72
+ return this.createEmptyNode();
73
+ }
74
+ const rawAstPath = this.getAstOutputPath(sourceFile, cppAstPath);
75
+ const astPath = path.resolve(rawAstPath);
76
+ this.ensureOutputDir(path.dirname(astPath));
77
+ const workingDir = this.getWorkingDir(ccJsonPath);
78
+ const finalIncludeDirs = includeDirs ? [...includeDirs] : [];
79
+ const projectRoot = this.resolveProjectRoot(sourceFile);
80
+ if (projectRoot && !finalIncludeDirs.includes(projectRoot)) {
81
+ finalIncludeDirs.push(projectRoot);
82
+ }
83
+ const status = (0, napiApi_1.dumpAstJson)({
84
+ sourceFile,
85
+ outputFile: astPath,
86
+ ccJsonPath: ccJsonPath !== null && ccJsonPath !== void 0 ? ccJsonPath : undefined,
87
+ includeDirs: finalIncludeDirs,
88
+ }, workingDir, llvmPath);
89
+ return this.processAstFile(astPath, sourceFile, status);
90
+ }
91
+ static resolveProjectRoot(sourceFile) {
92
+ try {
93
+ let currentDir = path.dirname(sourceFile);
94
+ for (let i = 0; i < 10; i++) {
95
+ if (path.dirname(currentDir) === currentDir) {
96
+ break;
97
+ }
98
+ if (path.basename(currentDir) === 'cpp' && path.basename(path.dirname(currentDir)) === 'main') {
99
+ const absRoot = path.resolve(currentDir);
100
+ logger.info(`[Debug] Found Source Root: ${absRoot}`);
101
+ return absRoot;
102
+ }
103
+ currentDir = path.dirname(currentDir);
104
+ }
105
+ }
106
+ catch (e) {
107
+ logger.error('[Debug] Error finding source root:', e);
108
+ }
109
+ return null;
110
+ }
111
+ static getWorkingDir(ccJsonPath) {
112
+ let workingDir = process.cwd();
113
+ if (ccJsonPath && fs.existsSync(ccJsonPath)) {
114
+ const stats = fs.statSync(ccJsonPath);
115
+ if (stats.isFile()) {
116
+ workingDir = path.dirname(ccJsonPath);
117
+ }
118
+ else {
119
+ workingDir = ccJsonPath;
120
+ }
121
+ }
122
+ return workingDir;
123
+ }
124
+ static processAstFile(astPath, sourceFile, status) {
125
+ try {
126
+ if (!fs.existsSync(astPath)) {
127
+ logger.error(`[Debug] AST file missing at: ${astPath}`);
128
+ return this.createEmptyNode();
129
+ }
130
+ const content = fs.readFileSync(astPath, 'utf-8');
131
+ if (!content || content.trim() === '') {
132
+ return this.createEmptyNode();
133
+ }
134
+ let tu = JSON.parse(content);
135
+ tu = this.filter(sourceFile, tu);
136
+ return tu;
137
+ }
138
+ catch (e) {
139
+ logger.error('Failed to parse AST json:', e);
140
+ return this.createEmptyNode();
141
+ }
142
+ finally {
143
+ this.deleteFileSync(astPath);
144
+ }
145
+ }
146
+ static createEmptyNode() {
147
+ return { kind: '', name: '', code: '', type: { qualType: '' }, inner: [] };
148
+ }
149
+ static updateInner(sourceFile, entry, newInner) {
150
+ if (entry.isImplicit) {
151
+ return;
152
+ }
153
+ const loc = entry.loc;
154
+ if (!loc) {
155
+ logger.warn('Node skipped due to missing "locFile", kind of node: ', entry.kind);
156
+ return;
157
+ }
158
+ newInner.push(entry);
159
+ }
160
+ static filter(sourceFile, translationUnit) {
161
+ const newInner = [];
162
+ for (const entry of translationUnit.inner) {
163
+ this.updateInner(sourceFile, entry, newInner);
164
+ }
165
+ translationUnit.inner = newInner;
166
+ translationUnit.fileName = sourceFile;
167
+ translationUnit.projectName = path.dirname(sourceFile);
168
+ this.fullInfo(translationUnit);
169
+ return translationUnit;
170
+ }
171
+ static filterChildren(cursor) {
172
+ if (!cursor.inner) {
173
+ return [];
174
+ }
175
+ return cursor.inner.filter((item) => !item.isImplicit);
176
+ }
177
+ static makeGetParent(cursor) {
178
+ function getParent(isNeedInner) {
179
+ if (isNeedInner) {
180
+ return Object.assign({}, cursor);
181
+ }
182
+ const { inner } = cursor, rest = __rest(cursor, ["inner"]);
183
+ return rest;
184
+ }
185
+ return getParent;
186
+ }
187
+ static fullInfo(cursor) {
188
+ if (!cursor.inner) {
189
+ cursor.inner = [];
190
+ }
191
+ cursor.inner = this.filterChildren(cursor);
192
+ if (cursor.name === undefined) {
193
+ cursor.name = '';
194
+ }
195
+ if (cursor.kind === 'LambdaExpr') {
196
+ this.processAccess(cursor);
197
+ }
198
+ if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl && cursor.tagUsed === 'class') {
199
+ this.currentAccess = 'private';
200
+ }
201
+ else if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl && cursor.tagUsed === 'struct') {
202
+ this.currentAccess = 'public';
203
+ }
204
+ else {
205
+ this.currentAccess = '';
206
+ }
207
+ for (const currentCursor of cursor.inner) {
208
+ Object.assign(currentCursor, { getParent: this.makeGetParent(cursor) });
209
+ if (cursor.kind === ArkCxxAstNode_1.astKind.CXXRecordDecl || cursor.kind === ArkCxxAstNode_1.astKind.CXXMethodDecl || cursor.kind === ArkCxxAstNode_1.astKind.FunctionDecl) {
210
+ this.processAccess(currentCursor);
211
+ }
212
+ this.fullInfo(currentCursor);
213
+ }
214
+ }
215
+ static processAccess(cursor) {
216
+ var _a, _b;
217
+ cursor.modifiers = [];
218
+ if (cursor.kind === 'AccessSpecDecl') {
219
+ this.currentAccess = (_b = (_a = cursor.access) !== null && _a !== void 0 ? _a : (0, astUtils_1.extractAllCppModifiers)(cursor.code)[0]) !== null && _b !== void 0 ? _b : '';
220
+ }
221
+ else {
222
+ const extractedCode = this.getCodeForExtractModifiers(cursor);
223
+ const codeModifier = (0, astUtils_1.extractAllCppModifiers)(extractedCode);
224
+ if (this.currentAccess !== '') {
225
+ cursor.modifiers.push(this.currentAccess);
226
+ }
227
+ if (codeModifier !== null) {
228
+ cursor.modifiers.push(...codeModifier);
229
+ }
230
+ }
231
+ }
232
+ static getCodeForExtractModifiers(cursor) {
233
+ const extractedCode = cursor.code;
234
+ if (!['CXXConstructorDecl', 'CXXDestructorDecl', 'CXXMethodDecl', 'FriendDecl', 'FunctionDecl', 'FunctionTemplateDecl'].includes(cursor.kind)) {
235
+ return extractedCode;
236
+ }
237
+ const bodyNode = cursor.inner.filter((inner) => inner.kind === 'CompoundStmt');
238
+ const bodyCode = bodyNode.length === 0 ? '' : bodyNode[0].code;
239
+ return this.stripFucntionParams(extractedCode.replace(bodyCode, ''));
240
+ }
241
+ static stripFucntionParams(code) {
242
+ let depth = 0;
243
+ let start = -1;
244
+ let end = -1;
245
+ for (let i = 0; i < code.length; i++) {
246
+ const ch = code[i];
247
+ if (ch === '(') {
248
+ if (depth === 0) {
249
+ start = i;
250
+ }
251
+ depth++;
252
+ }
253
+ else if (ch === ')') {
254
+ depth--;
255
+ if (depth === 0) {
256
+ end = i;
257
+ break;
258
+ }
259
+ }
260
+ }
261
+ if (start === -1 || end === -1) {
262
+ return code;
263
+ }
264
+ return code.slice(0, start).trimEnd() + ' ' + code.slice(end + 1).trimStart();
265
+ }
266
+ static getAstOutputPath(sourceFile, cppAstPath) {
267
+ const fileName = `${path.parse(path.basename(sourceFile)).name}_AST.json`;
268
+ if (cppAstPath !== '') {
269
+ return path.join(cppAstPath, fileName);
270
+ }
271
+ return path.join(astUtils_1.ClangPath.protectRoot, 'src', 'frontend', 'cppFrontend', 'ast', 'out', fileName);
272
+ }
273
+ static ensureOutputDir(dir) {
274
+ if (!fs.existsSync(dir)) {
275
+ fs.mkdirSync(dir, { recursive: true });
276
+ }
277
+ }
278
+ }
279
+ exports.AstParser = AstParser;
280
+ AstParser.currentAccess = '';
@@ -0,0 +1,18 @@
1
+ export declare function findProjectRoot(startDir?: string): string;
2
+ /**
3
+ * Resolved path to the astJsonDumper N-API addon ({@code astJsonDumper.node} under dumper/ or lib/ast/).
4
+ */
5
+ export declare function getAstJsonDumperNodePath(): string;
6
+ /** True when {@link getAstJsonDumperNodePath} exists on disk. */
7
+ export declare function isAstJsonDumperAvailable(): boolean;
8
+ /** Project-root anchor for C++ AST output paths (legacy name: historically held Clang binary paths). */
9
+ export declare class ClangPath {
10
+ static protectRoot: string;
11
+ }
12
+ export declare function extractAllCppModifiers(code: string): string[];
13
+ /**
14
+ * Find the absolute path of compile_commands.json starting from a file path.
15
+ * Strict logic: only traverses upward (ancestors) to find a ".cxx" directory.
16
+ */
17
+ export declare function findCompileCommands(filePath: string): string;
18
+ //# sourceMappingURL=astUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astUtils.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/ast/ts/astUtils.ts"],"names":[],"mappings":"AAqBA,wBAAgB,eAAe,CAAC,QAAQ,GAAE,MAAkB,GAAG,MAAM,CAYpE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAOjD;AAED,iEAAiE;AACjE,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED,wGAAwG;AACxG,qBAAa,SAAS;IAClB,OAAc,WAAW,SAA8B;CAC1D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB7D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA4B5D"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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.findCompileCommands = exports.extractAllCppModifiers = exports.ClangPath = exports.isAstJsonDumperAvailable = exports.getAstJsonDumperNodePath = exports.findProjectRoot = void 0;
41
+ const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
43
+ // Module level cache: Sub project root directory (including .cxx directory) -> compile_commands.json absolute path
44
+ const ccJsonCache = new Map();
45
+ function findProjectRoot(startDir = __dirname) {
46
+ let dir = path.resolve(startDir);
47
+ while (true) {
48
+ if (fs.existsSync(path.join(dir, 'package.json'))) {
49
+ return dir;
50
+ }
51
+ const parentDir = path.dirname(dir);
52
+ if (parentDir === dir) {
53
+ return dir;
54
+ }
55
+ dir = parentDir;
56
+ }
57
+ }
58
+ exports.findProjectRoot = findProjectRoot;
59
+ /**
60
+ * Resolved path to the astJsonDumper N-API addon ({@code astJsonDumper.node} under dumper/ or lib/ast/).
61
+ */
62
+ function getAstJsonDumperNodePath() {
63
+ const projectRoot = findProjectRoot(__dirname);
64
+ let nodeAddonPath = path.join(projectRoot, 'src', 'frontend', 'cppFrontend', 'ast', 'dumper', 'astJsonDumper.node');
65
+ if (!fs.existsSync(nodeAddonPath)) {
66
+ nodeAddonPath = path.join(projectRoot, 'lib', 'ast', 'astJsonDumper.node');
67
+ }
68
+ return nodeAddonPath;
69
+ }
70
+ exports.getAstJsonDumperNodePath = getAstJsonDumperNodePath;
71
+ /** True when {@link getAstJsonDumperNodePath} exists on disk. */
72
+ function isAstJsonDumperAvailable() {
73
+ return fs.existsSync(getAstJsonDumperNodePath());
74
+ }
75
+ exports.isAstJsonDumperAvailable = isAstJsonDumperAvailable;
76
+ /** Project-root anchor for C++ AST output paths (legacy name: historically held Clang binary paths). */
77
+ class ClangPath {
78
+ }
79
+ exports.ClangPath = ClangPath;
80
+ ClangPath.protectRoot = findProjectRoot(__dirname);
81
+ function extractAllCppModifiers(code) {
82
+ if (!code) {
83
+ return [];
84
+ }
85
+ const cppModifiers = [
86
+ 'static',
87
+ 'public',
88
+ 'private',
89
+ 'protected',
90
+ 'const',
91
+ 'virtual',
92
+ 'inline',
93
+ 'mutable',
94
+ 'explicit',
95
+ 'friend',
96
+ 'constexpr',
97
+ 'volatile'
98
+ ];
99
+ const pattern = new RegExp(`\\b(${cppModifiers.join('|')})\\b`, 'g');
100
+ const matches = code.match(pattern);
101
+ return matches ? matches : [];
102
+ }
103
+ exports.extractAllCppModifiers = extractAllCppModifiers;
104
+ /**
105
+ * Find the absolute path of compile_commands.json starting from a file path.
106
+ * Strict logic: only traverses upward (ancestors) to find a ".cxx" directory.
107
+ */
108
+ function findCompileCommands(filePath) {
109
+ for (const [projectRoot, jsonPath] of ccJsonCache) {
110
+ if (filePath === projectRoot || filePath.startsWith(projectRoot + path.sep)) {
111
+ return jsonPath;
112
+ }
113
+ }
114
+ let currentDir = path.dirname(filePath);
115
+ while (true) {
116
+ const cxxDir = path.join(currentDir, '.cxx');
117
+ if (fs.existsSync(cxxDir) && fs.statSync(cxxDir).isDirectory()) {
118
+ const result = searchCompileCommandsInDir(cxxDir);
119
+ if (result) {
120
+ ccJsonCache.set(currentDir, result);
121
+ return result;
122
+ }
123
+ return '';
124
+ }
125
+ const parent = path.dirname(currentDir);
126
+ if (parent === currentDir) {
127
+ break;
128
+ }
129
+ currentDir = parent;
130
+ }
131
+ return '';
132
+ }
133
+ exports.findCompileCommands = findCompileCommands;
134
+ /**
135
+ * Recursively search for compile_commands.json inside .cxx directory.
136
+ */
137
+ function searchCompileCommandsInDir(dir) {
138
+ let entries;
139
+ try {
140
+ entries = fs.readdirSync(dir, { withFileTypes: true });
141
+ }
142
+ catch (_a) {
143
+ return '';
144
+ }
145
+ for (const entry of entries) {
146
+ const fullPath = path.join(dir, entry.name);
147
+ if (entry.isFile() && entry.name === 'compile_commands.json') {
148
+ return dir;
149
+ }
150
+ if (entry.isDirectory()) {
151
+ const result = searchCompileCommandsInDir(fullPath);
152
+ if (result) {
153
+ return result;
154
+ }
155
+ }
156
+ }
157
+ return '';
158
+ }
@@ -14,17 +14,4 @@ export declare function getCxxHeaderFileExtensionSet(): ReadonlySet<string>;
14
14
  export declare function getCxxImplementationFileExtensions(): readonly string[];
15
15
  /** Returns a read-only set for fast C/C++ implementation-file checks. */
16
16
  export declare function getCxxImplementationFileExtensionSet(): ReadonlySet<string>;
17
- export declare function findProjectRoot(startDIr?: string): string;
18
- /**
19
- * Resolved path to the astJsonDumper executable for the current OS (Windows: .exe under dumper/ or lib/ast/).
20
- */
21
- export declare function getAstJsonDumperPath(): string;
22
- /** True when the astJsonDumper binary exists at {@link getAstJsonDumperPath}. */
23
- export declare function isAstJsonDumperAvailable(): boolean;
24
- export declare class ClangPath {
25
- static WindowsPath: string;
26
- static LinuxPath: string;
27
- static Unknown: string;
28
- static protectRoot: string;
29
- }
30
17
  //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/ast/ts/const.ts"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,SAAS,MAAM,EAAE,CAE9D;AAED,6EAA6E;AAC7E,wBAAgB,4BAA4B,IAAI,WAAW,CAAC,MAAM,CAAC,CAElE;AAED,sEAAsE;AACtE,wBAAgB,4BAA4B,IAAI,WAAW,CAAC,MAAM,CAAC,CAElE;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,IAAI,SAAS,MAAM,EAAE,CAEtE;AAED,yEAAyE;AACzE,wBAAgB,oCAAoC,IAAI,WAAW,CAAC,MAAM,CAAC,CAE1E"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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.getCxxImplementationFileExtensionSet = exports.getCxxImplementationFileExtensions = exports.getCxxHeaderFileExtensionSet = exports.getCxxSourceFileExtensionSet = exports.getCxxSourceFileExtensions = void 0;
18
+ /** C/C++ implementation file extensions (translation units). */
19
+ const CXX_IMPLEMENTATION_EXTENSIONS = ['.c', '.cc', '.cpp', '.cxx'];
20
+ /** C/C++ header extensions. */
21
+ const CXX_HEADER_EXTENSIONS = ['.h', '.hh', '.hpp'];
22
+ const CXX_IMPLEMENTATION_EXTENSION_SET = new Set(CXX_IMPLEMENTATION_EXTENSIONS);
23
+ const CXX_HEADER_EXTENSION_SET = new Set(CXX_HEADER_EXTENSIONS);
24
+ const CXX_SOURCE_EXTENSION_SET = new Set([
25
+ ...CXX_IMPLEMENTATION_EXTENSIONS,
26
+ ...CXX_HEADER_EXTENSIONS,
27
+ ]);
28
+ /**
29
+ * Returns extensions for C/C++ implementation and header files used across the C++ frontend
30
+ * (scanning, SceneConfig defaults, language detection).
31
+ */
32
+ function getCxxSourceFileExtensions() {
33
+ return [...CXX_IMPLEMENTATION_EXTENSIONS, ...CXX_HEADER_EXTENSIONS];
34
+ }
35
+ exports.getCxxSourceFileExtensions = getCxxSourceFileExtensions;
36
+ /** Returns a read-only set for fast C/C++ source/header extension checks. */
37
+ function getCxxSourceFileExtensionSet() {
38
+ return CXX_SOURCE_EXTENSION_SET;
39
+ }
40
+ exports.getCxxSourceFileExtensionSet = getCxxSourceFileExtensionSet;
41
+ /** Returns a read-only set for fast C/C++ header extension checks. */
42
+ function getCxxHeaderFileExtensionSet() {
43
+ return CXX_HEADER_EXTENSION_SET;
44
+ }
45
+ exports.getCxxHeaderFileExtensionSet = getCxxHeaderFileExtensionSet;
46
+ /**
47
+ * Returns extensions for C/C++ translation units only (no headers), e.g. for IR passes that
48
+ * walk implementation files.
49
+ */
50
+ function getCxxImplementationFileExtensions() {
51
+ return [...CXX_IMPLEMENTATION_EXTENSIONS];
52
+ }
53
+ exports.getCxxImplementationFileExtensions = getCxxImplementationFileExtensions;
54
+ /** Returns a read-only set for fast C/C++ implementation-file checks. */
55
+ function getCxxImplementationFileExtensionSet() {
56
+ return CXX_IMPLEMENTATION_EXTENSION_SET;
57
+ }
58
+ exports.getCxxImplementationFileExtensionSet = getCxxImplementationFileExtensionSet;
@@ -0,0 +1,8 @@
1
+ export interface AstJsonDumpRequest {
2
+ sourceFile: string;
3
+ outputFile: string;
4
+ ccJsonPath?: string;
5
+ includeDirs?: string[];
6
+ }
7
+ export declare function dumpAstJson(request: AstJsonDumpRequest, cwd: string, llvmPath?: string): number;
8
+ //# sourceMappingURL=napiApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"napiApi.d.ts","sourceRoot":"","sources":["../../../../../../src/frontend/cppFrontend/ast/ts/napi/napiApi.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,kBAAkB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AA6BD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAqB/F"}