| OLD | NEW |
| (Empty) |
| 1 part of dart._internal; | |
| 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))'; | |
| 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$]*'; | |
| 6 static const String operatorRE = r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|u
nary-)'; | |
| 7 static final RegExp publicSymbolPattern = new RegExp('^(?:$operatorRE\$|$public
IdentifierRE(?:=?\$|[.](?!\$)))+?\$'); | |
| 8 static final RegExp symbolPattern = new RegExp('^(?:$operatorRE\$|$identifierRE
(?:=?\$|[.](?!\$)))+?\$'); | |
| 9 external const Symbol(String name); | |
| 10 const Symbol.unvalidated(this._name); | |
| 11 Symbol.validated(String name) : this._name = validatePublicSymbol(name); | |
| 12 bool operator ==(Object other) => other is Symbol && _name == other._name; | |
| 13 int get hashCode { | |
| 14 const arbitraryPrime = 664597; | |
| 15 return 0x1fffffff & (arbitraryPrime * _name.hashCode); | |
| 16 } | |
| 17 toString() => 'Symbol("$_name")'; | |
| 18 static String getName(Symbol symbol) => symbol._name; | |
| 19 static String validatePublicSymbol(String name) { | |
| 20 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name; | |
| 21 if (name.startsWith('_')) { | |
| 22 throw new ArgumentError('"$name" is a private identifier'); | |
| 23 } | |
| 24 throw new ArgumentError('"$name" is not a valid (qualified) symbol name'); | |
| 25 } | |
| 26 static bool isValidSymbol(String name) { | |
| 27 return (name.isEmpty || symbolPattern.hasMatch(name)); | |
| 28 } | |
| 29 } | |
| OLD | NEW |