Index: pkg/compiler/lib/src/kernel/element_map_impl.dart |
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart |
index 5bccd2bda1810c598e475d1f5541b5837189e33f..6632ea041ff9f850b38f1ed7d617571413ddfdc5 100644 |
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart |
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart |
@@ -142,6 +142,7 @@ class KernelToElementMapImpl extends KernelToElementMapMixin { |
@override |
ConstantValue getFieldConstantValue(ir.Field field) { |
+ // TODO(johnniwinther): Cache the result in [_FieldData]. |
return getConstantValue(field.initializer, requireConstant: field.isConst); |
} |
@@ -674,12 +675,23 @@ class KernelToElementMapImpl extends KernelToElementMapMixin { |
@override |
FieldEntity getField(ir.Field node) => _getField(node); |
+ bool hasConstantFieldInitializer(KField field) { |
+ _FieldData data = _memberList[field.memberIndex]; |
+ return getFieldConstantValue(data.node) != null; |
+ } |
+ |
TypeVariableEntity getTypeVariable(ir.TypeParameter node) => |
_getTypeVariable(node); |
@override |
FunctionEntity getMethod(ir.Procedure node) => _getMethod(node); |
+ void forEachParameter(KFunction function, |
+ void f(DartType type, String name, ConstantValue defaultValue)) { |
+ _FunctionData data = _memberList[function.memberIndex]; |
+ data.forEachParameter(this, f); |
+ } |
+ |
@override |
MemberEntity getMember(ir.Member node) { |
if (node is ir.Field) { |
@@ -1067,6 +1079,30 @@ class _FunctionData extends _MemberData { |
FunctionType getFunctionType(KernelToElementMapImpl elementMap) { |
return _type ??= elementMap.getFunctionType(functionNode); |
} |
+ |
+ void forEachParameter(KernelToElementMap elementMap, |
+ void f(DartType type, String name, ConstantValue defaultValue)) { |
+ void handleParameter(ir.VariableDeclaration node, {bool isOptional: true}) { |
+ DartType type = elementMap.getDartType(node.type); |
+ String name = node.name; |
+ ConstantValue defaultValue; |
+ if (isOptional) { |
+ if (node.initializer != null) { |
+ defaultValue = elementMap.getConstantValue(node.initializer); |
+ } else { |
+ defaultValue = new NullConstantValue(); |
+ } |
+ } |
+ f(type, name, defaultValue); |
+ } |
+ |
+ for (int i = 0; i < functionNode.positionalParameters.length; i++) { |
+ handleParameter(functionNode.positionalParameters[i], |
+ isOptional: i < functionNode.requiredParameterCount); |
+ } |
+ functionNode.namedParameters.toList() |
Siggi Cherem (dart-lang)
2017/06/16 16:31:09
alternatively - we could mutate the original once,
Johnni Winther
2017/06/19 12:45:42
I don't like mutating our input (and relying upon
|
+ ..sort(namedOrdering).forEach(handleParameter); |
Johnni Winther
2017/06/16 12:57:17
.forEach changed to ..forEach before commit
|
+ } |
} |
class _ConstructorData extends _FunctionData { |