| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart'; | 8 import '../common/backend_api.dart'; |
| 9 import '../common/names.dart'; | 9 import '../common/names.dart'; |
| 10 import '../compile_time_constants.dart'; | 10 import '../compile_time_constants.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 KernelWorldBuilder(this.reporter, ir.Program program) | 71 KernelWorldBuilder(this.reporter, ir.Program program) |
| 72 : _env = new KEnv(program) { | 72 : _env = new KEnv(program) { |
| 73 _elementEnvironment = new KernelElementEnvironment(this); | 73 _elementEnvironment = new KernelElementEnvironment(this); |
| 74 _commonElements = new KernelCommonElements(_elementEnvironment); | 74 _commonElements = new KernelCommonElements(_elementEnvironment); |
| 75 ConstantEnvironment constants = new KernelConstantEnvironment(this); | 75 ConstantEnvironment constants = new KernelConstantEnvironment(this); |
| 76 _nativeBehaviorBuilder = | 76 _nativeBehaviorBuilder = |
| 77 new KernelBehaviorBuilder(_commonElements, helpers, constants); | 77 new KernelBehaviorBuilder(_commonElements, helpers, constants); |
| 78 _typeConverter = new DartTypeConverter(this); | 78 _typeConverter = new DartTypeConverter(this); |
| 79 } | 79 } |
| 80 | 80 |
| 81 KMethod get _mainFunction { |
| 82 return _env.program.mainMethod != null |
| 83 ? _getMethod(_env.program.mainMethod) |
| 84 : null; |
| 85 } |
| 86 |
| 87 KLibrary get _mainLibrary { |
| 88 return _env.program.mainMethod != null |
| 89 ? _getLibrary(_env.program.mainMethod.enclosingLibrary) |
| 90 : null; |
| 91 } |
| 92 |
| 81 @override | 93 @override |
| 82 CommonElements get commonElements => _commonElements; | 94 CommonElements get commonElements => _commonElements; |
| 83 | 95 |
| 84 @override | 96 @override |
| 85 ElementEnvironment get elementEnvironment => _elementEnvironment; | 97 ElementEnvironment get elementEnvironment => _elementEnvironment; |
| 86 | 98 |
| 87 @override | 99 @override |
| 88 native.BehaviorBuilder get nativeBehaviorBuilder => _nativeBehaviorBuilder; | 100 native.BehaviorBuilder get nativeBehaviorBuilder => _nativeBehaviorBuilder; |
| 89 | 101 |
| 90 LibraryEntity lookupLibrary(Uri uri) { | 102 LibraryEntity lookupLibrary(Uri uri) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 return _constructorMap[name]; | 493 return _constructorMap[name]; |
| 482 } | 494 } |
| 483 } | 495 } |
| 484 | 496 |
| 485 class KernelElementEnvironment implements ElementEnvironment { | 497 class KernelElementEnvironment implements ElementEnvironment { |
| 486 final KernelWorldBuilder worldBuilder; | 498 final KernelWorldBuilder worldBuilder; |
| 487 | 499 |
| 488 KernelElementEnvironment(this.worldBuilder); | 500 KernelElementEnvironment(this.worldBuilder); |
| 489 | 501 |
| 490 @override | 502 @override |
| 503 LibraryEntity get mainLibrary => worldBuilder._mainLibrary; |
| 504 |
| 505 @override |
| 506 FunctionEntity get mainFunction => worldBuilder._mainFunction; |
| 507 |
| 508 @override |
| 491 InterfaceType getThisType(ClassEntity cls) { | 509 InterfaceType getThisType(ClassEntity cls) { |
| 492 return worldBuilder._getThisType(cls); | 510 return worldBuilder._getThisType(cls); |
| 493 } | 511 } |
| 494 | 512 |
| 495 @override | 513 @override |
| 496 InterfaceType getRawType(ClassEntity cls) { | 514 InterfaceType getRawType(ClassEntity cls) { |
| 497 return worldBuilder._getRawType(cls); | 515 return worldBuilder._getRawType(cls); |
| 498 } | 516 } |
| 499 | 517 |
| 500 @override | 518 @override |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 } | 833 } |
| 816 | 834 |
| 817 InterfaceType getMixinTypeForClass(KClass cls) { | 835 InterfaceType getMixinTypeForClass(KClass cls) { |
| 818 KClassEnv env = builder._classEnvs[cls.classIndex]; | 836 KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 819 ir.Supertype mixedInType = env.cls.mixedInType; | 837 ir.Supertype mixedInType = env.cls.mixedInType; |
| 820 if (mixedInType == null) return null; | 838 if (mixedInType == null) return null; |
| 821 return builder.createInterfaceType( | 839 return builder.createInterfaceType( |
| 822 mixedInType.classNode, mixedInType.typeArguments); | 840 mixedInType.classNode, mixedInType.typeArguments); |
| 823 } | 841 } |
| 824 } | 842 } |
| OLD | NEW |