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

Side by Side Diff: dart/pkg/dart2js_incremental/lib/library_updater.dart

Issue 657883002: Handle instance methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r41481. 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/tests/try/web/incremental_compilation_update_test.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 library dart2js_incremental.library_updater; 5 library dart2js_incremental.library_updater;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:convert' show 10 import 'dart:convert' show
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 jsAst.Node computeMemberUpdateJs(Element element) { 300 jsAst.Node computeMemberUpdateJs(Element element) {
301 MemberInfo info = emitter.oldEmitter.containerBuilder 301 MemberInfo info = emitter.oldEmitter.containerBuilder
302 .analyzeMemberMethod(element); 302 .analyzeMemberMethod(element);
303 if (info == null) { 303 if (info == null) {
304 compiler.internalError(element, '${element.runtimeType}'); 304 compiler.internalError(element, '${element.runtimeType}');
305 } 305 }
306 String name = info.name; 306 String name = info.name;
307 jsAst.Node function = info.code; 307 jsAst.Node function = info.code;
308 jsAst.Node elementAccess = namer.elementAccess(element);
309 jsAst.Expression globalFunctionsAccess =
310 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
311 List<jsAst.Statement> statements = <jsAst.Statement>[]; 308 List<jsAst.Statement> statements = <jsAst.Statement>[];
312 statements.add( 309 if (element.isInstanceMember) {
313 js.statement( 310 jsAst.Node elementAccess = namer.elementAccess(element.enclosingClass);
314 '#.# = # = f', 311 statements.add(
315 [globalFunctionsAccess, name, elementAccess])); 312 js.statement('#.prototype.# = f', [elementAccess, name]));
316 if (info.canTearOff) { 313 } else {
317 String globalName = namer.globalObjectFor(element); 314 jsAst.Node elementAccess = namer.elementAccess(element);
315 jsAst.Expression globalFunctionsAccess =
316 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
318 statements.add( 317 statements.add(
319 js.statement( 318 js.statement(
320 '#.#().# = f', 319 '#.# = # = f',
321 [globalName, info.tearOffName, callNameFor(element)])); 320 [globalFunctionsAccess, name, elementAccess]));
321 if (info.canTearOff) {
322 String globalName = namer.globalObjectFor(element);
323 statements.add(
324 js.statement(
325 '#.#().# = f',
326 [globalName, info.tearOffName, callNameFor(element)]));
327 }
322 } 328 }
323 // Create a scope by creating a new function. The updated function literal 329 // Create a scope by creating a new function. The updated function literal
324 // is passed as an argument to this function which ensures that temporary 330 // is passed as an argument to this function which ensures that temporary
325 // names in updateScope don't shadow global names. 331 // names in updateScope don't shadow global names.
326 jsAst.Fun updateScope = js('function (f) { # }', [statements]); 332 jsAst.Fun updateScope = js('function (f) { # }', [statements]);
327 return js.statement('(#)(#)', [updateScope, function]); 333 return js.statement('(#)(#)', [updateScope, function]);
328 } 334 }
329 335
330 String prettyPrintJs(jsAst.Node node) { 336 String prettyPrintJs(jsAst.Node node) {
331 jsAst.Printer printer = new jsAst.Printer(compiler, null); 337 jsAst.Printer printer = new jsAst.Printer(compiler, null);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 before.getOrSet = after.getOrSet; 384 before.getOrSet = after.getOrSet;
379 } 385 }
380 386
381 /// Reset various caches and remove this element from the compiler's internal 387 /// Reset various caches and remove this element from the compiler's internal
382 /// state. 388 /// state.
383 void reuseElement() { 389 void reuseElement() {
384 compiler.forgetElement(before); 390 compiler.forgetElement(before);
385 before.reuseElement(); 391 before.reuseElement();
386 } 392 }
387 } 393 }
OLDNEW
« no previous file with comments | « no previous file | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698