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

Unified Diff: pkg/fletchc/lib/fletch_system.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 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
« no previous file with comments | « pkg/fletchc/lib/fletch_compiler.dart ('k') | pkg/fletchc/lib/fletch_vm.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/fletchc/lib/fletch_system.dart
diff --git a/pkg/fletchc/lib/fletch_system.dart b/pkg/fletchc/lib/fletch_system.dart
deleted file mode 100644
index 233a8668ac431ff225c85bfef2c36d6ae1da1f00..0000000000000000000000000000000000000000
--- a/pkg/fletchc/lib/fletch_system.dart
+++ /dev/null
@@ -1,328 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// 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;
-
-import 'package:compiler/src/constants/values.dart' show
- ConstantValue;
-
-import 'package:compiler/src/elements/elements.dart' show
- ClassElement,
- ConstructorElement,
- Element,
- FieldElement,
- FunctionSignature;
-
-import 'package:compiler/src/universe/call_structure.dart' show
- CallStructure;
-
-import 'package:persistent/persistent.dart' show
- PersistentMap;
-
-import 'bytecodes.dart';
-import 'vm_commands.dart';
-
-import 'src/fletch_selector.dart' show
- FletchSelector;
-
-import 'src/fletch_system_printer.dart' show
- FletchSystemPrinter;
-
-enum FletchFunctionKind {
- NORMAL,
- LAZY_FIELD_INITIALIZER,
- INITIALIZER_LIST,
- PARAMETER_STUB,
- ACCESSOR
-}
-
-// TODO(ajohnsen): Move to separate file.
-class FletchConstant {
- final int id;
- final MapId mapId;
- const FletchConstant(this.id, this.mapId);
-
- String toString() => "FletchConstant($id, $mapId)";
-}
-
-// TODO(ajohnsen): Move to separate file.
-class FletchClass {
- final int classId;
- final String name;
- final ClassElement element;
- final int superclassId;
- final int superclassFields;
- final PersistentMap<int, int> methodTable;
- final List<FieldElement> fields;
-
- const FletchClass(
- this.classId,
- this.name,
- this.element,
- this.superclassId,
- this.superclassFields,
- this.methodTable,
- this.fields);
-
- bool get hasSuperclassId => superclassId >= 0;
-
- String toString() => "FletchClass($classId, '$name')";
-}
-
-// TODO(ajohnsen): Move to separate file.
-abstract class FletchFunctionBase {
- final int functionId;
- final FletchFunctionKind kind;
- // TODO(ajohnsen): Merge with function signature?
- final int arity;
- // TODO(ajohnsen): Remove name?
- final String name;
- final Element element;
-
- /**
- * The signature of the FletchFunctionBuilder.
- *
- * Some compiled functions does not have a signature (for example, generated
- * accessors).
- */
- final FunctionSignature signature;
- final int memberOf;
-
- const FletchFunctionBase(
- this.functionId,
- this.kind,
- this.arity,
- this.name,
- this.element,
- this.signature,
- this.memberOf);
-
- bool get isInstanceMember => memberOf != null;
- bool get isInternal => element == null;
-
- bool get isLazyFieldInitializer {
- return kind == FletchFunctionKind.LAZY_FIELD_INITIALIZER;
- }
-
- bool get isInitializerList {
- return kind == FletchFunctionKind.INITIALIZER_LIST;
- }
-
- bool get isAccessor {
- return kind == FletchFunctionKind.ACCESSOR;
- }
-
- bool get isParameterStub {
- return kind == FletchFunctionKind.PARAMETER_STUB;
- }
-
- bool get isConstructor => element != null && element.isConstructor;
-
- String verboseToString();
-}
-
-// TODO(ajohnsen): Move to separate file.
-class FletchFunction extends FletchFunctionBase {
- final List<Bytecode> bytecodes;
- final List<FletchConstant> constants;
-
- const FletchFunction(
- int functionId,
- FletchFunctionKind kind,
- int arity,
- String name,
- Element element,
- FunctionSignature signature,
- this.bytecodes,
- this.constants,
- int memberOf)
- : super(functionId, kind, arity, name, element, signature, memberOf);
-
- FletchFunction withReplacedConstants(List<FletchConstant> constants) {
- return new FletchFunction(
- functionId,
- kind,
- arity,
- name,
- element,
- signature,
- bytecodes,
- constants,
- memberOf);
- }
-
- /// Represents a function we have lost track off, for example, -1 in a
- /// backtrace from the Fletch VM.
- const FletchFunction.missing()
- : this(
- -1, FletchFunctionKind.NORMAL, 0, "<missing>", null, null,
- const <Bytecode>[], const <FletchConstant>[], null);
-
- String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.write("FletchFunction($functionId, '$name'");
- if (isInstanceMember) {
- buffer.write(", memberOf=$memberOf");
- }
- buffer.write(")");
- return buffer.toString();
- }
-
- String verboseToString() {
- StringBuffer sb = new StringBuffer();
-
- sb.writeln("Function $functionId, Arity=$arity");
- sb.writeln("Constants:");
- for (int i = 0; i < constants.length; i++) {
- FletchConstant constant = constants[i];
- sb.writeln(" #$i: $constant");
- }
-
- sb.writeln("Bytecodes:");
- Bytecode.prettyPrint(sb, bytecodes);
-
- return '$sb';
- }
-}
-
-class ParameterStubSignature {
- final int functionId;
- final CallStructure callStructure;
-
- const ParameterStubSignature(this.functionId, this.callStructure);
-
- int get hashCode => functionId ^ callStructure.hashCode;
-
- bool operator==(other) {
- return other is ParameterStubSignature &&
- other.functionId == functionId &&
- other.callStructure == callStructure;
- }
-}
-
-class FletchSystem {
- // functionsByElement is a subset of functionsById: Some functions do not
- // have an element reference.
- final PersistentMap<int, FletchFunction> functionsById;
- final PersistentMap<Element, FletchFunction> functionsByElement;
-
- final PersistentMap<ConstructorElement, FletchFunction>
- constructorInitializersByElement;
-
- final PersistentMap<int, int> tearoffsById;
-
- // classesByElement is a subset of classesById: Some classes do not
- // have an element reference.
- final PersistentMap<int, FletchClass> classesById;
- final PersistentMap<ClassElement, FletchClass> classesByElement;
-
- final PersistentMap<int, FletchConstant> constantsById;
- final PersistentMap<ConstantValue, FletchConstant> constantsByValue;
-
- final PersistentMap<int, String> symbolByFletchSelectorId;
-
- final PersistentMap<int, int> gettersByFieldIndex;
-
- final PersistentMap<int, int> settersByFieldIndex;
-
- final PersistentMap<ParameterStubSignature, FletchFunction> parameterStubs;
-
- const FletchSystem(
- this.functionsById,
- this.functionsByElement,
- this.constructorInitializersByElement,
- this.tearoffsById,
- this.classesById,
- this.classesByElement,
- this.constantsById,
- this.constantsByValue,
- this.symbolByFletchSelectorId,
- this.gettersByFieldIndex,
- this.settersByFieldIndex,
- this.parameterStubs);
-
- bool get isEmpty => functionsById.isEmpty;
-
- String lookupSymbolBySelector(int fletchSelector) {
- return symbolByFletchSelectorId[FletchSelector.decodeId(fletchSelector)];
- }
-
- FletchFunction lookupFunctionById(int functionId) {
- return functionsById[functionId];
- }
-
- FletchFunction lookupFunctionByElement(Element element) {
- return functionsByElement[element];
- }
-
- Iterable<FletchFunction> functionsWhere(bool f(FletchFunction function)) {
- return functionsById.values.where(f);
- }
-
- FletchConstant lookupConstantById(int constantId) {
- return constantsById[constantId];
- }
-
- FletchConstant lookupConstantByValue(ConstantValue value) {
- return constantsByValue[value];
- }
-
- FletchFunction lookupConstructorInitializerByElement(
- ConstructorElement element) {
- return constructorInitializersByElement[element];
- }
-
- /// Map from the ID of a [FletchFunction] to the ID of its corresponding
- /// tear-off [FletchFunction].
- ///
- /// To obtain the tear-off corresponding to an [Element], look up the
- /// function in [functionsByElement].
- int lookupTearOffById(int functionId) => tearoffsById[functionId];
-
- /// Instance field getters can be reused between classes. This method returns
- /// a getter that gets the field at [fieldIndex]. Returns `null` if no such
- /// getter exists.
- int lookupGetterByFieldIndex(int fieldIndex) {
- return gettersByFieldIndex[fieldIndex];
- }
-
- /// Instance field setters can be reused between classes. This method returns
- /// a setter that sets the field at [fieldIndex]. Returns `null` if no such
- /// setter exists.
- int lookupSetterByFieldIndex(int fieldIndex) {
- return settersByFieldIndex[fieldIndex];
- }
-
- FletchClass lookupClassById(int classId) {
- return classesById[classId];
- }
-
- FletchClass lookupClassByElement(ClassElement element) {
- return classesByElement[element];
- }
-
- FletchFunction lookupParameterStub(ParameterStubSignature signature) {
- return parameterStubs[signature];
- }
-
- int computeMaxFunctionId() {
- return functionsById.keys.fold(-1, (x, y) => x > y ? x : y);
- }
-
- int computeMaxClassId() {
- return classesById.keys.fold(-1, (x, y) => x > y ? x : y);
- }
-
- String toDebugString(Uri base) {
- return new FletchSystemPrinter(this, base).generateDebugString();
- }
-}
-
-class FletchDelta {
- final FletchSystem system;
- final FletchSystem predecessorSystem;
- final List<VmCommand> commands;
-
- const FletchDelta(this.system, this.predecessorSystem, this.commands);
-}
« no previous file with comments | « pkg/fletchc/lib/fletch_compiler.dart ('k') | pkg/fletchc/lib/fletch_vm.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698