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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../closure.dart'; | 7 import '../closure.dart'; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/codegen.dart' show CodegenRegistry; | 9 import '../common/codegen.dart' show CodegenRegistry; |
10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 HInstruction errorMessage = graph.addConstantString(message, closedWorld); | 1330 HInstruction errorMessage = graph.addConstantString(message, closedWorld); |
1331 // TODO(sra): Associate source info from [node]. | 1331 // TODO(sra): Associate source info from [node]. |
1332 _pushStaticInvocation(function, [errorMessage], typeMask); | 1332 _pushStaticInvocation(function, [errorMessage], typeMask); |
1333 } | 1333 } |
1334 | 1334 |
1335 void generateTypeError(ir.Node node, String message) { | 1335 void generateTypeError(ir.Node node, String message) { |
1336 generateError(node, _commonElements.throwTypeError, message, | 1336 generateError(node, _commonElements.throwTypeError, message, |
1337 astAdapter.getReturnTypeOf(_commonElements.throwTypeError)); | 1337 astAdapter.getReturnTypeOf(_commonElements.throwTypeError)); |
1338 } | 1338 } |
1339 | 1339 |
| 1340 void generateUnsupportedError(ir.Node node, String message) { |
| 1341 generateError(node, _commonElements.throwUnsupportedError, message, |
| 1342 astAdapter.getReturnTypeOf(_commonElements.throwUnsupportedError)); |
| 1343 } |
| 1344 |
1340 @override | 1345 @override |
1341 void visitAssertStatement(ir.AssertStatement assertStatement) { | 1346 void visitAssertStatement(ir.AssertStatement assertStatement) { |
1342 if (!options.enableUserAssertions) return; | 1347 if (!options.enableUserAssertions) return; |
1343 if (assertStatement.message == null) { | 1348 if (assertStatement.message == null) { |
1344 assertStatement.condition.accept(this); | 1349 assertStatement.condition.accept(this); |
1345 _pushStaticInvocation(_commonElements.assertHelper, <HInstruction>[pop()], | 1350 _pushStaticInvocation(_commonElements.assertHelper, <HInstruction>[pop()], |
1346 astAdapter.getReturnTypeOf(_commonElements.assertHelper)); | 1351 astAdapter.getReturnTypeOf(_commonElements.assertHelper)); |
1347 pop(); | 1352 pop(); |
1348 return; | 1353 return; |
1349 } | 1354 } |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 return; | 2248 return; |
2244 } | 2249 } |
2245 FunctionEntity function = _elementMap.getMember(target); | 2250 FunctionEntity function = _elementMap.getMember(target); |
2246 TypeMask typeMask = astAdapter.getReturnTypeOf(function); | 2251 TypeMask typeMask = astAdapter.getReturnTypeOf(function); |
2247 | 2252 |
2248 // TODO(sra): For JS interop external functions, use a different function to | 2253 // TODO(sra): For JS interop external functions, use a different function to |
2249 // build arguments. | 2254 // build arguments. |
2250 List<HInstruction> arguments = | 2255 List<HInstruction> arguments = |
2251 _visitArgumentsForStaticTarget(target.function, invocation.arguments); | 2256 _visitArgumentsForStaticTarget(target.function, invocation.arguments); |
2252 | 2257 |
2253 // Factory constructors take type parameters; other static methods ignore | |
2254 // them. | |
2255 if (function is ConstructorEntity && function.isFactoryConstructor) { | 2258 if (function is ConstructorEntity && function.isFactoryConstructor) { |
| 2259 if (function.isExternal && function.isFromEnvironmentConstructor) { |
| 2260 if (invocation.isConst) { |
| 2261 // Just like all const constructors (see visitConstructorInvocation). |
| 2262 stack.add(graph.addConstant( |
| 2263 astAdapter.getConstantFor(invocation), closedWorld)); |
| 2264 } else { |
| 2265 generateUnsupportedError( |
| 2266 invocation, |
| 2267 '${function.enclosingClass.name}.${function.name} ' |
| 2268 'can only be used as a const constructor'); |
| 2269 } |
| 2270 return; |
| 2271 } |
| 2272 |
| 2273 // Factory constructors take type parameters; other static methods ignore |
| 2274 // them. |
2256 if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { | 2275 if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { |
2257 _addTypeArguments(arguments, invocation.arguments); | 2276 _addTypeArguments(arguments, invocation.arguments); |
2258 } | 2277 } |
2259 } | 2278 } |
2260 | 2279 |
2261 _pushStaticInvocation(function, arguments, typeMask); | 2280 _pushStaticInvocation(function, arguments, typeMask); |
2262 } | 2281 } |
2263 | 2282 |
2264 void handleInvokeStaticForeign( | 2283 void handleInvokeStaticForeign( |
2265 ir.StaticInvocation invocation, ir.Procedure target) { | 2284 ir.StaticInvocation invocation, ir.Procedure target) { |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3381 enterBlock.setBlockFlow( | 3400 enterBlock.setBlockFlow( |
3382 new HTryBlockInformation( | 3401 new HTryBlockInformation( |
3383 kernelBuilder.wrapStatementGraph(bodyGraph), | 3402 kernelBuilder.wrapStatementGraph(bodyGraph), |
3384 exception, | 3403 exception, |
3385 kernelBuilder.wrapStatementGraph(catchGraph), | 3404 kernelBuilder.wrapStatementGraph(catchGraph), |
3386 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3405 kernelBuilder.wrapStatementGraph(finallyGraph)), |
3387 exitBlock); | 3406 exitBlock); |
3388 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3407 kernelBuilder.inTryStatement = previouslyInTryStatement; |
3389 } | 3408 } |
3390 } | 3409 } |
OLD | NEW |