| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library dartino_compiler.worker.developer; | 5 library dartino_compiler.worker.developer; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future, | 8 Future, |
| 9 TimeoutException; | 9 TimeoutException; |
| 10 | 10 |
| 11 import 'dart:convert' show | 11 import 'dart:convert' show |
| 12 JSON, | 12 JSON, |
| 13 JsonEncoder, | 13 JsonEncoder, |
| 14 LineSplitter, | 14 LineSplitter, |
| 15 UTF8; | 15 UTF8; |
| 16 | 16 |
| 17 import 'dart:io' show | 17 import 'dart:io' show |
| 18 Directory, | 18 Directory, |
| 19 File, | 19 File, |
| 20 FileSystemEntity, | 20 FileSystemEntity, |
| 21 InternetAddress, | 21 InternetAddress, |
| 22 Platform, | 22 Platform, |
| 23 Process, | 23 Process, |
| 24 ProcessResult, | 24 ProcessResult, |
| 25 SocketException; | 25 SocketException; |
| 26 | 26 |
| 27 import 'dart:typed_data' show |
| 28 Uint8List; |
| 29 |
| 27 import 'package:sdk_services/sdk_services.dart' show | 30 import 'package:sdk_services/sdk_services.dart' show |
| 28 OutputService, | 31 OutputService, |
| 29 SDKServices, | 32 SDKServices, |
| 30 DownloadException; | 33 DownloadException; |
| 31 | 34 |
| 32 import 'package:dartino_agent/agent_connection.dart' show | 35 import 'package:dartino_agent/agent_connection.dart' show |
| 33 AgentConnection, | 36 AgentConnection, |
| 34 AgentException, | 37 AgentException, |
| 35 VmData; | 38 VmData; |
| 36 | 39 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 DartinoCompiler, | 79 DartinoCompiler, |
| 77 DartinoDelta, | 80 DartinoDelta, |
| 78 IncrementalCompiler, | 81 IncrementalCompiler, |
| 79 WorkerConnection, | 82 WorkerConnection, |
| 80 IsolatePool, | 83 IsolatePool, |
| 81 SharedTask, | 84 SharedTask, |
| 82 StreamIterator, | 85 StreamIterator, |
| 83 throwFatalError; | 86 throwFatalError; |
| 84 | 87 |
| 85 import '../../vm_context.dart' show | 88 import '../../vm_context.dart' show |
| 86 DartinoVmContext, | 89 DartinoVmContext; |
| 87 SinkDebugListener; | |
| 88 | 90 |
| 89 import '../../incremental/dartino_compiler_incremental.dart' show | 91 import '../../incremental/dartino_compiler_incremental.dart' show |
| 90 IncrementalCompilationFailed; | 92 IncrementalCompilationFailed; |
| 91 | 93 |
| 92 import '../dartino_compiler_options.dart' show | 94 import '../dartino_compiler_options.dart' show |
| 93 IncrementalMode, | 95 IncrementalMode, |
| 94 parseIncrementalMode, | 96 parseIncrementalMode, |
| 95 unparseIncrementalMode; | 97 unparseIncrementalMode; |
| 96 | 98 |
| 97 export '../dartino_compiler_options.dart' show | 99 export '../dartino_compiler_options.dart' show |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 BackTrace; | 126 BackTrace; |
| 125 | 127 |
| 126 import '../vm_connection.dart' show | 128 import '../vm_connection.dart' show |
| 127 TcpConnection, | 129 TcpConnection, |
| 128 VmConnection, | 130 VmConnection, |
| 129 connectToTty; | 131 connectToTty; |
| 130 | 132 |
| 131 import '../dartino_compiler_options.dart' show | 133 import '../dartino_compiler_options.dart' show |
| 132 DartinoCompilerOptions; | 134 DartinoCompilerOptions; |
| 133 | 135 |
| 136 import '../../vm_context.dart' show DebugListener; |
| 137 |
| 134 import '../hub/exit_codes.dart' show | 138 import '../hub/exit_codes.dart' show |
| 135 INPUT_ERROR; | 139 INPUT_ERROR; |
| 136 | 140 |
| 137 import '../diagnostic.dart' show | 141 import '../diagnostic.dart' show |
| 138 InputError; | 142 InputError; |
| 139 | 143 |
| 140 typedef Future<Null> ClientEventHandler(DartinoVmContext vmContext); | 144 typedef Future<Null> ClientEventHandler(DartinoVmContext vmContext); |
| 141 | 145 |
| 142 Uri configFileUri; | 146 Uri configFileUri; |
| 143 | 147 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 ttyDevice, "vmTty", state.log); | 256 ttyDevice, "vmTty", state.log); |
| 253 await attachToVm(connection, state, maxTimeSpent: new Duration(seconds: 20)); | 257 await attachToVm(connection, state, maxTimeSpent: new Duration(seconds: 20)); |
| 254 } | 258 } |
| 255 | 259 |
| 256 Future<Null> attachToVmTcp(String host, int port, SessionState state) async { | 260 Future<Null> attachToVmTcp(String host, int port, SessionState state) async { |
| 257 TcpConnection connection = await TcpConnection.connect( | 261 TcpConnection connection = await TcpConnection.connect( |
| 258 host, port, "vmSocket", state.log); | 262 host, port, "vmSocket", state.log); |
| 259 await attachToVm(connection, state); | 263 await attachToVm(connection, state); |
| 260 } | 264 } |
| 261 | 265 |
| 266 class SinkDebugListener extends DebugListener { |
| 267 final Sink stdoutSink; |
| 268 final Sink stderrSink; |
| 269 SinkDebugListener(this.stdoutSink, this.stderrSink); |
| 270 |
| 271 // Notification of bytes written to stdout. |
| 272 writeStdOut(int processId, Uint8List data) { |
| 273 stdoutSink.add(data); |
| 274 } |
| 275 |
| 276 // Notification of bytes written stderr. |
| 277 writeStdErr(int processId, Uint8List data) { |
| 278 stderrSink.add(data); |
| 279 } |
| 280 } |
| 281 |
| 262 Future<Null> attachToVm( | 282 Future<Null> attachToVm( |
| 263 VmConnection connection, | 283 VmConnection connection, |
| 264 SessionState state, | 284 SessionState state, |
| 265 {Duration maxTimeSpent}) async { | 285 {Duration maxTimeSpent}) async { |
| 266 DartinoVmContext vmContext = new DartinoVmContext( | 286 DartinoVmContext vmContext = new DartinoVmContext( |
| 267 connection, | 287 connection, |
| 268 state.compiler, | 288 state.compiler, |
| 269 null); | 289 null); |
| 270 | 290 |
| 271 vmContext.listeners.add( | 291 vmContext.listeners.add( |
| (...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 addIfNotNull("open_ocd_board", open_ocd_board); | 2154 addIfNotNull("open_ocd_board", open_ocd_board); |
| 2135 return result; | 2155 return result; |
| 2136 } | 2156 } |
| 2137 } | 2157 } |
| 2138 | 2158 |
| 2139 Uri defaultSnapshotLocation(Uri script) { | 2159 Uri defaultSnapshotLocation(Uri script) { |
| 2140 // TODO(sgjesse): Use a temp directory for the snapshot. | 2160 // TODO(sgjesse): Use a temp directory for the snapshot. |
| 2141 String snapshotName = basenameWithoutExtension(script.path) + '.snapshot'; | 2161 String snapshotName = basenameWithoutExtension(script.path) + '.snapshot'; |
| 2142 return script.resolve(snapshotName); | 2162 return script.resolve(snapshotName); |
| 2143 } | 2163 } |
| OLD | NEW |