OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 patch class Symbol { |
| 6 final String _name; |
| 7 /* patch */ const Symbol(String name) |
| 8 : this._name = _validate(name); |
| 9 |
| 10 static _validate(String name) { |
| 11 if (name is! String) throw new ArgumentError('name must be a String'); |
| 12 if (name.isEmpty) return; |
| 13 if (name.startsWith('_')) { |
| 14 throw new ArgumentError('"$name" is a private identifier'); |
| 15 } |
| 16 if (!new RegExp(r'^[a-zA-Z$][a-zA-Z$0-9]*=?').hasMatch(name)) { |
| 17 throw new ArgumentError( |
| 18 '"$name" is not an identifier or the empty String'); |
| 19 } |
| 20 } |
| 21 } |
OLD | NEW |