| Index: pkg/compiler/lib/src/universe/codegen_world_builder.dart
|
| diff --git a/pkg/compiler/lib/src/universe/codegen_world_builder.dart b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
|
| index 7fb0523f3d6d5e08321306c24bc982eae7295e30..edccc6eed9d3bb5c9e14133453916e0cf5012ac1 100644
|
| --- a/pkg/compiler/lib/src/universe/codegen_world_builder.dart
|
| +++ b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
|
| @@ -14,9 +14,9 @@ abstract class CodegenWorldBuilder implements WorldBuilder {
|
| ClassEntity cls, void f(ClassEntity declarer, FieldEntity field));
|
|
|
| /// Calls [f] for each parameter of [function] providing the type and name of
|
| - /// the parameter.
|
| - void forEachParameter(
|
| - FunctionEntity function, void f(DartType type, String name));
|
| + /// the parameter and the [defaultValue] if the parameter is optional.
|
| + void forEachParameter(FunctionEntity function,
|
| + void f(DartType type, String name, ConstantValue defaultValue));
|
|
|
| void forEachInvokedName(
|
| f(String name, Map<Selector, SelectorConstraints> selectors));
|
| @@ -27,6 +27,9 @@ abstract class CodegenWorldBuilder implements WorldBuilder {
|
| void forEachInvokedSetter(
|
| f(String name, Map<Selector, SelectorConstraints> selectors));
|
|
|
| + /// Returns `true` if [field] constant or final with a constant initializer.
|
| + bool hasConstantFieldInitializer(FieldEntity field);
|
| +
|
| /// Returns `true` if [member] is invoked as a setter.
|
| bool hasInvokedSetter(MemberEntity member, ClosedWorld world);
|
|
|
| @@ -542,7 +545,10 @@ abstract class CodegenWorldBuilderImpl implements CodegenWorldBuilder {
|
| }
|
|
|
| class ElementCodegenWorldBuilderImpl extends CodegenWorldBuilderImpl {
|
| + final JavaScriptConstantCompiler _constants;
|
| +
|
| ElementCodegenWorldBuilderImpl(
|
| + this._constants,
|
| ElementEnvironment elementEnvironment,
|
| NativeBasicData nativeBasicData,
|
| ClosedWorld world,
|
| @@ -550,6 +556,11 @@ class ElementCodegenWorldBuilderImpl extends CodegenWorldBuilderImpl {
|
| : super(elementEnvironment, nativeBasicData, world,
|
| selectorConstraintsStrategy);
|
|
|
| + @override
|
| + bool hasConstantFieldInitializer(FieldElement field) {
|
| + return field.constant != null;
|
| + }
|
| +
|
| /// Calls [f] with every instance field, together with its declarer, in an
|
| /// instance of [cls].
|
| void forEachInstanceField(
|
| @@ -559,11 +570,17 @@ class ElementCodegenWorldBuilderImpl extends CodegenWorldBuilderImpl {
|
| }
|
|
|
| @override
|
| - void forEachParameter(
|
| - MethodElement function, void f(DartType type, String name)) {
|
| + void forEachParameter(MethodElement function,
|
| + void f(DartType type, String name, ConstantValue defaultValue)) {
|
| FunctionSignature parameters = function.functionSignature;
|
| parameters.forEachParameter((ParameterElement parameter) {
|
| - f(parameter.type, parameter.name);
|
| + ConstantValue value;
|
| + if (parameter.constant != null) {
|
| + value = _constants.getConstantValue(parameter.constant);
|
| + } else {
|
| + value = new NullConstantValue();
|
| + }
|
| + f(parameter.type, parameter.name, value);
|
| });
|
| }
|
|
|
| @@ -599,7 +616,10 @@ class ElementCodegenWorldBuilderImpl extends CodegenWorldBuilderImpl {
|
| }
|
|
|
| class KernelCodegenWorldBuilder extends CodegenWorldBuilderImpl {
|
| + KernelToElementMapImpl _elementMap;
|
| +
|
| KernelCodegenWorldBuilder(
|
| + this._elementMap,
|
| ElementEnvironment elementEnvironment,
|
| NativeBasicData nativeBasicData,
|
| ClosedWorld world,
|
| @@ -608,9 +628,14 @@ class KernelCodegenWorldBuilder extends CodegenWorldBuilderImpl {
|
| selectorConstraintsStrategy);
|
|
|
| @override
|
| - void forEachParameter(
|
| - FunctionEntity function, void f(DartType type, String name)) {
|
| - throw new UnimplementedError('KernelCodegenWorldBuilder.forEachParameter');
|
| + bool hasConstantFieldInitializer(FieldEntity field) {
|
| + return _elementMap.hasConstantFieldInitializer(field);
|
| + }
|
| +
|
| + @override
|
| + void forEachParameter(FunctionEntity function,
|
| + void f(DartType type, String name, ConstantValue defaultValue)) {
|
| + _elementMap.forEachParameter(function, f);
|
| }
|
|
|
| @override
|
|
|