| Index: pkg/dartino_compiler/lib/src/dartino_system_builder.dart
|
| diff --git a/pkg/fletchc/lib/src/fletch_system_builder.dart b/pkg/dartino_compiler/lib/src/dartino_system_builder.dart
|
| similarity index 71%
|
| rename from pkg/fletchc/lib/src/fletch_system_builder.dart
|
| rename to pkg/dartino_compiler/lib/src/dartino_system_builder.dart
|
| index 6b0ca868306d10797b56d22a89ce98b933481ed7..342fdde6b13190cef2aba9d99a2dbe776f8cf93c 100644
|
| --- a/pkg/fletchc/lib/src/fletch_system_builder.dart
|
| +++ b/pkg/dartino_compiler/lib/src/dartino_system_builder.dart
|
| @@ -2,7 +2,7 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE.md file.
|
|
|
| -library fletchc.fletch_system_builder;
|
| +library dartino_compiler.dartino_system_builder;
|
|
|
| import 'dart:typed_data';
|
|
|
| @@ -31,43 +31,43 @@ import 'package:compiler/src/universe/call_structure.dart' show
|
| import 'package:persistent/persistent.dart' show
|
| PersistentMap;
|
|
|
| -import 'fletch_constants.dart' show
|
| - FletchClassConstant,
|
| - FletchFunctionConstant,
|
| - FletchClassInstanceConstant;
|
| +import 'dartino_constants.dart' show
|
| + DartinoClassConstant,
|
| + DartinoFunctionConstant,
|
| + DartinoClassInstanceConstant;
|
|
|
| -import 'fletch_class_builder.dart';
|
| -import 'fletch_context.dart';
|
| -import 'fletch_function_builder.dart';
|
| +import 'dartino_class_builder.dart';
|
| +import 'dartino_context.dart';
|
| +import 'dartino_function_builder.dart';
|
|
|
| -import '../fletch_system.dart';
|
| +import '../dartino_system.dart';
|
| import '../vm_commands.dart';
|
|
|
| -class FletchSystemBuilder {
|
| - final FletchSystem predecessorSystem;
|
| +class DartinoSystemBuilder {
|
| + final DartinoSystem predecessorSystem;
|
| final int functionIdStart;
|
| final int classIdStart;
|
|
|
| - final List<FletchFunctionBuilder> _newFunctions = <FletchFunctionBuilder>[];
|
| - final Map<int, FletchClassBuilder> _newClasses = <int, FletchClassBuilder>{};
|
| + final List<DartinoFunctionBuilder> _newFunctions = <DartinoFunctionBuilder>[];
|
| + final Map<int, DartinoClassBuilder> _newClasses = <int, DartinoClassBuilder>{};
|
| final Map<ConstantValue, int> _newConstants = <ConstantValue, int>{};
|
| - final Map<ParameterStubSignature, FletchFunctionBuilder> _newParameterStubs =
|
| - <ParameterStubSignature, FletchFunctionBuilder>{};
|
| + final Map<ParameterStubSignature, DartinoFunctionBuilder> _newParameterStubs =
|
| + <ParameterStubSignature, DartinoFunctionBuilder>{};
|
|
|
| final Map<int, int> _newGettersByFieldIndex = <int, int>{};
|
| final Map<int, int> _newSettersByFieldIndex = <int, int>{};
|
|
|
| - final List<FletchFunction> _removedFunctions = <FletchFunction>[];
|
| + final List<DartinoFunction> _removedFunctions = <DartinoFunction>[];
|
|
|
| - final Map<Element, FletchFunctionBuilder> _functionBuildersByElement =
|
| - <Element, FletchFunctionBuilder>{};
|
| + final Map<Element, DartinoFunctionBuilder> _functionBuildersByElement =
|
| + <Element, DartinoFunctionBuilder>{};
|
|
|
| - final Map<ClassElement, FletchClassBuilder> _classBuildersByElement =
|
| - <ClassElement, FletchClassBuilder>{};
|
| + final Map<ClassElement, DartinoClassBuilder> _classBuildersByElement =
|
| + <ClassElement, DartinoClassBuilder>{};
|
|
|
| - final Map<ConstructorElement, FletchFunctionBuilder>
|
| + final Map<ConstructorElement, DartinoFunctionBuilder>
|
| _newConstructorInitializers =
|
| - <ConstructorElement, FletchFunctionBuilder>{};
|
| + <ConstructorElement, DartinoFunctionBuilder>{};
|
|
|
| // TODO(ajohnsen): By function/class?
|
| final Map<Element, List<FunctionElement>> _replaceUsage =
|
| @@ -78,9 +78,9 @@ class FletchSystemBuilder {
|
| final int maxInt64 = (1 << 63) - 1;
|
| final int minInt64 = -(1 << 63);
|
|
|
| - final Map<int, String> _symbolByFletchSelectorId = <int, String>{};
|
| + final Map<int, String> _symbolByDartinoSelectorId = <int, String>{};
|
|
|
| - FletchSystemBuilder(FletchSystem predecessorSystem)
|
| + DartinoSystemBuilder(DartinoSystem predecessorSystem)
|
| : this.predecessorSystem = predecessorSystem,
|
| this.functionIdStart = predecessorSystem.computeMaxFunctionId() + 1,
|
| this.classIdStart = predecessorSystem.computeMaxClassId() + 1;
|
| @@ -88,7 +88,7 @@ class FletchSystemBuilder {
|
| int lookupConstantIdByValue(ConstantValue value) {
|
| int id = _newConstants[value];
|
| if (id != null) return id;
|
| - FletchConstant constant = predecessorSystem.lookupConstantByValue(value);
|
| + DartinoConstant constant = predecessorSystem.lookupConstantByValue(value);
|
| return constant?.id;
|
| }
|
|
|
| @@ -96,8 +96,8 @@ class FletchSystemBuilder {
|
| _replaceUsage.putIfAbsent(element, () => []).add(usage);
|
| }
|
|
|
| - FletchFunctionBuilder newFunctionBuilder(
|
| - FletchFunctionKind kind,
|
| + DartinoFunctionBuilder newFunctionBuilder(
|
| + DartinoFunctionKind kind,
|
| int arity,
|
| {String name,
|
| Element element,
|
| @@ -105,7 +105,7 @@ class FletchSystemBuilder {
|
| int memberOf,
|
| Element mapByElement}) {
|
| int nextFunctionId = functionIdStart + _newFunctions.length;
|
| - FletchFunctionBuilder builder = new FletchFunctionBuilder(
|
| + DartinoFunctionBuilder builder = new DartinoFunctionBuilder(
|
| nextFunctionId,
|
| kind,
|
| arity,
|
| @@ -120,12 +120,12 @@ class FletchSystemBuilder {
|
| return builder;
|
| }
|
|
|
| - FletchFunctionBuilder newFunctionBuilderWithSignature(
|
| + DartinoFunctionBuilder newFunctionBuilderWithSignature(
|
| String name,
|
| Element element,
|
| FunctionSignature signature,
|
| int memberOf,
|
| - {FletchFunctionKind kind: FletchFunctionKind.NORMAL,
|
| + {DartinoFunctionKind kind: DartinoFunctionKind.NORMAL,
|
| Element mapByElement}) {
|
| int arity = signature.parameterCount + (memberOf != null ? 1 : 0);
|
| return newFunctionBuilder(
|
| @@ -138,7 +138,7 @@ class FletchSystemBuilder {
|
| mapByElement: mapByElement);
|
| }
|
|
|
| - FletchFunctionBase lookupFunction(int functionId) {
|
| + DartinoFunctionBase lookupFunction(int functionId) {
|
| if (functionId < functionIdStart) {
|
| return predecessorSystem.lookupFunctionById(functionId);
|
| } else {
|
| @@ -146,36 +146,36 @@ class FletchSystemBuilder {
|
| }
|
| }
|
|
|
| - FletchFunctionBuilder lookupFunctionBuilder(int functionId) {
|
| + DartinoFunctionBuilder lookupFunctionBuilder(int functionId) {
|
| return _newFunctions[functionId - functionIdStart];
|
| }
|
|
|
| - FletchFunctionBase lookupFunctionByElement(Element element) {
|
| - FletchFunctionBase function = _functionBuildersByElement[element];
|
| + DartinoFunctionBase lookupFunctionByElement(Element element) {
|
| + DartinoFunctionBase function = _functionBuildersByElement[element];
|
| if (function != null) return function;
|
| return predecessorSystem.lookupFunctionByElement(element);
|
| }
|
|
|
| - FletchFunctionBuilder lookupFunctionBuilderByElement(Element element) {
|
| + DartinoFunctionBuilder lookupFunctionBuilderByElement(Element element) {
|
| return _functionBuildersByElement[element];
|
| }
|
|
|
| - FletchFunctionBase lookupConstructorInitializerByElement(
|
| + DartinoFunctionBase lookupConstructorInitializerByElement(
|
| ConstructorElement element) {
|
| assert(element.isImplementation);
|
| - FletchFunctionBase function = _newConstructorInitializers[element];
|
| + DartinoFunctionBase function = _newConstructorInitializers[element];
|
| if (function != null) return function;
|
| return predecessorSystem.lookupConstructorInitializerByElement(element);
|
| }
|
|
|
| - FletchFunctionBuilder newConstructorInitializer(ConstructorElement element) {
|
| + DartinoFunctionBuilder newConstructorInitializer(ConstructorElement element) {
|
| assert(element.isImplementation);
|
| - FletchFunctionBuilder builder = newFunctionBuilderWithSignature(
|
| + DartinoFunctionBuilder builder = newFunctionBuilderWithSignature(
|
| element.name,
|
| element,
|
| element.functionSignature,
|
| null,
|
| - kind: FletchFunctionKind.INITIALIZER_LIST);
|
| + kind: DartinoFunctionKind.INITIALIZER_LIST);
|
| _newConstructorInitializers[element] = builder;
|
| return builder;
|
| }
|
| @@ -186,8 +186,8 @@ class FletchSystemBuilder {
|
| return predecessorSystem.lookupTearOffById(functionId);
|
| }
|
|
|
| - FletchFunctionBuilder newTearOff(FletchFunctionBase function, int classId) {
|
| - FletchFunctionBuilder builder = newFunctionBuilderWithSignature(
|
| + DartinoFunctionBuilder newTearOff(DartinoFunctionBase function, int classId) {
|
| + DartinoFunctionBuilder builder = newFunctionBuilderWithSignature(
|
| 'call',
|
| null,
|
| function.signature,
|
| @@ -207,9 +207,9 @@ class FletchSystemBuilder {
|
| }
|
|
|
| /// Create a new getter for [fieldIndex].
|
| - FletchFunctionBuilder newGetter(int fieldIndex) {
|
| - FletchFunctionBuilder builder =
|
| - newFunctionBuilder(FletchFunctionKind.ACCESSOR, 1);
|
| + DartinoFunctionBuilder newGetter(int fieldIndex) {
|
| + DartinoFunctionBuilder builder =
|
| + newFunctionBuilder(DartinoFunctionKind.ACCESSOR, 1);
|
| _newGettersByFieldIndex[fieldIndex] = builder.functionId;
|
| return builder;
|
| }
|
| @@ -219,7 +219,7 @@ class FletchSystemBuilder {
|
| int getGetterByFieldIndex(int fieldIndex) {
|
| int id = lookupGetterByFieldIndex(fieldIndex);
|
| if (id != null) return id;
|
| - FletchFunctionBuilder stub = newGetter(fieldIndex);
|
| + DartinoFunctionBuilder stub = newGetter(fieldIndex);
|
| stub.assembler
|
| ..loadParameter(0)
|
| ..loadField(fieldIndex)
|
| @@ -239,9 +239,9 @@ class FletchSystemBuilder {
|
| }
|
|
|
| /// Create a new setter for [fieldIndex].
|
| - FletchFunctionBuilder newSetter(int fieldIndex) {
|
| - FletchFunctionBuilder builder =
|
| - newFunctionBuilder(FletchFunctionKind.ACCESSOR, 2);
|
| + DartinoFunctionBuilder newSetter(int fieldIndex) {
|
| + DartinoFunctionBuilder builder =
|
| + newFunctionBuilder(DartinoFunctionKind.ACCESSOR, 2);
|
| _newSettersByFieldIndex[fieldIndex] = builder.functionId;
|
| return builder;
|
| }
|
| @@ -251,7 +251,7 @@ class FletchSystemBuilder {
|
| int getSetterByFieldIndex(int fieldIndex) {
|
| int id = lookupSetterByFieldIndex(fieldIndex);
|
| if (id != null) return id;
|
| - FletchFunctionBuilder stub = newSetter(fieldIndex);
|
| + DartinoFunctionBuilder stub = newSetter(fieldIndex);
|
| stub.assembler
|
| ..loadParameter(0)
|
| ..loadParameter(1)
|
| @@ -262,58 +262,58 @@ class FletchSystemBuilder {
|
| return stub.functionId;
|
| }
|
|
|
| - void forgetFunction(FletchFunction function) {
|
| + void forgetFunction(DartinoFunction function) {
|
| _removedFunctions.add(function);
|
| }
|
|
|
| - List<FletchFunctionBuilder> getNewFunctions() => _newFunctions;
|
| + List<DartinoFunctionBuilder> getNewFunctions() => _newFunctions;
|
|
|
| - FletchClassBuilder getTearoffClassBuilder(
|
| - FletchFunctionBase function,
|
| - FletchClassBuilder superclass) {
|
| + DartinoClassBuilder getTearoffClassBuilder(
|
| + DartinoFunctionBase function,
|
| + DartinoClassBuilder superclass) {
|
| int functionId = lookupTearOffById(function.functionId);
|
| if (functionId == null) return null;
|
| - FletchFunctionBase functionBuilder = lookupFunction(functionId);
|
| - FletchClassBuilder classBuilder =
|
| + DartinoFunctionBase functionBuilder = lookupFunction(functionId);
|
| + DartinoClassBuilder classBuilder =
|
| lookupClassBuilder(functionBuilder.memberOf);
|
| if (classBuilder != null) return classBuilder;
|
| - FletchClass cls = lookupClass(functionBuilder.memberOf);
|
| + DartinoClass cls = lookupClass(functionBuilder.memberOf);
|
| return newClassBuilderInternal(cls, superclass);
|
| }
|
|
|
| - FletchClassBuilder newClassBuilderInternal(
|
| - FletchClass klass,
|
| - FletchClassBuilder superclass) {
|
| - FletchClassBuilder builder = new FletchPatchClassBuilder(
|
| + DartinoClassBuilder newClassBuilderInternal(
|
| + DartinoClass klass,
|
| + DartinoClassBuilder superclass) {
|
| + DartinoClassBuilder builder = new DartinoPatchClassBuilder(
|
| klass, superclass);
|
| assert(_newClasses[klass.classId] == null);
|
| _newClasses[klass.classId] = builder;
|
| return builder;
|
| }
|
|
|
| - FletchClassBuilder newPatchClassBuilder(
|
| + DartinoClassBuilder newPatchClassBuilder(
|
| int classId,
|
| - FletchClassBuilder superclass) {
|
| - FletchClass klass = lookupClass(classId);
|
| + DartinoClassBuilder superclass) {
|
| + DartinoClass klass = lookupClass(classId);
|
| return newClassBuilderInternal(klass, superclass);
|
| }
|
|
|
| - FletchClassBuilder newClassBuilder(
|
| + DartinoClassBuilder newClassBuilder(
|
| ClassElement element,
|
| - FletchClassBuilder superclass,
|
| + DartinoClassBuilder superclass,
|
| bool isBuiltin,
|
| {int extraFields: 0}) {
|
| if (element != null) {
|
| - FletchClass klass = predecessorSystem.lookupClassByElement(element);
|
| + DartinoClass klass = predecessorSystem.lookupClassByElement(element);
|
| if (klass != null) {
|
| - FletchClassBuilder builder = newClassBuilderInternal(klass, superclass);
|
| + DartinoClassBuilder builder = newClassBuilderInternal(klass, superclass);
|
| _classBuildersByElement[element] = builder;
|
| return builder;
|
| }
|
| }
|
|
|
| int nextClassId = classIdStart + _newClasses.length;
|
| - FletchClassBuilder builder = new FletchNewClassBuilder(
|
| + DartinoClassBuilder builder = new DartinoNewClassBuilder(
|
| nextClassId,
|
| element,
|
| superclass,
|
| @@ -324,21 +324,21 @@ class FletchSystemBuilder {
|
| return builder;
|
| }
|
|
|
| - FletchClass lookupClass(int classId) {
|
| + DartinoClass lookupClass(int classId) {
|
| return predecessorSystem.classesById[classId];
|
| }
|
|
|
| - FletchClassBuilder lookupClassBuilder(int classId) {
|
| + DartinoClassBuilder lookupClassBuilder(int classId) {
|
| return _newClasses[classId];
|
| }
|
|
|
| - FletchClassBuilder lookupClassBuilderByElement(ClassElement element) {
|
| + DartinoClassBuilder lookupClassBuilderByElement(ClassElement element) {
|
| return _classBuildersByElement[element];
|
| }
|
|
|
| - Iterable<FletchClassBuilder> getNewClasses() => _newClasses.values;
|
| + Iterable<DartinoClassBuilder> getNewClasses() => _newClasses.values;
|
|
|
| - void registerConstant(ConstantValue constant, FletchContext context) {
|
| + void registerConstant(ConstantValue constant, DartinoContext context) {
|
| if (predecessorSystem.lookupConstantByValue(constant) != null) return;
|
| _newConstants.putIfAbsent(constant, () {
|
| if (constant.isConstructedObject) {
|
| @@ -355,58 +355,58 @@ class FletchSystemBuilder {
|
| });
|
| }
|
|
|
| - void registerSymbol(String symbol, int fletchSelectorId) {
|
| - _symbolByFletchSelectorId[fletchSelectorId] = symbol;
|
| + void registerSymbol(String symbol, int dartinoSelectorId) {
|
| + _symbolByDartinoSelectorId[dartinoSelectorId] = symbol;
|
| }
|
|
|
| - FletchFunctionBase lookupParameterStub(ParameterStubSignature signature) {
|
| - FletchFunctionBuilder stub = _newParameterStubs[signature];
|
| + DartinoFunctionBase lookupParameterStub(ParameterStubSignature signature) {
|
| + DartinoFunctionBuilder stub = _newParameterStubs[signature];
|
| if (stub != null) return stub;
|
| return predecessorSystem.lookupParameterStub(signature);
|
| }
|
|
|
| void registerParameterStub(
|
| ParameterStubSignature signature,
|
| - FletchFunctionBuilder stub) {
|
| + DartinoFunctionBuilder stub) {
|
| assert(lookupParameterStub(signature) == null);
|
| _newParameterStubs[signature] = stub;
|
| }
|
|
|
| - FletchSystem computeSystem(FletchContext context, List<VmCommand> commands) {
|
| + DartinoSystem computeSystem(DartinoContext context, List<VmCommand> commands) {
|
| // TODO(ajohnsen): Consider if the incremental compiler should be aware of
|
| // callMain, when detecting changes.
|
| FunctionElement callMain =
|
| - context.backend.fletchSystemLibrary.findLocal('callMain');
|
| + context.backend.dartinoSystemLibrary.findLocal('callMain');
|
| replaceUsage(callMain, context.compiler.mainFunction);
|
|
|
| int changes = 0;
|
|
|
| - // Remove all removed FletchFunctions.
|
| - for (FletchFunction function in _removedFunctions) {
|
| + // Remove all removed DartinoFunctions.
|
| + for (DartinoFunction function in _removedFunctions) {
|
| commands.add(new RemoveFromMap(MapId.methods, function.functionId));
|
| }
|
|
|
| - // Create all new FletchFunctions.
|
| - List<FletchFunction> functions = <FletchFunction>[];
|
| - for (FletchFunctionBuilder builder in _newFunctions) {
|
| + // Create all new DartinoFunctions.
|
| + List<DartinoFunction> functions = <DartinoFunction>[];
|
| + for (DartinoFunctionBuilder builder in _newFunctions) {
|
| context.compiler.reporter.withCurrentElement(builder.element, () {
|
| functions.add(builder.finalizeFunction(context, commands));
|
| });
|
| }
|
|
|
| - // Create all new FletchClasses.
|
| - List<FletchClass> classes = <FletchClass>[];
|
| - for (FletchClassBuilder builder in _newClasses.values) {
|
| + // Create all new DartinoClasses.
|
| + List<DartinoClass> classes = <DartinoClass>[];
|
| + for (DartinoClassBuilder builder in _newClasses.values) {
|
| classes.add(builder.finalizeClass(context, commands));
|
| changes++;
|
| }
|
|
|
| // Create all statics.
|
| - // TODO(ajohnsen): Should be part of the fletch system. Does not work with
|
| + // TODO(ajohnsen): Should be part of the dartino system. Does not work with
|
| // incremental.
|
| if (predecessorSystem.isEmpty) {
|
| context.forEachStatic((element, index) {
|
| - FletchFunctionBuilder initializer =
|
| + DartinoFunctionBuilder initializer =
|
| context.backend.lazyFieldInitializers[element];
|
| if (initializer != null) {
|
| commands.add(new PushFromMap(MapId.methods, initializer.functionId));
|
| @@ -419,10 +419,10 @@ class FletchSystemBuilder {
|
| changes++;
|
| }
|
|
|
| - // Create all FletchConstants.
|
| - PersistentMap<int, FletchConstant> constantsById =
|
| + // Create all DartinoConstants.
|
| + PersistentMap<int, DartinoConstant> constantsById =
|
| predecessorSystem.constantsById;
|
| - PersistentMap<ConstantValue, FletchConstant> constantsByValue =
|
| + PersistentMap<ConstantValue, DartinoConstant> constantsByValue =
|
| predecessorSystem.constantsByValue;
|
| _newConstants.forEach((constant, int id) {
|
| void addList(List<ConstantValue> list, bool isByteList) {
|
| @@ -465,10 +465,10 @@ class FletchSystemBuilder {
|
| value >>= 32;
|
| }
|
|
|
| - // TODO(ajohnsen): Avoid usage of builders (should be FletchClass).
|
| - FletchClassBuilder bigintClassBuilder =
|
| + // TODO(ajohnsen): Avoid usage of builders (should be DartinoClass).
|
| + DartinoClassBuilder bigintClassBuilder =
|
| _classBuildersByElement[context.backend.bigintClass];
|
| - FletchClassBuilder uint32DigitsClassBuilder =
|
| + DartinoClassBuilder uint32DigitsClassBuilder =
|
| _classBuildersByElement[context.backend.uint32DigitsClass];
|
|
|
| commands.add(new PushNewBigInteger(
|
| @@ -505,17 +505,17 @@ class FletchSystemBuilder {
|
| } else if (constant.isFunction) {
|
| FunctionConstantValue value = constant;
|
| FunctionElement element = value.element;
|
| - FletchFunctionBase function = lookupFunctionByElement(element);
|
| + DartinoFunctionBase function = lookupFunctionByElement(element);
|
| int tearoffId = lookupTearOffById(function.functionId);
|
| - FletchFunctionBase tearoff = lookupFunction(tearoffId);
|
| + DartinoFunctionBase tearoff = lookupFunction(tearoffId);
|
| commands
|
| ..add(new PushFromMap(MapId.classes, tearoff.memberOf))
|
| ..add(const PushNewInstance());
|
| } else if (constant.isConstructedObject) {
|
| ConstructedConstantValue value = constant;
|
| ClassElement classElement = value.type.element;
|
| - // TODO(ajohnsen): Avoid usage of builders (should be FletchClass).
|
| - FletchClassBuilder classBuilder = _classBuildersByElement[classElement];
|
| + // TODO(ajohnsen): Avoid usage of builders (should be DartinoClass).
|
| + DartinoClassBuilder classBuilder = _classBuildersByElement[classElement];
|
|
|
| void addIfField(MemberElement member) {
|
| if (!member.isField || member.isStatic || member.isPatch) return;
|
| @@ -543,7 +543,7 @@ class FletchSystemBuilder {
|
| commands
|
| ..add(new PushFromMap(MapId.classes, classBuilder.classId))
|
| ..add(const PushNewInstance());
|
| - } else if (constant is FletchClassInstanceConstant) {
|
| + } else if (constant is DartinoClassInstanceConstant) {
|
| commands
|
| ..add(new PushFromMap(MapId.classes, constant.classId))
|
| ..add(const PushNewInstance());
|
| @@ -556,14 +556,14 @@ class FletchSystemBuilder {
|
| } else {
|
| throw "Unsupported constant: ${constant.toStructuredString()}";
|
| }
|
| - FletchConstant fletchConstant = new FletchConstant(id, MapId.constants);
|
| - constantsByValue = constantsByValue.insert(constant, fletchConstant);
|
| - constantsById = constantsById.insert(id, fletchConstant);
|
| + DartinoConstant dartinoConstant = new DartinoConstant(id, MapId.constants);
|
| + constantsByValue = constantsByValue.insert(constant, dartinoConstant);
|
| + constantsById = constantsById.insert(id, dartinoConstant);
|
| commands.add(new PopToMap(MapId.constants, id));
|
| });
|
|
|
| // Set super class for classes, now they are resolved.
|
| - for (FletchClass klass in classes) {
|
| + for (DartinoClass klass in classes) {
|
| if (!klass.hasSuperclassId) continue;
|
| commands.add(new PushFromMap(MapId.classes, klass.classId));
|
| commands.add(new PushFromMap(MapId.classes, klass.superclassId));
|
| @@ -573,10 +573,10 @@ class FletchSystemBuilder {
|
|
|
| // Change constants for the functions, now that classes and constants has
|
| // been added.
|
| - for (FletchFunction function in functions) {
|
| - List<FletchConstant> constants = function.constants;
|
| + for (DartinoFunction function in functions) {
|
| + List<DartinoConstant> constants = function.constants;
|
| for (int i = 0; i < constants.length; i++) {
|
| - FletchConstant constant = constants[i];
|
| + DartinoConstant constant = constants[i];
|
| commands
|
| ..add(new PushFromMap(MapId.methods, function.functionId))
|
| ..add(new PushFromMap(constant.mapId, constant.id))
|
| @@ -586,37 +586,37 @@ class FletchSystemBuilder {
|
| }
|
|
|
| // Compute all scheme changes.
|
| - for (FletchClassBuilder builder in _newClasses.values) {
|
| + for (DartinoClassBuilder builder in _newClasses.values) {
|
| if (builder.computeSchemaChange(commands)) changes++;
|
| }
|
|
|
| - List<FletchFunction> changedFunctions = <FletchFunction>[];
|
| + List<DartinoFunction> changedFunctions = <DartinoFunction>[];
|
| for (Element element in _replaceUsage.keys) {
|
| // Don't modify already replaced elements.
|
| if (lookupFunctionBuilderByElement(element) != null) continue;
|
|
|
| - FletchFunction function =
|
| + DartinoFunction function =
|
| predecessorSystem.lookupFunctionByElement(element);
|
| // Due to false positive, the element can be uncompiled.
|
| if (function == null) continue;
|
|
|
| bool constantsChanged = false;
|
| - List<FletchConstant> constants = function.constants.toList();
|
| + List<DartinoConstant> constants = function.constants.toList();
|
| for (int i = 0; i < constants.length; i++) {
|
| - FletchConstant constant = constants[i];
|
| + DartinoConstant constant = constants[i];
|
| if (constant.mapId != MapId.methods) continue;
|
| for (var usage in _replaceUsage[element]) {
|
| - FletchFunction oldFunction =
|
| + DartinoFunction oldFunction =
|
| predecessorSystem.lookupFunctionByElement(usage);
|
| if (oldFunction == null) continue;
|
| if (oldFunction.functionId != constant.id) continue;
|
| - FletchFunctionBuilder newFunction =
|
| + DartinoFunctionBuilder newFunction =
|
| lookupFunctionBuilderByElement(usage);
|
|
|
| // If the method didn't really change, ignore.
|
| if (newFunction == null) continue;
|
|
|
| - constant = new FletchConstant(newFunction.functionId, MapId.methods);
|
| + constant = new DartinoConstant(newFunction.functionId, MapId.methods);
|
| commands
|
| ..add(new PushFromMap(MapId.methods, function.functionId))
|
| ..add(new PushFromMap(constant.mapId, constant.id))
|
| @@ -635,23 +635,23 @@ class FletchSystemBuilder {
|
|
|
| commands.add(new CommitChanges(changes));
|
|
|
| - PersistentMap<int, FletchClass> classesById = predecessorSystem.classesById;
|
| - PersistentMap<ClassElement, FletchClass> classesByElement =
|
| + PersistentMap<int, DartinoClass> classesById = predecessorSystem.classesById;
|
| + PersistentMap<ClassElement, DartinoClass> classesByElement =
|
| predecessorSystem.classesByElement;
|
|
|
| - for (FletchClass klass in classes) {
|
| + for (DartinoClass klass in classes) {
|
| classesById = classesById.insert(klass.classId, klass);
|
| if (klass.element != null) {
|
| classesByElement = classesByElement.insert(klass.element, klass);
|
| }
|
| }
|
|
|
| - PersistentMap<int, FletchFunction> functionsById =
|
| + PersistentMap<int, DartinoFunction> functionsById =
|
| predecessorSystem.functionsById;
|
| - PersistentMap<Element, FletchFunction> functionsByElement =
|
| + PersistentMap<Element, DartinoFunction> functionsByElement =
|
| predecessorSystem.functionsByElement;
|
|
|
| - for (FletchFunction function in changedFunctions) {
|
| + for (DartinoFunction function in changedFunctions) {
|
| assert(functionsById[function.functionId] != null);
|
| functionsById = functionsById.insert(function.functionId, function);
|
| Element element = function.element;
|
| @@ -661,7 +661,7 @@ class FletchSystemBuilder {
|
| }
|
| }
|
|
|
| - for (FletchFunction function in _removedFunctions) {
|
| + for (DartinoFunction function in _removedFunctions) {
|
| functionsById = functionsById.delete(function.functionId);
|
| Element element = function.element;
|
| if (element != null) {
|
| @@ -669,7 +669,7 @@ class FletchSystemBuilder {
|
| }
|
| }
|
|
|
| - for (FletchFunction function in functions) {
|
| + for (DartinoFunction function in functions) {
|
| functionsById = functionsById.insert(function.functionId, function);
|
| }
|
|
|
| @@ -682,7 +682,7 @@ class FletchSystemBuilder {
|
| });
|
| });
|
|
|
| - PersistentMap<ConstructorElement, FletchFunction>
|
| + PersistentMap<ConstructorElement, DartinoFunction>
|
| constructorInitializersByElement =
|
| predecessorSystem.constructorInitializersByElement;
|
|
|
| @@ -697,10 +697,10 @@ class FletchSystemBuilder {
|
| tearoffsById = tearoffsById.insert(functionId, stubId);
|
| });
|
|
|
| - PersistentMap<int, String> symbolByFletchSelectorId =
|
| - predecessorSystem.symbolByFletchSelectorId;
|
| - _symbolByFletchSelectorId.forEach((int id, String name) {
|
| - symbolByFletchSelectorId = symbolByFletchSelectorId.insert(id, name);
|
| + PersistentMap<int, String> symbolByDartinoSelectorId =
|
| + predecessorSystem.symbolByDartinoSelectorId;
|
| + _symbolByDartinoSelectorId.forEach((int id, String name) {
|
| + symbolByDartinoSelectorId = symbolByDartinoSelectorId.insert(id, name);
|
| });
|
|
|
| PersistentMap<int, int> gettersByFieldIndex =
|
| @@ -715,14 +715,14 @@ class FletchSystemBuilder {
|
| settersByFieldIndex = settersByFieldIndex.insert(fieldIndex, functionId);
|
| });
|
|
|
| - PersistentMap<ParameterStubSignature, FletchFunction> parameterStubs =
|
| + PersistentMap<ParameterStubSignature, DartinoFunction> parameterStubs =
|
| predecessorSystem.parameterStubs;
|
| _newParameterStubs.forEach((signature, functionBuilder) {
|
| - FletchFunction function = functionsById[functionBuilder.functionId];
|
| + DartinoFunction function = functionsById[functionBuilder.functionId];
|
| parameterStubs = parameterStubs.insert(signature, function);
|
| });
|
|
|
| - return new FletchSystem(
|
| + return new DartinoSystem(
|
| functionsById,
|
| functionsByElement,
|
| constructorInitializersByElement,
|
| @@ -731,7 +731,7 @@ class FletchSystemBuilder {
|
| classesByElement,
|
| constantsById,
|
| constantsByValue,
|
| - symbolByFletchSelectorId,
|
| + symbolByDartinoSelectorId,
|
| gettersByFieldIndex,
|
| settersByFieldIndex,
|
| parameterStubs);
|
|
|