Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| index 3d2a71b5c1afc0b49dded9105f5e5f6fdb967c0c..5e305548e1ef07d03cbdf88166372b3d3c4a8358 100644 |
| --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart |
| @@ -14,10 +14,10 @@ import '../parser/identifier_context.dart' show IdentifierContext; |
| import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; |
| import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' |
| - show KernelVariableDeclaration; |
| + show KernelField, KernelVariableDeclaration; |
| import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' |
| - show TypeInferrer; |
| + show FieldNode, TypeInferrer; |
| import 'package:kernel/ast.dart'; |
| @@ -87,11 +87,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| @override |
| final Uri uri; |
| - final TypeInferrer<Statement, Expression, KernelVariableDeclaration, Field> |
| - _typeInferrer; |
| + final TypeInferrer<Statement, Expression, KernelVariableDeclaration, |
| + KernelField> _typeInferrer; |
| final AstFactory astFactory; |
| + /// If not `null`, dependencies on fields are accumulated into this list. |
|
karlklose
2017/04/21 11:11:01
Maybe add a short comment on when this is `null`.
Paul Berry
2017/04/21 11:32:25
Done.
|
| + final List<FieldNode<KernelField>> fieldDependencies; |
| + |
| /// Only used when [member] is a constructor. It tracks if an implicit super |
| /// initializer is needed. |
| /// |
| @@ -141,7 +144,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| this.isInstanceMember, |
| this.uri, |
| this._typeInferrer, |
| - this.astFactory) |
| + this.astFactory, |
| + {this.fieldDependencies}) |
| : enclosingScope = scope, |
| library = library, |
| isDartLibrary = library.uri.scheme == "dart", |
| @@ -1070,7 +1074,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| } |
| @override |
| - void endFieldInitializer(Token assignmentOperator) { |
| + void endFieldInitializer(Token assignmentOperator, Token token) { |
| debugEvent("FieldInitializer"); |
| assert(assignmentOperator.stringValue == "="); |
| push(popForValue()); |
| @@ -2613,6 +2617,19 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper { |
| void debugEvent(String name) { |
| // printEvent(name); |
| } |
| + |
| + @override |
| + StaticGet makeStaticGet(Member readTarget, int offset) { |
| + // TODO(paulberry): only record the dependencies mandated by the top level |
| + // type inference spec. |
| + if (fieldDependencies != null && readTarget is KernelField) { |
| + var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget); |
| + if (fieldNode != null) { |
| + fieldDependencies.add(fieldNode); |
| + } |
| + } |
| + return astFactory.staticGet(readTarget, offset); |
| + } |
| } |
| // TODO(ahe): Shouldn't need to be an expression. |