| 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:js_runtime/shared/embedded_names.dart'; | 5 import 'package:js_runtime/shared/embedded_names.dart'; |
| 6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 7 | 7 |
| 8 import '../closure.dart'; | 8 import '../closure.dart'; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 ResolutionInterfaceType getDartTypeOfMapLiteral(ir.MapLiteral literal) { | 359 ResolutionInterfaceType getDartTypeOfMapLiteral(ir.MapLiteral literal) { |
| 360 ast.Node node = getNodeOrNull(literal); | 360 ast.Node node = getNodeOrNull(literal); |
| 361 if (node != null) return elements.getType(node); | 361 if (node != null) return elements.getType(node); |
| 362 assertNodeIsSynthetic(literal); | 362 assertNodeIsSynthetic(literal); |
| 363 return _compiler.commonElements | 363 return _compiler.commonElements |
| 364 .mapType(getDartType(literal.keyType), getDartType(literal.valueType)); | 364 .mapType(getDartType(literal.keyType), getDartType(literal.valueType)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 ResolutionDartType getFunctionReturnType(ir.FunctionNode node) { | |
| 368 if (node.returnType is ir.InvalidType) return const ResolutionDynamicType(); | |
| 369 return getDartType(node.returnType); | |
| 370 } | |
| 371 | |
| 372 /// Computes the function type corresponding the signature of [node]. | 367 /// Computes the function type corresponding the signature of [node]. |
| 373 ResolutionFunctionType getFunctionType(ir.FunctionNode node) { | 368 ResolutionFunctionType getFunctionType(ir.FunctionNode node) { |
| 374 ResolutionDartType returnType = getFunctionReturnType(node); | 369 ResolutionDartType returnType = getDartType(node.returnType); |
| 375 List<ResolutionDartType> parameterTypes = <ResolutionDartType>[]; | 370 List<ResolutionDartType> parameterTypes = <ResolutionDartType>[]; |
| 376 List<ResolutionDartType> optionalParameterTypes = <ResolutionDartType>[]; | 371 List<ResolutionDartType> optionalParameterTypes = <ResolutionDartType>[]; |
| 377 for (ir.VariableDeclaration variable in node.positionalParameters) { | 372 for (ir.VariableDeclaration variable in node.positionalParameters) { |
| 378 if (parameterTypes.length == node.requiredParameterCount) { | 373 if (parameterTypes.length == node.requiredParameterCount) { |
| 379 optionalParameterTypes.add(getDartType(variable.type)); | 374 optionalParameterTypes.add(getDartType(variable.type)); |
| 380 } else { | 375 } else { |
| 381 parameterTypes.add(getDartType(variable.type)); | 376 parameterTypes.add(getDartType(variable.type)); |
| 382 } | 377 } |
| 383 } | 378 } |
| 384 List<String> namedParameters = <String>[]; | 379 List<String> namedParameters = <String>[]; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return const ResolutionVoidType(); | 482 return const ResolutionVoidType(); |
| 488 } | 483 } |
| 489 | 484 |
| 490 @override | 485 @override |
| 491 ResolutionDartType visitDynamicType(ir.DynamicType node) { | 486 ResolutionDartType visitDynamicType(ir.DynamicType node) { |
| 492 return const ResolutionDynamicType(); | 487 return const ResolutionDynamicType(); |
| 493 } | 488 } |
| 494 | 489 |
| 495 @override | 490 @override |
| 496 ResolutionDartType visitInvalidType(ir.InvalidType node) { | 491 ResolutionDartType visitInvalidType(ir.InvalidType node) { |
| 497 if (topLevel) { | 492 // Root uses such a `o is Unresolved` and `o as Unresolved` must be special |
| 498 throw new UnimplementedError( | 493 // cased in the builder, nested invalid types are treated as `dynamic`. |
| 499 "Outermost invalid types not currently supported"); | |
| 500 } | |
| 501 // Nested invalid types are treated as `dynamic`. | |
| 502 return const ResolutionDynamicType(); | 494 return const ResolutionDynamicType(); |
| 503 } | 495 } |
| 504 } | 496 } |
| 505 | 497 |
| 506 class KernelJumpTarget extends JumpTarget { | 498 class KernelJumpTarget extends JumpTarget { |
| 507 static int index = 0; | 499 static int index = 0; |
| 508 | 500 |
| 509 /// Pointer to the actual executable statements that a jump target refers to. | 501 /// Pointer to the actual executable statements that a jump target refers to. |
| 510 /// If this jump target was not initially constructed with a LabeledStatement, | 502 /// If this jump target was not initially constructed with a LabeledStatement, |
| 511 /// this value is identical to originalStatement. This Node is actually of | 503 /// this value is identical to originalStatement. This Node is actually of |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { | 701 TypeMask selectorTypeOf(Selector selector, TypeMask mask) { |
| 710 return TypeMaskFactory.inferredTypeForSelector( | 702 return TypeMaskFactory.inferredTypeForSelector( |
| 711 selector, mask, _globalInferenceResults); | 703 selector, mask, _globalInferenceResults); |
| 712 } | 704 } |
| 713 | 705 |
| 714 TypeMask typeFromNativeBehavior( | 706 TypeMask typeFromNativeBehavior( |
| 715 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { | 707 native.NativeBehavior nativeBehavior, ClosedWorld closedWorld) { |
| 716 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); | 708 return TypeMaskFactory.fromNativeBehavior(nativeBehavior, closedWorld); |
| 717 } | 709 } |
| 718 } | 710 } |
| OLD | NEW |