Chromium Code Reviews| Index: pkg/fletchc/lib/src/fletch_system_builder.dart |
| diff --git a/pkg/fletchc/lib/src/fletch_system_builder.dart b/pkg/fletchc/lib/src/fletch_system_builder.dart |
| index 258b1190a9bcba61d825137ba8c2269308629907..59f2fa99ad415f41f4352448b777d38ef9cd647f 100644 |
| --- a/pkg/fletchc/lib/src/fletch_system_builder.dart |
| +++ b/pkg/fletchc/lib/src/fletch_system_builder.dart |
| @@ -20,10 +20,12 @@ import 'package:compiler/src/elements/elements.dart' show |
| ClassElement, |
| ConstructorElement, |
| Element, |
| + FieldElement, |
| FunctionElement, |
| - FunctionSignature; |
| + FunctionSignature, |
| + MemberElement; |
| -import 'package:compiler/src/universe/universe.dart' show |
| +import 'package:compiler/src/universe/call_structure.dart' show |
| CallStructure; |
| import 'package:persistent/persistent.dart' show |
| @@ -361,7 +363,7 @@ class FletchSystemBuilder { |
| // Create all new FletchFunctions. |
| List<FletchFunction> functions = <FletchFunction>[]; |
| for (FletchFunctionBuilder builder in _newFunctions) { |
| - context.compiler.withCurrentElement(builder.element, () { |
| + context.compiler.reporter.withCurrentElement(builder.element, () { |
| functions.add(builder.finalizeFunction(context, commands)); |
| }); |
| } |
| @@ -485,10 +487,30 @@ class FletchSystemBuilder { |
| ClassElement classElement = value.type.element; |
| // TODO(ajohnsen): Avoid usage of builders (should be FletchClass). |
| FletchClassBuilder classBuilder = _classBuildersByElement[classElement]; |
| - for (ConstantValue field in value.fields.values) { |
| - int fieldId = context.compiledConstants[field]; |
| + |
| + void addIfField(MemberElement member) { |
|
ahe
2015/12/01 10:12:13
Rename to addIfInstanceField.
sigurdm
2015/12/03 14:48:10
Done.
|
| + if (!member.isField || member.isStatic || member.isPatch) return; |
| + FieldElement fieldElement = member; |
| + ConstantValue fieldValue = value.fields[fieldElement]; |
| + int fieldId = context.compiledConstants[fieldValue]; |
| commands.add(new PushFromMap(MapId.constants, fieldId)); |
| } |
| + |
| + // Adds all the fields of [currentClass] in order starting from the top |
| + // of the inheritance chain, and for each class adds non-patch fields |
| + // before patch fields. |
| + void addFields(ClassElement currentClass) { |
| + if (currentClass.superclass != null) { |
| + addFields(currentClass.superclass); |
| + } |
| + currentClass.forEachLocalMember(addIfField); |
| + if (currentClass.isPatched) { |
| + currentClass.patch.forEachLocalMember(addIfField); |
| + } |
| + } |
| + |
| + addFields(classElement); |
| + |
| commands |
| ..add(new PushFromMap(MapId.classes, classBuilder.classId)) |
| ..add(const PushNewInstance()); |