Index: pkg/compiler/lib/src/js_backend/constant_emitter.dart |
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart |
index 9bb14173935072bc250e33954a1f2f295e9aa996..fc53cb4158aece420c3232b6661dbebe9d90fc77 100644 |
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart |
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart |
@@ -15,13 +15,11 @@ typedef jsAst.Expression _ConstantListGenerator(jsAst.Expression array); |
* (if there are some). It is hence up to that function to decide which |
* constants should be inlined or not. |
*/ |
-class ConstantEmitter |
- implements ConstantValueVisitor<jsAst.Expression, Null> { |
- |
+class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> { |
// Matches blank lines, comment lines and trailing comments that can't be part |
// of a string. |
static final RegExp COMMENT_RE = |
- new RegExp(r'''^ *(//.*)?\n| *//[^''"\n]*$''' , multiLine: true); |
+ new RegExp(r'''^ *(//.*)?\n| *//[^''"\n]*$''', multiLine: true); |
final Compiler compiler; |
final Namer namer; |
@@ -66,12 +64,11 @@ class ConstantEmitter |
return new jsAst.LiteralNull(); |
} |
- static final _exponentialRE = new RegExp( |
- '^' |
- '\([-+]?\)' // 1: sign |
- '\([0-9]+\)' // 2: leading digit(s) |
+ static final _exponentialRE = new RegExp('^' |
+ '\([-+]?\)' // 1: sign |
+ '\([0-9]+\)' // 2: leading digit(s) |
'\(\.\([0-9]*\)\)?' // 4: fraction digits |
- 'e\([-+]?[0-9]+\)' // 5: exponent with sign |
+ 'e\([-+]?[0-9]+\)' // 5: exponent with sign |
r'$'); |
/// Reduces the size of exponential representations when minification is |
@@ -154,7 +151,7 @@ class ConstantEmitter |
@override |
jsAst.Expression visitString(StringConstantValue constant, [_]) { |
return js.escapedString(constant.primitiveValue.slowToString(), |
- ascii: true); |
+ ascii: true); |
} |
@override |
@@ -189,7 +186,8 @@ class ConstantEmitter |
jsAst.Expression jsGeneralMap() { |
List<jsAst.Expression> data = <jsAst.Expression>[]; |
for (int i = 0; i < constant.keys.length; i++) { |
- jsAst.Expression keyExpression = constantReferenceGenerator(constant.keys[i]); |
+ jsAst.Expression keyExpression = |
+ constantReferenceGenerator(constant.keys[i]); |
jsAst.Expression valueExpression = |
constantReferenceGenerator(constant.values[i]); |
data.add(keyExpression); |
@@ -208,32 +206,32 @@ class ConstantEmitter |
int emittedArgumentCount = 0; |
classElement.implementation.forEachInstanceField( |
(ClassElement enclosing, Element field) { |
- if (field.name == JavaScriptMapConstant.LENGTH_NAME) { |
- arguments.add( |
- new jsAst.LiteralNumber('${constant.keyList.entries.length}')); |
- } else if (field.name == JavaScriptMapConstant.JS_OBJECT_NAME) { |
- arguments.add(jsMap()); |
- } else if (field.name == JavaScriptMapConstant.KEYS_NAME) { |
- arguments.add(constantReferenceGenerator(constant.keyList)); |
- } else if (field.name == JavaScriptMapConstant.PROTO_VALUE) { |
- assert(constant.protoValue != null); |
- arguments.add(constantReferenceGenerator(constant.protoValue)); |
- } else if (field.name == JavaScriptMapConstant.JS_DATA_NAME) { |
- arguments.add(jsGeneralMap()); |
- } else { |
- reporter.internalError(field, |
- "Compiler has unexpected field ${field.name} for " |
- "${className}."); |
- } |
- emittedArgumentCount++; |
- }, |
- includeSuperAndInjectedMembers: true); |
+ if (field.name == JavaScriptMapConstant.LENGTH_NAME) { |
+ arguments |
+ .add(new jsAst.LiteralNumber('${constant.keyList.entries.length}')); |
+ } else if (field.name == JavaScriptMapConstant.JS_OBJECT_NAME) { |
+ arguments.add(jsMap()); |
+ } else if (field.name == JavaScriptMapConstant.KEYS_NAME) { |
+ arguments.add(constantReferenceGenerator(constant.keyList)); |
+ } else if (field.name == JavaScriptMapConstant.PROTO_VALUE) { |
+ assert(constant.protoValue != null); |
+ arguments.add(constantReferenceGenerator(constant.protoValue)); |
+ } else if (field.name == JavaScriptMapConstant.JS_DATA_NAME) { |
+ arguments.add(jsGeneralMap()); |
+ } else { |
+ reporter.internalError( |
+ field, |
+ "Compiler has unexpected field ${field.name} for " |
+ "${className}."); |
+ } |
+ emittedArgumentCount++; |
+ }, includeSuperAndInjectedMembers: true); |
if ((className == JavaScriptMapConstant.DART_STRING_CLASS && |
- emittedArgumentCount != 3) || |
+ emittedArgumentCount != 3) || |
(className == JavaScriptMapConstant.DART_PROTO_CLASS && |
- emittedArgumentCount != 4) || |
+ emittedArgumentCount != 4) || |
(className == JavaScriptMapConstant.DART_GENERAL_CLASS && |
- emittedArgumentCount != 1)) { |
+ emittedArgumentCount != 1)) { |
reporter.internalError(classElement, |
"Compiler and ${className} disagree on number of fields."); |
} |
@@ -255,7 +253,7 @@ class ConstantEmitter |
DartType type = constant.representedType; |
jsAst.Name typeName = namer.runtimeTypeName(type.element); |
return new jsAst.Call(getHelperProperty(backend.helpers.createRuntimeType), |
- [js.quoteName(typeName)]); |
+ [js.quoteName(typeName)]); |
} |
@override |
@@ -275,7 +273,7 @@ class ConstantEmitter |
return constant.payload; |
default: |
reporter.internalError(NO_LOCATION_SPANNABLE, |
- "Unexpected DummyConstantKind ${constant.kind}"); |
+ "Unexpected DummyConstantKind ${constant.kind}"); |
return null; |
} |
} |
@@ -283,16 +281,15 @@ class ConstantEmitter |
@override |
jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) { |
Element element = constant.type.element; |
- if (backend.isForeign(element) |
- && element.name == 'JS_CONST') { |
+ if (backend.isForeign(element) && element.name == 'JS_CONST') { |
StringConstantValue str = constant.fields.values.single; |
String value = str.primitiveValue.slowToString(); |
return new jsAst.LiteralExpression(stripComments(value)); |
} |
jsAst.Expression constructor = |
backend.emitter.constructorAccess(constant.type.element); |
- List<jsAst.Expression> fields = |
- constant.fields.values.map(constantReferenceGenerator) |
+ List<jsAst.Expression> fields = constant.fields.values |
+ .map(constantReferenceGenerator) |
.toList(growable: false); |
jsAst.New instantiation = new jsAst.New(constructor, fields); |
return maybeAddTypeArguments(constant.type, instantiation); |
@@ -302,16 +299,16 @@ class ConstantEmitter |
return rawJavaScript.replaceAll(COMMENT_RE, ''); |
} |
- jsAst.Expression maybeAddTypeArguments(InterfaceType type, |
- jsAst.Expression value) { |
+ jsAst.Expression maybeAddTypeArguments( |
+ InterfaceType type, jsAst.Expression value) { |
if (type is InterfaceType && |
!type.treatAsRaw && |
backend.classNeedsRti(type.element)) { |
InterfaceType interface = type; |
RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder; |
- Iterable<jsAst.Expression> arguments = interface.typeArguments |
- .map((DartType type) => |
- rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_){})); |
+ Iterable<jsAst.Expression> arguments = interface.typeArguments.map( |
+ (DartType type) => |
+ rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_) {})); |
jsAst.Expression argumentList = |
new jsAst.ArrayInitializer(arguments.toList()); |
return new jsAst.Call( |