| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // TODO(ahe): Share these with js_helper.dart. | 7 // TODO(ahe): Share these with js_helper.dart. |
| 8 const FUNCTION_INDEX = 0; | 8 const FUNCTION_INDEX = 0; |
| 9 const NAME_INDEX = 1; | 9 const NAME_INDEX = 1; |
| 10 const CALL_NAME_INDEX = 2; | 10 const CALL_NAME_INDEX = 2; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // object and copy over the members. | 368 // object and copy over the members. |
| 369 jsAst.Statement finishClasses = js.statement('''{ | 369 jsAst.Statement finishClasses = js.statement('''{ |
| 370 function finishClasses(processedClasses) { | 370 function finishClasses(processedClasses) { |
| 371 if (#debugFastObjects) | 371 if (#debugFastObjects) |
| 372 print("Number of classes: " + | 372 print("Number of classes: " + |
| 373 Object.getOwnPropertyNames(processedClasses.collected).length); | 373 Object.getOwnPropertyNames(processedClasses.collected).length); |
| 374 | 374 |
| 375 var allClasses = #allClasses; | 375 var allClasses = #allClasses; |
| 376 | 376 |
| 377 if (#inCspMode) { | 377 if (#inCspMode) { |
| 378 var constructors = dart_precompiled(processedClasses.collected); | 378 var constructors = #precompiled(processedClasses.collected); |
| 379 } | 379 } |
| 380 | 380 |
| 381 if (#notInCspMode) { | 381 if (#notInCspMode) { |
| 382 processedClasses.combinedConstructorFunction += | 382 processedClasses.combinedConstructorFunction += |
| 383 "return [\\n" + processedClasses.constructorsList.join(",\\n ") + | 383 "return [\\n" + processedClasses.constructorsList.join(",\\n ") + |
| 384 "\\n]"; | 384 "\\n]"; |
| 385 var constructors = | 385 var constructors = |
| 386 new Function("\$collectedClasses", | 386 new Function("\$collectedClasses", |
| 387 processedClasses.combinedConstructorFunction) | 387 processedClasses.combinedConstructorFunction) |
| 388 (processedClasses.collected); | 388 (processedClasses.collected); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 411 | 411 |
| 412 var properties = Object.keys(processedClasses.pending); | 412 var properties = Object.keys(processedClasses.pending); |
| 413 for (var i = 0; i < properties.length; i++) finishClass(properties[i]); | 413 for (var i = 0; i < properties.length; i++) finishClass(properties[i]); |
| 414 } | 414 } |
| 415 }''', {'allClasses': allClassesAccess, | 415 }''', {'allClasses': allClassesAccess, |
| 416 'debugFastObjects': DEBUG_FAST_OBJECTS, | 416 'debugFastObjects': DEBUG_FAST_OBJECTS, |
| 417 'isTreeShakingDisabled': backend.isTreeShakingDisabled, | 417 'isTreeShakingDisabled': backend.isTreeShakingDisabled, |
| 418 'finishClassFunction': oldEmitter.buildFinishClass(hasNativeClasses), | 418 'finishClassFunction': oldEmitter.buildFinishClass(hasNativeClasses), |
| 419 'trivialNsmHandlers': oldEmitter.buildTrivialNsmHandlers(), | 419 'trivialNsmHandlers': oldEmitter.buildTrivialNsmHandlers(), |
| 420 'inCspMode': compiler.useContentSecurityPolicy, | 420 'inCspMode': compiler.useContentSecurityPolicy, |
| 421 'notInCspMode': !compiler.useContentSecurityPolicy}); | 421 'notInCspMode': !compiler.useContentSecurityPolicy, |
| 422 'precompiled': oldEmitter |
| 423 .generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED)}); |
| 422 | 424 |
| 423 List<jsAst.Statement> incrementalSupport = <jsAst.Statement>[]; | 425 List<jsAst.Statement> incrementalSupport = <jsAst.Statement>[]; |
| 424 if (compiler.hasIncrementalSupport) { | 426 if (compiler.hasIncrementalSupport) { |
| 425 incrementalSupport.add( | 427 incrementalSupport.add( |
| 426 js.statement( | 428 js.statement( |
| 427 '#.addStubs = addStubs;', [namer.accessIncrementalHelper])); | 429 '#.addStubs = addStubs;', [namer.accessIncrementalHelper])); |
| 428 } | 430 } |
| 429 | 431 |
| 430 return js(''' | 432 return js(''' |
| 431 function $parseReflectionDataName(reflectionData) { | 433 function $parseReflectionDataName(reflectionData) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 (function() { | 486 (function() { |
| 485 var result = $array[$index]; | 487 var result = $array[$index]; |
| 486 if ($check) { | 488 if ($check) { |
| 487 throw new Error( | 489 throw new Error( |
| 488 name + ": expected value of type \'$type\' at index " + ($index) + | 490 name + ": expected value of type \'$type\' at index " + ($index) + |
| 489 " but got " + (typeof result)); | 491 " but got " + (typeof result)); |
| 490 } | 492 } |
| 491 return result; | 493 return result; |
| 492 })()'''; | 494 })()'''; |
| 493 } | 495 } |
| OLD | NEW |