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

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

Issue 14079003: Implement Symbol correctly in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments 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
« no previous file with comments | « dart/pkg/pkg.status ('k') | dart/sdk/lib/_collection_dev/symbol.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 patch class Symbol { 5 patch class Symbol {
6 /* patch */ const Symbol(String name) 6 /* patch */ const Symbol(String name)
7 : this._name = _validate(name); 7 : this._name = validate(name);
8
9 static final RegExp _validationPattern =
10 new RegExp(r'^(?:[a-zA-Z$][a-zA-Z$0-9_]*\.)*(?:[a-zA-Z$][a-zA-Z$0-9_]*=?|'
11 r'-|'
12 r'unary-|'
13 r'\[\]=|'
14 r'~|'
15 r'==|'
16 r'\[\]|'
17 r'\*|'
18 r'/|'
19 r'%|'
20 r'~/|'
21 r'\+|'
22 r'<<|'
23 r'>>|'
24 r'>=|'
25 r'>|'
26 r'<=|'
27 r'<|'
28 r'&|'
29 r'\^|'
30 r'\|'
31 r')$');
32
33 static _validate(String name) {
34 if (name.isEmpty) return name;
35 if (name.startsWith('_')) {
36 throw new ArgumentError('"$name" is a private identifier');
37 }
38 if (!_validationPattern.hasMatch(name)) {
39 throw new ArgumentError(
40 '"$name" is not an identifier or an empty String');
41 }
42 return name;
43 }
44 } 8 }
OLDNEW
« no previous file with comments | « dart/pkg/pkg.status ('k') | dart/sdk/lib/_collection_dev/symbol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698