| 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.new_js_emitter.model_emitter; | 5 library dart2js.new_js_emitter.model_emitter; |
| 6 | 6 |
| 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
| 8 import '../../dart2jslib.dart' show Compiler; | 8 import '../../dart2jslib.dart' show Compiler; |
| 9 import '../../dart_types.dart' show DartType; | |
| 10 import '../../elements/elements.dart' show ClassElement, FunctionElement; | 9 import '../../elements/elements.dart' show ClassElement, FunctionElement; |
| 11 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| 12 import '../../js_backend/js_backend.dart' show | 11 import '../../js_backend/js_backend.dart' show |
| 13 JavaScriptBackend, | 12 JavaScriptBackend, |
| 14 Namer, | 13 Namer, |
| 15 ConstantEmitter; | 14 ConstantEmitter; |
| 16 | 15 |
| 17 import '../js_emitter.dart' show | 16 import '../js_emitter.dart' show |
| 18 NativeEmitter; | 17 NativeEmitter; |
| 19 | 18 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 }); | 470 }); |
| 472 } | 471 } |
| 473 | 472 |
| 474 js.Template get templateForReadMetadata { | 473 js.Template get templateForReadMetadata { |
| 475 // TODO(floitsch): make sure that no local variable shadows the access to | 474 // TODO(floitsch): make sure that no local variable shadows the access to |
| 476 // the readMetadata function. | 475 // the readMetadata function. |
| 477 return js.js.expressionTemplateFor('$readMetadataName(#)'); | 476 return js.js.expressionTemplateFor('$readMetadataName(#)'); |
| 478 } | 477 } |
| 479 | 478 |
| 480 List<js.Property> emitMetadata(Program program) { | 479 List<js.Property> emitMetadata(Program program) { |
| 481 // Unparses all given js-expressions (suitable for `expressionCompile`) and | |
| 482 // returns the result in a js-array. | |
| 483 // If the given [expressions] is null returns the empty js-array. | |
| 484 js.ArrayInitializer unparseExpressions(List<js.Expression> expressions) { | |
| 485 if (expressions == null) expressions = <js.Expression>[]; | |
| 486 List<js.LiteralString> unparsedExpressions = expressions | |
| 487 .map((expr) => unparse(compiler, expr, protectForEval: false)) | |
| 488 .toList(); | |
| 489 return new js.ArrayInitializer(unparsedExpressions); | |
| 490 } | |
| 491 | |
| 492 List<js.Property> metadataGlobals = <js.Property>[]; | 480 List<js.Property> metadataGlobals = <js.Property>[]; |
| 493 | 481 |
| 494 js.Property createGlobal(js.Expression metadata, String global) { | 482 js.Property createGlobal(js.Expression metadata, String global) { |
| 495 return new js.Property(js.string(global), metadata); | 483 return new js.Property(js.string(global), metadata); |
| 496 } | 484 } |
| 497 | 485 |
| 498 metadataGlobals.add(createGlobal(program.metadata, METADATA)); | 486 metadataGlobals.add(createGlobal(program.metadata, METADATA)); |
| 499 js.Expression types = | 487 js.Expression types = |
| 500 program.metadataTypesForOutputUnit(program.mainFragment.outputUnit); | 488 program.metadataTypesForOutputUnit(program.mainFragment.outputUnit); |
| 501 metadataGlobals.add(createGlobal(types, TYPES)); | 489 metadataGlobals.add(createGlobal(types, TYPES)); |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 | 1235 |
| 1248 var end = Date.now(); | 1236 var end = Date.now(); |
| 1249 // print('Setup: ' + (end - start) + ' ms.'); | 1237 // print('Setup: ' + (end - start) + ' ms.'); |
| 1250 | 1238 |
| 1251 #invokeMain; // Start main. | 1239 #invokeMain; // Start main. |
| 1252 | 1240 |
| 1253 }(Date.now(), #code) | 1241 }(Date.now(), #code) |
| 1254 }"""; | 1242 }"""; |
| 1255 | 1243 |
| 1256 } | 1244 } |
| OLD | NEW |