| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Script script = currentScript(); | 101 Script script = currentScript(); |
| 102 if (node !== null) { | 102 if (node !== null) { |
| 103 print(spanFromNode(node, script).toMessageString("cancel leg: $reason")); | 103 print(spanFromNode(node, script).toMessageString("cancel leg: $reason")); |
| 104 } else if (token !== null) { | 104 } else if (token !== null) { |
| 105 String tokenString = token.toString(); | 105 String tokenString = token.toString(); |
| 106 int begin = token.charOffset; | 106 int begin = token.charOffset; |
| 107 int end = begin + tokenString.length; | 107 int end = begin + tokenString.length; |
| 108 print(script.file.getLocationMessage("cancel leg: $reason", | 108 print(script.file.getLocationMessage("cancel leg: $reason", |
| 109 begin, end, true)); | 109 begin, end, true)); |
| 110 } else if (element !== null) { | 110 } else if (element !== null) { |
| 111 if (element.position() === null) { |
| 112 // Sometimes, the backend fakes up elements that have no |
| 113 // position. So we use the enclosing element instead. It is |
| 114 // not a good error location, but cancel really is "internal |
| 115 // error" or "not implemented yet", so the vicinity is good |
| 116 // enough for now. |
| 117 element = element.enclosingElement; |
| 118 // TODO(ahe): I plan to overhaul this infrastructure anyways. |
| 119 } |
| 111 withCurrentElement(element, | 120 withCurrentElement(element, |
| 112 () => cancel(reason: reason, token: element.position())); | 121 () => cancel(reason: reason, token: element.position())); |
| 113 } | 122 } |
| 114 if (throwOnError) { | 123 if (throwOnError) { |
| 115 throw new AbortLeg(reason); | 124 throw new AbortLeg(reason); |
| 116 } | 125 } |
| 117 super.cancel(reason, node, token, instruction); | 126 super.cancel(reason, node, token, instruction); |
| 118 } | 127 } |
| 119 } | 128 } |
| 120 | 129 |
| 121 class AbortLeg { | 130 class AbortLeg { |
| 122 final message; | 131 final message; |
| 123 AbortLeg(this.message); | 132 AbortLeg(this.message); |
| 124 toString() => 'Aborted due to --throw-on-error: $message'; | 133 toString() => 'Aborted due to --throw-on-error: $message'; |
| 125 } | 134 } |
| OLD | NEW |