| 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 org_dartlang_compiler_util; | 5 library org_dartlang_compiler_util; |
| 6 | 6 |
| 7 import 'util_implementation.dart'; | 7 import 'util_implementation.dart'; |
| 8 import 'characters.dart'; | 8 import 'characters.dart'; |
| 9 | 9 |
| 10 part 'link.dart'; | 10 part 'link.dart'; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Tagging interface for classes from which source spans can be generated. | 13 * Tagging interface for classes from which source spans can be generated. |
| 14 */ | 14 */ |
| 15 // TODO(johnniwinther): Find a better name. | 15 // TODO(johnniwinther): Find a better name. |
| 16 // TODO(ahe): How about "Bolt"? | 16 // TODO(ahe): How about "Bolt"? |
| 17 abstract class Spannable {} | 17 abstract class Spannable {} |
| 18 | 18 |
| 19 class _SpannableSentinel implements Spannable { |
| 20 final String name; |
| 21 |
| 22 const _SpannableSentinel(this.name); |
| 23 |
| 24 String toString() => name; |
| 25 } |
| 26 |
| 27 const Spannable CURRENT_ELEMENT_SPANNABLE = |
| 28 const _SpannableSentinel("Current element"); |
| 29 |
| 19 class SpannableAssertionFailure { | 30 class SpannableAssertionFailure { |
| 20 final Spannable node; | 31 final Spannable node; |
| 21 final String message; | 32 final String message; |
| 22 SpannableAssertionFailure(this.node, this.message); | 33 SpannableAssertionFailure(this.node, this.message); |
| 23 | 34 |
| 24 String toString() => 'Compiler crashed: $message.'; | 35 String toString() => 'Compiler crashed: $message.'; |
| 25 } | 36 } |
| 26 | 37 |
| 27 /// Writes the characters of [string] on [buffer]. The characters | 38 /// Writes the characters of [string] on [buffer]. The characters |
| 28 /// are escaped as suitable for JavaScript and JSON. [buffer] is | 39 /// are escaped as suitable for JavaScript and JSON. [buffer] is |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 for (int i = 0; i < string.length; i++) { | 100 for (int i = 0; i < string.length; i++) { |
| 90 int code = string.charCodeAt(i); | 101 int code = string.charCodeAt(i); |
| 91 if (code < 0x20 || code == $DEL || code == $DQ || code == $LS || | 102 if (code < 0x20 || code == $DEL || code == $DQ || code == $LS || |
| 92 code == $PS || code == $BACKSLASH || code >= 0x80) { | 103 code == $PS || code == $BACKSLASH || code >= 0x80) { |
| 93 writeEscapedOn(string, buffer); | 104 writeEscapedOn(string, buffer); |
| 94 return; | 105 return; |
| 95 } | 106 } |
| 96 } | 107 } |
| 97 buffer.add(string); | 108 buffer.add(string); |
| 98 } | 109 } |
| OLD | NEW |