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

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

Issue 2942863002: Compile and run Hello World! (Closed)
Patch Set: Rebased 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 SelectorConstraintsStrategy selectorConstraintsStrategy) 637 SelectorConstraintsStrategy selectorConstraintsStrategy)
628 : super(elementEnvironment, nativeBasicData, world, 638 : super(elementEnvironment, nativeBasicData, world,
629 selectorConstraintsStrategy); 639 selectorConstraintsStrategy);
630 640
631 @override 641 @override
632 bool hasConstantFieldInitializer(FieldEntity field) { 642 bool hasConstantFieldInitializer(FieldEntity field) {
633 return _elementMap.hasConstantFieldInitializer(field); 643 return _elementMap.hasConstantFieldInitializer(field);
634 } 644 }
635 645
636 @override 646 @override
647 ConstantValue getConstantFieldInitializer(FieldEntity field) {
648 return _elementMap.getConstantFieldInitializer(field);
649 }
650
651 @override
637 void forEachParameter(FunctionEntity function, 652 void forEachParameter(FunctionEntity function,
638 void f(DartType type, String name, ConstantValue defaultValue)) { 653 void f(DartType type, String name, ConstantValue defaultValue)) {
639 _elementMap.forEachParameter(function, f); 654 _elementMap.forEachParameter(function, f);
640 } 655 }
641 656
642 @override 657 @override
643 void forEachInstanceField( 658 void forEachInstanceField(
644 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field)) { 659 ClassEntity cls, void f(ClassEntity declarer, FieldEntity field)) {
645 _elementEnvironment.forEachClassMember(cls, 660 _elementEnvironment.forEachClassMember(cls,
646 (ClassEntity declarer, MemberEntity member) { 661 (ClassEntity declarer, MemberEntity member) {
647 if (member.isField && member.isInstanceMember) f(declarer, member); 662 if (member.isField && member.isInstanceMember) f(declarer, member);
648 }); 663 });
649 } 664 }
650 } 665 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/ssa.dart ('k') | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698