| Index: pkg/dartino_compiler/lib/vm_session.dart
|
| diff --git a/pkg/fletchc/lib/vm_session.dart b/pkg/dartino_compiler/lib/vm_session.dart
|
| similarity index 90%
|
| rename from pkg/fletchc/lib/vm_session.dart
|
| rename to pkg/dartino_compiler/lib/vm_session.dart
|
| index 94757fe153afe595f89fd0fb4b373275a9948c95..6292d36b4d2907d5f13c02c6781395ccd7740707 100644
|
| --- a/pkg/fletchc/lib/vm_session.dart
|
| +++ b/pkg/dartino_compiler/lib/vm_session.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 fletch.vm_session;
|
| +library dartino.vm_session;
|
|
|
| import 'dart:core';
|
| import 'dart:async';
|
| @@ -14,19 +14,19 @@ import 'dart:typed_data' show
|
| Uint8List;
|
|
|
| import 'vm_commands.dart';
|
| -import 'fletch_system.dart';
|
| +import 'dartino_system.dart';
|
|
|
| -import 'incremental/fletchc_incremental.dart'
|
| +import 'incremental/dartino_compiler_incremental.dart'
|
| show IncrementalCompiler;
|
|
|
| import 'src/codegen_visitor.dart';
|
| import 'src/debug_info.dart';
|
|
|
| // TODO(ahe): Get rid of this import.
|
| -import 'src/fletch_backend.dart' show FletchBackend;
|
| +import 'src/dartino_backend.dart' show DartinoBackend;
|
|
|
| -import 'src/fletch_selector.dart' show
|
| - FletchSelector,
|
| +import 'src/dartino_selector.dart' show
|
| + DartinoSelector,
|
| SelectorKind;
|
|
|
| import 'debug_state.dart';
|
| @@ -41,10 +41,10 @@ import 'src/hub/session_manager.dart' show
|
| part 'vm_command_reader.dart';
|
| part 'input_handler.dart';
|
|
|
| -/// Encapsulates a TCP connection to a running fletch-vm and provides a
|
| +/// Encapsulates a TCP connection to a running dartino-vm and provides a
|
| /// [VmCommand] based view on top of it.
|
| -class FletchVmSession {
|
| - /// The outgoing connection to the fletch-vm.
|
| +class DartinoVmSession {
|
| + /// The outgoing connection to the dartino-vm.
|
| final StreamSink<List<int>> _outgoingSink;
|
|
|
| final Sink<List<int>> stdoutSink;
|
| @@ -79,7 +79,7 @@ class FletchVmSession {
|
|
|
| VmCommand connectionError = new ConnectionError("Connection is closed", null);
|
|
|
| - FletchVmSession(Socket vmSocket,
|
| + DartinoVmSession(Socket vmSocket,
|
| Sink<List<int>> stdoutSink,
|
| Sink<List<int>> stderrSink)
|
| : _outgoingSink = vmSocket,
|
| @@ -103,7 +103,7 @@ class FletchVmSession {
|
| return runCommands([command]);
|
| }
|
|
|
| - /// Sends the given commands to a fletch-vm and reads response commands
|
| + /// Sends the given commands to a dartino-vm and reads response commands
|
| /// (if necessary).
|
| ///
|
| /// If all commands have been successfully applied and responses been awaited,
|
| @@ -127,24 +127,24 @@ class FletchVmSession {
|
| return lastResponse;
|
| }
|
|
|
| - /// Sends all given [VmCommand]s to a fletch-vm.
|
| + /// Sends all given [VmCommand]s to a dartino-vm.
|
| Future sendCommands(List<VmCommand> commands) async {
|
| for (var command in commands) {
|
| await sendCommand(command);
|
| }
|
| }
|
|
|
| - /// Sends a [VmCommand] to a fletch-vm.
|
| + /// Sends a [VmCommand] to a dartino-vm.
|
| Future sendCommand(VmCommand command) async {
|
| if (_connectionIsDead) {
|
| throw new StateError(
|
| - 'Trying to send command ${command} to fletch-vm, but '
|
| + 'Trying to send command ${command} to dartino-vm, but '
|
| 'the connection is already closed.');
|
| }
|
| command.addTo(_outgoingSink);
|
| }
|
|
|
| - /// Will read the next [VmCommand] the fletch-vm sends to us.
|
| + /// Will read the next [VmCommand] the dartino-vm sends to us.
|
| Future<VmCommand> readNextCommand({bool force: true}) async {
|
| if (_drainedIncomingCommands) {
|
| return connectionError;
|
| @@ -163,11 +163,11 @@ class FletchVmSession {
|
| return _commandReader.iterator.current;
|
| }
|
|
|
| - /// Closes the connection to the fletch-vm and drains the remaining response
|
| + /// Closes the connection to the dartino-vm and drains the remaining response
|
| /// commands.
|
| ///
|
| /// If [ignoreExtraCommands] is `false` it will throw a StateError if the
|
| - /// fletch-vm sent any commands.
|
| + /// dartino-vm sent any commands.
|
| Future shutdown({bool ignoreExtraCommands: false}) async {
|
| await _outgoingSink.close().catchError((_) {});
|
|
|
| @@ -176,7 +176,7 @@ class FletchVmSession {
|
| if (!ignoreExtraCommands && response != null) {
|
| await kill();
|
| throw new StateError(
|
| - "Got unexpected command from fletch-vm during shutdown "
|
| + "Got unexpected command from dartino-vm during shutdown "
|
| "($response)");
|
| }
|
| }
|
| @@ -188,7 +188,7 @@ class FletchVmSession {
|
| return sendCommand(const ProcessDebugInterrupt());
|
| }
|
|
|
| - /// Closes the connection to the fletch-vm. It does not wait until it shuts
|
| + /// Closes the connection to the dartino-vm. It does not wait until it shuts
|
| /// down.
|
| ///
|
| /// This method will never complete with an exception.
|
| @@ -205,32 +205,32 @@ class FletchVmSession {
|
| }
|
| }
|
|
|
| -/// Extends a bare [FletchVmSession] with debugging functionality.
|
| -class Session extends FletchVmSession {
|
| +/// Extends a bare [DartinoVmSession] with debugging functionality.
|
| +class Session extends DartinoVmSession {
|
| final IncrementalCompiler compiler;
|
| final Future processExitCodeFuture;
|
|
|
| DebugState debugState;
|
| - FletchSystem fletchSystem;
|
| + DartinoSystem dartinoSystem;
|
| bool loaded = false;
|
| bool running = false;
|
| bool terminated = false;
|
|
|
| - Session(Socket fletchVmSocket,
|
| + Session(Socket dartinoVmSocket,
|
| this.compiler,
|
| Sink<List<int>> stdoutSink,
|
| Sink<List<int>> stderrSink,
|
| [this.processExitCodeFuture])
|
| - : super(fletchVmSocket, stdoutSink, stderrSink) {
|
| + : super(dartinoVmSocket, stdoutSink, stderrSink) {
|
| // We send many small packages, so use no-delay.
|
| - fletchVmSocket.setOption(SocketOption.TCP_NODELAY, true);
|
| + dartinoVmSocket.setOption(SocketOption.TCP_NODELAY, true);
|
| // TODO(ajohnsen): Should only be initialized on debug()/testDebugger().
|
| debugState = new DebugState(this);
|
| }
|
|
|
| - Future applyDelta(FletchDelta delta) async {
|
| + Future applyDelta(DartinoDelta delta) async {
|
| VmCommand response = await runCommands(delta.commands);
|
| - fletchSystem = delta.system;
|
| + dartinoSystem = delta.system;
|
| return response;
|
| }
|
|
|
| @@ -265,7 +265,7 @@ class Session extends FletchVmSession {
|
| await runCommand(const ProcessRun());
|
| // NOTE: The [ProcessRun] command normally results in a
|
| // [ProcessTerminated] command. But if the compiler emitted a compile time
|
| - // error, the fletch-vm will just halt()/exit() and we therefore get no
|
| + // error, the dartino-vm will just halt()/exit() and we therefore get no
|
| // response.
|
| var command = await readNextCommand(force: false);
|
| if (command != null && command is! ProcessTerminated) {
|
| @@ -319,7 +319,7 @@ class Session extends FletchVmSession {
|
|
|
| case VmCommandCode.ProcessBreakpoint:
|
| ProcessBreakpoint command = response;
|
| - var function = fletchSystem.lookupFunctionById(command.functionId);
|
| + var function = dartinoSystem.lookupFunctionById(command.functionId);
|
| debugState.topFrame = new BackTraceFrame(
|
| function, command.bytecodeIndex, compiler, debugState);
|
| running = true;
|
| @@ -327,7 +327,7 @@ class Session extends FletchVmSession {
|
|
|
| default:
|
| throw new StateError(
|
| - "Unhandled response from Fletch VM connection: ${response.code}");
|
| + "Unhandled response from Dartino VM connection: ${response.code}");
|
|
|
| }
|
| return response;
|
| @@ -343,7 +343,7 @@ class Session extends FletchVmSession {
|
| }
|
|
|
| Future setBreakpointHelper(String name,
|
| - FletchFunction function,
|
| + DartinoFunction function,
|
| int bytecodeIndex) async {
|
| ProcessSetBreakpoint response = await runCommands([
|
| new PushFromMap(MapId.methods, function.functionId),
|
| @@ -359,10 +359,10 @@ class Session extends FletchVmSession {
|
| // error situations such as bytecode indices that are out of bounds for
|
| // some of the methods with the given name.
|
| Future setBreakpoint({String methodName, int bytecodeIndex}) async {
|
| - Iterable<FletchFunction> functions =
|
| - fletchSystem.functionsWhere((f) => f.name == methodName);
|
| + Iterable<DartinoFunction> functions =
|
| + dartinoSystem.functionsWhere((f) => f.name == methodName);
|
| List<Breakpoint> breakpoints = [];
|
| - for (FletchFunction function in functions) {
|
| + for (DartinoFunction function in functions) {
|
| breakpoints.add(
|
| await setBreakpointHelper(methodName, function, bytecodeIndex));
|
| }
|
| @@ -378,7 +378,7 @@ class Session extends FletchVmSession {
|
| DebugInfo debugInfo = compiler.debugInfoForPosition(
|
| file,
|
| position,
|
| - fletchSystem);
|
| + dartinoSystem);
|
| if (debugInfo == null) {
|
| return null;
|
| }
|
| @@ -386,7 +386,7 @@ class Session extends FletchVmSession {
|
| if (location == null) {
|
| return null;
|
| }
|
| - FletchFunction function = debugInfo.function;
|
| + DartinoFunction function = debugInfo.function;
|
| int bytecodeIndex = location.bytecodeIndex;
|
| return setBreakpointHelper(function.name, function, bytecodeIndex);
|
| }
|
| @@ -554,9 +554,9 @@ class Session extends FletchVmSession {
|
| BackTrace stackTrace = new BackTrace(frames, debugState);
|
| for (int i = 0; i < frames; ++i) {
|
| int functionId = backtraceResponse.functionIds[i];
|
| - FletchFunction function = fletchSystem.lookupFunctionById(functionId);
|
| + DartinoFunction function = dartinoSystem.lookupFunctionById(functionId);
|
| if (function == null) {
|
| - function = const FletchFunction.missing();
|
| + function = const DartinoFunction.missing();
|
| }
|
| stackTrace.addFrame(
|
| compiler,
|
| @@ -634,7 +634,7 @@ class Session extends FletchVmSession {
|
| String dartValueToString(DartValue value) {
|
| if (value is Instance) {
|
| Instance i = value;
|
| - String className = fletchSystem.lookupClassById(i.classId).name;
|
| + String className = dartinoSystem.lookupClassById(i.classId).name;
|
| return "Instance of '$className'";
|
| } else {
|
| return value.dartToString();
|
| @@ -644,12 +644,12 @@ class Session extends FletchVmSession {
|
| String instanceStructureToString(InstanceStructure structure,
|
| List<DartValue> fields) {
|
| int classId = structure.classId;
|
| - FletchClass klass = fletchSystem.lookupClassById(classId);
|
| + DartinoClass klass = dartinoSystem.lookupClassById(classId);
|
|
|
| - // TODO(fletchc-team): This should be more strict and a compiler bug
|
| + // TODO(dartino_compiler-team): This should be more strict and a compiler bug
|
| // should be reported to the user in order for us to get a bugreport.
|
| if (klass == null) {
|
| - return 'Unknown (Fletch compiler was unable to find exception class)';
|
| + return 'Unknown (Dartino compiler was unable to find exception class)';
|
| }
|
|
|
| StringBuffer sb = new StringBuffer();
|
| @@ -671,12 +671,12 @@ class Session extends FletchVmSession {
|
| DartValue receiver = nsmFields[0];
|
| ClassValue receiverClass = nsmFields[1];
|
| Integer receiverSelector = nsmFields[2];
|
| - FletchSelector selector = new FletchSelector(receiverSelector.value);
|
| + DartinoSelector selector = new DartinoSelector(receiverSelector.value);
|
|
|
| String method =
|
| - fletchSystem.lookupSymbolBySelector(selector.encodedSelector);
|
| - FletchClass klass = fletchSystem.lookupClassById(receiverClass.classId);
|
| - // TODO(ahe): If FletchClass is a synthetic closure class, improve the
|
| + dartinoSystem.lookupSymbolBySelector(selector.encodedSelector);
|
| + DartinoClass klass = dartinoSystem.lookupClassById(receiverClass.classId);
|
| + // TODO(ahe): If DartinoClass is a synthetic closure class, improve the
|
| // message. For example, "(local) function `foo` takes 3 arguments, but
|
| // called with 4" instead of "Class '<internal>' has no method named 'call'
|
| // that takes 4 arguments".
|
| @@ -716,13 +716,13 @@ class Session extends FletchVmSession {
|
| } else if (exception is RemoteInstance) {
|
| InstanceStructure structure = exception.instance;
|
| int classId = structure.classId;
|
| - FletchClass klass = fletchSystem.lookupClassById(classId);
|
| + DartinoClass klass = dartinoSystem.lookupClassById(classId);
|
|
|
| - FletchBackend backend = compiler.compiler.backend;
|
| - var fletchNoSuchMethodErrorClass = fletchSystem.lookupClassByElement(
|
| - backend.fletchNoSuchMethodErrorClass);
|
| + DartinoBackend backend = compiler.compiler.backend;
|
| + var dartinoNoSuchMethodErrorClass = dartinoSystem.lookupClassByElement(
|
| + backend.dartinoNoSuchMethodErrorClass);
|
|
|
| - if (klass == fletchNoSuchMethodErrorClass) {
|
| + if (klass == dartinoNoSuchMethodErrorClass) {
|
| message = noSuchMethodErrorToString(exception.fields);
|
| } else {
|
| message = instanceStructureToString(
|
|
|