OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.modifier; | 5 library fasta.modifier; |
6 | 6 |
7 import 'errors.dart' show internalError; | 7 import 'deprecated_problems.dart' show deprecated_internalProblem; |
8 | 8 |
9 enum ModifierEnum { | 9 enum ModifierEnum { |
10 Abstract, | 10 Abstract, |
11 Const, | 11 Const, |
12 Covariant, | 12 Covariant, |
13 External, | 13 External, |
14 Final, | 14 Final, |
15 Static, | 15 Static, |
16 | 16 |
17 // Not a real modifier. | 17 // Not a real modifier. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const Modifier(this.kind, this.mask); | 60 const Modifier(this.kind, this.mask); |
61 | 61 |
62 factory Modifier.fromString(String string) { | 62 factory Modifier.fromString(String string) { |
63 if (identical('abstract', string)) return Abstract; | 63 if (identical('abstract', string)) return Abstract; |
64 if (identical('const', string)) return Const; | 64 if (identical('const', string)) return Const; |
65 if (identical('covariant', string)) return Covariant; | 65 if (identical('covariant', string)) return Covariant; |
66 if (identical('external', string)) return External; | 66 if (identical('external', string)) return External; |
67 if (identical('final', string)) return Final; | 67 if (identical('final', string)) return Final; |
68 if (identical('static', string)) return Static; | 68 if (identical('static', string)) return Static; |
69 if (identical('var', string)) return Var; | 69 if (identical('var', string)) return Var; |
70 return internalError("Unhandled modifier: $string"); | 70 return deprecated_internalProblem("Unhandled modifier: $string"); |
71 } | 71 } |
72 | 72 |
73 toString() => "modifier(${'$kind'.substring('ModifierEnum.'.length)})"; | 73 toString() => "modifier(${'$kind'.substring('ModifierEnum.'.length)})"; |
74 | 74 |
75 static int validate(List<Modifier> modifiers, {bool isAbstract: false}) { | 75 static int validate(List<Modifier> modifiers, {bool isAbstract: false}) { |
76 // TODO(ahe): Rename this method, validation is now taken care of by the | 76 // TODO(ahe): Rename this method, validation is now taken care of by the |
77 // parser. | 77 // parser. |
78 int result = isAbstract ? abstractMask : 0; | 78 int result = isAbstract ? abstractMask : 0; |
79 if (modifiers == null) return result; | 79 if (modifiers == null) return result; |
80 for (Modifier modifier in modifiers) { | 80 for (Modifier modifier in modifiers) { |
81 result |= modifier.mask; | 81 result |= modifier.mask; |
82 } | 82 } |
83 return result; | 83 return result; |
84 } | 84 } |
85 } | 85 } |
OLD | NEW |