dumpQuickjsByteCode function
Implementation
Future<Uint8List> dumpQuickjsByteCode(double contextId, Uint8List code, {String? url, bool isModule = false}) async {
Completer<Uint8List> completer = Completer();
// Assign `vm://$id` for no url (anonymous scripts).
if (url == null) {
url = 'vm://$_anonymousScriptEvaluationId';
_anonymousScriptEvaluationId++;
}
Pointer<Uint8> codePtr = uint8ListToPointer(code);
Pointer<Utf8> urlPtr = url.toNativeUtf8();
// Export the bytecode from scripts
Pointer<Pointer<Uint8>> bytecodes = malloc.allocate(sizeOf<Pointer<Uint8>>());
Pointer<Uint64> bytecodeLen = malloc.allocate(sizeOf<Uint64>());
_DumpQuickjsByteCodeContext context = _DumpQuickjsByteCodeContext(completer, bytecodes, bytecodeLen);
Pointer<NativeFunction<NativeDumpQuickjsByteCodeResultCallback>> resultCallback =
Pointer.fromFunction(_handleQuickjsByteCodeResults);
_dumpQuickjsByteCode(_allocatedPages[contextId]!, codePtr, code.length, bytecodes, bytecodeLen, urlPtr, isModule,
context, resultCallback);
// return bytes;
return completer.future;
}