@idlizer/arktscgen 2.1.10-arktscgen-9 → 2.1.10-arktscgen-10
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 +21 -4
- package/build/libarkts-copy/native/meson.build +18 -63
- package/build/libarkts-copy/native/mingw.cross +5 -2
- package/build/libarkts-copy/native/src/bridges.cpp +0 -29
- package/build/libarkts-copy/native/src/common.cpp +237 -9
- package/build/libarkts-copy/package.json +11 -11
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +30 -7
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +14 -0
- package/build/libarkts-copy/src/arkts-api/plugins.ts +1 -0
- package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +99 -9
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +66 -149
- package/build/libarkts-copy/src/arkts-api/visitor.ts +17 -3
- package/build/libarkts-copy/src/utils.ts +4 -0
- package/lib/index.js +4273 -4147
- package/package.json +2 -2
|
@@ -107,8 +107,7 @@
|
|
|
107
107
|
// Handwritten bridges
|
|
108
108
|
"ConfigGetOptions", // handwritten class
|
|
109
109
|
"SourcePositionCol", // not in idl
|
|
110
|
-
"
|
|
111
|
-
"CreateDiagnosticKind",
|
|
110
|
+
"CreateDiagnosticKind", // no const suffix in idl
|
|
112
111
|
"GetSemanticErrors",
|
|
113
112
|
"GetSyntaxErrors",
|
|
114
113
|
"GetPluginErrors",
|
|
@@ -172,12 +171,22 @@
|
|
|
172
171
|
{
|
|
173
172
|
interface: "ClassDefinition",
|
|
174
173
|
methods: [
|
|
175
|
-
"SetBody", //
|
|
176
|
-
// probably, an optimized version.
|
|
174
|
+
"SetBody", // TODO: implement in compiler some time
|
|
177
175
|
]
|
|
178
176
|
},
|
|
179
177
|
]
|
|
180
178
|
},
|
|
179
|
+
globalAliases: {
|
|
180
|
+
classes: [
|
|
181
|
+
"parser.Program",
|
|
182
|
+
"es2panda.ArkTsConfig",
|
|
183
|
+
],
|
|
184
|
+
functions: [
|
|
185
|
+
"compiler.*",
|
|
186
|
+
"compiler.ProceedToState!",
|
|
187
|
+
"compiler.Is*!",
|
|
188
|
+
]
|
|
189
|
+
},
|
|
181
190
|
nonNullable: [
|
|
182
191
|
{
|
|
183
192
|
name: "es2panda_Impl",
|
|
@@ -210,6 +219,14 @@
|
|
|
210
219
|
name: "CreateGlobalContext",
|
|
211
220
|
types: ["returnType"],
|
|
212
221
|
},
|
|
222
|
+
{
|
|
223
|
+
name: "CreateDiagnosticInfo",
|
|
224
|
+
types: ["returnType"],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "CreateSuggestionInfo",
|
|
228
|
+
types: ["returnType"],
|
|
229
|
+
},
|
|
213
230
|
],
|
|
214
231
|
},
|
|
215
232
|
{
|
|
@@ -28,7 +28,6 @@ sources = [
|
|
|
28
28
|
'./src/bridges.cpp',
|
|
29
29
|
'../generated/native/bridges.cpp',
|
|
30
30
|
get_option('interop_src_dir') / 'common-interop.cpp',
|
|
31
|
-
get_option('interop_src_dir') / 'callback-resource.cpp',
|
|
32
31
|
get_option('interop_src_dir') / 'interop-logging.cpp',
|
|
33
32
|
get_option('interop_src_dir') / 'napi' / 'convertors-napi.cpp',
|
|
34
33
|
]
|
|
@@ -42,77 +41,32 @@ cflags = [
|
|
|
42
41
|
|
|
43
42
|
ldflags = []
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
arch = target_machine.cpu()
|
|
45
|
+
|
|
46
|
+
oses = { 'darwin': 'macos', 'windows': 'win32' } # rename meson default names to convenient ones
|
|
47
|
+
archs = { 'x86_64': 'x64', 'aarch64': 'arm64', 'armv7-a': 'arm32', 'wasm32': 'wasm' }
|
|
48
|
+
|
|
49
|
+
os = target_machine.system()
|
|
50
|
+
os = oses.get(os, os)
|
|
51
|
+
arch = target_machine.cpu()
|
|
52
|
+
arch = archs.get(arch, arch)
|
|
53
|
+
|
|
54
|
+
if os == 'win32'
|
|
46
55
|
cflags += ['-DKOALA_WINDOWS']
|
|
47
56
|
# apply node.exe symbol loading hook
|
|
48
57
|
sources += [
|
|
49
58
|
get_option('interop_src_dir') / 'napi/win-dynamic-node.cpp'
|
|
50
59
|
]
|
|
60
|
+
ldflags += ['-static']
|
|
61
|
+
endif
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
'-nostdinc++',
|
|
54
|
-
'-I/home/huawei/Projects/idlize/external/arkoala-arkts/tools/compiler/llvm-toolchain/include/c++/v1',
|
|
55
|
-
'-I/home/huawei/Projects/idlize/external/arkoala-arkts/tools/compiler/llvm-toolchain/include/x86_64-unknown-linux-gnu/c++/v1',
|
|
56
|
-
'-std=c++17',
|
|
57
|
-
'-Wall',
|
|
58
|
-
'-Werror',
|
|
59
|
-
'-Wno-unused-variable',
|
|
60
|
-
'-Wno-unused-command-line-argument',
|
|
61
|
-
'-fPIC',
|
|
62
|
-
'-Wno-error=deprecated-copy',
|
|
63
|
-
'-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang',
|
|
64
|
-
'-ftrivial-auto-var-init=zero',
|
|
65
|
-
'-fcolor-diagnostics',
|
|
66
|
-
'-fmerge-all-constants',
|
|
67
|
-
'-Xclang',
|
|
68
|
-
'-mllvm',
|
|
69
|
-
'-Xclang',
|
|
70
|
-
'-instcombine-lower-dbg-declare=0',
|
|
71
|
-
'-no-canonical-prefixes',
|
|
72
|
-
'-fuse-ld=lld',
|
|
73
|
-
'-fno-stack-protector',
|
|
74
|
-
'-fno-strict-aliasing',
|
|
75
|
-
'-Wno-builtin-macro-redefined',
|
|
76
|
-
'-fms-extensions',
|
|
77
|
-
'-static',
|
|
78
|
-
'-rtlib=compiler-rt',
|
|
79
|
-
'-stdlib=libc++',
|
|
80
|
-
'-lunwind',
|
|
81
|
-
'-lpthread',
|
|
82
|
-
'-Qunused-arguments',
|
|
83
|
-
'-D__CUSTOM_SECURITY_LIBRARY',
|
|
84
|
-
'-fno-exceptions',
|
|
85
|
-
'-fno-rtti',
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
ldflags += [
|
|
89
|
-
'-Wl,--fatal-warnings',
|
|
90
|
-
'-fPIC',
|
|
91
|
-
'-Wl,--as-needed',
|
|
92
|
-
'-fuse-ld=lld',
|
|
93
|
-
'-Wl,--icf=all',
|
|
94
|
-
'-m64',
|
|
95
|
-
'-static',
|
|
96
|
-
'-rtlib=compiler-rt',
|
|
97
|
-
'-stdlib=libc++',
|
|
98
|
-
'-std=c++17',
|
|
99
|
-
'-lunwind',
|
|
100
|
-
'-lpthread',
|
|
101
|
-
'-Qunused-arguments',
|
|
102
|
-
]
|
|
103
|
-
else
|
|
63
|
+
if os == 'linux'
|
|
104
64
|
cflags += ['-DKOALA_LINUX']
|
|
105
65
|
endif
|
|
106
66
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
archs = { 'x86_64': 'x64', 'aarch64': 'arm64', 'armv7-a': 'arm32', 'wasm32': 'wasm' }
|
|
111
|
-
|
|
112
|
-
os = target_machine.system()
|
|
113
|
-
os = oses.get(os, os)
|
|
114
|
-
arch = target_machine.cpu()
|
|
115
|
-
arch = archs.get(arch, arch)
|
|
67
|
+
if os == 'macos'
|
|
68
|
+
cflags += ['-DKOALA_MACOS']
|
|
69
|
+
endif
|
|
116
70
|
|
|
117
71
|
cflags_cross = []
|
|
118
72
|
suffix_host = '_' + os + '_' + arch
|
|
@@ -152,6 +106,7 @@ shared_library(
|
|
|
152
106
|
'b_lundef=false',
|
|
153
107
|
],
|
|
154
108
|
install: true,
|
|
109
|
+
install_dir: meson.current_source_dir() + '/../build/native/build',
|
|
155
110
|
name_prefix: '',
|
|
156
111
|
name_suffix: 'node',
|
|
157
112
|
include_directories: [
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
|
|
14
14
|
[binaries]
|
|
15
|
-
c =
|
|
16
|
-
cpp =
|
|
15
|
+
c = 'x86_64-w64-mingw32-gcc'
|
|
16
|
+
cpp = 'x86_64-w64-mingw32-g++'
|
|
17
17
|
ar = 'x86_64-w64-mingw32-ar'
|
|
18
18
|
windres = 'x86_64-w64-mingw32-windres'
|
|
19
19
|
strip = 'x86_64-w64-mingw32-strip'
|
|
@@ -24,3 +24,6 @@ system = 'windows'
|
|
|
24
24
|
cpu_family = 'x86_64'
|
|
25
25
|
cpu = 'x86_64'
|
|
26
26
|
endian = 'little'
|
|
27
|
+
|
|
28
|
+
[built-in options]
|
|
29
|
+
cpp_link_args = ['-lpsapi']
|
|
@@ -118,25 +118,6 @@ KBoolean impl_HasGlobalStructInfo(KNativePointer contextPtr, KStringPtr& instanc
|
|
|
118
118
|
}
|
|
119
119
|
KOALA_INTEROP_2(HasGlobalStructInfo, KBoolean, KNativePointer, KStringPtr);
|
|
120
120
|
|
|
121
|
-
KNativePointer impl_ClassVariableDeclaration(KNativePointer context, KNativePointer classInstance)
|
|
122
|
-
{
|
|
123
|
-
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
124
|
-
const auto _classInstance = reinterpret_cast<es2panda_AstNode*>(classInstance);
|
|
125
|
-
auto _typedTsType = GetImpl()->TypedTsType(_context, _classInstance);
|
|
126
|
-
if (_typedTsType == nullptr) {
|
|
127
|
-
return nullptr;
|
|
128
|
-
}
|
|
129
|
-
const auto _instanceType = reinterpret_cast<es2panda_Type*>(_typedTsType);
|
|
130
|
-
auto _typeVar = GetImpl()->TypeVariable(_context, _instanceType);
|
|
131
|
-
if (_typeVar == nullptr) {
|
|
132
|
-
return nullptr;
|
|
133
|
-
}
|
|
134
|
-
const auto result = reinterpret_cast<es2panda_Declaration*>(GetImpl()->VariableDeclaration(_context, _typeVar));
|
|
135
|
-
const auto declNode = GetImpl()->DeclNode(_context, result);
|
|
136
|
-
return declNode;
|
|
137
|
-
}
|
|
138
|
-
KOALA_INTEROP_2(ClassVariableDeclaration, KNativePointer, KNativePointer, KNativePointer)
|
|
139
|
-
|
|
140
121
|
KNativePointer impl_ETSParserGetGlobalProgramAbsName(KNativePointer contextPtr)
|
|
141
122
|
{
|
|
142
123
|
auto context = reinterpret_cast<es2panda_Context*>(contextPtr);
|
|
@@ -154,16 +135,6 @@ KNativePointer impl_CreateDiagnosticKind(KNativePointer context, KStringPtr& mes
|
|
|
154
135
|
}
|
|
155
136
|
KOALA_INTEROP_3(CreateDiagnosticKind, KNativePointer, KNativePointer, KStringPtr, KInt)
|
|
156
137
|
|
|
157
|
-
void impl_LogDiagnostic(
|
|
158
|
-
KNativePointer context, KNativePointer kind, KStringArray& argvPtr, KInt argc, KNativePointer pos)
|
|
159
|
-
{
|
|
160
|
-
auto&& _context_ = reinterpret_cast<es2panda_Context*>(context);
|
|
161
|
-
auto&& _kind_ = reinterpret_cast<es2panda_DiagnosticKind*>(kind);
|
|
162
|
-
auto&& _pos_ = reinterpret_cast<es2panda_SourcePosition*>(pos);
|
|
163
|
-
GetImpl()->LogDiagnostic(_context_, _kind_, getStringArray(argvPtr), argc, _pos_);
|
|
164
|
-
}
|
|
165
|
-
KOALA_INTEROP_V5(LogDiagnostic, KNativePointer, KNativePointer, KStringArray, KInt, KNativePointer)
|
|
166
|
-
|
|
167
138
|
KNativePointer impl_AnnotationUsageIrPropertiesPtrConst(KNativePointer context, KNativePointer receiver)
|
|
168
139
|
{
|
|
169
140
|
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
|
|
27
27
|
using std::string, std::cout, std::endl, std::vector;
|
|
28
28
|
constexpr int AST_NODE_TYPE_LIMIT = 256;
|
|
29
|
+
constexpr int MAX_ALLOC_SIZE = 1 << 25;
|
|
29
30
|
|
|
30
31
|
es2panda_Impl* es2pandaImplementation = nullptr;
|
|
31
|
-
static thread_local StageArena
|
|
32
|
+
static thread_local StageArena g_currentArena;
|
|
32
33
|
|
|
33
34
|
StageArena* StageArena::Instance()
|
|
34
35
|
{
|
|
35
|
-
return &
|
|
36
|
+
return &g_currentArena;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
void StageArena::Add(void* pointer)
|
|
@@ -73,6 +74,9 @@ char* StageArena::Strdup(const char* string)
|
|
|
73
74
|
|
|
74
75
|
void* StageArena::Alloc(size_t size)
|
|
75
76
|
{
|
|
77
|
+
if (size > MAX_ALLOC_SIZE) {
|
|
78
|
+
INTEROP_FATAL("Cannot allocate memory");
|
|
79
|
+
}
|
|
76
80
|
void* result = malloc(size);
|
|
77
81
|
if (!result) {
|
|
78
82
|
INTEROP_FATAL("Cannot allocate memory");
|
|
@@ -99,8 +103,12 @@ void* StageArena::Alloc(size_t size)
|
|
|
99
103
|
#endif
|
|
100
104
|
|
|
101
105
|
#define LIB_PREFIX "lib"
|
|
106
|
+
#ifdef KOALA_MACOS
|
|
107
|
+
#define LIB_SUFFIX ".dylib"
|
|
108
|
+
#else
|
|
102
109
|
#define LIB_SUFFIX ".so"
|
|
103
110
|
#endif
|
|
111
|
+
#endif
|
|
104
112
|
|
|
105
113
|
const char* DEFAULT_SDK_PATH = "../../../incremental/tools/panda/node_modules/@panda/sdk";
|
|
106
114
|
|
|
@@ -204,13 +212,11 @@ es2panda_Impl* GetImplSlow()
|
|
|
204
212
|
}
|
|
205
213
|
auto library = FindLibrary();
|
|
206
214
|
if (!library) {
|
|
207
|
-
|
|
208
|
-
abort();
|
|
215
|
+
INTEROP_FATAL("No library (common.cpp): %s and %s", LIB_ES2PANDA_PUBLIC, LIB_ES2PANDA_PUBLIC_ALT);
|
|
209
216
|
}
|
|
210
217
|
auto symbol = findSymbol(library, "es2panda_GetImpl");
|
|
211
218
|
if (!symbol) {
|
|
212
|
-
|
|
213
|
-
abort();
|
|
219
|
+
INTEROP_FATAL("no entry point: es2panda_GetImpl");
|
|
214
220
|
}
|
|
215
221
|
es2pandaImplementation = reinterpret_cast<es2panda_Impl* (*)(int)>(symbol)(ES2PANDA_LIB_VERSION);
|
|
216
222
|
return es2pandaImplementation;
|
|
@@ -258,7 +264,7 @@ KOALA_INTEROP_V4(ClassDefinitionSetBody, KNativePointer, KNativePointer, KNative
|
|
|
258
264
|
|
|
259
265
|
/*
|
|
260
266
|
Improve: NOT FROM API (shouldn't be there)
|
|
261
|
-
|
|
267
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
262
268
|
*/
|
|
263
269
|
|
|
264
270
|
es2panda_AstNode* cachedParentNode;
|
|
@@ -322,6 +328,23 @@ void impl_AstNodeOnUpdate(KNativePointer context, KNativePointer newNode, KNativ
|
|
|
322
328
|
}
|
|
323
329
|
KOALA_INTEROP_V3(AstNodeOnUpdate, KNativePointer, KNativePointer, KNativePointer)
|
|
324
330
|
|
|
331
|
+
KNativePointer impl_JumpFromETSTypeReferenceToTSTypeAliasDeclarationTypeAnnotation(
|
|
332
|
+
KNativePointer context, KNativePointer etsTypeReference
|
|
333
|
+
) {
|
|
334
|
+
auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
335
|
+
auto _node = reinterpret_cast<es2panda_AstNode*>(etsTypeReference);
|
|
336
|
+
auto _name = GetImpl()->ETSTypeReferencePartName(_context,
|
|
337
|
+
GetImpl()->ETSTypeReferencePart(_context, _node)
|
|
338
|
+
);
|
|
339
|
+
auto _decl = GetImpl()->DeclarationFromIdentifier(_context, _name);
|
|
340
|
+
if (_decl && GetImpl()->IsTSTypeAliasDeclaration(_decl)) {
|
|
341
|
+
return GetImpl()->TSTypeAliasDeclarationTypeAnnotationConst(_context, _decl);
|
|
342
|
+
}
|
|
343
|
+
return nullptr;
|
|
344
|
+
}
|
|
345
|
+
KOALA_INTEROP_2(JumpFromETSTypeReferenceToTSTypeAliasDeclarationTypeAnnotation,
|
|
346
|
+
KNativePointer, KNativePointer, KNativePointer)
|
|
347
|
+
|
|
325
348
|
static thread_local std::vector<es2panda_AstNode*> cachedChildren;
|
|
326
349
|
|
|
327
350
|
static void visitChild(es2panda_AstNode* node)
|
|
@@ -587,7 +610,7 @@ KNativePointer impl_FilterNodes3(KNativePointer context, KNativePointer node, KI
|
|
|
587
610
|
KOALA_INTEROP_4(FilterNodes3, KNativePointer, KNativePointer, KNativePointer, KInt*, KInt)
|
|
588
611
|
|
|
589
612
|
/*
|
|
590
|
-
|
|
613
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
591
614
|
*/
|
|
592
615
|
|
|
593
616
|
// From koala-wrapper
|
|
@@ -638,7 +661,11 @@ KNativePointer impl_AstNodeProgram(KNativePointer contextPtr, KNativePointer ins
|
|
|
638
661
|
if (GetImpl()->AstNodeIsProgramConst(_context, _receiver)) {
|
|
639
662
|
return GetImpl()->ETSModuleProgram(_context, _receiver);
|
|
640
663
|
}
|
|
641
|
-
|
|
664
|
+
auto parent = GetImpl()->AstNodeParent(_context, _receiver);
|
|
665
|
+
if (parent == nullptr) {
|
|
666
|
+
return nullptr;
|
|
667
|
+
}
|
|
668
|
+
return impl_AstNodeProgram(_context, parent);
|
|
642
669
|
}
|
|
643
670
|
KOALA_INTEROP_2(AstNodeProgram, KNativePointer, KNativePointer, KNativePointer)
|
|
644
671
|
|
|
@@ -687,3 +714,204 @@ void impl_MemoryTrackerPrintCurrent(KNativePointer context)
|
|
|
687
714
|
}
|
|
688
715
|
KOALA_INTEROP_V1(MemoryTrackerPrintCurrent, KNativePointer);
|
|
689
716
|
|
|
717
|
+
static KNativePointer findPropertyInClassDefinition(KNativePointer context, KNativePointer classInstance, char *keyName)
|
|
718
|
+
{
|
|
719
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
720
|
+
const auto _instance = reinterpret_cast<es2panda_AstNode*>(classInstance);
|
|
721
|
+
std::size_t bodySize = 0;
|
|
722
|
+
const auto _body = GetImpl()->ClassDefinitionBody(_context, _instance, &bodySize);
|
|
723
|
+
if (_body == nullptr) {
|
|
724
|
+
return nullptr;
|
|
725
|
+
}
|
|
726
|
+
const auto _bodyInstance = reinterpret_cast<es2panda_AstNode**>(_body);
|
|
727
|
+
for (std::size_t i = 0; i < bodySize; i++) {
|
|
728
|
+
const auto _member = reinterpret_cast<es2panda_AstNode*>(_bodyInstance[i]);
|
|
729
|
+
const auto _key = reinterpret_cast<es2panda_AstNode*>(GetImpl()->ClassElementKey(_context, _member));
|
|
730
|
+
if (strcmp(GetImpl()->IdentifierName(_context, _key), keyName) == 0) {
|
|
731
|
+
return _member;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return nullptr;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
static KNativePointer findPropertyInTSInterfaceDeclaration(
|
|
738
|
+
KNativePointer context, KNativePointer classInstance, char *keyName)
|
|
739
|
+
{
|
|
740
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
741
|
+
const auto _instance = reinterpret_cast<es2panda_AstNode*>(classInstance);
|
|
742
|
+
const auto _body = GetImpl()->TSInterfaceDeclarationBody(_context, _instance);
|
|
743
|
+
if (_body == nullptr) {
|
|
744
|
+
return nullptr;
|
|
745
|
+
}
|
|
746
|
+
const auto _bodyInstance = reinterpret_cast<es2panda_AstNode*>(_body);
|
|
747
|
+
std::size_t bodySize = 0;
|
|
748
|
+
const auto _bodyBody = GetImpl()->TSInterfaceBodyBodyConst(_context, _bodyInstance, &bodySize);
|
|
749
|
+
if (_bodyBody == nullptr) {
|
|
750
|
+
return nullptr;
|
|
751
|
+
}
|
|
752
|
+
const auto _bodyBodyInstance = reinterpret_cast<es2panda_AstNode**>(_bodyBody);
|
|
753
|
+
for (std::size_t i = 0; i < bodySize; i++) {
|
|
754
|
+
const auto _member = reinterpret_cast<es2panda_AstNode*>(_bodyBodyInstance[i]);
|
|
755
|
+
const auto _key = reinterpret_cast<es2panda_AstNode*>(GetImpl()->ClassElementKey(_context, _member));
|
|
756
|
+
if (strcmp(GetImpl()->IdentifierName(_context, _key), keyName) == 0) {
|
|
757
|
+
return _member;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return nullptr;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
KNativePointer impl_ClassVariableDeclaration(KNativePointer context, KNativePointer classInstance);
|
|
764
|
+
|
|
765
|
+
KNativePointer impl_DeclarationFromProperty(KNativePointer context, KNativePointer property)
|
|
766
|
+
{
|
|
767
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
768
|
+
const auto _property = reinterpret_cast<es2panda_AstNode*>(property);
|
|
769
|
+
auto _key = GetImpl()->PropertyKey(_context, _property);
|
|
770
|
+
if (_key == nullptr) {
|
|
771
|
+
return nullptr;
|
|
772
|
+
}
|
|
773
|
+
auto _parent = GetImpl()->AstNodeParent(_context, _property);
|
|
774
|
+
if (_parent == nullptr) {
|
|
775
|
+
return nullptr;
|
|
776
|
+
}
|
|
777
|
+
const auto _parentInstance = reinterpret_cast<es2panda_AstNode*>(_parent);
|
|
778
|
+
auto _decl = impl_ClassVariableDeclaration(_context, _parentInstance);
|
|
779
|
+
if (_decl == nullptr) {
|
|
780
|
+
return nullptr;
|
|
781
|
+
}
|
|
782
|
+
const auto _declInstance = reinterpret_cast<es2panda_AstNode*>(_decl);
|
|
783
|
+
const auto _keyInstance = reinterpret_cast<es2panda_AstNode*>(_key);
|
|
784
|
+
auto _keyName = GetImpl()->IdentifierName(_context, _keyInstance);
|
|
785
|
+
if (GetImpl()->IsClassDefinition(_declInstance)) {
|
|
786
|
+
return findPropertyInClassDefinition(_context, _declInstance, _keyName);
|
|
787
|
+
}
|
|
788
|
+
if (GetImpl()->IsTSInterfaceDeclaration(_declInstance)) {
|
|
789
|
+
return findPropertyInTSInterfaceDeclaration(_context, _declInstance, _keyName);
|
|
790
|
+
}
|
|
791
|
+
return nullptr;
|
|
792
|
+
}
|
|
793
|
+
KOALA_INTEROP_2(DeclarationFromProperty, KNativePointer, KNativePointer, KNativePointer);
|
|
794
|
+
|
|
795
|
+
KNativePointer impl_DeclarationFromMemberExpression(KNativePointer context, KNativePointer nodePtr)
|
|
796
|
+
{
|
|
797
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
798
|
+
const auto _node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
|
|
799
|
+
auto _object = GetImpl()->MemberExpressionObject(_context, _node);
|
|
800
|
+
auto _property = GetImpl()->MemberExpressionProperty(_context, _node);
|
|
801
|
+
if (_property == nullptr) {
|
|
802
|
+
return nullptr;
|
|
803
|
+
}
|
|
804
|
+
const auto _propertyInstance = reinterpret_cast<es2panda_AstNode*>(_property);
|
|
805
|
+
if (GetImpl()->IsNumberLiteral(_propertyInstance) && _object != nullptr) {
|
|
806
|
+
const auto _objectInstance = reinterpret_cast<es2panda_AstNode*>(_object);
|
|
807
|
+
if (GetImpl()->IsMemberExpression(_objectInstance)) {
|
|
808
|
+
return impl_DeclarationFromMemberExpression(_context, _objectInstance);
|
|
809
|
+
}
|
|
810
|
+
return GetImpl()->DeclarationFromIdentifier(_context, _objectInstance);
|
|
811
|
+
}
|
|
812
|
+
if (GetImpl()->IsMemberExpression(_propertyInstance)) {
|
|
813
|
+
return impl_DeclarationFromMemberExpression(_context, _propertyInstance);
|
|
814
|
+
}
|
|
815
|
+
return GetImpl()->DeclarationFromIdentifier(_context, _propertyInstance);
|
|
816
|
+
}
|
|
817
|
+
KOALA_INTEROP_2(DeclarationFromMemberExpression, KNativePointer, KNativePointer, KNativePointer);
|
|
818
|
+
|
|
819
|
+
KNativePointer impl_DeclarationFromAstNode(KNativePointer context, KNativePointer nodePtr)
|
|
820
|
+
{
|
|
821
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
822
|
+
const auto _node = reinterpret_cast<es2panda_AstNode*>(nodePtr);
|
|
823
|
+
if (GetImpl()->IsMemberExpression(_node)) {
|
|
824
|
+
return impl_DeclarationFromMemberExpression(_context, _node);
|
|
825
|
+
}
|
|
826
|
+
if (GetImpl()->IsObjectExpression(_node)) {
|
|
827
|
+
return impl_ClassVariableDeclaration(_context, _node);
|
|
828
|
+
}
|
|
829
|
+
if (GetImpl()->IsProperty(_node)) {
|
|
830
|
+
return impl_DeclarationFromProperty(_context, _node);
|
|
831
|
+
}
|
|
832
|
+
return GetImpl()->DeclarationFromIdentifier(_context, _node);
|
|
833
|
+
}
|
|
834
|
+
KOALA_INTEROP_2(DeclarationFromAstNode, KNativePointer, KNativePointer, KNativePointer);
|
|
835
|
+
|
|
836
|
+
KNativePointer impl_ClassVariableDeclaration(KNativePointer context, KNativePointer classInstance)
|
|
837
|
+
{
|
|
838
|
+
const auto _context = reinterpret_cast<es2panda_Context*>(context);
|
|
839
|
+
const auto _classInstance = reinterpret_cast<es2panda_AstNode*>(classInstance);
|
|
840
|
+
auto _typedTsType = GetImpl()->TypedTsType(_context, _classInstance);
|
|
841
|
+
if (_typedTsType == nullptr) {
|
|
842
|
+
return nullptr;
|
|
843
|
+
}
|
|
844
|
+
const auto _instanceType = reinterpret_cast<es2panda_Type*>(_typedTsType);
|
|
845
|
+
auto _typeVar = GetImpl()->TypeVariable(_context, _instanceType);
|
|
846
|
+
if (_typeVar == nullptr) {
|
|
847
|
+
return nullptr;
|
|
848
|
+
}
|
|
849
|
+
const auto result = reinterpret_cast<es2panda_Declaration*>(GetImpl()->VariableDeclaration(_context, _typeVar));
|
|
850
|
+
const auto declNode = GetImpl()->DeclNode(_context, result);
|
|
851
|
+
return declNode;
|
|
852
|
+
}
|
|
853
|
+
KOALA_INTEROP_2(ClassVariableDeclaration, KNativePointer, KNativePointer, KNativePointer)
|
|
854
|
+
|
|
855
|
+
thread_local KBoolean targetChildFound = false;
|
|
856
|
+
thread_local es2panda_AstNode *targetInnerChild = nullptr;
|
|
857
|
+
thread_local KInt targetAstNodeType = -1;
|
|
858
|
+
|
|
859
|
+
static void findNodeInnerChild(es2panda_AstNode *node)
|
|
860
|
+
{
|
|
861
|
+
if (targetInnerChild == node) {
|
|
862
|
+
targetChildFound = true;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
KBoolean impl_AstNodeFindNodeInInnerChild(
|
|
867
|
+
KNativePointer contextPtr, KNativePointer instancePtr, KNativePointer tartgetPtr)
|
|
868
|
+
{
|
|
869
|
+
if (tartgetPtr == nullptr) {
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
auto _context = reinterpret_cast<es2panda_Context*>(contextPtr);
|
|
873
|
+
auto _receiver = reinterpret_cast<es2panda_AstNode*>(instancePtr);
|
|
874
|
+
auto _target = reinterpret_cast<es2panda_AstNode*>(tartgetPtr);
|
|
875
|
+
targetChildFound = false;
|
|
876
|
+
targetInnerChild = _target;
|
|
877
|
+
GetImpl()->AstNodeIterateConst(_context, _receiver, findNodeInnerChild);
|
|
878
|
+
return targetChildFound;
|
|
879
|
+
}
|
|
880
|
+
KOALA_INTEROP_3(AstNodeFindNodeInInnerChild, KBoolean, KNativePointer, KNativePointer, KNativePointer);
|
|
881
|
+
|
|
882
|
+
static void findInnerChild(es2panda_AstNode *node, void *arg)
|
|
883
|
+
{
|
|
884
|
+
auto *context = static_cast<es2panda_Context *>(arg);
|
|
885
|
+
if (targetAstNodeType == GetImpl()->AstNodeTypeConst(context, node)) {
|
|
886
|
+
targetInnerChild = node;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
KNativePointer impl_AstNodeFindInnerChild(KNativePointer contextPtr, KNativePointer instancePtr, KInt AstNodeType)
|
|
891
|
+
{
|
|
892
|
+
auto _context = reinterpret_cast<es2panda_Context*>(contextPtr);
|
|
893
|
+
auto _receiver = reinterpret_cast<es2panda_AstNode*>(instancePtr);
|
|
894
|
+
targetAstNodeType = AstNodeType;
|
|
895
|
+
|
|
896
|
+
GetImpl()->AstNodeForEach(_receiver, findInnerChild, _context);
|
|
897
|
+
return targetInnerChild;
|
|
898
|
+
}
|
|
899
|
+
KOALA_INTEROP_3(AstNodeFindInnerChild, KNativePointer, KNativePointer, KNativePointer, KInt);
|
|
900
|
+
|
|
901
|
+
KNativePointer impl_AstNodeFindOuterParent(KNativePointer contextPtr, KNativePointer instancePtr, KInt AstNodeType)
|
|
902
|
+
{
|
|
903
|
+
auto _context = reinterpret_cast<es2panda_Context*>(contextPtr);
|
|
904
|
+
auto _receiver = reinterpret_cast<es2panda_AstNode*>(instancePtr);
|
|
905
|
+
if (GetImpl()->AstNodeIsProgramConst(_context, _receiver)) {
|
|
906
|
+
return nullptr;
|
|
907
|
+
}
|
|
908
|
+
if (AstNodeType == GetImpl()->AstNodeTypeConst(_context, _receiver)) {
|
|
909
|
+
return _receiver;
|
|
910
|
+
}
|
|
911
|
+
auto parent = GetImpl()->AstNodeParent(_context, _receiver);
|
|
912
|
+
if (parent == nullptr) {
|
|
913
|
+
return nullptr;
|
|
914
|
+
}
|
|
915
|
+
return impl_AstNodeFindOuterParent(_context, parent, AstNodeType);
|
|
916
|
+
}
|
|
917
|
+
KOALA_INTEROP_3(AstNodeFindOuterParent, KNativePointer, KNativePointer, KNativePointer, KInt);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaui/libarkts",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13+devel",
|
|
4
4
|
"main": "./lib/libarkts.js",
|
|
5
5
|
"typesVersions": {
|
|
6
6
|
"*": {
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
],
|
|
21
21
|
"config": {
|
|
22
22
|
"panda_sdk_path": "../incremental/tools/panda/node_modules/@panda/sdk",
|
|
23
|
-
"panda_sdk_version": "
|
|
23
|
+
"panda_sdk_version": "next"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@koalaui/compat": "1.7.
|
|
27
|
-
"@koalaui/common": "1.7.
|
|
28
|
-
"@koalaui/interop": "1.7.
|
|
26
|
+
"@koalaui/compat": "1.7.13+devel",
|
|
27
|
+
"@koalaui/common": "1.7.13+devel",
|
|
28
|
+
"@koalaui/interop": "1.7.13+devel",
|
|
29
29
|
"commander": "10.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
38
38
|
"tsconfig-paths": "^4.2.0",
|
|
39
39
|
"rimraf": "^6.0.1",
|
|
40
|
-
"@koalaui/fast-arktsc": "1.7.
|
|
41
|
-
"@idlizer/arktscgen": "2.1.10-arktscgen-
|
|
40
|
+
"@koalaui/fast-arktsc": "1.7.13+devel",
|
|
41
|
+
"@idlizer/arktscgen": "2.1.10-arktscgen-9",
|
|
42
42
|
"mocha": "^9.2.2",
|
|
43
|
-
"@koalaui/harness": "1.7.
|
|
43
|
+
"@koalaui/harness": "1.7.13+devel",
|
|
44
44
|
"@koalaui/ets-tsc": "4.9.5-r6",
|
|
45
|
-
"@koalaui/build-common": "1.7.
|
|
45
|
+
"@koalaui/build-common": "1.7.13+devel",
|
|
46
46
|
"node-addon-api": "8.0.0",
|
|
47
47
|
"node-api-headers": "0.0.5"
|
|
48
48
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"clean:plugins": "rimraf plugins/build",
|
|
52
52
|
"compile:koala:interop": "npm run --prefix ../interop compile",
|
|
53
53
|
"compile:meson": "cd native && meson setup build && meson compile -C build",
|
|
54
|
-
"compile:meson:mingw": "cd native && meson setup --cross-file ./mingw.cross mingw_build && meson
|
|
54
|
+
"compile:meson:mingw": "cd native && meson setup --strip --cross-file ./mingw.cross mingw_build && meson install -C mingw_build",
|
|
55
55
|
"crosscompile:meson": "cd native && CXX=clang++ meson setup -D cross_compile=true build && CXX=clang++ meson compile -C build",
|
|
56
56
|
"copy:.node": "mkdir -p ./build/native/build && cp ./native/build/es2panda_*.node ./build/native/build",
|
|
57
57
|
"compile:native": "npm run compile:koala:interop && npm run compile:meson && npm run copy:.node",
|
|
@@ -83,4 +83,4 @@
|
|
|
83
83
|
"format:generated:ts": "npx prettier --config .prettierrc --write \"./generated/**/*.ts\"",
|
|
84
84
|
"format:ts": "npm run format:src:ts && npm run format:generated:ts"
|
|
85
85
|
}
|
|
86
|
-
}
|
|
86
|
+
}
|
|
@@ -132,13 +132,11 @@ export class Es2pandaNativeModule {
|
|
|
132
132
|
_OptionsArkTsConfig(context: KNativePointer, options: KNativePointer): KNativePointer {
|
|
133
133
|
throw new Error('Not implemented');
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
_JumpFromETSTypeReferenceToTSTypeAliasDeclarationTypeAnnotation(
|
|
136
136
|
context: KNativePointer,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
): void {
|
|
141
|
-
throw new Error('Not implemented');
|
|
137
|
+
etsTypeReference: KNativePointer,
|
|
138
|
+
): KNativePointer {
|
|
139
|
+
throw new Error('Not implemented')
|
|
142
140
|
}
|
|
143
141
|
_ClassDefinitionSetBody(
|
|
144
142
|
context: KNativePointer,
|
|
@@ -162,6 +160,15 @@ export class Es2pandaNativeModule {
|
|
|
162
160
|
_ClassVariableDeclaration(context: KNativePointer, classInstance: KNativePointer): KNativePointer {
|
|
163
161
|
throw new Error('Not implemented');
|
|
164
162
|
}
|
|
163
|
+
_DeclarationFromProperty(context: KPtr, property: KPtr): KPtr {
|
|
164
|
+
throw new Error('Not implemented');
|
|
165
|
+
}
|
|
166
|
+
_DeclarationFromMemberExpression(context: KPtr, expression: KPtr): KPtr {
|
|
167
|
+
throw new Error('Not implemented');
|
|
168
|
+
}
|
|
169
|
+
_DeclarationFromAstNode(context: KPtr, node: KPtr): KPtr {
|
|
170
|
+
throw new Error('Not implemented');
|
|
171
|
+
}
|
|
165
172
|
_ETSParserGetGlobalProgramAbsName(context: KNativePointer): KNativePointer {
|
|
166
173
|
throw new Error('Not implemented');
|
|
167
174
|
}
|
|
@@ -191,6 +198,18 @@ export class Es2pandaNativeModule {
|
|
|
191
198
|
throw new Error('Not implemented');
|
|
192
199
|
}
|
|
193
200
|
|
|
201
|
+
_AstNodeFindNodeInInnerChild(context: KNativePointer, node: KNativePointer, target: KNativePointer): boolean {
|
|
202
|
+
throw new Error('Not implemented');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_AstNodeFindInnerChild(context: KNativePointer, node: KNativePointer, nodeType: KInt): KNativePointer {
|
|
206
|
+
throw new Error('Not implemented');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_AstNodeFindOuterParent(context: KNativePointer, node: KNativePointer, nodeType: KInt): KNativePointer {
|
|
210
|
+
throw new Error('Not implemented');
|
|
211
|
+
}
|
|
212
|
+
|
|
194
213
|
_GetCompilationMode(config: KNativePointer): KInt {
|
|
195
214
|
throw new Error('Not implemented');
|
|
196
215
|
}
|
|
@@ -213,7 +232,11 @@ export class Es2pandaNativeModule {
|
|
|
213
232
|
}
|
|
214
233
|
|
|
215
234
|
export function findNativeModule(): string {
|
|
216
|
-
const candidates = [
|
|
235
|
+
const candidates = [
|
|
236
|
+
path.resolve(__dirname, '../native/build'),
|
|
237
|
+
path.resolve(__dirname, '../build/native'),
|
|
238
|
+
path.resolve(__dirname, '../build/native/build')
|
|
239
|
+
];
|
|
217
240
|
let result = undefined;
|
|
218
241
|
candidates.forEach((path) => {
|
|
219
242
|
if (fs.existsSync(path)) {
|
|
@@ -105,6 +105,20 @@ export abstract class AstNode extends ArktsObject {
|
|
|
105
105
|
return clonedNode as this;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
public findNodeInInnerChild(node: AstNode): boolean {
|
|
109
|
+
return global.es2panda._AstNodeFindNodeInInnerChild(global.context, this.peer, node.peer);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public findInnerChild<T extends AstNode>(nodeType: Es2pandaAstNodeType): T | undefined {
|
|
113
|
+
const childNodePeer = global.es2panda._AstNodeFindInnerChild(global.context, this.peer, nodeType);
|
|
114
|
+
return unpackNode(childNodePeer, nodeType);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public findOuterParent<T extends AstNode>(nodeType: Es2pandaAstNodeType): T | undefined {
|
|
118
|
+
const parentNodePeer = global.es2panda._AstNodeFindOuterParent(global.context, this.peer, nodeType);
|
|
119
|
+
return unpackNode(parentNodePeer, nodeType);
|
|
120
|
+
}
|
|
121
|
+
|
|
108
122
|
public get parent(): AstNode | undefined {
|
|
109
123
|
const parent = global.generatedEs2panda._AstNodeParent(global.context, this.peer);
|
|
110
124
|
return unpackNode(parent);
|