| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library("total:dartc"); | 5 #library("total:dartc"); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A simple wrapper around dartc. | 8 * A simple wrapper around dartc. |
| 9 * TODO: automatically determine the exec path to dartc | 9 * TODO: automatically determine the exec path to dartc |
| 10 * TODO: prevent ANSI colors from being exposed to the user | 10 * TODO: prevent ANSI colors from being exposed to the user |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 StringBuffer messages = new StringBuffer(); | 51 StringBuffer messages = new StringBuffer(); |
| 52 compiler.setExitHandler((int status) { | 52 compiler.setExitHandler((int status) { |
| 53 compiler.close(); | 53 compiler.close(); |
| 54 callback(status, messages.toString()); | 54 callback(status, messages.toString()); |
| 55 }); | 55 }); |
| 56 | 56 |
| 57 compiler.start(); | 57 compiler.start(); |
| 58 // TODO(rchandia) increase read size when stream handling works better | 58 // TODO(rchandia) increase read size when stream handling works better |
| 59 int BUFSIZE = 1; | 59 int BUFSIZE = 1; |
| 60 | 60 |
| 61 _readAll(false, compiler.stdoutStream, new List<int>(BUFSIZE), messages); | 61 _readAll(false, compiler.stdout, new List<int>(BUFSIZE), messages); |
| 62 _readAll(false, compiler.stderrStream, new List<int>(BUFSIZE), messages); | 62 _readAll(false, compiler.stderr, new List<int>(BUFSIZE), messages); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 void _readAll(bool fromCallback, InputStream input, List<int> buffer, StringBuff
er output) { | 66 void _readAll(bool fromCallback, InputStream input, List<int> buffer, StringBuff
er output) { |
| 67 if (fromCallback) { | 67 if (fromCallback) { |
| 68 output.add(new String.fromCharCodes(buffer)); | 68 output.add(new String.fromCharCodes(buffer)); |
| 69 } | 69 } |
| 70 while (input.read(buffer, 0, buffer.length, () => _readAll(true, input, buffer
, output))) { | 70 while (input.read(buffer, 0, buffer.length, () => _readAll(true, input, buffer
, output))) { |
| 71 output.add(new String.fromCharCodes(buffer)); | 71 output.add(new String.fromCharCodes(buffer)); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| OLD | NEW |