Skip to content

Commit 3abf782

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
Bytecode compiler
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 <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
1 parent 6c9b36f commit 3abf782

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+22247
-0
lines changed

pkg/dart2bytecode/OWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set noparent
2+
file:/tools/OWNERS_VM
3+
# In addition to VM team allow global owners.
4+
file:/OWNERS

pkg/dart2bytecode/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This package contains Dart bytecode compiler.
2+
3+
## Status: experimental
4+
5+
**NOTE**: This package is currently experimental and not published or
6+
included in the SDK.
7+
8+
Do not take dependency on this package unless you are prepared for
9+
breaking changes and possibly removal of this code at any point in time.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
include: package:lints/core.yaml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:dart2bytecode/dart2bytecode.dart' as dart2bytecode;
6+
7+
Future<void> main(List<String> args) async {
8+
await dart2bytecode.main(args);
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:dart2bytecode/bytecode_serialization.dart'
8+
show LinkReader, BufferedReader;
9+
import 'package:dart2bytecode/declarations.dart' show Component;
10+
11+
final String _usage = '''
12+
Usage: dump_bytecode input.bytecode
13+
Dumps bytecode file.
14+
''';
15+
16+
main(List<String> arguments) async {
17+
if (arguments.length != 1) {
18+
print(_usage);
19+
exit(1);
20+
}
21+
22+
final input = arguments[0];
23+
24+
final List<int> bytes = File(input).readAsBytesSync();
25+
26+
final linkReader = LinkReader();
27+
final reader = BufferedReader(linkReader, bytes);
28+
final bytecodeComponent = Component.read(reader);
29+
print(bytecodeComponent.toString());
30+
}

0 commit comments

Comments
 (0)