Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1258)

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 791543004: Revert "Isolates: allow sending of arbitrary objects in dart2js." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/collection_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index a3747abb672d7c2bcc07e88c4a72d64ee8d23dfe..b429495122bb9b9332d8a176daa666445ecd3cbb 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -288,7 +288,7 @@ class OldEmitter implements Emitter {
}''');
}
- List<jsAst.Node> get defineClassFunction {
+ List get defineClassFunction {
// First the class name, then the field names in an array and the members
// (inside an Object literal).
// The caller can also pass in the constructor as a function if needed.
@@ -303,21 +303,16 @@ class OldEmitter implements Emitter {
// },
// });
- bool hasIsolateSupport = compiler.hasIsolateSupport;
- String fieldNamesProperty = r"$__fields__";
-
- jsAst.Expression defineClass = js('''function(name, fields) {
+ var defineClass = js('''function(name, fields) {
var accessors = [];
var str = "function " + name + "(";
var body = "";
- if (#hasIsolateSupport) { var fieldNames = ""; }
for (var i = 0; i < fields.length; i++) {
if(i != 0) str += ", ";
var field = generateAccessor(fields[i], accessors, name);
- if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; }
var parameter = "parameter_" + field;
str += parameter;
body += ("this." + field + " = " + parameter + ";\\n");
@@ -330,71 +325,23 @@ class OldEmitter implements Emitter {
if (typeof defineClass.name != "string") {
str += name + ".name=\\"" + name + "\\";\\n";
}
- if (#hasIsolateSupport) {
- str += name + ".$fieldNamesProperty=[" + fieldNames + "];\\n";
- }
str += accessors.join("");
return str;
- }''', { 'hasIsolateSupport': hasIsolateSupport });
-
+ }''');
// Declare a function called "generateAccessor". This is used in
// defineClassFunction (it's a local declaration in init()).
- List result = <jsAst.Node>[
- generateAccessorFunction,
- js('$generateAccessorHolder = generateAccessor'),
- new jsAst.FunctionDeclaration(
- new jsAst.VariableDeclaration('defineClass'), defineClass) ];
-
+ List<jsAst.Node> saveDefineClass = [];
if (compiler.hasIncrementalSupport) {
- result.add(
+ saveDefineClass.add(
js(r'self.$dart_unsafe_eval.defineClass = defineClass'));
}
-
- if (hasIsolateSupport) {
- jsAst.Expression classIdExtractorAccess =
- generateEmbeddedGlobalAccess(embeddedNames.CLASS_ID_EXTRACTOR);
- var classIdExtractorAssignment =
- js('# = function(o) { return o.constructor.name; }',
- classIdExtractorAccess);
-
- jsAst.Expression classFieldsExtractorAccess =
- generateEmbeddedGlobalAccess(embeddedNames.CLASS_FIELDS_EXTRACTOR);
- var classFieldsExtractorAssignment = js('''
- # = function(o) {
- var fieldNames = o.constructor.$fieldNamesProperty;
- if (!fieldNames) return []; // TODO(floitsch): do something else here.
- var result = [];
- result.length = fieldNames.length;
- for (var i = 0; i < fieldNames.length; i++) {
- result[i] = o[fieldNames[i]];
- }
- return result;
- }''', classFieldsExtractorAccess);
-
- jsAst.Expression instanceFromClassIdAccess =
- generateEmbeddedGlobalAccess(embeddedNames.INSTANCE_FROM_CLASS_ID);
- jsAst.Expression allClassesAccess =
- generateEmbeddedGlobalAccess(embeddedNames.ALL_CLASSES);
- var instanceFromClassIdAssignment =
- js('# = function(name) { return new #[name](); }',
- [instanceFromClassIdAccess, allClassesAccess]);
-
- jsAst.Expression initializeEmptyInstanceAccess =
- generateEmbeddedGlobalAccess(embeddedNames.INITIALIZE_EMPTY_INSTANCE);
- var initializeEmptyInstanceAssignment = js('''
- # = function(name, o, fields) {
- #[name].apply(o, fields);
- return o;
- }''', [ initializeEmptyInstanceAccess, allClassesAccess ]);
-
- result.addAll([classIdExtractorAssignment,
- classFieldsExtractorAssignment,
- instanceFromClassIdAssignment,
- initializeEmptyInstanceAssignment]);
- }
-
- return result;
+ return [
+ generateAccessorFunction,
+ js('$generateAccessorHolder = generateAccessor'),
+ new jsAst.FunctionDeclaration(
+ new jsAst.VariableDeclaration('defineClass'), defineClass) ]
+ ..addAll(saveDefineClass);
}
/** Needs defineClass to be defined. */
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698