| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 ddc.src.codegen.js_codegen; | 5 library ddc.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:io' show Directory, File; | 7 import 'dart:io' show Directory, File; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return _addTypeParameters(node.typeParameters, name, _statement(body)); | 308 return _addTypeParameters(node.typeParameters, name, _statement(body)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 /// Generates the implicit default constructor for class C of the form | 311 /// Generates the implicit default constructor for class C of the form |
| 312 /// `C() : super() {}`. | 312 /// `C() : super() {}`. |
| 313 JS.Method _emitImplicitConstructor( | 313 JS.Method _emitImplicitConstructor( |
| 314 ClassDeclaration node, String name, List<FieldDeclaration> fields) { | 314 ClassDeclaration node, String name, List<FieldDeclaration> fields) { |
| 315 // If we don't have a method body, skip this. | 315 // If we don't have a method body, skip this. |
| 316 if (fields.isEmpty) return null; | 316 if (fields.isEmpty) return null; |
| 317 | 317 |
| 318 var body = _initializeFields(fields); | 318 dynamic body = _initializeFields(fields); |
| 319 var superCall = _superConstructorCall(node); | 319 var superCall = _superConstructorCall(node); |
| 320 if (superCall != null) body = [[body, superCall]]; | 320 if (superCall != null) body = [[body, superCall]]; |
| 321 return new JS.Method( | 321 return new JS.Method( |
| 322 new JS.PropertyName(name), js.call('function() { #; }', body)); | 322 new JS.PropertyName(name), js.call('function() { #; }', body)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 JS.Method _emitConstructor(ConstructorDeclaration node, String className, | 325 JS.Method _emitConstructor(ConstructorDeclaration node, String className, |
| 326 List<FieldDeclaration> fields) { | 326 List<FieldDeclaration> fields) { |
| 327 if (_externalOrNative(node)) return null; | 327 if (_externalOrNative(node)) return null; |
| 328 | 328 |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 /// Choose a canonical name from the library element. | 1713 /// Choose a canonical name from the library element. |
| 1714 /// This never uses the library's name (the identifier in the `library` | 1714 /// This never uses the library's name (the identifier in the `library` |
| 1715 /// declaration) as it doesn't have any meaningful rules enforced. | 1715 /// declaration) as it doesn't have any meaningful rules enforced. |
| 1716 String jsLibraryName(LibraryElement library) => canonicalLibraryName(library); | 1716 String jsLibraryName(LibraryElement library) => canonicalLibraryName(library); |
| 1717 | 1717 |
| 1718 /// Path to file that will be generated for [info]. | 1718 /// Path to file that will be generated for [info]. |
| 1719 // TODO(jmesserly): library directory should be relative to its package | 1719 // TODO(jmesserly): library directory should be relative to its package |
| 1720 // root. For example, "package:dev_compiler/src/codegen/js_codegen.dart" would b
e: | 1720 // root. For example, "package:dev_compiler/src/codegen/js_codegen.dart" would b
e: |
| 1721 // "ddc/src/codegen/js_codegen.js" under the output directory. | 1721 // "ddc/src/codegen/js_codegen.js" under the output directory. |
| 1722 String jsOutputPath(LibraryInfo info) => '${info.name}/${info.name}.js'; | 1722 String jsOutputPath(LibraryInfo info) => '${info.name}/${info.name}.js'; |
| OLD | NEW |