| 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 409624961d863a400324b2f93936a657a3a90bd9..7df0e20de6ec1083905453b37d35fb6e1673f625 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,12 +570,18 @@ 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((_parameter) {
|
| + parameters.orderedForEachParameter((_parameter) {
|
| ParameterElement parameter = _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);
|
| });
|
| }
|
|
|
| @@ -600,7 +617,10 @@ class ElementCodegenWorldBuilderImpl extends CodegenWorldBuilderImpl {
|
| }
|
|
|
| class KernelCodegenWorldBuilder extends CodegenWorldBuilderImpl {
|
| + KernelToElementMapImpl _elementMap;
|
| +
|
| KernelCodegenWorldBuilder(
|
| + this._elementMap,
|
| ElementEnvironment elementEnvironment,
|
| NativeBasicData nativeBasicData,
|
| ClosedWorld world,
|
| @@ -609,9 +629,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
|
|
|