Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
|
kasperl
2013/04/11 10:48:58
2013
ahe
2013/04/11 11:26:06
Done.
| |
| 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)) { | |
|
kasperl
2013/04/11 10:48:58
Throw the RegExp into a lazily initialized static
ahe
2013/04/11 11:26:06
Done * 2
| |
| 17 throw new ArgumentError( | |
| 18 '"$name" is not an identifier or the empty String'); | |
|
kasperl
2013/04/11 10:48:58
I'd change 'the empty String' to 'an empty string'
ahe
2013/04/11 11:26:06
Done.
| |
| 19 } | |
| 20 } | |
| 21 } | |
| OLD | NEW |