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

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

Issue 961493003: don't run dart gen on JS patch code (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « test/dart_codegen/expect/_internal/print.dart ('k') | test/dart_codegen/expect/async/async » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of dart._internal; 1 part of dart._internal;
2 2
3 class Symbol implements core.Symbol { 3 class Symbol implements core.Symbol {
4 final String _name; 4 final String _name;
5 static const String reservedWordRE = 5 static const String reservedWordRE =
6 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[fns]|n(?:ew|ull)|' r'ret(?:hrow|ur n)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|' r'v(?:ar|oid)|w(?:hile|ith))'; 6 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[fns]|n(?:ew|ull)|' r'ret(?:hrow|ur n)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|' r'v(?:ar|oid)|w(?:hile|ith))';
7 static const String publicIdentifierRE = 7 static const String publicIdentifierRE =
8 r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$][\w$]*'; 8 r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$][\w$]*';
9 static const String identifierRE = 9 static const String identifierRE =
10 r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$_][\w$]*'; 10 r'(?!' '$reservedWordRE' r'\b(?!\$))[a-zA-Z$_][\w$]*';
11 static const String operatorRE = 11 static const String operatorRE =
12 r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|unary-)'; 12 r'(?:[\-+*/%&|^]|\[\]=?|==|~/?|<[<=]?|>[>=]?|unary-)';
13 static final RegExp publicSymbolPattern = new RegExp( 13 static final RegExp publicSymbolPattern = new RegExp(
14 '^(?:$operatorRE\$|$publicIdentifierRE(?:=?\$|[.](?!\$)))+?\$'); 14 '^(?:$operatorRE\$|$publicIdentifierRE(?:=?\$|[.](?!\$)))+?\$');
15 static final RegExp symbolPattern = 15 static final RegExp symbolPattern =
16 new RegExp('^(?:$operatorRE\$|$identifierRE(?:=?\$|[.](?!\$)))+?\$'); 16 new RegExp('^(?:$operatorRE\$|$identifierRE(?:=?\$|[.](?!\$)))+?\$');
17 const Symbol(String name) : this._name = name; 17 external const Symbol(String name);
18 const Symbol.unvalidated(this._name); 18 const Symbol.unvalidated(this._name);
19 Symbol.validated(String name) : this._name = validatePublicSymbol(name); 19 Symbol.validated(String name) : this._name = validatePublicSymbol(name);
20 bool operator ==(other) => other is Symbol && _name == other._name; 20 bool operator ==(other) => other is Symbol && _name == other._name;
21 int get hashCode { 21 int get hashCode {
22 const arbitraryPrime = 664597; 22 const arbitraryPrime = 664597;
23 return 0x1fffffff & (arbitraryPrime * _name.hashCode); 23 return 0x1fffffff & (arbitraryPrime * _name.hashCode);
24 } 24 }
25 toString() => 'Symbol("$_name")'; 25 toString() => 'Symbol("$_name")';
26 static String getName(Symbol symbol) => symbol._name; 26 static String getName(Symbol symbol) => symbol._name;
27 static String validatePublicSymbol(String name) { 27 static String validatePublicSymbol(String name) {
28 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name; 28 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name;
29 if (name.startsWith('_')) { 29 if (name.startsWith('_')) {
30 throw new ArgumentError('"$name" is a private identifier'); 30 throw new ArgumentError('"$name" is a private identifier');
31 } 31 }
32 throw new ArgumentError('"$name" is not a valid (qualified) symbol name'); 32 throw new ArgumentError('"$name" is not a valid (qualified) symbol name');
33 } 33 }
34 static bool isValidSymbol(String name) { 34 static bool isValidSymbol(String name) {
35 return (name.isEmpty || symbolPattern.hasMatch(name)); 35 return (name.isEmpty || symbolPattern.hasMatch(name));
36 } 36 }
37 } 37 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/_internal/print.dart ('k') | test/dart_codegen/expect/async/async » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698