| 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.js_emitter.program_builder; | 5 library dart2js.js_emitter.program_builder; |
| 6 | 6 |
| 7 import '../js_emitter.dart' show | 7 import '../js_emitter.dart' show |
| 8 ClassStubGenerator, | 8 ClassStubGenerator, |
| 9 CodeEmitterTask, | 9 CodeEmitterTask, |
| 10 computeMixinClass, | 10 computeMixinClass, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 // Generating stubs for direct calls and stubs for call-through | 410 // Generating stubs for direct calls and stubs for call-through |
| 411 // of getters that happen to be functions. | 411 // of getters that happen to be functions. |
| 412 bool isFunctionLike = false; | 412 bool isFunctionLike = false; |
| 413 FunctionType functionType = null; | 413 FunctionType functionType = null; |
| 414 | 414 |
| 415 if (member.isFunction) { | 415 if (member.isFunction) { |
| 416 FunctionElement fn = member; | 416 FunctionElement fn = member; |
| 417 functionType = fn.type; | 417 functionType = fn.type; |
| 418 } else if (member.isGetter) { | 418 } else if (member.isGetter) { |
| 419 if (_compiler.trustTypeAnnotations) { | 419 if (_compiler.options.trustTypeAnnotations) { |
| 420 GetterElement getter = member; | 420 GetterElement getter = member; |
| 421 DartType returnType = getter.type.returnType; | 421 DartType returnType = getter.type.returnType; |
| 422 if (returnType.isFunctionType) { | 422 if (returnType.isFunctionType) { |
| 423 functionType = returnType; | 423 functionType = returnType; |
| 424 } else if (returnType.treatAsDynamic || | 424 } else if (returnType.treatAsDynamic || |
| 425 _compiler.types.isSubtype(returnType, | 425 _compiler.types.isSubtype(returnType, |
| 426 backend.coreTypes.functionType)) { | 426 backend.coreTypes.functionType)) { |
| 427 if (returnType.isTypedef) { | 427 if (returnType.isTypedef) { |
| 428 TypedefType typedef = returnType; | 428 TypedefType typedef = returnType; |
| 429 // TODO(jacobr): can we just use typdef.unaliased instead? | 429 // TODO(jacobr): can we just use typdef.unaliased instead? |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 List<Field> staticFieldsForReflection = _buildFields(library, visitStatics); | 515 List<Field> staticFieldsForReflection = _buildFields(library, visitStatics); |
| 516 | 516 |
| 517 return new Library(library, uri, statics, classes, | 517 return new Library(library, uri, statics, classes, |
| 518 staticFieldsForReflection); | 518 staticFieldsForReflection); |
| 519 } | 519 } |
| 520 | 520 |
| 521 /// HACK for Incremental Compilation. | 521 /// HACK for Incremental Compilation. |
| 522 /// | 522 /// |
| 523 /// Returns a class that contains the fields of a class. | 523 /// Returns a class that contains the fields of a class. |
| 524 Class buildFieldsHackForIncrementalCompilation(ClassElement element) { | 524 Class buildFieldsHackForIncrementalCompilation(ClassElement element) { |
| 525 assert(_compiler.hasIncrementalSupport); | 525 assert(_compiler.options.hasIncrementalSupport); |
| 526 | 526 |
| 527 List<Field> instanceFields = _buildFields(element, false); | 527 List<Field> instanceFields = _buildFields(element, false); |
| 528 js.Name name = namer.className(element); | 528 js.Name name = namer.className(element); |
| 529 | 529 |
| 530 return new Class( | 530 return new Class( |
| 531 element, name, null, [], instanceFields, [], [], [], [], [], [], null, | 531 element, name, null, [], instanceFields, [], [], [], [], [], [], null, |
| 532 isDirectlyInstantiated: true, | 532 isDirectlyInstantiated: true, |
| 533 onlyForRti: false, | 533 onlyForRti: false, |
| 534 isNative: backend.isNative(element)); | 534 isNative: backend.isNative(element)); |
| 535 } | 535 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 687 } |
| 688 | 688 |
| 689 bool _methodNeedsStubs(FunctionElement method) { | 689 bool _methodNeedsStubs(FunctionElement method) { |
| 690 return !method.functionSignature.optionalParameters.isEmpty; | 690 return !method.functionSignature.optionalParameters.isEmpty; |
| 691 } | 691 } |
| 692 | 692 |
| 693 bool _methodCanBeReflected(FunctionElement method) { | 693 bool _methodCanBeReflected(FunctionElement method) { |
| 694 return backend.isAccessibleByReflection(method) || | 694 return backend.isAccessibleByReflection(method) || |
| 695 // During incremental compilation, we have to assume that reflection | 695 // During incremental compilation, we have to assume that reflection |
| 696 // *might* get enabled. | 696 // *might* get enabled. |
| 697 _compiler.hasIncrementalSupport; | 697 _compiler.options.hasIncrementalSupport; |
| 698 } | 698 } |
| 699 | 699 |
| 700 bool _methodCanBeApplied(FunctionElement method) { | 700 bool _methodCanBeApplied(FunctionElement method) { |
| 701 return _compiler.enabledFunctionApply && | 701 return _compiler.enabledFunctionApply && |
| 702 _compiler.world.getMightBePassedToApply(method); | 702 _compiler.world.getMightBePassedToApply(method); |
| 703 } | 703 } |
| 704 | 704 |
| 705 // TODO(herhut): Refactor incremental compilation and remove method. | 705 // TODO(herhut): Refactor incremental compilation and remove method. |
| 706 Method buildMethodHackForIncrementalCompilation(FunctionElement element) { | 706 Method buildMethodHackForIncrementalCompilation(FunctionElement element) { |
| 707 assert(_compiler.hasIncrementalSupport); | 707 assert(_compiler.options.hasIncrementalSupport); |
| 708 if (element.isInstanceMember) { | 708 if (element.isInstanceMember) { |
| 709 return _buildMethod(element); | 709 return _buildMethod(element); |
| 710 } else { | 710 } else { |
| 711 return _buildStaticMethod(element); | 711 return _buildStaticMethod(element); |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 | 714 |
| 715 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) { | 715 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) { |
| 716 var /* Map | List */ optionalParameterDefaultValues; | 716 var /* Map | List */ optionalParameterDefaultValues; |
| 717 if (signature.optionalParametersAreNamed) { | 717 if (signature.optionalParametersAreNamed) { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 Constant constant = new Constant(name, holder, constantValue); | 1011 Constant constant = new Constant(name, holder, constantValue); |
| 1012 _constants[constantValue] = constant; | 1012 _constants[constantValue] = constant; |
| 1013 } | 1013 } |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 Holder _registerStaticStateHolder() { | 1016 Holder _registerStaticStateHolder() { |
| 1017 return _registry.registerHolder( | 1017 return _registry.registerHolder( |
| 1018 namer.staticStateHolder, isStaticStateHolder: true); | 1018 namer.staticStateHolder, isStaticStateHolder: true); |
| 1019 } | 1019 } |
| 1020 } | 1020 } |
| OLD | NEW |