| 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 if (token !== null) { |
| 99 String tokenString = token.toString(); | 99 String tokenString = token.toString(); |
| 100 int begin = token.charOffset; | 100 int begin = token.charOffset; |
| 101 int end = begin + tokenString.length; | 101 int end = begin + tokenString.length; |
| 102 print(script.file.getLocationMessage("cancel leg: $reason", | 102 print(script.file.getLocationMessage("cancel leg: $reason", |
| 103 begin, end, true)); | 103 begin, end, true)); |
| 104 } else if (element !== null) { |
| 105 currentElement = element; |
| 106 cancel(reason: reason, token: element.position()); |
| 104 } | 107 } |
| 105 if (throwOnError) { | 108 if (throwOnError) { |
| 106 throw new AbortLeg(reason); | 109 throw new AbortLeg(reason); |
| 107 } | 110 } |
| 108 super.cancel(reason, node, token, instruction); | 111 super.cancel(reason, node, token, instruction); |
| 109 } | 112 } |
| 110 } | 113 } |
| 111 | 114 |
| 112 class AbortLeg { | 115 class AbortLeg { |
| 113 final message; | 116 final message; |
| 114 AbortLeg(this.message); | 117 AbortLeg(this.message); |
| 115 toString() => 'Aborted due to --throw-on-error: $message'; | 118 toString() => 'Aborted due to --throw-on-error: $message'; |
| 116 } | 119 } |
| OLD | NEW |