| Index: pkg/dartino_compiler/lib/src/dartino_system_printer.dart
|
| diff --git a/pkg/fletchc/lib/src/fletch_system_printer.dart b/pkg/dartino_compiler/lib/src/dartino_system_printer.dart
|
| similarity index 67%
|
| rename from pkg/fletchc/lib/src/fletch_system_printer.dart
|
| rename to pkg/dartino_compiler/lib/src/dartino_system_printer.dart
|
| index e822c7ab436a9f43e2f745c487610351894db8ea..d579df4072bf0d749accc21d183e45d8f10ba6b0 100644
|
| --- a/pkg/fletchc/lib/src/fletch_system_printer.dart
|
| +++ b/pkg/dartino_compiler/lib/src/dartino_system_printer.dart
|
| @@ -2,26 +2,26 @@
|
| // 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_printer;
|
| +library dartino_compiler.dartino_system_printer;
|
|
|
| -import '../fletch_system.dart' show
|
| - FletchClass,
|
| - FletchFunction,
|
| - FletchSystem;
|
| +import '../dartino_system.dart' show
|
| + DartinoClass,
|
| + DartinoFunction,
|
| + DartinoSystem;
|
|
|
| import 'package:compiler/src/util/uri_extras.dart' show
|
| relativize;
|
|
|
| -import 'fletch_selector.dart' show
|
| - FletchSelector,
|
| +import 'dartino_selector.dart' show
|
| + DartinoSelector,
|
| SelectorKind;
|
|
|
| import 'package:compiler/src/elements/elements.dart' show
|
| Element,
|
| CompilationUnitElement;
|
|
|
| -class FletchSystemPrinter {
|
| - final FletchSystem system;
|
| +class DartinoSystemPrinter {
|
| + final DartinoSystem system;
|
| final Uri base;
|
| final StringBuffer buffer = new StringBuffer();
|
| final String baseIndentation = " ";
|
| @@ -30,7 +30,7 @@ class FletchSystemPrinter {
|
|
|
| int indentationLevel = 0;
|
|
|
| - FletchSystemPrinter(this.system, this.base);
|
| + DartinoSystemPrinter(this.system, this.base);
|
|
|
| void indent() {
|
| for (int i = 0; i < indentationLevel; i++) {
|
| @@ -60,7 +60,7 @@ class FletchSystemPrinter {
|
| beginningOfLine = true;
|
| }
|
|
|
| - void writeFletchFunctionAsBody(FletchFunction function) {
|
| + void writeDartinoFunctionAsBody(DartinoFunction function) {
|
| if (function.element != null) {
|
| writeLine("=> ${function.element};");
|
| } else {
|
| @@ -75,7 +75,7 @@ class FletchSystemPrinter {
|
| }
|
|
|
| void writeMethodTableEntry(
|
| - DecodedFletchSelector selector, int functionId) {
|
| + DecodedDartinoSelector selector, int functionId) {
|
| switch (selector.kind) {
|
| case SelectorKind.Method:
|
| write("${selector.symbol}#${selector.arity}()");
|
| @@ -96,28 +96,28 @@ class FletchSystemPrinter {
|
| break;
|
| }
|
| write(" ");
|
| - FletchFunction function = system.functionsById[functionId];
|
| - writeFletchFunctionAsBody(function);
|
| + DartinoFunction function = system.functionsById[functionId];
|
| + writeDartinoFunctionAsBody(function);
|
| }
|
|
|
| - void writeFletchClass(FletchClass cls, Set<FletchFunction> unseen) {
|
| + void writeDartinoClass(DartinoClass cls, Set<DartinoFunction> unseen) {
|
| // TODO(ahe): Important if class is builtin or not. Information lost in
|
| - // FletchNewClassBuilder.finalizeClass.
|
| + // DartinoNewClassBuilder.finalizeClass.
|
| if (cls.element != null) {
|
| writeLine("class ${cls.element.name} {");
|
| } else {
|
| writeLine("$cls {");
|
| }
|
| indented(() {
|
| - Map<DecodedFletchSelector, int> methodTable =
|
| - <DecodedFletchSelector, int>{};
|
| + Map<DecodedDartinoSelector, int> methodTable =
|
| + <DecodedDartinoSelector, int>{};
|
| for (var pair in cls.methodTable) {
|
| - DecodedFletchSelector selector =
|
| - new DecodedFletchSelector.fromEncodedSelector(pair.fst, system);
|
| + DecodedDartinoSelector selector =
|
| + new DecodedDartinoSelector.fromEncodedSelector(pair.fst, system);
|
| methodTable[selector] = pair.snd;
|
| }
|
| - List<DecodedFletchSelector> selectors = methodTable.keys.toList()..sort();
|
| - for (DecodedFletchSelector selector in selectors) {
|
| + List<DecodedDartinoSelector> selectors = methodTable.keys.toList()..sort();
|
| + for (DecodedDartinoSelector selector in selectors) {
|
| int methodId = methodTable[selector];
|
| unseen.remove(system.lookupFunctionById(methodId));
|
| writeMethodTableEntry(selector, methodId);
|
| @@ -130,7 +130,7 @@ class FletchSystemPrinter {
|
| buffer.clear();
|
|
|
| Map<String, List<Element>> elementsByPath = <String, List<Element>>{};
|
| - Set<FletchFunction> unseenFunctions = new Set<FletchFunction>();
|
| + Set<DartinoFunction> unseenFunctions = new Set<DartinoFunction>();
|
|
|
| for (var pair in system.functionsById) {
|
| unseenFunctions.add(pair.snd);
|
| @@ -155,11 +155,11 @@ class FletchSystemPrinter {
|
| elements.sort((a, b) => "$a".compareTo("$b"));
|
| for (Element element in elements) {
|
| if (element.isClass) {
|
| - writeFletchClass(system.classesByElement[element], unseenFunctions);
|
| + writeDartinoClass(system.classesByElement[element], unseenFunctions);
|
| } else if (!element.isInstanceMember) {
|
| unseenFunctions.remove(system.functionsByElement[element]);
|
| // TODO(ahe): It would probably be better to call
|
| - // writeFletchFunctionAsBody here, but we have an element, not an
|
| + // writeDartinoFunctionAsBody here, but we have an element, not an
|
| // ID.
|
| writeLine("$element");
|
| }
|
| @@ -170,9 +170,9 @@ class FletchSystemPrinter {
|
| writeLine("Classes without an element:");
|
| indented(() {
|
| for (var pair in system.classesById) {
|
| - FletchClass fletchClass = pair.snd;
|
| - if (system.classesByElement[fletchClass.element] != fletchClass) {
|
| - writeFletchClass(fletchClass, unseenFunctions);
|
| + DartinoClass dartinoClass = pair.snd;
|
| + if (system.classesByElement[dartinoClass.element] != dartinoClass) {
|
| + writeDartinoClass(dartinoClass, unseenFunctions);
|
| }
|
| }
|
| });
|
| @@ -180,10 +180,10 @@ class FletchSystemPrinter {
|
| writeLine("Other functions:");
|
| indented(() {
|
| for (var pair in system.functionsById) {
|
| - FletchFunction fletchFunction = pair.snd;
|
| - if (unseenFunctions.remove(fletchFunction)) {
|
| - write("$fletchFunction ");
|
| - writeFletchFunctionAsBody(fletchFunction);
|
| + DartinoFunction dartinoFunction = pair.snd;
|
| + if (unseenFunctions.remove(dartinoFunction)) {
|
| + write("$dartinoFunction ");
|
| + writeDartinoFunctionAsBody(dartinoFunction);
|
| }
|
| }
|
| });
|
| @@ -198,19 +198,19 @@ class FletchSystemPrinter {
|
| }
|
| }
|
|
|
| -class DecodedFletchSelector implements Comparable<DecodedFletchSelector> {
|
| - final FletchSelector selector;
|
| +class DecodedDartinoSelector implements Comparable<DecodedDartinoSelector> {
|
| + final DartinoSelector selector;
|
|
|
| final String symbol;
|
|
|
| - const DecodedFletchSelector(this.selector, this.symbol);
|
| + const DecodedDartinoSelector(this.selector, this.symbol);
|
|
|
| - factory DecodedFletchSelector.fromEncodedSelector(
|
| + factory DecodedDartinoSelector.fromEncodedSelector(
|
| int encodedSelector,
|
| - FletchSystem system) {
|
| - FletchSelector selector = new FletchSelector(encodedSelector);
|
| - return new DecodedFletchSelector(
|
| - selector, system.symbolByFletchSelectorId[selector.id]);
|
| + DartinoSystem system) {
|
| + DartinoSelector selector = new DartinoSelector(encodedSelector);
|
| + return new DecodedDartinoSelector(
|
| + selector, system.symbolByDartinoSelectorId[selector.id]);
|
| }
|
|
|
| int get id => selector.id;
|
| @@ -219,9 +219,9 @@ class DecodedFletchSelector implements Comparable<DecodedFletchSelector> {
|
|
|
| int get arity => selector.arity;
|
|
|
| - String toString() => "DecodedFletchSelector($id, $symbol, $kind, $arity)";
|
| + String toString() => "DecodedDartinoSelector($id, $symbol, $kind, $arity)";
|
|
|
| - int compareTo(DecodedFletchSelector other) {
|
| + int compareTo(DecodedDartinoSelector other) {
|
| int result = this.symbol.compareTo(other.symbol);
|
| if (result != 0) return result;
|
| result = this.kind.index.compareTo(other.kind.index);
|
|
|