Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: pkg/kernel/lib/binary/ast_from_binary.dart

Issue 2931773005: [kernel] Delete most of the AST (Closed)
Patch Set: Review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/binary/ast_from_binary.dart
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index f0c34cd1dab49c9515f8e8d54d17baa8b22fc2a0..9923be85526de19f2739f22c1a0673e5ed05b2bc 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -68,7 +68,7 @@ class BinaryBuilder {
}
}
- int readMagicWord() {
+ int readUint32() {
return (readByte() << 24) |
(readByte() << 16) |
(readByte() << 8) |
@@ -237,7 +237,7 @@ class BinaryBuilder {
_readOneProgram(program);
if (_byteIndex < _bytes.length) {
if (_byteIndex + 3 < _bytes.length) {
- int magic = readMagicWord();
+ int magic = readUint32();
if (magic == Tag.ProgramFile) {
throw 'Concatenated program file given when a single program '
'was expected.';
@@ -248,7 +248,7 @@ class BinaryBuilder {
}
void _readOneProgram(Program program) {
- int magic = readMagicWord();
+ int magic = readUint32();
if (magic != Tag.ProgramFile) {
throw fail('This is not a binary dart file. '
'Magic number was: ${magic.toRadixString(16)}');
@@ -264,6 +264,20 @@ class BinaryBuilder {
}
var mainMethod = readMemberReference(allowNull: true);
program.mainMethodName ??= mainMethod;
+
+ // Read the program index.
+ readUint32(); // binary offset for source table.
+ readUint32(); // binary offset for link table.
+ readUint32(); // main
+ for (int i = 0; i < numberOfLibraries; i++) {
+ readUint32(); // binary offset for library #i.
+ }
+ int numberOfLibrariesCheck = readUint32();
+ if (numberOfLibraries != numberOfLibrariesCheck) {
+ throw 'Malformed binary: the program index indicates there are '
+ '$numberOfLibrariesCheck libraries but the binary contains '
+ '$numberOfLibraries.';
+ }
}
Map<String, Source> readUriToSource() {
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698