Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: dart/runtime/lib/symbol_patch.dart

Issue 14142003: Add Symbol class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698