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

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

Issue 734323003: Use Object.create instead of a tmp-function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/js_lib/js_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 generateAccessorFunction, 299 generateAccessorFunction,
300 js('$generateAccessorHolder = generateAccessor'), 300 js('$generateAccessorHolder = generateAccessor'),
301 new jsAst.FunctionDeclaration( 301 new jsAst.FunctionDeclaration(
302 new jsAst.VariableDeclaration('defineClass'), defineClass) ]; 302 new jsAst.VariableDeclaration('defineClass'), defineClass) ];
303 } 303 }
304 304
305 /** Needs defineClass to be defined. */ 305 /** Needs defineClass to be defined. */
306 jsAst.Expression buildInheritFrom() { 306 jsAst.Expression buildInheritFrom() {
307 jsAst.Expression result = js(r''' 307 jsAst.Expression result = js(r'''
308 function() { 308 function() {
309 function tmp() {}
310 var hasOwnProperty = Object.prototype.hasOwnProperty; 309 var hasOwnProperty = Object.prototype.hasOwnProperty;
311 return function (constructor, superConstructor) { 310 return function (constructor, superConstructor) {
312 tmp.prototype = superConstructor.prototype; 311 var object = Object.create(superConstructor.prototype);
313 var object = new tmp();
314 var properties = constructor.prototype; 312 var properties = constructor.prototype;
315 for (var member in properties) { 313 for (var member in properties) {
316 if (hasOwnProperty.call(properties, member)) { 314 if (hasOwnProperty.call(properties, member)) {
317 object[member] = properties[member]; 315 object[member] = properties[member];
318 } 316 }
319 } 317 }
320 object.constructor = constructor; 318 object.constructor = constructor;
321 constructor.prototype = object; 319 constructor.prototype = object;
322 return object; 320 return object;
323 }; 321 };
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2007 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2010 if (element.isInstanceMember) { 2008 if (element.isInstanceMember) {
2011 cachedClassBuilders.remove(element.enclosingClass); 2009 cachedClassBuilders.remove(element.enclosingClass);
2012 2010
2013 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2011 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2014 2012
2015 } 2013 }
2016 } 2014 }
2017 } 2015 }
2018 } 2016 }
OLDNEW
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/js_lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698