@idlizer/arktscgen 2.1.9-arktscgen-8 → 2.1.9-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 +27 -1
- package/build/libarkts-copy/native/src/bridges.cc +51 -13
- package/build/libarkts-copy/native/src/common.cc +6 -2
- package/build/libarkts-copy/native/src/common.h +1 -0
- package/build/libarkts-copy/native/src/generated/bridges.cc +30 -2
- package/build/libarkts-copy/package.json +4 -4
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +17 -5
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -11
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +7 -0
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +4 -0
- package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -4
- package/build/libarkts-copy/src/arkts-api/static/global.ts +1 -0
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +24 -1
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +68 -4
- package/build/libarkts-copy/src/arkts-api/visitor.ts +1 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +93 -91
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +9 -0
- package/build/libarkts-copy/src/generated/factory.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/Program.ts +2 -0
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +12 -0
- package/build/libarkts-copy/src/plugin-utils.ts +13 -3
- package/build/libarkts-copy/src/reexport-for-generated.ts +3 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +2 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +2 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +3 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +3 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +2 -19
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +4 -2
- package/lib/index.js +159 -94
- package/package.json +2 -2
|
@@ -253,7 +253,16 @@
|
|
|
253
253
|
types: ["returnType"]
|
|
254
254
|
}
|
|
255
255
|
]
|
|
256
|
-
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "ClassDeclaration",
|
|
259
|
+
methods: [
|
|
260
|
+
{
|
|
261
|
+
name: "Definition",
|
|
262
|
+
types: ["returnType"]
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
},
|
|
257
266
|
],
|
|
258
267
|
fragments: [
|
|
259
268
|
{
|
|
@@ -281,6 +290,14 @@
|
|
|
281
290
|
{
|
|
282
291
|
interface: "ScriptFunction",
|
|
283
292
|
methods: [
|
|
293
|
+
{
|
|
294
|
+
name: "getSignaturePointer",
|
|
295
|
+
definition: "extension_ScriptFunctionGetSignaturePointer",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "setSignaturePointer",
|
|
299
|
+
definition: "extension_ScriptFunctionSetSignaturePointer",
|
|
300
|
+
},
|
|
284
301
|
{
|
|
285
302
|
name: "getPreferredReturnTypePointer",
|
|
286
303
|
definition: "extension_ScriptFunctionGetPreferredReturnTypePointer",
|
|
@@ -291,6 +308,15 @@
|
|
|
291
308
|
},
|
|
292
309
|
]
|
|
293
310
|
},
|
|
311
|
+
{
|
|
312
|
+
interface: "Program",
|
|
313
|
+
methods: [
|
|
314
|
+
{
|
|
315
|
+
name: "getExternalSources",
|
|
316
|
+
definition: "extension_ProgramGetExternalSources",
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
}
|
|
294
320
|
],
|
|
295
321
|
parameters: [
|
|
296
322
|
{
|
|
@@ -405,6 +405,32 @@ KOALA_INTEROP_V1(DestroyGlobalContext, KNativePointer)
|
|
|
405
405
|
// All these "Checker_" bridges are related to checker namespace in es2panda, so work with them carefully
|
|
406
406
|
// Checker.Type does reset on recheck, so modifying them makes no sence
|
|
407
407
|
// It seems that compiler does not provide API to convert Checker.Type to ir.Type
|
|
408
|
+
KNativePointer impl_Checker_ScriptFunctionSignature(KNativePointer context, KNativePointer node)
|
|
409
|
+
{
|
|
410
|
+
auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
411
|
+
auto _node = reinterpret_cast<es2panda_AstNode*>(node);
|
|
412
|
+
return GetImpl()->ScriptFunctionSignature(_context, _node);
|
|
413
|
+
}
|
|
414
|
+
KOALA_INTEROP_2(Checker_ScriptFunctionSignature, KNativePointer, KNativePointer, KNativePointer)
|
|
415
|
+
|
|
416
|
+
void impl_Checker_ScriptFunctionSetSignature(KNativePointer context, KNativePointer node, KNativePointer signature)
|
|
417
|
+
{
|
|
418
|
+
auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
419
|
+
auto _node = reinterpret_cast<es2panda_AstNode*>(node);
|
|
420
|
+
auto _signature = reinterpret_cast<es2panda_Signature*>(signature);
|
|
421
|
+
GetImpl()->ScriptFunctionSetSignature(_context, _node, _signature);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
KOALA_INTEROP_V3(Checker_ScriptFunctionSetSignature, KNativePointer, KNativePointer, KNativePointer)
|
|
425
|
+
|
|
426
|
+
KNativePointer impl_Checker_SignatureReturnType(KNativePointer context, KNativePointer signature)
|
|
427
|
+
{
|
|
428
|
+
auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
429
|
+
auto _signature = reinterpret_cast<es2panda_Signature*>(signature);
|
|
430
|
+
return GetImpl()->SignatureReturnType(_context, _signature);
|
|
431
|
+
}
|
|
432
|
+
KOALA_INTEROP_2(Checker_SignatureReturnType, KNativePointer, KNativePointer, KNativePointer)
|
|
433
|
+
|
|
408
434
|
KNativePointer impl_Checker_ScriptFunctionGetPreferredReturnType(KNativePointer context, KNativePointer node)
|
|
409
435
|
{
|
|
410
436
|
auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
@@ -553,10 +579,12 @@ KNativePointer impl_CreateDiagnosticKind(KNativePointer context, KStringPtr& mes
|
|
|
553
579
|
}
|
|
554
580
|
KOALA_INTEROP_3(CreateDiagnosticKind, KNativePointer, KNativePointer, KStringPtr, KInt)
|
|
555
581
|
|
|
556
|
-
KNativePointer impl_CreateDiagnosticInfo(KNativePointer context, KNativePointer kind, KStringArray argsPtr,
|
|
582
|
+
KNativePointer impl_CreateDiagnosticInfo(KNativePointer context, KNativePointer kind, KStringArray argsPtr,
|
|
583
|
+
KInt argc, KNativePointer pos)
|
|
557
584
|
{
|
|
558
585
|
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
559
586
|
const auto _kind = reinterpret_cast<es2panda_DiagnosticKind*>(kind);
|
|
587
|
+
const auto _pos = reinterpret_cast<es2panda_SourcePosition *>(pos);
|
|
560
588
|
const std::size_t headerLen = 4;
|
|
561
589
|
const char** _args = new const char*[argc];
|
|
562
590
|
std::size_t position = headerLen;
|
|
@@ -567,15 +595,17 @@ KNativePointer impl_CreateDiagnosticInfo(KNativePointer context, KNativePointer
|
|
|
567
595
|
_args[i] = strdup(std::string(reinterpret_cast<const char*>(argsPtr + position), strLen).c_str());
|
|
568
596
|
position += strLen;
|
|
569
597
|
}
|
|
570
|
-
return GetImpl()->CreateDiagnosticInfo(_context, _kind, _args, argc);
|
|
598
|
+
return GetImpl()->CreateDiagnosticInfo(_context, _kind, _args, argc, _pos);
|
|
571
599
|
}
|
|
572
|
-
|
|
600
|
+
KOALA_INTEROP_5(CreateDiagnosticInfo, KNativePointer, KNativePointer, KNativePointer,
|
|
601
|
+
KStringArray, KInt, KNativePointer)
|
|
573
602
|
|
|
574
603
|
KNativePointer impl_CreateSuggestionInfo(KNativePointer context, KNativePointer kind, KStringArray argsPtr,
|
|
575
|
-
KInt argc, KStringPtr& substitutionCode)
|
|
604
|
+
KInt argc, KStringPtr& substitutionCode, KNativePointer range)
|
|
576
605
|
{
|
|
577
606
|
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
578
607
|
const auto _kind = reinterpret_cast<es2panda_DiagnosticKind *>(kind);
|
|
608
|
+
const auto _range = reinterpret_cast<es2panda_SourceRange *>(range);
|
|
579
609
|
const std::size_t headerLen = 4;
|
|
580
610
|
const char** _args = new const char*[argc];
|
|
581
611
|
std::size_t position = headerLen;
|
|
@@ -587,9 +617,9 @@ KNativePointer impl_CreateSuggestionInfo(KNativePointer context, KNativePointer
|
|
|
587
617
|
position += strLen;
|
|
588
618
|
}
|
|
589
619
|
const auto _substitutionCode = getStringCopy(substitutionCode);
|
|
590
|
-
return GetImpl()->CreateSuggestionInfo(_context, _kind, _args, argc, _substitutionCode);
|
|
620
|
+
return GetImpl()->CreateSuggestionInfo(_context, _kind, _args, argc, _substitutionCode, _range);
|
|
591
621
|
}
|
|
592
|
-
|
|
622
|
+
KOALA_INTEROP_6(CreateSuggestionInfo, KNativePointer, KNativePointer, KNativePointer, KStringArray, KInt, KStringPtr, KNativePointer)
|
|
593
623
|
|
|
594
624
|
void impl_LogDiagnostic(KNativePointer context, KNativePointer kind, KStringArray argvPtr,
|
|
595
625
|
KInt argc, KNativePointer pos)
|
|
@@ -612,15 +642,14 @@ void impl_LogDiagnostic(KNativePointer context, KNativePointer kind, KStringArra
|
|
|
612
642
|
KOALA_INTEROP_V5(LogDiagnostic, KNativePointer, KNativePointer, KStringArray, KInt, KNativePointer)
|
|
613
643
|
|
|
614
644
|
void impl_LogDiagnosticWithSuggestion(KNativePointer context, KNativePointer diagnosticInfo,
|
|
615
|
-
KNativePointer suggestionInfo
|
|
645
|
+
KNativePointer suggestionInfo)
|
|
616
646
|
{
|
|
617
647
|
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
618
648
|
const auto _diagnosticInfo = reinterpret_cast<es2panda_DiagnosticInfo*>(diagnosticInfo);
|
|
619
649
|
const auto _suggestionInfo = reinterpret_cast<es2panda_SuggestionInfo*>(suggestionInfo);
|
|
620
|
-
|
|
621
|
-
GetImpl()->LogDiagnosticWithSuggestion(_context, _diagnosticInfo, _suggestionInfo, _range);
|
|
650
|
+
GetImpl()->LogDiagnosticWithSuggestion(_context, _diagnosticInfo, _suggestionInfo);
|
|
622
651
|
}
|
|
623
|
-
|
|
652
|
+
KOALA_INTEROP_V3(LogDiagnosticWithSuggestion, KNativePointer, KNativePointer, KNativePointer)
|
|
624
653
|
|
|
625
654
|
KInt impl_GenerateStaticDeclarationsFromContext(KNativePointer contextPtr, KStringPtr &outputPath)
|
|
626
655
|
{
|
|
@@ -640,12 +669,12 @@ KNativePointer impl_AnnotationUsageIrPropertiesPtrConst(KNativePointer context,
|
|
|
640
669
|
KOALA_INTEROP_2(AnnotationUsageIrPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer);
|
|
641
670
|
|
|
642
671
|
KInt impl_GenerateTsDeclarationsFromContext(KNativePointer contextPtr, KStringPtr &outputDeclEts, KStringPtr &outputEts,
|
|
643
|
-
KBoolean exportAll, KBoolean isolated)
|
|
672
|
+
KBoolean exportAll, KBoolean isolated, KStringPtr &recordFile)
|
|
644
673
|
{
|
|
645
674
|
auto context = reinterpret_cast<es2panda_Context *>(contextPtr);
|
|
646
|
-
return GetImpl()->GenerateTsDeclarationsFromContext(context, outputDeclEts.data(), outputEts.data(), exportAll, isolated );
|
|
675
|
+
return GetImpl()->GenerateTsDeclarationsFromContext(context, outputDeclEts.data(), outputEts.data(), exportAll, isolated, recordFile.data() );
|
|
647
676
|
}
|
|
648
|
-
|
|
677
|
+
KOALA_INTEROP_6(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean, KBoolean, KStringPtr)
|
|
649
678
|
|
|
650
679
|
// Improve: simplify
|
|
651
680
|
KNativePointer impl_CreateContextGenerateAbcForExternalSourceFiles(
|
|
@@ -670,3 +699,12 @@ KNativePointer impl_CreateContextGenerateAbcForExternalSourceFiles(
|
|
|
670
699
|
config, fileNamesCount, argv);
|
|
671
700
|
}
|
|
672
701
|
KOALA_INTEROP_3(CreateContextGenerateAbcForExternalSourceFiles, KNativePointer, KNativePointer, KInt, KStringArray)
|
|
702
|
+
|
|
703
|
+
KNativePointer impl_JsdocStringFromDeclaration(KNativePointer contextPtr, KNativePointer nodePtr)
|
|
704
|
+
{
|
|
705
|
+
auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
|
|
706
|
+
auto node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
|
|
707
|
+
return StageArena::strdup(GetImpl()->JsdocStringFromDeclaration(context, node));
|
|
708
|
+
}
|
|
709
|
+
KOALA_INTEROP_2(JsdocStringFromDeclaration, KNativePointer, KNativePointer, KNativePointer)
|
|
710
|
+
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
#include <common.h>
|
|
17
17
|
#include <utility>
|
|
18
|
+
#include "interop-types.h"
|
|
18
19
|
|
|
19
20
|
using std::string, std::cout, std::endl, std::vector;
|
|
20
21
|
|
|
@@ -58,13 +59,16 @@ char* StageArena::strdup(const char* string)
|
|
|
58
59
|
auto* arena = StageArena::instance();
|
|
59
60
|
auto size = strlen(string) + 1;
|
|
60
61
|
char* memory = (char*)arena->alloc(size);
|
|
61
|
-
|
|
62
|
+
interop_memcpy(memory, size, string, size);
|
|
62
63
|
return memory;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
void* StageArena::alloc(size_t size)
|
|
66
67
|
{
|
|
67
68
|
void* result = malloc(size);
|
|
69
|
+
if (!result) {
|
|
70
|
+
INTEROP_FATAL("Cannot allocate memory");
|
|
71
|
+
}
|
|
68
72
|
totalSize += size;
|
|
69
73
|
add(result);
|
|
70
74
|
return result;
|
|
@@ -131,7 +135,7 @@ KOALA_INTEROP_V1(SetUpSoPath, KStringPtr);
|
|
|
131
135
|
void* FindLibrary() {
|
|
132
136
|
void *res = nullptr;
|
|
133
137
|
std::vector<std::string> pathArray;
|
|
134
|
-
|
|
138
|
+
|
|
135
139
|
// find by SetUpSoPath
|
|
136
140
|
if (!ES2PANDA_LIB_PATH.empty()) {
|
|
137
141
|
pathArray = {ES2PANDA_LIB_PATH, LIB_DIR, LIB_ES2PANDA_PUBLIC};
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
#include <common.h>
|
|
17
17
|
|
|
18
18
|
/*
|
|
19
|
-
* THIS FILE IS AUTOGENERATED BY arktscgen v2.1.9
|
|
20
|
-
* es2panda
|
|
19
|
+
* THIS FILE IS AUTOGENERATED BY arktscgen v2.1.9-arktscgen-8. DO NOT EDIT MANUALLY!
|
|
20
|
+
* es2panda 2d77536b9b49352e16827106a4f4311e221008c5(2025-07-30) sdk v1.5.0-dev.39323
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
KNativePointer impl_CreateNumberLiteral(KNativePointer context, KInt value)
|
|
@@ -4281,6 +4281,34 @@ KUInt impl_ScriptFunctionFormalParamsLengthConst(KNativePointer context, KNative
|
|
|
4281
4281
|
}
|
|
4282
4282
|
KOALA_INTEROP_2(ScriptFunctionFormalParamsLengthConst, KUInt, KNativePointer, KNativePointer);
|
|
4283
4283
|
|
|
4284
|
+
void impl_ScriptFunctionSetAsyncPairMethod(KNativePointer context, KNativePointer receiver, KNativePointer asyncPairFunction)
|
|
4285
|
+
{
|
|
4286
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
4287
|
+
const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
|
|
4288
|
+
const auto _asyncPairFunction = reinterpret_cast<es2panda_AstNode*>(asyncPairFunction);
|
|
4289
|
+
GetImpl()->ScriptFunctionSetAsyncPairMethod(_context, _receiver, _asyncPairFunction);
|
|
4290
|
+
return ;
|
|
4291
|
+
}
|
|
4292
|
+
KOALA_INTEROP_V3(ScriptFunctionSetAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer);
|
|
4293
|
+
|
|
4294
|
+
KNativePointer impl_ScriptFunctionAsyncPairMethodConst(KNativePointer context, KNativePointer receiver)
|
|
4295
|
+
{
|
|
4296
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
4297
|
+
const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
|
|
4298
|
+
auto result = GetImpl()->ScriptFunctionAsyncPairMethodConst(_context, _receiver);
|
|
4299
|
+
return (void*)result;
|
|
4300
|
+
}
|
|
4301
|
+
KOALA_INTEROP_2(ScriptFunctionAsyncPairMethodConst, KNativePointer, KNativePointer, KNativePointer);
|
|
4302
|
+
|
|
4303
|
+
KNativePointer impl_ScriptFunctionAsyncPairMethod(KNativePointer context, KNativePointer receiver)
|
|
4304
|
+
{
|
|
4305
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
4306
|
+
const auto _receiver = reinterpret_cast<es2panda_AstNode*>(receiver);
|
|
4307
|
+
auto result = GetImpl()->ScriptFunctionAsyncPairMethod(_context, _receiver);
|
|
4308
|
+
return result;
|
|
4309
|
+
}
|
|
4310
|
+
KOALA_INTEROP_2(ScriptFunctionAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer);
|
|
4311
|
+
|
|
4284
4312
|
void impl_ScriptFunctionEmplaceReturnStatements(KNativePointer context, KNativePointer receiver, KNativePointer returnStatements)
|
|
4285
4313
|
{
|
|
4286
4314
|
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"typesVersions": {
|
|
6
6
|
"*": {
|
|
7
7
|
"./compat/*": [
|
|
8
|
-
"./
|
|
8
|
+
"./lib/types/wrapper-compat/index.d.ts"
|
|
9
9
|
],
|
|
10
10
|
"*": [
|
|
11
|
-
"./lib/
|
|
11
|
+
"./lib/types/index.d.ts"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./plugins/build/src/**/*"
|
|
24
24
|
],
|
|
25
25
|
"config": {
|
|
26
|
-
"gen_version": "2.1.9-arktscgen-
|
|
26
|
+
"gen_version": "2.1.9-arktscgen-8",
|
|
27
27
|
"panda_sdk_path": "../../incremental/tools/panda/node_modules/@panda/sdk",
|
|
28
28
|
"ohos_panda_sdk_path": "../build/sdk",
|
|
29
29
|
"panda_sdk_version": "next"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"compile:js": "rm -rf lib/ && rollup -c rollup.lib.mjs && rollup -c rollup.es2panda.mjs",
|
|
66
66
|
"compile:plugins": "rollup -c ./rollup.printer-plugin.mjs",
|
|
67
67
|
"direct": "fast-arktsc --config arktsconfig.json --compiler ../../incremental/tools/panda/arkts/ui2abc --link-name ./build/abc/main.abc && ninja -f build/abc/build.ninja",
|
|
68
|
-
"simultaneous": "../../incremental/tools/panda/arkts/ui2abc --arktsconfig arktsconfig.json --output ./build/abc/main.abc:./build/abc/library.abc plugins/input/main.ets:plugins/input/library.ets",
|
|
68
|
+
"simultaneous": "mkdir -p build/abc && bash ../../incremental/tools/panda/arkts/ui2abc --simultaneous --arktsconfig arktsconfig.json --output ./build/abc/main.abc:./build/abc/library.abc plugins/input/main.ets:plugins/input/library.ets",
|
|
69
69
|
"run": "npm run compile && npm run compile:plugins && npm run simultaneous",
|
|
70
70
|
"run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo",
|
|
71
71
|
"run:abc": "$npm_package_config_panda_sdk_path/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=$npm_package_config_panda_sdk_path/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main",
|
|
@@ -162,6 +162,15 @@ export class Es2pandaNativeModule {
|
|
|
162
162
|
_OptionsArkTsConfig(context: KNativePointer, options: KNativePointer): KNativePointer {
|
|
163
163
|
throw new Error("Not implemented");
|
|
164
164
|
}
|
|
165
|
+
_Checker_ScriptFunctionSignature(context: KNativePointer, node: KNativePointer): KNativePointer {
|
|
166
|
+
throw new Error("Not implemented");
|
|
167
|
+
}
|
|
168
|
+
_Checker_ScriptFunctionSetSignature(context: KNativePointer, node: KNativePointer, signature: KNativePointer): void {
|
|
169
|
+
throw new Error("Not implemented");
|
|
170
|
+
}
|
|
171
|
+
_Checker_SignatureReturnType(context: KNativePointer, signature: KNativePointer): KNativePointer {
|
|
172
|
+
throw new Error("Not implemented");
|
|
173
|
+
}
|
|
165
174
|
_Checker_ScriptFunctionGetPreferredReturnType(context: KNativePointer, node: KNativePointer): KNativePointer {
|
|
166
175
|
throw new Error("Not implemented");
|
|
167
176
|
}
|
|
@@ -174,6 +183,9 @@ export class Es2pandaNativeModule {
|
|
|
174
183
|
_Checker_TypeNodeGetType(context: KNativePointer, node: KNativePointer): KNativePointer {
|
|
175
184
|
throw new Error("Not implemented");
|
|
176
185
|
}
|
|
186
|
+
_JsdocStringFromDeclaration(context: KPtr, node: KPtr): KPtr {
|
|
187
|
+
throw new Error("Not implemented")
|
|
188
|
+
}
|
|
177
189
|
|
|
178
190
|
// From koala-wrapper
|
|
179
191
|
_ClassVariableDeclaration(context: KNativePointer, classInstance: KNativePointer): KNativePointer {
|
|
@@ -200,18 +212,18 @@ export class Es2pandaNativeModule {
|
|
|
200
212
|
_CreateDiagnosticKind(context: KNativePointer, message: string, type: Es2pandaPluginDiagnosticType): KNativePointer {
|
|
201
213
|
throw new Error("Not implemented")
|
|
202
214
|
}
|
|
203
|
-
_CreateDiagnosticInfo(context: KNativePointer, kind: KNativePointer, args: string[], argc: number): KNativePointer {
|
|
215
|
+
_CreateDiagnosticInfo(context: KNativePointer, kind: KNativePointer, args: string[], argc: number, pos: KNativePointer): KNativePointer {
|
|
204
216
|
throw new Error("Not implemented")
|
|
205
217
|
}
|
|
206
218
|
_CreateSuggestionInfo(context: KNativePointer, kind: KNativePointer, args: string[],
|
|
207
|
-
argc: number, substitutionCode: string): KNativePointer {
|
|
219
|
+
argc: number, substitutionCode: string, range: KNativePointer): KNativePointer {
|
|
208
220
|
throw new Error("Not implemented")
|
|
209
221
|
}
|
|
210
222
|
_LogDiagnostic(context: KNativePointer, kind: KNativePointer, argv: string[], argc: number, pos: KNativePointer): void {
|
|
211
223
|
throw new Error("Not implemented")
|
|
212
224
|
}
|
|
213
225
|
_LogDiagnosticWithSuggestion(context: KNativePointer, diagnosticInfo: KNativePointer,
|
|
214
|
-
suggestionInfo?: KNativePointer
|
|
226
|
+
suggestionInfo?: KNativePointer): void {
|
|
215
227
|
throw new Error("Not implemented")
|
|
216
228
|
}
|
|
217
229
|
_SetUpSoPath(soPath: string): void {
|
|
@@ -226,7 +238,7 @@ export class Es2pandaNativeModule {
|
|
|
226
238
|
_ProgramCanSkipPhases(context: KNativePointer, program: KNativePointer): boolean {
|
|
227
239
|
throw new Error("Not implemented")
|
|
228
240
|
}
|
|
229
|
-
_GenerateTsDeclarationsFromContext(config: KPtr, outputDeclEts: String, outputEts: String, exportAll: KBoolean, isolated: KBoolean): KPtr {
|
|
241
|
+
_GenerateTsDeclarationsFromContext(config: KPtr, outputDeclEts: String, outputEts: String, exportAll: KBoolean, isolated: KBoolean, recordFile: String): KPtr {
|
|
230
242
|
throw new Error("Not implemented")
|
|
231
243
|
}
|
|
232
244
|
_GenerateStaticDeclarationsFromContext(config: KPtr, outputPath: String): KPtr {
|
|
@@ -270,4 +282,4 @@ export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule {
|
|
|
270
282
|
// registerNativeModule("InteropNativeModule", NativeModule)
|
|
271
283
|
loadNativeModuleLibrary("NativeModule", instance)
|
|
272
284
|
return instance
|
|
273
|
-
}
|
|
285
|
+
}
|
|
@@ -13,19 +13,8 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { ExternalSource } from "../peers/ExternalSource"
|
|
17
|
-
import { acceptNativeObjectArrayResult } from "../utilities/private"
|
|
18
|
-
import { KNativePointer } from "@koalaui/interop"
|
|
19
|
-
import { global } from "../static/global"
|
|
20
16
|
import { Program } from "../../generated"
|
|
21
17
|
|
|
22
|
-
export function programGetExternalSources(program: Program, context: KNativePointer = global.context): ExternalSource[] {
|
|
23
|
-
return acceptNativeObjectArrayResult<ExternalSource>(
|
|
24
|
-
global.es2panda._ProgramExternalSources(context, program.peer),
|
|
25
|
-
(instance: KNativePointer) => new ExternalSource(instance)
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
18
|
export function dumpProgramInfo(program: Program) {
|
|
30
19
|
console.log(`Program info:`)
|
|
31
20
|
console.log(`\tAbsoluteName: ${program.absoluteName}`)
|
|
@@ -38,6 +38,7 @@ export function createScriptFunction(
|
|
|
38
38
|
dataflags: Es2pandaModifierFlags,
|
|
39
39
|
ident: Identifier | undefined,
|
|
40
40
|
annotations: readonly AnnotationUsage[] | undefined,
|
|
41
|
+
signaturePointer?: KNativePointer,
|
|
41
42
|
preferredReturnTypePointer?: KNativePointer,
|
|
42
43
|
) {
|
|
43
44
|
const res = ScriptFunction.createScriptFunction(
|
|
@@ -53,6 +54,9 @@ export function createScriptFunction(
|
|
|
53
54
|
ident,
|
|
54
55
|
annotations,
|
|
55
56
|
)
|
|
57
|
+
if (signaturePointer) {
|
|
58
|
+
res.setSignaturePointer(signaturePointer)
|
|
59
|
+
}
|
|
56
60
|
if (preferredReturnTypePointer) {
|
|
57
61
|
res.setPreferredReturnTypePointer(preferredReturnTypePointer)
|
|
58
62
|
}
|
|
@@ -70,6 +74,7 @@ export function updateScriptFunction(
|
|
|
70
74
|
dataflags: Es2pandaModifierFlags,
|
|
71
75
|
ident: Identifier | undefined,
|
|
72
76
|
annotations: readonly AnnotationUsage[] | undefined,
|
|
77
|
+
signaturePointer?: KNativePointer,
|
|
73
78
|
preferredReturnTypePointer?: KNativePointer,
|
|
74
79
|
) {
|
|
75
80
|
if (isSameNativeObject(databody, original.body)
|
|
@@ -81,6 +86,7 @@ export function updateScriptFunction(
|
|
|
81
86
|
&& isSameNativeObject(dataflags, original.modifierFlags)
|
|
82
87
|
&& isSameNativeObject(ident, original.id)
|
|
83
88
|
&& isSameNativeObject(annotations, original.annotations)
|
|
89
|
+
&& signaturePointer == original.getSignaturePointer()
|
|
84
90
|
&& preferredReturnTypePointer == original.getPreferredReturnTypePointer()
|
|
85
91
|
) {
|
|
86
92
|
return original
|
|
@@ -96,6 +102,7 @@ export function updateScriptFunction(
|
|
|
96
102
|
dataflags,
|
|
97
103
|
ident,
|
|
98
104
|
annotations,
|
|
105
|
+
signaturePointer,
|
|
99
106
|
preferredReturnTypePointer,
|
|
100
107
|
),
|
|
101
108
|
original
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { isNullPtr, KInt, KNativePointer, nullptr } from "@koalaui/interop"
|
|
17
17
|
import { global } from "../static/global"
|
|
18
|
-
import { allFlags, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private"
|
|
18
|
+
import { allFlags, unpackNode, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private"
|
|
19
19
|
import { throwError } from "../../utils"
|
|
20
20
|
import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums"
|
|
21
21
|
import { ArktsObject } from "./ArktsObject"
|
|
@@ -117,7 +117,7 @@ export abstract class AstNode extends ArktsObject {
|
|
|
117
117
|
|
|
118
118
|
public get parent(): AstNode | undefined {
|
|
119
119
|
const parent = global.generatedEs2panda._AstNodeParent(global.context, this.peer);
|
|
120
|
-
return
|
|
120
|
+
return unpackNode(parent);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
public set parent(node: AstNode | undefined) {
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
import { Es2pandaContextState } from "../generated/Es2pandaEnums"
|
|
17
17
|
import { Program } from "../generated"
|
|
18
18
|
import { ExternalSource } from "./peers/ExternalSource"
|
|
19
|
-
import { programGetExternalSources } from "./node-utilities/Program"
|
|
20
19
|
import { KNativePointer } from "@koalaui/interop"
|
|
21
20
|
import { global } from "./static/global"
|
|
22
21
|
import { RunTransformerHooks } from "../plugin-utils"
|
|
23
22
|
|
|
24
23
|
export interface CompilationOptions {
|
|
25
|
-
readonly
|
|
24
|
+
readonly isProgramForCodegeneration: boolean,
|
|
26
25
|
readonly state: Es2pandaContextState,
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -49,10 +48,10 @@ export function defaultFilter(name: string) {
|
|
|
49
48
|
return true
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter
|
|
51
|
+
export function listPrograms(program: Program, filter: (name: string) => boolean = defaultFilter): Program[] {
|
|
53
52
|
return [
|
|
54
53
|
program,
|
|
55
|
-
...
|
|
54
|
+
...program.getExternalSources().flatMap((it: ExternalSource) => {
|
|
56
55
|
if (filter(it.getName())) {
|
|
57
56
|
return it.programs
|
|
58
57
|
}
|
|
@@ -48,6 +48,7 @@ export class global {
|
|
|
48
48
|
|
|
49
49
|
// Improve: rename to context when the pointer valued one is eliminated
|
|
50
50
|
public static compilerContext: Context
|
|
51
|
+
public static isContextGenerateAbcForExternalSourceFiles: boolean = false
|
|
51
52
|
|
|
52
53
|
private static _es2panda: Es2pandaNativeModule | undefined = undefined
|
|
53
54
|
public static get es2panda(): Es2pandaNativeModule {
|
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { KNativePointer } from "@koalaui/interop"
|
|
16
17
|
import type {
|
|
17
18
|
ETSModule,
|
|
18
19
|
MethodDefinition,
|
|
20
|
+
Program,
|
|
19
21
|
ScriptFunction,
|
|
20
22
|
} from "../../generated"
|
|
23
|
+
import { ExternalSource } from "../peers/ExternalSource"
|
|
21
24
|
import { Es2pandaModuleFlag } from "../../generated/Es2pandaEnums"
|
|
22
|
-
import { global
|
|
25
|
+
import { global } from "../static/global"
|
|
26
|
+
import { acceptNativeObjectArrayResult } from "./private"
|
|
23
27
|
|
|
24
28
|
export function extension_ETSModuleGetNamespaceFlag(this: ETSModule): Es2pandaModuleFlag {
|
|
25
29
|
return (this.isETSScript ? Es2pandaModuleFlag.MODULE_FLAG_ETSSCRIPT : 0)
|
|
@@ -27,6 +31,7 @@ export function extension_ETSModuleGetNamespaceFlag(this: ETSModule): Es2pandaMo
|
|
|
27
31
|
+ (this.isNamespaceChainLastNode ? Es2pandaModuleFlag.MODULE_FLAG_NAMESPACE_CHAIN_LAST_NODE : 0)
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
// this is a workaround for overloads not included in children list
|
|
30
35
|
export function extension_MethodDefinitionSetChildrenParentPtr(this: MethodDefinition) {
|
|
31
36
|
global.es2panda._AstNodeSetChildrenParentPtr(global.context, this.peer)
|
|
32
37
|
const overloads = this.overloads
|
|
@@ -48,6 +53,16 @@ export function extension_MethodDefinitionOnUpdate(this: MethodDefinition, origi
|
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
56
|
+
// Improve: generate checker related stuff
|
|
57
|
+
export function extension_ScriptFunctionGetSignaturePointer(this: ScriptFunction): KNativePointer {
|
|
58
|
+
return global.es2panda._Checker_ScriptFunctionSignature(global.context, this.peer)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function extension_ScriptFunctionSetSignaturePointer(this: ScriptFunction, signaturePointer: KNativePointer): void {
|
|
62
|
+
global.es2panda._Checker_ScriptFunctionSetSignature(global.context, this.peer, signaturePointer)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Improve: perhaps "preferredReturnType" stuff can be removed later if "signature" is always enough
|
|
51
66
|
export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: ScriptFunction): KNativePointer {
|
|
52
67
|
return global.es2panda._Checker_ScriptFunctionGetPreferredReturnType(global.context, this.peer)
|
|
53
68
|
}
|
|
@@ -55,3 +70,11 @@ export function extension_ScriptFunctionGetPreferredReturnTypePointer(this: Scri
|
|
|
55
70
|
export function extension_ScriptFunctionSetPreferredReturnTypePointer(this: ScriptFunction, typePointer: KNativePointer): void {
|
|
56
71
|
global.es2panda._Checker_ScriptFunctionSetPreferredReturnType(global.context, this.peer, typePointer)
|
|
57
72
|
}
|
|
73
|
+
|
|
74
|
+
// Improve: generate methods with string[] args or return type
|
|
75
|
+
export function extension_ProgramGetExternalSources(this: Program): ExternalSource[] {
|
|
76
|
+
return acceptNativeObjectArrayResult<ExternalSource>(
|
|
77
|
+
global.es2panda._ProgramExternalSources(global.context, this.peer),
|
|
78
|
+
ExternalSource.instantiate,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
@@ -17,7 +17,7 @@ import { global } from "../static/global"
|
|
|
17
17
|
import { isNumber, throwError, withWarning } from "../../utils"
|
|
18
18
|
import { KNativePointer, nullptr, KInt} from "@koalaui/interop"
|
|
19
19
|
import { passNode, passNodeArray, unpackNodeArray, unpackNonNullableNode, passString, unpackString } from "./private"
|
|
20
|
-
import { Es2pandaContextState, Es2pandaModifierFlags, Es2pandaMethodDefinitionKind, Es2pandaPrimitiveType } from "../../generated/Es2pandaEnums"
|
|
20
|
+
import { Es2pandaContextState, Es2pandaModifierFlags, Es2pandaMethodDefinitionKind, Es2pandaPrimitiveType, Es2pandaScriptFunctionFlags } from "../../generated/Es2pandaEnums"
|
|
21
21
|
import type { AstNode } from "../peers/AstNode"
|
|
22
22
|
import { isSameNativeObject } from "../peers/ArktsObject"
|
|
23
23
|
import {
|
|
@@ -245,6 +245,12 @@ export function getFileName(): string {
|
|
|
245
245
|
return global.filePath
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
export function getJsDoc(node: AstNode): string | undefined {
|
|
249
|
+
const result = unpackString(global.es2panda._JsdocStringFromDeclaration(global.context, node.peer))
|
|
250
|
+
return result === 'Empty Jsdoc' ? undefined : result
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
248
254
|
// Improve: It seems like Definition overrides AstNode modifiers
|
|
249
255
|
// with it's own modifiers which is completely unrelated set of flags.
|
|
250
256
|
// Use this function if you need
|
|
@@ -323,14 +329,16 @@ export function generateTsDeclarationsFromContext(
|
|
|
323
329
|
outputDeclEts: string,
|
|
324
330
|
outputEts: string,
|
|
325
331
|
exportAll: boolean,
|
|
326
|
-
isolated: boolean
|
|
332
|
+
isolated: boolean,
|
|
333
|
+
recordFile: string
|
|
327
334
|
): KInt {
|
|
328
335
|
return global.es2panda._GenerateTsDeclarationsFromContext(
|
|
329
336
|
global.context,
|
|
330
337
|
passString(outputDeclEts),
|
|
331
338
|
passString(outputEts),
|
|
332
339
|
exportAll,
|
|
333
|
-
isolated
|
|
340
|
+
isolated,
|
|
341
|
+
recordFile
|
|
334
342
|
);
|
|
335
343
|
}
|
|
336
344
|
|
|
@@ -346,15 +354,71 @@ export function importDeclarationInsert(node: ETSImportDeclaration, program: Pro
|
|
|
346
354
|
global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer)
|
|
347
355
|
}
|
|
348
356
|
|
|
357
|
+
export function signatureReturnType(signature: KNativePointer): KNativePointer {
|
|
358
|
+
if (!signature) {
|
|
359
|
+
return nullptr
|
|
360
|
+
}
|
|
361
|
+
return global.es2panda._Checker_SignatureReturnType(global.context, signature)
|
|
362
|
+
}
|
|
363
|
+
|
|
349
364
|
export function tryConvertCheckerTypeToTypeNode(typePeer: KNativePointer | undefined): TypeNode | undefined {
|
|
350
365
|
if (!typePeer) {
|
|
351
366
|
return undefined
|
|
352
367
|
}
|
|
353
368
|
const str = unpackString(global.es2panda._Checker_TypeToString(global.context, typePeer))
|
|
369
|
+
// Primitive types
|
|
354
370
|
if (str == "void") {
|
|
355
371
|
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID)
|
|
356
372
|
}
|
|
357
|
-
if (str == "
|
|
373
|
+
if (str == "Byte") {
|
|
374
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_BYTE)
|
|
375
|
+
}
|
|
376
|
+
if (str == "Int") {
|
|
377
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_INT)
|
|
378
|
+
}
|
|
379
|
+
if (str == "Long") {
|
|
380
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_LONG)
|
|
381
|
+
}
|
|
382
|
+
if (str == "Short") {
|
|
383
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_SHORT)
|
|
384
|
+
}
|
|
385
|
+
if (str == "Float") {
|
|
386
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_FLOAT)
|
|
387
|
+
}
|
|
388
|
+
if (str == "Double") {
|
|
389
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_DOUBLE)
|
|
390
|
+
}
|
|
391
|
+
if (str == "Boolean") {
|
|
392
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_BOOLEAN)
|
|
393
|
+
}
|
|
394
|
+
if (str == "Char") {
|
|
395
|
+
return factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_CHAR)
|
|
396
|
+
}
|
|
397
|
+
// Special types
|
|
398
|
+
if (str == "undefined") {
|
|
399
|
+
return factory.createETSUndefinedType()
|
|
400
|
+
}
|
|
401
|
+
// Stdlib types
|
|
402
|
+
if (str == "String" || str == "Object" || str == "Any") {
|
|
403
|
+
return factory.createETSTypeReference(
|
|
404
|
+
factory.createETSTypeReferencePart(
|
|
405
|
+
factory.createIdentifier(str)
|
|
406
|
+
)
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
// Basic arrow type
|
|
410
|
+
if (str == "() => void") {
|
|
411
|
+
return factory.createETSFunctionType(
|
|
412
|
+
undefined,
|
|
413
|
+
[],
|
|
414
|
+
factory.createETSPrimitiveType(Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID),
|
|
415
|
+
false,
|
|
416
|
+
Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE,
|
|
417
|
+
undefined,
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
// Only used in samples code
|
|
421
|
+
if (str == "StringerNode") {
|
|
358
422
|
return factory.createETSTypeReference(
|
|
359
423
|
factory.createETSTypeReferencePart(
|
|
360
424
|
factory.createIdentifier(str)
|