Chromium Code Reviews| 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('frog_leg'); | 5 #library('frog_leg'); |
| 6 | 6 |
| 7 #import('../lang.dart', prefix: 'frog'); | 7 #import('../lang.dart', prefix: 'frog'); |
| 8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
| 9 #import('io/io.dart', prefix: 'io'); | 9 #import('io/io.dart', prefix: 'io'); |
| 10 #import('leg.dart'); | 10 #import('leg.dart'); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 84 } |
| 85 | 85 |
| 86 Script readScript(String filename) { | 86 Script readScript(String filename) { |
| 87 String text = frog.world.files.readAll(filename); | 87 String text = frog.world.files.readAll(filename); |
| 88 frog.SourceFile sourceFile = new frog.SourceFile(filename, text); | 88 frog.SourceFile sourceFile = new frog.SourceFile(filename, text); |
| 89 return new Script(sourceFile); | 89 return new Script(sourceFile); |
| 90 } | 90 } |
| 91 | 91 |
| 92 String get legDirectory() => io.join([frog.options.libDir, '..', 'leg']); | 92 String get legDirectory() => io.join([frog.options.libDir, '..', 'leg']); |
| 93 | 93 |
| 94 void cancel([String reason, Node node, token, instruction]) { | 94 void cancel([String reason, Node node, token, instruction, element]) { |
| 95 Script script = currentScript(); | 95 Script script = currentScript(); |
| 96 if (node !== null) { | 96 if (node !== null) { |
| 97 print(spanFromNode(node, script).toMessageString("cancel leg: $reason")); | 97 print(spanFromNode(node, script).toMessageString("cancel leg: $reason")); |
| 98 } else if (token !== null) { | 98 } else { |
| 99 String tokenString = token.toString(); | 99 if (token === null && element !== null) { |
|
ahe
2012/01/24 16:01:35
This is way too complicated. I have made a better
| |
| 100 int begin = token.charOffset; | 100 currentElement = element; |
| 101 int end = begin + tokenString.length; | 101 script = currentScript(); |
| 102 print(script.file.getLocationMessage("cancel leg: $reason", | 102 token = element.position(); |
| 103 begin, end, true)); | 103 } |
| 104 if (token !== null) { | |
| 105 String tokenString = token.toString(); | |
| 106 int begin = token.charOffset; | |
| 107 int end = begin + tokenString.length; | |
| 108 print(script.file.getLocationMessage("cancel leg: $reason", | |
| 109 begin, end, true)); | |
| 110 } | |
| 104 } | 111 } |
| 105 if (throwOnError) { | 112 if (throwOnError) { |
| 106 throw new AbortLeg(reason); | 113 throw new AbortLeg(reason); |
| 107 } | 114 } |
| 108 super.cancel(reason, node, token, instruction); | 115 super.cancel(reason, node, token, instruction); |
| 109 } | 116 } |
| 110 } | 117 } |
| 111 | 118 |
| 112 class AbortLeg { | 119 class AbortLeg { |
| 113 final message; | 120 final message; |
| 114 AbortLeg(this.message); | 121 AbortLeg(this.message); |
| 115 toString() => 'Aborted due to --throw-on-error: $message'; | 122 toString() => 'Aborted due to --throw-on-error: $message'; |
| 116 } | 123 } |
| OLD | NEW |