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

Side by Side Diff: pkg/compiler/lib/src/universe/codegen_world_builder.dart

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Cleanup 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
OLDNEW
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 part of world_builder; 5 part of world_builder;
6 6
7 /// World builder specific to codegen. 7 /// World builder specific to codegen.
8 /// 8 ///
9 /// This adds additional access to liveness of selectors and elements. 9 /// This adds additional access to liveness of selectors and elements.
10 abstract class CodegenWorldBuilder implements WorldBuilder { 10 abstract class CodegenWorldBuilder implements WorldBuilder {
11 /// Calls [f] with every instance field, together with its declarer, in an 11 /// Calls [f] with every instance field, together with its declarer, in an
12 /// instance of [cls]. 12 /// instance of [cls].
13 void forEachInstanceField( 13 void forEachInstanceField(
14 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field)); 14 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field));
15 15
16 /// Calls [f] for each parameter of [function] providing the type and name of 16 /// Calls [f] for each parameter of [function] providing the type and name of
17 /// the parameter and the [defaultValue] if the parameter is optional. 17 /// the parameter and the [defaultValue] if the parameter is optional.
18 void forEachParameter(FunctionEntity function, 18 void forEachParameter(FunctionEntity function,
19 void f(DartType type, String name, ConstantValue defaultValue)); 19 void f(DartType type, String name, ConstantValue defaultValue));
20 20
21 void forEachInvokedName( 21 void forEachInvokedName(
22 f(String name, Map<Selector, SelectorConstraints> selectors)); 22 f(String name, Map<Selector, SelectorConstraints> selectors));
23 23
24 void forEachInvokedGetter( 24 void forEachInvokedGetter(
25 f(String name, Map<Selector, SelectorConstraints> selectors)); 25 f(String name, Map<Selector, SelectorConstraints> selectors));
26 26
27 void forEachInvokedSetter( 27 void forEachInvokedSetter(
28 f(String name, Map<Selector, SelectorConstraints> selectors)); 28 f(String name, Map<Selector, SelectorConstraints> selectors));
29 29
30 /// Returns `true` if [field] constant or final with a constant initializer. 30 /// Returns `true` if [field] has a constant initializer.
31 bool hasConstantFieldInitializer(FieldEntity field); 31 bool hasConstantFieldInitializer(FieldEntity field);
32 32
33 /// Returns the constant initializer for [field].
34 ConstantValue getConstantFieldInitializer(FieldEntity field);
35
33 /// Returns `true` if [member] is invoked as a setter. 36 /// Returns `true` if [member] is invoked as a setter.
34 bool hasInvokedSetter(MemberEntity member, ClosedWorld world); 37 bool hasInvokedSetter(MemberEntity member, ClosedWorld world);
35 38
36 bool hasInvokedGetter(MemberEntity member, ClosedWorld world); 39 bool hasInvokedGetter(MemberEntity member, ClosedWorld world);
37 40
38 Map<Selector, SelectorConstraints> invocationsByName(String name); 41 Map<Selector, SelectorConstraints> invocationsByName(String name);
39 42
40 Map<Selector, SelectorConstraints> getterInvocationsByName(String name); 43 Map<Selector, SelectorConstraints> getterInvocationsByName(String name);
41 44
42 Map<Selector, SelectorConstraints> setterInvocationsByName(String name); 45 Map<Selector, SelectorConstraints> setterInvocationsByName(String name);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 ClosedWorld world, 557 ClosedWorld world,
555 SelectorConstraintsStrategy selectorConstraintsStrategy) 558 SelectorConstraintsStrategy selectorConstraintsStrategy)
556 : super(elementEnvironment, nativeBasicData, world, 559 : super(elementEnvironment, nativeBasicData, world,
557 selectorConstraintsStrategy); 560 selectorConstraintsStrategy);
558 561
559 @override 562 @override
560 bool hasConstantFieldInitializer(FieldElement field) { 563 bool hasConstantFieldInitializer(FieldElement field) {
561 return field.constant != null; 564 return field.constant != null;
562 } 565 }
563 566
567 @override
568 ConstantValue getConstantFieldInitializer(FieldElement field) {
569 assert(field.constant != null,
570 failedAt(field, "Field $field doesn't have a constant initial value."));
571 return _constants.getConstantValue(field.constant);
572 }
573
564 /// Calls [f] with every instance field, together with its declarer, in an 574 /// Calls [f] with every instance field, together with its declarer, in an
565 /// instance of [cls]. 575 /// instance of [cls].
566 void forEachInstanceField( 576 void forEachInstanceField(
567 ClassElement cls, void f(ClassEntity declarer, FieldEntity field)) { 577 ClassElement cls, void f(ClassEntity declarer, FieldEntity field)) {
568 cls.implementation 578 cls.implementation
569 .forEachInstanceField(f, includeSuperAndInjectedMembers: true); 579 .forEachInstanceField(f, includeSuperAndInjectedMembers: true);
570 } 580 }
571 581
572 @override 582 @override
573 void forEachParameter(MethodElement function, 583 void forEachParameter(MethodElement function,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 SelectorConstraintsStrategy selectorConstraintsStrategy) 636 SelectorConstraintsStrategy selectorConstraintsStrategy)
627 : super(elementEnvironment, nativeBasicData, world, 637 : super(elementEnvironment, nativeBasicData, world,
628 selectorConstraintsStrategy); 638 selectorConstraintsStrategy);
629 639
630 @override 640 @override
631 bool hasConstantFieldInitializer(FieldEntity field) { 641 bool hasConstantFieldInitializer(FieldEntity field) {
632 return _elementMap.hasConstantFieldInitializer(field); 642 return _elementMap.hasConstantFieldInitializer(field);
633 } 643 }
634 644
635 @override 645 @override
646 ConstantValue getConstantFieldInitializer(FieldEntity field) {
647 return _elementMap.getConstantFieldInitializer(field);
648 }
649
650 @override
636 void forEachParameter(FunctionEntity function, 651 void forEachParameter(FunctionEntity function,
637 void f(DartType type, String name, ConstantValue defaultValue)) { 652 void f(DartType type, String name, ConstantValue defaultValue)) {
638 _elementMap.forEachParameter(function, f); 653 _elementMap.forEachParameter(function, f);
639 } 654 }
640 655
641 @override 656 @override
642 void forEachInstanceField( 657 void forEachInstanceField(
643 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field)) { 658 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field)) {
644 _elementEnvironment.forEachClassMember(cls, 659 _elementEnvironment.forEachClassMember(cls,
645 (ClassEntity declarer, MemberEntity member) { 660 (ClassEntity declarer, MemberEntity member) {
646 if (member.isField && member.isInstanceMember) f(declarer, member); 661 if (member.isField && member.isInstanceMember) f(declarer, member);
647 }); 662 });
648 } 663 }
649 } 664 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698