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

Side by Side Diff: frog/leg/warnings.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/util/util_implementation.dart ('k') | frog/presubmit.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5 class MessageKind {
6 final String template;
7 const MessageKind(this.template);
8
9 static final GENERIC = const MessageKind('#{1}');
10
11 static final NOT_ASSIGNABLE = const MessageKind(
12 '#{2} is not assignable to #{1}');
13 static final VOID_EXPRESSION = const MessageKind(
14 'expression does not yield a value');
15 static final VOID_VARIABLE = const MessageKind(
16 'variable cannot be of type void');
17 static final RETURN_VALUE_IN_VOID = const MessageKind(
18 'cannot return value from void function');
19 static final RETURN_NOTHING = const MessageKind(
20 'value of type #{1} expected');
21 static final MISSING_ARGUMENT = const MessageKind(
22 'missing argument of type #{1}');
23 static final ADDITIONAL_ARGUMENT = const MessageKind(
24 'additional argument');
25 static final METHOD_NOT_FOUND = const MessageKind(
26 'no method named #{2} in class #{1}');
27 static final MEMBER_NOT_STATIC = const MessageKind(
28 '#{1}.#{2} is not static');
29 static final NO_INSTANCE_AVAILABLE = const MessageKind(
30 '#{1} is only available in instance methods');
31
32 static final UNREACHABLE_CODE = const MessageKind(
33 'unreachable code');
34 static final MISSING_RETURN = const MessageKind(
35 'missing return');
36 static final MAYBE_MISSING_RETURN = const MessageKind(
37 'not all paths lead to a return or throw statement');
38
39 static final CANNOT_RESOLVE = const MessageKind(
40 'cannot resolve #{1}');
41 static final CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind(
42 'cannot resolve constructor #{1}');
43 static final CANNOT_RESOLVE_TYPE = const MessageKind(
44 'cannot resolve type #{1}');
45 static final DUPLICATE_DEFINITION = const MessageKind(
46 'duplicate definition of #{1}');
47 static final NOT_A_TYPE = const MessageKind(
48 '#{1} is not a type');
49 static final NOT_A_PREFIX = const MessageKind(
50 '#{1} is not a prefix');
51 static final NO_SUPER_IN_OBJECT = const MessageKind(
52 "'Object' does not have a superclass");
53 static final CANNOT_FIND_CONSTRUCTOR = const MessageKind(
54 'cannot find constructor #{1}');
55 static final CANNOT_FIND_CONSTRUCTOR2 = const MessageKind(
56 'cannot find constructor #{1} or #{2}');
57 static final CYCLIC_CLASS_HIERARCHY = const MessageKind(
58 '#{1} creates a cycle in the class hierarchy');
59 static final INVALID_RECEIVER_IN_INITIALIZER = const MessageKind(
60 'field initializer expected');
61 static final NO_SUPER_IN_STATIC = const MessageKind(
62 "'super' is only available in instance methods");
63 static final DUPLICATE_INITIALIZER = const MessageKind(
64 'field #{1} is initialized more than once');
65 static final ALREADY_INITIALIZED = const MessageKind(
66 '#{1} was already initialized here');
67 static final INIT_STATIC_FIELD = const MessageKind(
68 'cannot initialize static field #{1}');
69 static final NOT_A_FIELD = const MessageKind(
70 '#{1} is not a field');
71 static final CONSTRUCTOR_CALL_EXPECTED = const MessageKind(
72 "only call to 'this' or 'super' constructor allowed");
73 static final INVALID_FOR_IN = const MessageKind(
74 'invalid for-in variable declaration.');
75 static final INVALID_INITIALIZER = const MessageKind(
76 'invalid initializer');
77 static final FUNCTION_WITH_INITIALIZER = const MessageKind(
78 'only constructors can have initializers');
79 static final REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind(
80 'cyclic constructor redirection');
81 static final REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind(
82 'redirecting constructor cannot have a body');
83 static final REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = const MessageKind(
84 'redirecting constructor cannot have other initializers');
85 static final SUPER_INITIALIZER_IN_OBJECT = const MessageKind(
86 "'Object' cannot have a super initializer");
87 static final DUPLICATE_SUPER_INITIALIZER = const MessageKind(
88 'cannot have more than one super initializer');
89 static final NO_MATCHING_CONSTRUCTOR = const MessageKind(
90 'no matching constructor found');
91 static final NO_CONSTRUCTOR = const MessageKind(
92 '#{1} is a #{2}, not a constructor');
93 static final FIELD_PARAMETER_NOT_ALLOWED = const MessageKind(
94 'a field parameter is only allowed in generative constructors');
95 static final INVALID_PARAMETER = const MessageKind(
96 "cannot resolve parameter");
97 static final NOT_INSTANCE_FIELD = const MessageKind(
98 '#{1} is not an instance field');
99 static final NO_CATCH_NOR_FINALLY = const MessageKind(
100 "expected 'catch' or 'finally'");
101 static final EMPTY_CATCH_DECLARATION = const MessageKind(
102 'expected a variable in catch declaration');
103 static final EXTRA_CATCH_DECLARATION = const MessageKind(
104 'extra variable in catch declaration');
105 static final UNBOUND_LABEL = const MessageKind(
106 'cannot resolve label #{1}');
107 static final NO_BREAK_TARGET = const MessageKind(
108 'break statement not inside switch or loop');
109 static final NO_CONTINUE_TARGET = const MessageKind(
110 'continue statement not inside loop');
111 static final EXISTING_LABEL = const MessageKind(
112 'original declaration of duplicate label #{1}');
113 static final DUPLICATE_LABEL = const MessageKind(
114 'duplicate declaration of label #{1}');
115 static final UNUSED_LABEL = const MessageKind(
116 'unused label #{1}');
117 static final INVALID_CONTINUE = const MessageKind(
118 'target of continue is not a loop or switch case');
119 static final TYPE_VARIABLE_AS_CONSTRUCTOR = const MessageKind(
120 'cannot use type variable as constructor');
121 static final INVALID_BREAK = const MessageKind(
122 'target of break is not a statement');
123 static final INVALID_USE_OF_SUPER = const MessageKind(
124 'super not allowed here');
125 static final INVALID_CASE_DEFAULT = const MessageKind(
126 'default only allowed on last case of a switch');
127 static final INVALID_ARGUMENT_AFTER_NAMED = const MessageKind(
128 'non-named argument after named argument');
129
130 static final NOT_A_COMPILE_TIME_CONSTANT = const MessageKind(
131 'not a compile-time constant');
132 static final CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind(
133 'cycle in the compile-time constant computation');
134
135 static final KEY_NOT_A_STRING_LITERAL = const MessageKind(
136 'map-literal key not a string literal');
137
138 static final NO_SUCH_LIBRARY_MEMBER = const MessageKind(
139 '#{1} has no member named #{2}');
140
141 static final CANNOT_INSTANTIATE_INTERFACE = const MessageKind(
142 "cannot instantiate interface '#{1}'");
143
144 static final CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
145 "cannot instantiate typedef '#{1}'");
146
147 static final NO_DEFAULT_CLASS = const MessageKind(
148 "no default class on enclosing interface '#{1}'");
149
150 static final CYCLIC_TYPE_VARIABLE = const MessageKind(
151 "cyclic reference to type variable #{1}");
152 static final TYPE_NAME_EXPECTED = const MessageKind(
153 "class or interface name exptected");
154
155 static final CANNOT_EXTEND = const MessageKind(
156 "#{1} cannot be extended");
157
158 static final CANNOT_IMPLEMENT = const MessageKind(
159 "#{1} cannot be implemented");
160
161 static final ILLEGAL_SUPER_SEND = const MessageKind(
162 "#{1} cannot be called on super");
163
164 toString() => template;
165 }
166
167 class Message {
168 final kind;
169 final List arguments;
170 String message;
171
172 Message(this.kind, this.arguments);
173
174 String toString() {
175 if (message === null) {
176 message = kind.template;
177 int position = 1;
178 for (var argument in arguments) {
179 String string = slowToString(argument);
180 message = message.replaceAll('#{${position++}}', string);
181 }
182 }
183 return message;
184 }
185
186 bool operator==(other) {
187 if (other is !Message) return false;
188 return (kind == other.kind) && (toString() == other.toString());
189 }
190
191 String slowToString(object) {
192 if (object is SourceString) {
193 return object.slowToString();
194 } else {
195 return object.toString();
196 }
197 }
198 }
199
200 class TypeWarning {
201 final Message message;
202 TypeWarning.message(this.message);
203 TypeWarning(MessageKind kind, List<Type> arguments)
204 : message = new Message(kind, arguments);
205 String toString() => message.toString();
206 }
207
208 class ResolutionError {
209 final Message message;
210 ResolutionError.message(this.message);
211 ResolutionError(MessageKind kind, List<Type> arguments)
212 : message = new Message(kind, arguments);
213 String toString() => message.toString();
214 }
215
216 class ResolutionWarning {
217 final Message message;
218 ResolutionWarning.message(this.message);
219 ResolutionWarning(MessageKind kind, List<Type> arguments)
220 : message = new Message(kind, arguments);
221 String toString() => message.toString();
222 }
223
224 class CompileTimeConstantError {
225 final Message message;
226 CompileTimeConstantError.message(this.message);
227 CompileTimeConstantError(MessageKind kind, List<Type> arguments)
228 : message = new Message(kind, arguments);
229 String toString() => message.toString();
230 }
OLDNEW
« no previous file with comments | « frog/leg/util/util_implementation.dart ('k') | frog/presubmit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698