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

Side by Side Diff: pkg/kernel/lib/target/targets.dart

Issue 2931423002: Prepare for improved error recovery from compile-time errors. (Closed)
Patch Set: Rebased on 11f82b12d2fb4f2c323cbc5a25de9835cc8e5031 Created 3 years, 6 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/kernel/lib/core_types.dart ('k') | runtime/lib/errors_patch.dart » ('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 library kernel.target.targets; 4 library kernel.target.targets;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../class_hierarchy.dart'; 7 import '../class_hierarchy.dart';
8 import '../core_types.dart'; 8 import '../core_types.dart';
9 import '../transformations/treeshaker.dart' show ProgramRoot; 9 import '../transformations/treeshaker.dart' show ProgramRoot;
10 import 'flutter.dart' show FlutterTarget; 10 import 'flutter.dart' show FlutterTarget;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 bool isGetter: false, 123 bool isGetter: false,
124 bool isSetter: false, 124 bool isSetter: false,
125 bool isField: false, 125 bool isField: false,
126 bool isLocalVariable: false, 126 bool isLocalVariable: false,
127 bool isDynamic: false, 127 bool isDynamic: false,
128 bool isSuper: false, 128 bool isSuper: false,
129 bool isStatic: false, 129 bool isStatic: false,
130 bool isConstructor: false, 130 bool isConstructor: false,
131 bool isTopLevel: false}); 131 bool isTopLevel: false});
132 132
133 /// Builds an expression that throws [error] as compile-time error. The
134 /// target must be able to handle this expression in a constant expression.
135 Expression throwCompileConstantError(CoreTypes coreTypes, Expression error) {
136 // This method returns `const _ConstantExpressionError()._throw(error)`.
137 int offset = error.fileOffset;
138 var receiver = new ConstructorInvocation(
139 coreTypes.constantExpressionErrorDefaultConstructor,
140 new Arguments.empty()..fileOffset = offset,
141 isConst: true)
142 ..fileOffset = offset;
143 return new MethodInvocation(
144 receiver,
145 new Name("_throw", coreTypes.coreLibrary),
146 new Arguments(<Expression>[error])..fileOffset = error.fileOffset)
147 ..fileOffset = offset;
148 }
149
150 /// Builds an expression that represents a compile-time error which is
151 /// suitable for being passed to [throwCompileConstantError].
152 Expression buildCompileTimeError(
153 CoreTypes coreTypes, String message, int offset) {
154 return new ConstructorInvocation(
155 coreTypes.compileTimeErrorDefaultConstructor,
156 new Arguments(<Expression>[new StringLiteral(message)])
157 ..fileOffset = offset)
158 ..fileOffset = offset;
159 }
160
133 String toString() => 'Target($name)'; 161 String toString() => 'Target($name)';
134 } 162 }
135 163
136 class NoneTarget extends Target { 164 class NoneTarget extends Target {
137 final TargetFlags flags; 165 final TargetFlags flags;
138 166
139 NoneTarget(this.flags); 167 NoneTarget(this.flags);
140 168
141 bool get strongMode => flags.strongMode; 169 bool get strongMode => flags.strongMode;
142 String get name => 'none'; 170 String get name => 'none';
(...skipping 19 matching lines...) Expand all
162 bool isField: false, 190 bool isField: false,
163 bool isLocalVariable: false, 191 bool isLocalVariable: false,
164 bool isDynamic: false, 192 bool isDynamic: false,
165 bool isSuper: false, 193 bool isSuper: false,
166 bool isStatic: false, 194 bool isStatic: false,
167 bool isConstructor: false, 195 bool isConstructor: false,
168 bool isTopLevel: false}) { 196 bool isTopLevel: false}) {
169 return new InvalidExpression(); 197 return new InvalidExpression();
170 } 198 }
171 } 199 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/core_types.dart ('k') | runtime/lib/errors_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698