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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/builder_accessors.dart

Issue 2735393002: Compile-time errors instead of internal errors. (Closed)
Patch Set: Created 3 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 | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.builder_accessors; 5 library fasta.builder_accessors;
6 6
7 export 'frontend_accessors.dart' show wrapInvalid; 7 export 'frontend_accessors.dart' show wrapInvalid;
8 8
9 import 'frontend_accessors.dart' show Accessor; 9 import 'frontend_accessors.dart' show Accessor;
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 Expression buildCompileTimeError(error, [int charOffset]); 51 Expression buildCompileTimeError(error, [int charOffset]);
52 52
53 Initializer buildCompileTimeErrorIntializer(error, [int charOffset]); 53 Initializer buildCompileTimeErrorIntializer(error, [int charOffset]);
54 54
55 Expression buildStaticInvocation(Procedure target, Arguments arguments); 55 Expression buildStaticInvocation(Procedure target, Arguments arguments);
56 56
57 Expression buildProblemExpression(Builder builder, String name); 57 Expression buildProblemExpression(Builder builder, String name);
58 } 58 }
59 59
60 abstract class BuilderAccessor implements Accessor { 60 abstract class BuilderAccessor implements Accessor {
karlklose 2017/03/09 10:48:26 Please add a TODO to document this hierarchy.
ahe 2017/03/09 13:03:10 I created this bug instead: https://github.com/dar
61 BuilderHelper get helper; 61 BuilderHelper get helper;
62 62
63 int get charOffset; 63 int get charOffset;
64 64
65 String get plainNameForRead; 65 String get plainNameForRead;
66 66
67 Uri get uri => helper.uri; 67 Uri get uri => helper.uri;
68 68
69 CoreTypes get coreTypes => helper.coreTypes; 69 CoreTypes get coreTypes => helper.coreTypes;
70 70
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 isSuper: isSuper))); 243 isSuper: isSuper)));
244 } else if (isSuper) { 244 } else if (isSuper) {
245 result = new SuperInitializer(constructor, arguments); 245 result = new SuperInitializer(constructor, arguments);
246 } else { 246 } else {
247 result = new RedirectingInitializer(constructor, arguments); 247 result = new RedirectingInitializer(constructor, arguments);
248 } 248 }
249 return result..fileOffset = charOffset; 249 return result..fileOffset = charOffset;
250 } 250 }
251 251
252 Expression buildAssignment(Expression value, {bool voidContext: false}) { 252 Expression buildAssignment(Expression value, {bool voidContext: false}) {
253 return internalError(""); 253 return buildAssignmentError();
254 } 254 }
255 255
256 Expression buildNullAwareAssignment(Expression value, DartType type, 256 Expression buildNullAwareAssignment(Expression value, DartType type,
257 {bool voidContext: false}) { 257 {bool voidContext: false}) {
258 return internalError(""); 258 return buildAssignmentError();
259 } 259 }
260 260
261 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 261 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
262 {bool voidContext: false, Procedure interfaceTarget}) { 262 {bool voidContext: false, Procedure interfaceTarget}) {
263 return internalError(""); 263 return buildAssignmentError();
264 } 264 }
265 265
266 Expression buildPrefixIncrement(Name binaryOperator, 266 Expression buildPrefixIncrement(Name binaryOperator,
267 {bool voidContext: false, Procedure interfaceTarget}) { 267 {bool voidContext: false, Procedure interfaceTarget}) {
268 return internalError(""); 268 return buildAssignmentError();
269 } 269 }
270 270
271 Expression buildPostfixIncrement(Name binaryOperator, 271 Expression buildPostfixIncrement(Name binaryOperator,
272 {bool voidContext: false, Procedure interfaceTarget}) { 272 {bool voidContext: false, Procedure interfaceTarget}) {
273 return internalError(""); 273 return buildAssignmentError();
274 }
275
276 Expression buildAssignmentError() {
277 String message =
278 isSuper ? "Can't assign to 'super'." : "Can't assign to 'this'.";
279 return helper.buildCompileTimeError(message, charOffset);
274 } 280 }
275 281
276 toString() => "ThisAccessor($charOffset${isSuper ? ', super' : ''})"; 282 toString() => "ThisAccessor($charOffset${isSuper ? ', super' : ''})";
277 } 283 }
278 284
279 abstract class IncompleteSend extends BuilderAccessor { 285 abstract class IncompleteSend extends BuilderAccessor {
280 final BuilderHelper helper; 286 final BuilderHelper helper;
281 287
282 final int charOffset; 288 final int charOffset;
283 289
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } else { 363 } else {
358 result = buildMethodInvocation( 364 result = buildMethodInvocation(
359 helper.toValue(receiver), name, arguments, charOffset, 365 helper.toValue(receiver), name, arguments, charOffset,
360 isNullAware: isNullAware); 366 isNullAware: isNullAware);
361 } 367 }
362 return result..fileOffset = charOffset; 368 return result..fileOffset = charOffset;
363 } 369 }
364 370
365 Expression buildNullAwareAssignment(Expression value, DartType type, 371 Expression buildNullAwareAssignment(Expression value, DartType type,
366 {bool voidContext: false}) { 372 {bool voidContext: false}) {
367 return internalError(""); 373 return internalError("Unhandled");
368 } 374 }
369 375
370 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 376 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
371 {bool voidContext: false, Procedure interfaceTarget}) { 377 {bool voidContext: false, Procedure interfaceTarget}) {
372 return internalError(""); 378 return internalError("Unhandled");
373 } 379 }
374 380
375 Expression buildPrefixIncrement(Name binaryOperator, 381 Expression buildPrefixIncrement(Name binaryOperator,
376 {bool voidContext: false, Procedure interfaceTarget}) { 382 {bool voidContext: false, Procedure interfaceTarget}) {
377 return internalError("Unhandled"); 383 return internalError("Unhandled");
378 } 384 }
379 385
380 Expression buildPostfixIncrement(Name binaryOperator, 386 Expression buildPostfixIncrement(Name binaryOperator,
381 {bool voidContext: false, Procedure interfaceTarget}) { 387 {bool voidContext: false, Procedure interfaceTarget}) {
382 return internalError("Unhandled"); 388 return internalError("Unhandled");
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 buildIsNull(new VariableGet(variable)), 755 buildIsNull(new VariableGet(variable)),
750 new NullLiteral(), 756 new NullLiteral(),
751 new MethodInvocation(new VariableGet(variable), name, arguments) 757 new MethodInvocation(new VariableGet(variable), name, arguments)
752 ..fileOffset = charOffset, 758 ..fileOffset = charOffset,
753 const DynamicType())); 759 const DynamicType()));
754 } else { 760 } else {
755 return new MethodInvocation(receiver, name, arguments) 761 return new MethodInvocation(receiver, name, arguments)
756 ..fileOffset = charOffset; 762 ..fileOffset = charOffset;
757 } 763 }
758 } 764 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698