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

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

Issue 2626613002: More offsets in kernel (Closed)
Patch Set: Removed debugging stuff Created 3 years, 11 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
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 0dee08d44ed19a63acf53af9a77533062490b5a1..8c940f69fe5586c80a9aab09cc9354c5f8db56a9 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -321,6 +321,7 @@ class BinaryBuilder {
}
void readNormalClass(Class node) {
+ node.fileOffset = readOffset();
int flags = readByte();
node.isAbstract = flags & 0x1 != 0;
node.level = _currentLibrary.isExternal
@@ -347,6 +348,7 @@ class BinaryBuilder {
}
void readMixinClass(Class node) {
+ node.fileOffset = readOffset();
int flags = readByte();
node.isAbstract = flags & 0x1 != 0;
node.level = _currentLibrary.isExternal
@@ -384,6 +386,7 @@ class BinaryBuilder {
// consumed from the input.
assert(tag == Tag.Field);
node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
node.flags = readByte();
node.name = readName();
node.fileUri = readUriReference();
@@ -399,6 +402,8 @@ class BinaryBuilder {
void readConstructor(Constructor node, int tag) {
assert(tag == Tag.Constructor);
+ node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
node.flags = readByte();
node.name = readName();
node.annotations = readAnnotationList(node);
@@ -414,6 +419,8 @@ class BinaryBuilder {
void readProcedure(Procedure node, int tag) {
assert(tag == Tag.Procedure);
+ node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
int kindIndex = readByte();
node.kind = ProcedureKind.values[kindIndex];
node.flags = readByte();
@@ -451,7 +458,10 @@ class BinaryBuilder {
}
FunctionNode readFunctionNode() {
+ int offset = readOffset();
+ int endOffset = readOffset();
AsyncMarker asyncMarker = AsyncMarker.values[readByte()];
+ bool debuggable = readByte() == 1 ? true : false;
int typeParameterStackHeight = typeParameterStack.length;
var typeParameters = readAndPushTypeParameterList();
var requiredParameterCount = readUInt();
@@ -473,7 +483,10 @@ class BinaryBuilder {
namedParameters: named,
returnType: returnType,
inferredReturnValue: inferredReturnValue,
- asyncMarker: asyncMarker);
+ asyncMarker: asyncMarker)
+ ..fileOffset = offset
+ ..fileEndOffset = endOffset
+ ..debuggable = debuggable;
}
void pushVariableDeclaration(VariableDeclaration variable) {
@@ -520,15 +533,22 @@ class BinaryBuilder {
case Tag.InvalidExpression:
return new InvalidExpression();
case Tag.VariableGet:
- return new VariableGet(readVariableReference(), readDartTypeOption());
+ int offset = readOffset();
+ return new VariableGet(readVariableReference(), readDartTypeOption())
+ ..fileOffset = offset;
case Tag.SpecializedVariableGet:
int index = tagByte & Tag.SpecializedPayloadMask;
- return new VariableGet(variableStack[index]);
+ int offset = readOffset();
+ return new VariableGet(variableStack[index])..fileOffset = offset;
case Tag.VariableSet:
- return new VariableSet(readVariableReference(), readExpression());
+ int offset = readOffset();
+ return new VariableSet(readVariableReference(), readExpression())
+ ..fileOffset = offset;
case Tag.SpecializedVariableSet:
int index = tagByte & Tag.SpecializedPayloadMask;
- return new VariableSet(variableStack[index], readExpression());
+ int offset = readOffset();
+ return new VariableSet(variableStack[index], readExpression())
+ ..fileOffset = offset;
case Tag.PropertyGet:
int offset = readOffset();
return new PropertyGet(
@@ -597,9 +617,13 @@ class BinaryBuilder {
return new ConditionalExpression(readExpression(), readExpression(),
readExpression(), readDartTypeOption());
case Tag.StringConcatenation:
- return new StringConcatenation(readExpressionList());
+ int offset = readOffset();
+ return new StringConcatenation(readExpressionList())
+ ..fileOffset = offset;
case Tag.IsExpression:
- return new IsExpression(readExpression(), readDartType());
+ int offset = readOffset();
+ return new IsExpression(readExpression(), readDartType())
+ ..fileOffset = offset;
case Tag.AsExpression:
return new AsExpression(readExpression(), readDartType());
case Tag.StringLiteral:
@@ -641,15 +665,21 @@ class BinaryBuilder {
return new ListLiteral(readExpressionList(),
typeArgument: typeArgument, isConst: true);
case Tag.MapLiteral:
+ int offset = readOffset();
var keyType = readDartType();
var valueType = readDartType();
return new MapLiteral(readMapEntryList(),
- keyType: keyType, valueType: valueType, isConst: false);
+ keyType: keyType,
+ valueType: valueType,
+ isConst: false)..fileOffset = offset;
case Tag.ConstMapLiteral:
+ int offset = readOffset();
var keyType = readDartType();
var valueType = readDartType();
return new MapLiteral(readMapEntryList(),
- keyType: keyType, valueType: valueType, isConst: true);
+ keyType: keyType,
+ valueType: valueType,
+ isConst: true)..fileOffset = offset;
case Tag.AwaitExpression:
return new AwaitExpression(readExpression());
case Tag.FunctionExpression:
@@ -755,25 +785,29 @@ class BinaryBuilder {
return new IfStatement(
readExpression(), readStatement(), readStatementOrNullIfEmpty());
case Tag.ReturnStatement:
- return new ReturnStatement(readExpressionOption());
+ int offset = readOffset();
+ return new ReturnStatement(readExpressionOption())..fileOffset = offset;
case Tag.TryCatch:
return new TryCatch(readStatement(), readCatchList());
case Tag.TryFinally:
return new TryFinally(readStatement(), readStatement());
case Tag.YieldStatement:
+ int offset = readOffset();
int flags = readByte();
return new YieldStatement(readExpression(),
isYieldStar: flags & YieldStatement.FlagYieldStar != 0,
- isNative: flags & YieldStatement.FlagNative != 0);
+ isNative: flags & YieldStatement.FlagNative != 0)
+ ..fileOffset = offset;
case Tag.VariableDeclaration:
var variable = readVariableDeclaration();
variableStack.add(variable); // Will be popped by the enclosing scope.
return variable;
case Tag.FunctionDeclaration:
+ int offset = readOffset();
var variable = readVariableDeclaration();
variableStack.add(variable); // Will be popped by the enclosing scope.
var function = readFunctionNode();
- return new FunctionDeclaration(variable, function);
+ return new FunctionDeclaration(variable, function)..fileOffset = offset;
default:
throw fail('Invalid statement tag: $tag');
}
@@ -925,13 +959,14 @@ class BinaryBuilder {
}
VariableDeclaration readVariableDeclaration() {
+ int offset = readOffset();
int flags = readByte();
return new VariableDeclaration(readStringOrNullIfEmpty(),
type: readDartType(),
inferredValue: readOptionalInferredValue(),
initializer: readExpressionOption(),
isFinal: flags & 0x1 != 0,
- isConst: flags & 0x2 != 0);
+ isConst: flags & 0x2 != 0)..fileOffset = offset;
}
int readOffset() {

Powered by Google App Engine
This is Rietveld 408576698