3abf78212c
Add dart2bytecode tool which takes Dart sources and produces Dart bytecode. The tool uses common front-end (CFE) to parse Dart source code and contains bytecode generator which translates kernel AST to bytecode. Change-Id: I90bd6e72c619cf0edc556da0640760b30e81091d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378560 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
123 lines
3.3 KiB
Dart
123 lines
3.3 KiB
Dart
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Selection of methods used during bootstrapping.
|
|
|
|
// ignore_for_file: unused_element, unused_field
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
external void _printString(String s);
|
|
|
|
void _print(arg) {
|
|
_printString(arg.toString());
|
|
}
|
|
|
|
_getPrintClosure() => _print;
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
typedef _ScheduleImmediateClosure = void Function(void Function() callback);
|
|
|
|
class _ScheduleImmediate {
|
|
static _ScheduleImmediateClosure? _closure;
|
|
}
|
|
|
|
void _setScheduleImmediateClosure(_ScheduleImmediateClosure closure) {
|
|
_ScheduleImmediate._closure = closure;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
base class _NamespaceImpl implements _Namespace {
|
|
_NamespaceImpl._();
|
|
|
|
external static _NamespaceImpl _create(_NamespaceImpl namespace, var n);
|
|
external static int _getPointer(_NamespaceImpl namespace);
|
|
external static int _getDefault();
|
|
|
|
static _NamespaceImpl? _cachedNamespace = null;
|
|
static void _setupNamespace(var namespace) {
|
|
_cachedNamespace = _create(new _NamespaceImpl._(), namespace);
|
|
}
|
|
|
|
static _NamespaceImpl get _namespace {
|
|
if (_cachedNamespace == null) {
|
|
_cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
|
|
}
|
|
return _cachedNamespace!;
|
|
}
|
|
|
|
static int get _namespacePointer => _getPointer(_namespace);
|
|
}
|
|
|
|
class _Namespace {
|
|
static void _setupNamespace(var namespace) {
|
|
_NamespaceImpl._setupNamespace(namespace);
|
|
}
|
|
|
|
static _Namespace get _namespace => _NamespaceImpl._namespace;
|
|
|
|
static int get _namespacePointer => _NamespaceImpl._namespacePointer;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
class Stdin {}
|
|
|
|
final Stdin _stdin = _StdIOUtils._getStdioInputStream(_stdinFD);
|
|
|
|
int _stdinFD = 0;
|
|
int _stdoutFD = 1;
|
|
int _stderrFD = 2;
|
|
|
|
void _setStdioFDs(int stdin, int stdout, int stderr) {
|
|
_stdinFD = stdin;
|
|
_stdoutFD = stdout;
|
|
_stderrFD = stderr;
|
|
}
|
|
|
|
class _StdIOUtils {
|
|
external static Stdin _getStdioInputStream(int fd);
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
class Timer {}
|
|
|
|
class SendPort {}
|
|
|
|
class VMLibraryHooks {
|
|
// Example: "dart:isolate _Timer._factory"
|
|
static Timer Function(int, void Function(Timer), bool)? timerFactory;
|
|
|
|
// Example: "dart:io _EventHandler._sendData"
|
|
static late void Function(Object?, SendPort, int) eventHandlerSendData;
|
|
|
|
// A nullary closure that answers the current clock value in milliseconds.
|
|
// Example: "dart:io _EventHandler._timerMillisecondClock"
|
|
static late int Function() timerMillisecondClock;
|
|
|
|
// Implementation of package root/map provision.
|
|
static String? packageRootString;
|
|
static String? packageConfigString;
|
|
static Uri? Function()? packageConfigUriSync;
|
|
static Uri? Function(Uri)? resolvePackageUriSync;
|
|
|
|
static Uri Function()? _computeScriptUri;
|
|
static Uri? _cachedScript;
|
|
static set platformScript(Object? f) {
|
|
_computeScriptUri = f as Uri Function()?;
|
|
_cachedScript = null;
|
|
}
|
|
|
|
static Uri? get platformScript {
|
|
return _cachedScript ??= _computeScriptUri?.call();
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
main() {}
|