Version 1.2.0-dev.5.14
svn merge -c 32893 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 32897 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
Review URL: https://codereview.chromium.org//175043004
git-svn-id: http://dart.googlecode.com/svn/trunk@32899 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
index 33804f6..8ac77b0 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
@@ -227,6 +227,8 @@
final String methodsWithOptionalArgumentsField =
r'$methodsWithOptionalArguments';
+ final String classDescriptorProperty = r'^';
+
// Name of property in a class description for the native dispatch metadata.
final String nativeSpecProperty = '%';
@@ -290,6 +292,7 @@
case 'SETTER_PREFIX': return setterPrefix;
case 'CALL_CATCH_ALL': return callCatchAllName;
case 'REFLECTABLE': return reflectableField;
+ case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty;
default:
compiler.reportError(
node, MessageKind.GENERIC,
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
index b178723..d6a2229 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
@@ -342,7 +342,7 @@
String superName = backend.namer.getNameOfClass(superclass);
- ClassBuilder builder = new ClassBuilder();
+ ClassBuilder builder = new ClassBuilder(backend.namer);
emitter.classEmitter.emitClassConstructor(classElement, builder, null);
bool hasFields = emitter.classEmitter.emitFields(
classElement, builder, superName, classIsNative: true);
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart
index 53e32d8..044368b 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/class_builder.dart
@@ -16,9 +16,13 @@
String functionType;
List<jsAst.Node> fieldMetadata;
+ final Namer namer;
+
/// Set to true by user if class is indistinguishable from its superclass.
bool isTrivial = false;
+ ClassBuilder(this.namer);
+
// Has the same signature as [DefineStubFunction].
void addProperty(String name, jsAst.Expression value) {
properties.add(new jsAst.Property(js.string(name), value));
@@ -50,7 +54,8 @@
new jsAst.ArrayInitializer.from([classData]..addAll(fieldMetadata));
}
var fieldsAndProperties =
- [new jsAst.Property(js.string(''), classData)]
+ [new jsAst.Property(js.string(namer.classDescriptorProperty),
+ classData)]
..addAll(properties);
return new jsAst.ObjectInitializer(fieldsAndProperties, isOneLiner: false);
}
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
index 49f51a9..9a6ca0b 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/class_emitter.dart
@@ -36,7 +36,7 @@
task.needsMixinSupport = true;
}
- ClassBuilder builder = new ClassBuilder();
+ ClassBuilder builder = new ClassBuilder(namer);
emitClassConstructor(classElement, builder, runtimeName,
onlyForRti: onlyForRti);
emitFields(classElement, builder, superName, onlyForRti: onlyForRti);
@@ -314,7 +314,7 @@
}
List<jsAst.Property> statics = new List<jsAst.Property>();
- ClassBuilder staticsBuilder = new ClassBuilder();
+ ClassBuilder staticsBuilder = new ClassBuilder(namer);
if (emitFields(classElement, staticsBuilder, null, emitStatics: true)) {
statics.add(staticsBuilder.toObjectInitializer().properties.single);
}
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
index 531d1e6..88359b1 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
@@ -331,12 +331,13 @@
* string encoding fields, constructor and superclass. Get
* the superclass and the fields in the format
* '[name/]Super;field1,field2'
- * from the null-string property on the descriptor.
+ * from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor.
* The 'name/' is optional and contains the name that should be used
* when printing the runtime type string. It is used, for example, to
* print the runtime type JSInt as 'int'.
*/
- js('var classData = desc[""], supr, name = cls, fields = classData'),
+ js('var classData = desc["${namer.classDescriptorProperty}"], '
+ 'supr, name = cls, fields = classData'),
optional(
backend.hasRetainedMetadata,
js.if_('typeof classData == "object" && '
@@ -828,7 +829,7 @@
backend.generatedCode.keys.where(isStaticFunction);
for (Element element in Elements.sortedByPosition(elements)) {
- ClassBuilder builder = new ClassBuilder();
+ ClassBuilder builder = new ClassBuilder(namer);
containerBuilder.addMember(element, builder);
getElementDecriptor(element).properties.addAll(builder.properties);
}
@@ -1229,8 +1230,7 @@
for (OutputUnit outputUnit in compiler.deferredLoadTask.allOutputUnits) {
ClassBuilder descriptor =
- descriptors.putIfAbsent(outputUnit, ()
- => new ClassBuilder());
+ descriptors.putIfAbsent(outputUnit, () => new ClassBuilder(namer));
if (descriptor.properties.isEmpty) continue;
bool isDeferred =
outputUnit != compiler.deferredLoadTask.mainOutputUnit;
@@ -1348,7 +1348,7 @@
// not see libraries that only have fields.
if (element.isLibrary()) {
LibraryElement library = element;
- ClassBuilder builder = new ClassBuilder();
+ ClassBuilder builder = new ClassBuilder(namer);
if (classEmitter.emitFields(
library, builder, null, emitStatics: true)) {
OutputUnit mainUnit = compiler.deferredLoadTask.mainOutputUnit;
@@ -1546,7 +1546,7 @@
elementDescriptors.putIfAbsent(
element, () => new Map<OutputUnit, ClassBuilder>());
return descriptors.putIfAbsent(outputUnit,
- () => new ClassBuilder());
+ () => new ClassBuilder(namer));
}
ClassBuilder getElementDecriptor(Element element) {
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart
index bc13d80..db83cfe 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart
@@ -224,7 +224,7 @@
var globalObject = data[3];
var descriptor = data[4];
var isRoot = !!data[5];
- var fields = descriptor && descriptor[""];
+ var fields = descriptor && descriptor["${namer.classDescriptorProperty}"];
var classes = [];
var functions = [];
''';
@@ -233,7 +233,7 @@
function processStatics(descriptor) {
for (var property in descriptor) {
if (!hasOwnProperty.call(descriptor, property)) continue;
- if (property === "") continue;
+ if (property === "${namer.classDescriptorProperty}") continue;
var element = descriptor[property];
var firstChar = property.substring(0, 1);
var previousProperty;
@@ -286,7 +286,8 @@
optionalMethods[prop] = previousProp;
} else {
var elem = element[prop];
- if (prop && elem != null &&''' // Break long line.
+ if (prop !== "${namer.classDescriptorProperty}" &&'''
+ ''' elem != null &&''' // Break long line.
''' elem.constructor === Array &&''' // Break long line.
''' prop !== "<>") {
addStubs(newDesc, elem, prop, false, element, []);
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
index 0154824..b790ca9 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -569,7 +569,8 @@
// This is a native class, or an intercepted class.
// TODO(ahe): Preserve descriptor for such classes.
} else {
- fields = JS('', '#[""]', descriptor);
+ fields = JS('', '#[#]', descriptor,
+ JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY'));
if (fields is List) {
fieldsMetadata = fields.getRange(1, fields.length).toList();
fields = fields[0];
@@ -1592,7 +1593,10 @@
var staticDescriptor = JS('', 'init.statics[#]', _mangledName);
if (staticDescriptor != null) {
parseCompactFieldSpecification(
- fieldOwner, JS('', '#[""]', staticDescriptor), true, result);
+ fieldOwner,
+ JS('', '#[#]',
+ staticDescriptor, JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY')),
+ true, result);
}
return result;
}
@@ -2685,7 +2689,10 @@
/// Returns true if the key represent ancillary reflection data, that is, not a
/// method.
bool isReflectiveDataInPrototype(String key) {
- if (key == '' || key == METHODS_WITH_OPTIONAL_ARGUMENTS) return true;
+ if (key == JS_GET_NAME('CLASS_DESCRIPTOR_PROPERTY') ||
+ key == METHODS_WITH_OPTIONAL_ARGUMENTS) {
+ return true;
+ }
String firstChar = key[0];
return firstChar == '*' || firstChar == '+';
}
diff --git a/tests/compiler/dart2js/class_codegen_test.dart b/tests/compiler/dart2js/class_codegen_test.dart
index d2af8f7..13c21f0 100644
--- a/tests/compiler/dart2js/class_codegen_test.dart
+++ b/tests/compiler/dart2js/class_codegen_test.dart
@@ -67,15 +67,15 @@
twoClasses() {
asyncTest(() => compileAll(TEST_ONE).then((generated) {
- Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"": "Object;"')));
- Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"": "Object;"')));
+ Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"')));
+ Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "Object;"')));
}));
}
subClass() {
checkOutput(String generated) {
- Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"": "Object;"')));
- Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"": "A;"')));
+ Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"')));
+ Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "A;"')));
}
asyncTest(() => compileAll(TEST_TWO).then(checkOutput));
@@ -85,7 +85,7 @@
fieldTest() {
asyncTest(() => compileAll(TEST_FOUR).then((generated) {
Expect.isTrue(generated.contains(
- new RegExp('B: {[ \n]*"": "A;y,z,x",[ \n]*static:')));
+ new RegExp('B: {[ \n]*"\\^": "A;y,z,x",[ \n]*static:')));
}));
}
diff --git a/tests/compiler/dart2js/no_constructor_body_test.dart b/tests/compiler/dart2js/no_constructor_body_test.dart
index ddafc6c..b059f32 100644
--- a/tests/compiler/dart2js/no_constructor_body_test.dart
+++ b/tests/compiler/dart2js/no_constructor_body_test.dart
@@ -20,6 +20,6 @@
main() {
asyncTest(() => compileAll(TEST).then((generated) {
Expect.isTrue(generated.contains(
- new RegExp('A: {[ \n]*"": "Object;",[ \n]*static:')));
+ new RegExp('A: {[ \n]*"\\^": "Object;",[ \n]*static:')));
}));
}
diff --git a/tests/compiler/dart2js/no_duplicate_constructor_body_test.dart b/tests/compiler/dart2js/no_duplicate_constructor_body_test.dart
index 127be93..3005ddf 100644
--- a/tests/compiler/dart2js/no_duplicate_constructor_body_test.dart
+++ b/tests/compiler/dart2js/no_duplicate_constructor_body_test.dart
@@ -17,7 +17,7 @@
main() {
asyncTest(() => compileAll(CODE).then((generated) {
- RegExp regexp = new RegExp(r'\A: {[ \n]*"": "[A-za-z]+;"');
+ RegExp regexp = new RegExp(r'\A: {[ \n]*"\^": "[A-za-z]+;"');
Iterator<Match> matches = regexp.allMatches(generated).iterator;
checkNumberOfMatches(matches, 1);
}));
diff --git a/tools/VERSION b/tools/VERSION
index cfc2891..51c8aeb 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 2
PATCH 0
PRERELEASE 5
-PRERELEASE_PATCH 13
+PRERELEASE_PATCH 14