Index: pkg/kernel/lib/binary/ast_to_binary.dart |
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart |
index 2c87df570979b7c95ebca030b559d3357531f6bd..7a8980ecbf56a455c4007f9c9499c06c4cf8aeae 100644 |
--- a/pkg/kernel/lib/binary/ast_to_binary.dart |
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart |
@@ -393,7 +393,7 @@ class BinaryPrinter extends Visitor { |
visitLocalInitializer(LocalInitializer node) { |
writeByte(Tag.LocalInitializer); |
- writeVariableDeclaration(node.variable); |
+ writeVariableDeclaration(node.variable, false); |
} |
visitFunctionNode(FunctionNode node) { |
@@ -433,9 +433,11 @@ class BinaryPrinter extends Visitor { |
node.promotedType == null) { |
writeByte(Tag.SpecializedVariableGet + index); |
writeOffset(node.fileOffset); |
+ writeUInt30(node.variable.tempOffset); |
} else { |
writeByte(Tag.VariableGet); |
writeOffset(node.fileOffset); |
+ writeUInt30(node.variable.tempOffset); |
writeUInt30(_variableIndexer[node.variable]); |
writeOptionalNode(node.promotedType); |
} |
@@ -713,7 +715,7 @@ class BinaryPrinter extends Visitor { |
visitLet(Let node) { |
writeByte(Tag.Let); |
- writeVariableDeclaration(node.variable); |
+ writeVariableDeclaration(node.variable, false); |
writeNode(node.body); |
--_variableIndexer.stackHeight; |
} |
@@ -824,7 +826,7 @@ class BinaryPrinter extends Visitor { |
_variableIndexer.pushScope(); |
writeByte(node.isAsync ? Tag.AsyncForInStatement : Tag.ForInStatement); |
writeOffset(node.fileOffset); |
- writeVariableDeclaration(node.variable); |
+ writeVariableDeclaration(node.variable, false); |
writeNode(node.iterable); |
writeNode(node.body); |
_variableIndexer.popScope(); |
@@ -895,10 +897,13 @@ class BinaryPrinter extends Visitor { |
visitVariableDeclaration(VariableDeclaration node) { |
writeByte(Tag.VariableDeclaration); |
- writeVariableDeclaration(node); |
+ writeVariableDeclaration(node, true); |
} |
- void writeVariableDeclaration(VariableDeclaration node) { |
+ void writeVariableDeclaration(VariableDeclaration node, |
+ [bool hasTag = false]) { |
+ int length = _sink.flushedLength + _sink.length - (hasTag ? 1 : 0); |
Kevin Millikin (Google)
2017/04/05 08:59:57
It seems better to move writing of the tag here so
|
+ node.tempOffset = length; |
writeOffset(node.fileOffset); |
writeOffset(node.fileEqualsOffset); |
writeByte(node.flags); |
@@ -919,14 +924,14 @@ class BinaryPrinter extends Visitor { |
writeByte(Tag.Nothing); |
} else { |
writeByte(Tag.Something); |
- writeVariableDeclaration(node); |
+ writeVariableDeclaration(node, false); |
} |
} |
visitFunctionDeclaration(FunctionDeclaration node) { |
writeByte(Tag.FunctionDeclaration); |
writeOffset(node.fileOffset); |
- writeVariableDeclaration(node.variable); |
+ writeVariableDeclaration(node.variable, false); |
writeNode(node.function); |
} |
@@ -1252,6 +1257,7 @@ class BufferedSink { |
final Sink<List<int>> _sink; |
Uint8List _buffer = new Uint8List(SIZE); |
int length = 0; |
+ int flushedLength = 0; |
BufferedSink(this._sink); |
@@ -1261,6 +1267,7 @@ class BufferedSink { |
_sink.add(_buffer); |
_buffer = new Uint8List(SIZE); |
length = 0; |
+ flushedLength += SIZE; |
} |
} |
@@ -1271,6 +1278,7 @@ class BufferedSink { |
(bytes.length < SMALL || length < SMALL)) { |
if (length == 0) { |
_sink.add(bytes); |
+ flushedLength += bytes.length; |
} else { |
_buffer.setRange(length, length + bytes.length, bytes); |
length += bytes.length; |
@@ -1286,10 +1294,13 @@ class BufferedSink { |
_buffer = new Uint8List(SIZE); |
_buffer.setRange(0, remainder, bytes, alreadyEmitted); |
length = remainder; |
+ flushedLength += SIZE; |
} else { |
_sink.add(_buffer.sublist(0, length)); |
_sink.add(bytes); |
_buffer = new Uint8List(SIZE); |
+ flushedLength += length; |
+ flushedLength += bytes.length; |
length = 0; |
} |
} |
@@ -1297,6 +1308,7 @@ class BufferedSink { |
void flush() { |
_sink.add(_buffer.sublist(0, length)); |
_buffer = new Uint8List(SIZE); |
+ flushedLength += length; |
length = 0; |
} |