| OLD | NEW |
| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 removals.add(update); | 368 removals.add(update); |
| 369 } | 369 } |
| 370 } else { | 370 } else { |
| 371 elementsToInvalidate.add(element); | 371 elementsToInvalidate.add(element); |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 return elementsToInvalidate; | 374 return elementsToInvalidate; |
| 375 } | 375 } |
| 376 | 376 |
| 377 String computeUpdateJs() { | 377 String computeUpdateJs() { |
| 378 Set existingClasses = |
| 379 new Set.from(compiler.codegenWorld.directlyInstantiatedClasses); |
| 380 |
| 378 List<Update> removals = <Update>[]; | 381 List<Update> removals = <Update>[]; |
| 379 List<Element> updatedElements = applyUpdates(removals); | 382 List<Element> updatedElements = applyUpdates(removals); |
| 380 if (compiler.progress != null) { | 383 if (compiler.progress != null) { |
| 381 compiler.progress.reset(); | 384 compiler.progress.reset(); |
| 382 } | 385 } |
| 383 for (Element element in updatedElements) { | 386 for (Element element in updatedElements) { |
| 384 compiler.enqueuer.resolution.addToWorkList(element); | 387 compiler.enqueuer.resolution.addToWorkList(element); |
| 385 } | 388 } |
| 386 compiler.processQueue(compiler.enqueuer.resolution, null); | 389 compiler.processQueue(compiler.enqueuer.resolution, null); |
| 387 | 390 |
| 388 compiler.phase = Compiler.PHASE_DONE_RESOLVING; | 391 compiler.phase = Compiler.PHASE_DONE_RESOLVING; |
| 389 | 392 |
| 390 for (Element element in updatedElements) { | 393 for (Element element in updatedElements) { |
| 391 compiler.enqueuer.codegen.addToWorkList(element); | 394 compiler.enqueuer.codegen.addToWorkList(element); |
| 392 } | 395 } |
| 393 compiler.processQueue(compiler.enqueuer.codegen, null); | 396 compiler.processQueue(compiler.enqueuer.codegen, null); |
| 394 | 397 |
| 395 List<jsAst.Statement> updates = <jsAst.Statement>[]; | 398 List<jsAst.Statement> updates = <jsAst.Statement>[]; |
| 399 |
| 400 Set newClasses = |
| 401 new Set.from(compiler.codegenWorld.directlyInstantiatedClasses); |
| 402 newClasses.removeAll(existingClasses); |
| 403 |
| 404 for (ClassElementX cls in newClasses) { |
| 405 jsAst.Node access = namer.elementAccess(cls); |
| 406 String name = namer.getNameOfClass(cls); |
| 407 |
| 408 // TODO(ahe): Compute arguments. |
| 409 List<jsAst.Node> arguments = <jsAst.Node>[]; |
| 410 |
| 411 // TODO(ahe): Compute statements, that is initializers. |
| 412 List<jsAst.Statement> statements = <jsAst.Statement>[]; |
| 413 |
| 414 updates.add( |
| 415 js.statement( |
| 416 '# = function $name(#) {#}', [access, arguments, statements])); |
| 417 } |
| 418 |
| 419 for (ClassElementX cls in newClasses) { |
| 420 // TODO(ahe): Set up superclasses. |
| 421 } |
| 422 |
| 396 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 423 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 397 if (!element.isField) { | 424 if (!element.isField) { |
| 398 updates.add(computeMemberUpdateJs(element)); | 425 updates.add(computeMemberUpdateJs(element)); |
| 399 } | 426 } |
| 400 } | 427 } |
| 401 for (RemovedFunctionUpdate update in removals) { | 428 for (RemovedFunctionUpdate update in removals) { |
| 402 update.writeUpdateJsOn(updates); | 429 update.writeUpdateJsOn(updates); |
| 403 } | 430 } |
| 404 | 431 |
| 405 if (updates.length == 1) { | 432 if (updates.length == 1) { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 706 |
| 680 abstract class JsFeatures { | 707 abstract class JsFeatures { |
| 681 Compiler get compiler; | 708 Compiler get compiler; |
| 682 | 709 |
| 683 JavaScriptBackend get backend => compiler.backend; | 710 JavaScriptBackend get backend => compiler.backend; |
| 684 | 711 |
| 685 Namer get namer => backend.namer; | 712 Namer get namer => backend.namer; |
| 686 | 713 |
| 687 CodeEmitterTask get emitter => backend.emitter; | 714 CodeEmitterTask get emitter => backend.emitter; |
| 688 } | 715 } |
| OLD | NEW |