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

Side by Side Diff: test/dart_codegen/expect/_internal/symbol.dart

Issue 1112403004: SDK fixes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Formatting fix Created 5 years, 7 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
OLDNEW
1 part of dart._internal; 1 part of dart._internal;
2 class Symbol implements core.Symbol {final String _name; 2 class Symbol implements core.Symbol {final String _name;
3 static const String reservedWordRE = r'(?:assert|break|c(?:a(?:se|tch)|lass|on( ?:st|tinue))|d(?:efault|o)|' r'e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fn s]|n(?:ew|ull)|' r'ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|' r'v(?:ar|oid)|w(?:hile|ith))'; 3 static const String reservedWordRE = r'(?:assert|break|c(?:a(?:se|tch)|lass|on( ?:st|tinue))|d(?:efault|o)|' r'e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fn s]|n(?:ew|ull)|' r'ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|' r'v(?:ar|oid)|w(?:hile|ith))';
4 static const String publicIdentifierRE = r'(?!' '$reservedWordRE' r'\b(?!\$))[a -zA-Z$][\w$]*'; 4 static const String publicIdentifierRE = r'(?!' '$reservedWordRE' r'\b(?!\$))[a -zA-Z$][\w$]*';
5 static const String identifierRE = r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$ _][\w$]*'; 5 static const String identifierRE = r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$ _][\w$]*';
6 static const String operatorRE = r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|u nary-)'; 6 static const String operatorRE = r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|u nary-)';
7 static final RegExp publicSymbolPattern = new RegExp('^(?:$operatorRE\$|$public IdentifierRE(?:=?\$|[.](?!\$)))+?\$'); 7 static final RegExp publicSymbolPattern = new RegExp('^(?:$operatorRE\$|$public IdentifierRE(?:=?\$|[.](?!\$)))+?\$');
8 static final RegExp symbolPattern = new RegExp('^(?:$operatorRE\$|$identifierRE (?:=?\$|[.](?!\$)))+?\$'); 8 static final RegExp symbolPattern = new RegExp('^(?:$operatorRE\$|$identifierRE (?:=?\$|[.](?!\$)))+?\$');
9 external const Symbol(String name); 9 external const Symbol(String name);
10 const Symbol.unvalidated(this._name); 10 const Symbol.unvalidated(this._name);
11 Symbol.validated(String name) : this._name = validatePublicSymbol(name); 11 Symbol.validated(String name) : this._name = validatePublicSymbol(name);
12 bool operator ==(other) => other is Symbol && _name == other._name; 12 bool operator ==(Object other) => other is Symbol && _name == other._name;
13 int get hashCode { 13 int get hashCode {
14 const arbitraryPrime = 664597; 14 const arbitraryPrime = 664597;
15 return 0x1fffffff & (arbitraryPrime * _name.hashCode); 15 return 0x1fffffff & (arbitraryPrime * _name.hashCode);
16 } 16 }
17 toString() => 'Symbol("$_name")'; 17 toString() => 'Symbol("$_name")';
18 static String getName(Symbol symbol) => symbol._name; 18 static String getName(Symbol symbol) => symbol._name;
19 static String validatePublicSymbol(String name) { 19 static String validatePublicSymbol(String name) {
20 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name; 20 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name;
21 if (name.startsWith('_')) { 21 if (name.startsWith('_')) {
22 throw new ArgumentError('"$name" is a private identifier'); 22 throw new ArgumentError('"$name" is a private identifier');
23 } 23 }
24 throw new ArgumentError('"$name" is not a valid (qualified) symbol name'); 24 throw new ArgumentError('"$name" is not a valid (qualified) symbol name');
25 } 25 }
26 static bool isValidSymbol(String name) { 26 static bool isValidSymbol(String name) {
27 return (name.isEmpty || symbolPattern.hasMatch(name)); 27 return (name.isEmpty || symbolPattern.hasMatch(name));
28 } 28 }
29 } 29 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698