| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('frog_leg'); | 5 #library('frog_leg'); |
| 6 | 6 |
| 7 #import('../../lib/uri/uri.dart'); | 7 #import('../../lib/uri/uri.dart'); |
| 8 #import('../lang.dart', prefix: 'frog'); | 8 #import('../lang.dart', prefix: 'frog'); |
| 9 #import('elements/elements.dart'); | 9 #import('elements/elements.dart'); |
| 10 #import('io/io.dart', prefix: 'io'); | 10 #import('io/io.dart', prefix: 'io'); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } else { | 77 } else { |
| 78 span = spanFromNode(node, current); | 78 span = spanFromNode(node, current); |
| 79 } | 79 } |
| 80 world.warning('$message.', span); | 80 world.warning('$message.', span); |
| 81 } | 81 } |
| 82 | 82 |
| 83 reportError(Node node, var message) { | 83 reportError(Node node, var message) { |
| 84 cancel(message.toString(), node); | 84 cancel(message.toString(), node); |
| 85 } | 85 } |
| 86 | 86 |
| 87 Uri getUriFor(String fileName) { |
| 88 Uri cwd = new Uri(scheme: 'file', path: currentDirectory); |
| 89 return cwd.resolve(fileName); |
| 90 } |
| 91 |
| 87 Script readScript(Uri uri, [ScriptTag node]) { | 92 Script readScript(Uri uri, [ScriptTag node]) { |
| 93 String uriName = uri.toString(); |
| 94 // TODO(ahe): Clean this up. |
| 95 if (uriName == 'dart:dom') { |
| 96 uri = getUriFor(io.join([legDirectory, '..', '..', |
| 97 'client', 'dom', 'frog', 'dom_frog.dart'])); |
| 98 } else if (uriName == 'dart:html') { |
| 99 uri = getUriFor(io.join([legDirectory, '..', '..', |
| 100 'client', 'html', 'frog', 'html_frog.dart'])); |
| 101 } |
| 88 if (uri.scheme != 'file') cancel('cannot read $uri', node: node); | 102 if (uri.scheme != 'file') cancel('cannot read $uri', node: node); |
| 89 String text = ""; | 103 String text = ""; |
| 90 try { | 104 try { |
| 91 text = frog.world.files.readAll(uri.path); | 105 text = frog.world.files.readAll(uri.path); |
| 92 } catch (var exception) { | 106 } catch (var exception) { |
| 93 cancel("${uri.path}: $exception", node: node); | 107 cancel("${uri.path}: $exception", node: node); |
| 94 } | 108 } |
| 95 world.dartBytesRead += text.length; | 109 world.dartBytesRead += text.length; |
| 96 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text); | 110 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text); |
| 97 return new Script(uri, sourceFile); | 111 return new Script(uri, sourceFile); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 145 } |
| 132 super.cancel(reason, node, token, instruction); | 146 super.cancel(reason, node, token, instruction); |
| 133 } | 147 } |
| 134 } | 148 } |
| 135 | 149 |
| 136 class AbortLeg { | 150 class AbortLeg { |
| 137 final message; | 151 final message; |
| 138 AbortLeg(this.message); | 152 AbortLeg(this.message); |
| 139 toString() => 'Aborted due to --throw-on-error: $message'; | 153 toString() => 'Aborted due to --throw-on-error: $message'; |
| 140 } | 154 } |
| OLD | NEW |