@idlizer/arktscgen 2.1.10-arktscgen-7 → 2.1.10-arktscgen-9
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/build/libarkts-copy/generator/options.json5 +88 -97
- package/build/libarkts-copy/native/meson.build +56 -3
- package/build/libarkts-copy/native/mingw.cross +2 -5
- package/build/libarkts-copy/native/src/bridges.cpp +1 -269
- package/build/libarkts-copy/native/src/common.cpp +49 -67
- package/build/libarkts-copy/native/src/common.h +0 -15
- package/build/libarkts-copy/package.json +4 -8
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +0 -56
- package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +25 -58
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +8 -13
- package/build/libarkts-copy/src/arkts-api/plugins.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/static/global.ts +8 -1
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +9 -12
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +3 -0
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +8 -5
- package/build/libarkts-copy/src/index.ts +0 -1
- package/build/libarkts-copy/src/plugin-utils.ts +2 -1
- package/build/libarkts-copy/src/reexport-for-generated.ts +2 -1
- package/lib/index.js +305 -198
- package/package.json +3 -4
- package/templates/Es2pandaNativeModule.ts +1 -0
- package/templates/peer.ts +1 -0
|
@@ -14,110 +14,77 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { ArktsObject } from './ArktsObject';
|
|
17
|
-
import { Program } from '../../../generated';
|
|
17
|
+
import { compiler, Program } from '../../../generated';
|
|
18
18
|
import { global } from '../static/global';
|
|
19
|
-
import { passString, passStringArray } from '../utilities/private';
|
|
20
19
|
import { KNativePointer, nullptr, KBoolean } from '@koalaui/interop';
|
|
21
20
|
import { Config } from './Config';
|
|
22
|
-
import { filterSource
|
|
21
|
+
import { filterSource } from '../../utils';
|
|
23
22
|
import { AstNode } from './AstNode';
|
|
24
23
|
|
|
24
|
+
// Perhaps, this file would become generated some time later
|
|
25
|
+
// Please, do not add hard logic here
|
|
26
|
+
|
|
25
27
|
export class Context extends ArktsObject {
|
|
26
28
|
constructor(peer: KNativePointer) {
|
|
27
29
|
super(peer);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
static createFromString(source: string): Context {
|
|
31
|
-
|
|
32
|
-
throw new Error(`Config not initialized`);
|
|
33
|
-
}
|
|
34
|
-
return new Context(
|
|
35
|
-
global.generatedEs2panda._CreateContextFromString(global.config, passString(source), passString(global.filePath))
|
|
36
|
-
);
|
|
33
|
+
return compiler.createContextFromString(global.configObj, source, global.filePath);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
/** @deprecated Use {@link createCacheFromFile} instead */
|
|
40
36
|
static createCacheContextFromFile(
|
|
41
37
|
configPtr: KNativePointer,
|
|
42
38
|
fileName: string,
|
|
43
39
|
globalContextPtr: KNativePointer,
|
|
44
40
|
isExternal: KBoolean
|
|
45
41
|
): Context {
|
|
46
|
-
return new
|
|
47
|
-
global.generatedEs2panda._CreateCacheContextFromFile(configPtr, passString(fileName), globalContextPtr, isExternal)
|
|
48
|
-
);
|
|
42
|
+
return compiler.createCacheContextFromFile(new Config(configPtr), fileName, new GlobalContext(globalContextPtr), isExternal);
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
static createFromFile(filePath: string): Context {
|
|
52
|
-
return
|
|
46
|
+
return compiler.createContextFromFile(global.configObj, filePath);
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
static createCacheFromFile(filePath: string, config: Config, globalContext: GlobalContext, isExternal: boolean) {
|
|
56
|
-
return
|
|
57
|
-
global.generatedEs2panda._CreateCacheContextFromFile(
|
|
58
|
-
config.peer,
|
|
59
|
-
passString(filePath),
|
|
60
|
-
globalContext.peer,
|
|
61
|
-
isExternal
|
|
62
|
-
)
|
|
63
|
-
);
|
|
49
|
+
static createCacheFromFile(filePath: string, config: Config, globalContext: GlobalContext, isExternal: boolean): Context {
|
|
50
|
+
return compiler.createCacheContextFromFile(config, filePath, globalContext, isExternal);
|
|
64
51
|
}
|
|
65
52
|
|
|
66
53
|
static createContextGenerateAbcForExternalSourceFiles(filenames: string[]): Context {
|
|
67
|
-
|
|
68
|
-
throwError(`Config not initialized`);
|
|
69
|
-
}
|
|
70
|
-
return new Context(
|
|
71
|
-
global.generatedEs2panda._CreateContextGenerateAbcForExternalSourceFiles(
|
|
72
|
-
global.config,
|
|
73
|
-
filenames.length,
|
|
74
|
-
passStringArray(filenames)
|
|
75
|
-
)
|
|
76
|
-
);
|
|
54
|
+
return compiler.createContextGenerateAbcForExternalSourceFiles(global.configObj, filenames);
|
|
77
55
|
}
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
static createFromStringWithHistory(source: string): Context {
|
|
58
|
+
return compiler.createContextFromStringWithHistory(global.configObj, source, global.filePath);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
destroy(): void {
|
|
62
|
+
compiler.destroyContext();
|
|
84
63
|
}
|
|
85
64
|
|
|
86
65
|
/** @deprecated */
|
|
87
66
|
static destroyAndRecreate(ast: AstNode): Context {
|
|
88
67
|
console.log('[TS WRAPPER] DESTROY AND RECREATE');
|
|
89
68
|
const source = filterSource(ast.dumpSrc());
|
|
90
|
-
|
|
91
|
-
global.compilerContext = Context.createFromString(source)
|
|
92
|
-
|
|
93
|
-
return new Context(global.context);
|
|
69
|
+
compiler.destroyContext();
|
|
70
|
+
return global.compilerContext = Context.createFromString(source);
|
|
94
71
|
}
|
|
95
72
|
|
|
96
73
|
get program(): Program {
|
|
97
|
-
return
|
|
74
|
+
return compiler.contextProgram();
|
|
98
75
|
}
|
|
99
76
|
}
|
|
100
77
|
|
|
101
78
|
export class GlobalContext extends ArktsObject {
|
|
102
|
-
static create(config: Config, externalFileList: string[]): GlobalContext {
|
|
103
|
-
return new GlobalContext(
|
|
104
|
-
global.generatedEs2panda._CreateGlobalContext(
|
|
105
|
-
config.peer,
|
|
106
|
-
passStringArray(externalFileList),
|
|
107
|
-
externalFileList.length,
|
|
108
|
-
false
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
79
|
constructor(peer: KNativePointer) {
|
|
114
80
|
super(peer);
|
|
115
81
|
}
|
|
116
82
|
|
|
83
|
+
static create(config: Config, externalFileList: string[]): GlobalContext {
|
|
84
|
+
return compiler.createGlobalContext(config, externalFileList, false);
|
|
85
|
+
}
|
|
86
|
+
|
|
117
87
|
destroy() {
|
|
118
|
-
|
|
119
|
-
global.generatedEs2panda._DestroyGlobalContext(this.peer);
|
|
120
|
-
this.peer = nullptr;
|
|
121
|
-
}
|
|
88
|
+
compiler.destroyGlobalContext();
|
|
122
89
|
}
|
|
123
90
|
}
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import { acceptNativeObjectArrayResult, unpackString } from '../utilities/private';
|
|
18
|
-
import { KNativePointer, nullptr } from '@koalaui/interop';
|
|
16
|
+
import { KNativePointer } from '@koalaui/interop';
|
|
19
17
|
import { Program } from '../../../generated';
|
|
20
18
|
import { ArktsObject } from './ArktsObject';
|
|
19
|
+
import { compiler } from '../../../generated';
|
|
20
|
+
|
|
21
|
+
// Perhaps, this file would become generated some time later
|
|
22
|
+
// Please, do not add hard logic here
|
|
21
23
|
|
|
22
24
|
export class ExternalSource extends ArktsObject {
|
|
23
25
|
constructor(peer: KNativePointer) {
|
|
@@ -25,17 +27,10 @@ export class ExternalSource extends ArktsObject {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
getName(): string {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get programs(): Program[] {
|
|
32
|
-
return acceptNativeObjectArrayResult<Program>(
|
|
33
|
-
global.es2panda._ExternalSourcePrograms(this.peer),
|
|
34
|
-
(instance: KNativePointer) => new Program(instance)
|
|
35
|
-
);
|
|
30
|
+
return compiler.externalSourceName(this);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
return
|
|
33
|
+
get programs(): readonly Program[] {
|
|
34
|
+
return compiler.externalSourcePrograms(this);
|
|
40
35
|
}
|
|
41
36
|
}
|
|
@@ -223,10 +223,10 @@ export function defaultFilter(name: string): boolean {
|
|
|
223
223
|
return true;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter): Program[] {
|
|
226
|
+
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter): readonly Program[] {
|
|
227
227
|
return [
|
|
228
228
|
program,
|
|
229
|
-
...program.getExternalSources().flatMap((it: ExternalSource): Program[] => {
|
|
229
|
+
...program.getExternalSources().flatMap((it: ExternalSource): readonly Program[] => {
|
|
230
230
|
if (filter(it.getName())) {
|
|
231
231
|
return it.programs;
|
|
232
232
|
}
|
|
@@ -40,6 +40,7 @@ export class UpdateTracker {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export class global {
|
|
43
|
+
/** @deprecated */
|
|
43
44
|
public static filePath: string = './plugins/input/main.ets';
|
|
44
45
|
|
|
45
46
|
public static arktsconfig?: ArkTsConfig;
|
|
@@ -68,7 +69,6 @@ export class global {
|
|
|
68
69
|
|
|
69
70
|
// Improve: rename to context when the pointer valued one is eliminated
|
|
70
71
|
public static compilerContext: Context | undefined;
|
|
71
|
-
public static isContextGenerateAbcForExternalSourceFiles: boolean = false;
|
|
72
72
|
|
|
73
73
|
private static _es2panda: Es2pandaNativeModule | undefined = undefined;
|
|
74
74
|
public static get es2panda(): Es2pandaNativeModule {
|
|
@@ -79,6 +79,13 @@ export class global {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
private static _generatedEs2panda: GeneratedEs2pandaNativeModule | undefined = undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated
|
|
84
|
+
*
|
|
85
|
+
* You should not generally use generatedEs2panda in handwritten code
|
|
86
|
+
* (only in exceptional cases).
|
|
87
|
+
* Please use generated wrapper for native call instead.
|
|
88
|
+
*/
|
|
82
89
|
public static get generatedEs2panda(): GeneratedEs2pandaNativeModule {
|
|
83
90
|
if (this._generatedEs2panda === undefined) {
|
|
84
91
|
this._generatedEs2panda = initGeneratedEs2panda();
|
|
@@ -61,14 +61,14 @@ export function extension_MethodDefinitionOnUpdate(this: MethodDefinition, origi
|
|
|
61
61
|
|
|
62
62
|
// Improve: generate checker related stuff
|
|
63
63
|
export function extension_ScriptFunctionGetSignaturePointer(this: ScriptFunction): KNativePointer {
|
|
64
|
-
return global.
|
|
64
|
+
return global.generatedEs2panda._ScriptFunctionSignature(global.context, this.peer);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export function extension_ScriptFunctionSetSignaturePointer(
|
|
68
68
|
this: ScriptFunction,
|
|
69
69
|
signaturePointer: KNativePointer
|
|
70
70
|
): void {
|
|
71
|
-
global.
|
|
71
|
+
global.generatedEs2panda._ScriptFunctionSetSignature(global.context, this.peer, signaturePointer);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// Improve: weird API
|
|
@@ -81,23 +81,23 @@ export function extension_ScriptFunctionGetParamsCasted(this: ScriptFunction): r
|
|
|
81
81
|
|
|
82
82
|
// Improve: perhaps "preferredReturnType" stuff can be removed later if "signature" is always enough
|
|
83
83
|
export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: ScriptFunction): KNativePointer {
|
|
84
|
-
return global.
|
|
84
|
+
return global.generatedEs2panda._ScriptFunctionGetPreferredReturnType(global.context, this.peer);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function extension_ScriptFunctionSetPreferredReturnTypePointer(
|
|
88
88
|
this: ScriptFunction,
|
|
89
89
|
typePointer: KNativePointer
|
|
90
90
|
): void {
|
|
91
|
-
global.
|
|
91
|
+
global.generatedEs2panda._ScriptFunctionSetPreferredReturnType(global.context, this.peer, typePointer);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// Improve: generate checker related stuff
|
|
95
95
|
export function extension_ExpressionGetPreferredTypePointer(this: Expression): KNativePointer {
|
|
96
|
-
return global.
|
|
96
|
+
return global.generatedEs2panda._ExpressionPreferredTypeConst(global.context, this.peer);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export function extension_ExpressionSetPreferredTypePointer(this: Expression, typePointer: KNativePointer): void {
|
|
100
|
-
global.
|
|
100
|
+
global.generatedEs2panda._ExpressionSetPreferredType(global.context, this.peer, typePointer);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Improve: weird API
|
|
@@ -108,12 +108,9 @@ export function extension_ProgramGetAstCasted(this: Program): ETSModule {
|
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
export function extension_ProgramGetExternalSources(this: Program): ExternalSource[] {
|
|
113
|
-
return
|
|
114
|
-
global.es2panda._ProgramExternalSources(global.context, this.peer),
|
|
115
|
-
ExternalSource.instantiate
|
|
116
|
-
);
|
|
111
|
+
/** @deprecated Now generated */
|
|
112
|
+
export function extension_ProgramGetExternalSources(this: Program): readonly ExternalSource[] {
|
|
113
|
+
return this.externalSources;
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
// Improve: SourcePositionLine is global in idl
|
|
@@ -76,6 +76,9 @@ export function unpackNativeObjectArray<T extends ArktsObject>(
|
|
|
76
76
|
arrayObject: KNativePointer,
|
|
77
77
|
factory: (instance: KNativePointer) => T
|
|
78
78
|
): T[] {
|
|
79
|
+
if (arrayObject == nullptr) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
79
82
|
return acceptNativeObjectArrayResult(arrayObject, factory);
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -70,6 +70,7 @@ import { Context } from '../peers/Context';
|
|
|
70
70
|
import { NodeCache } from '../node-cache';
|
|
71
71
|
import { factory } from '../factory/nodeFactory';
|
|
72
72
|
import { traceGlobal } from '../../tracer';
|
|
73
|
+
import { compiler } from '../../../generated';
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Improve: Replace or remove with better naming
|
|
@@ -292,7 +293,7 @@ export function getAnnotations(node: AstNode): readonly AnnotationUsage[] {
|
|
|
292
293
|
if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) {
|
|
293
294
|
throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition');
|
|
294
295
|
}
|
|
295
|
-
return unpackNodeArray(global.
|
|
296
|
+
return unpackNodeArray(global.generatedEs2panda._AnnotationAllowedAnnotations(global.context, node.peer));
|
|
296
297
|
}
|
|
297
298
|
|
|
298
299
|
export function getOriginalNode(node: AstNode): AstNode {
|
|
@@ -411,14 +412,14 @@ export function signatureReturnType(signature: KNativePointer): KNativePointer {
|
|
|
411
412
|
if (!signature) {
|
|
412
413
|
return nullptr;
|
|
413
414
|
}
|
|
414
|
-
return global.
|
|
415
|
+
return global.generatedEs2panda._SignatureReturnType(global.context, signature);
|
|
415
416
|
}
|
|
416
417
|
|
|
417
418
|
export function convertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
418
419
|
if (!typePeer) {
|
|
419
420
|
return undefined;
|
|
420
421
|
}
|
|
421
|
-
return factory.createOpaqueTypeNode(global.
|
|
422
|
+
return factory.createOpaqueTypeNode(global.generatedEs2panda._TypeClone(global.context, typePeer));
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
export function originalSourcePositionString(node: AstNode | undefined) {
|
|
@@ -521,10 +522,12 @@ export function filterNodesByTypes(node: AstNode, types: Es2pandaAstNodeType[]):
|
|
|
521
522
|
return unpackNodeArray(global.es2panda._FilterNodes3(global.context, passNode(node), typesArray, types.length));
|
|
522
523
|
}
|
|
523
524
|
|
|
525
|
+
// This functions are used as capitalized in build-system, unlike the others
|
|
526
|
+
// See https://gitcode.com/openharmony/arkcompiler_ets_frontend/issues/8196
|
|
524
527
|
export function MemInitialize() {
|
|
525
|
-
|
|
528
|
+
compiler.memInitialize()
|
|
526
529
|
}
|
|
527
530
|
|
|
528
531
|
export function MemFinalize() {
|
|
529
|
-
|
|
532
|
+
compiler.memFinalize()
|
|
530
533
|
}
|
|
@@ -33,7 +33,6 @@ export * from './arkts-api/node-utilities/ArkTsConfig';
|
|
|
33
33
|
export * from './arkts-api/peers/AstNode';
|
|
34
34
|
export * from './arkts-api/peers/Config';
|
|
35
35
|
export * from './arkts-api/peers/Context';
|
|
36
|
-
export { GlobalContext } from './arkts-api/peers/Context';
|
|
37
36
|
export * from './arkts-api/peers/ExternalSource';
|
|
38
37
|
export * from './arkts-api/peers/ImportPathManager';
|
|
39
38
|
export * from './arkts-api/peers/Options';
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
ProgramProvider,
|
|
26
26
|
CompilationOptions,
|
|
27
27
|
PluginContextImpl,
|
|
28
|
+
Es2pandaCompilationMode,
|
|
28
29
|
} from './arkts-api';
|
|
29
30
|
import { Tracer } from './tracer';
|
|
30
31
|
import { global } from "./arkts-api/static/global";
|
|
@@ -114,7 +115,7 @@ export function runTransformer(
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
function isProgramForCodegeneration(program: Program, isMainProgram: boolean): boolean {
|
|
117
|
-
if (
|
|
118
|
+
if (arktsGlobal.configObj?.compilationMode != Es2pandaCompilationMode.COMPILATION_MODE_GEN_ABC_FOR_EXTERNAL_SOURCE) {
|
|
118
119
|
return isMainProgram;
|
|
119
120
|
}
|
|
120
121
|
return program.isGenAbcForExternal;
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
export { KNativePointer } from '@koalaui/interop';
|
|
16
|
+
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
16
17
|
export { AstNode } from './arkts-api/peers/AstNode';
|
|
17
18
|
export { Config } from './arkts-api/peers/Config';
|
|
18
19
|
export { Context, GlobalContext } from './arkts-api/peers/Context';
|
|
19
|
-
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
20
20
|
export { NodeCache } from './arkts-api/node-cache';
|
|
21
|
+
export { ExternalSource } from './arkts-api/peers/ExternalSource';
|
|
21
22
|
export {
|
|
22
23
|
passNode,
|
|
23
24
|
unpackNonNullableNode,
|