| 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 '../../closure.dart' show ClosureFieldElement; | 7 import '../../closure.dart' show ClosureFieldElement; |
| 8 import '../../common.dart'; | 8 import '../../common.dart'; |
| 9 import '../../common/names.dart' show Names, Selectors; | 9 import '../../common/names.dart' show Names, Selectors; |
| 10 import '../../compiler.dart' show Compiler; | 10 import '../../compiler.dart' show Compiler; |
| 11 import '../../constants/values.dart' | 11 import '../../constants/values.dart' |
| 12 show ConstantValue, InterceptorConstantValue; | 12 show ConstantValue, InterceptorConstantValue; |
| 13 import '../../core_types.dart' show CommonElements; | 13 import '../../core_types.dart' show CommonElements; |
| 14 import '../../elements/resolution_types.dart' | 14 import '../../elements/resolution_types.dart' |
| 15 show ResolutionDartType, ResolutionFunctionType, ResolutionTypedefType; | 15 show ResolutionDartType, ResolutionFunctionType, ResolutionTypedefType; |
| 16 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit; | 16 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit; |
| 17 import '../../elements/elements.dart' | 17 import '../../elements/elements.dart' |
| 18 show | 18 show |
| 19 ClassElement, | 19 ClassElement, |
| 20 Element, | 20 Element, |
| 21 Elements, | 21 Elements, |
| 22 FieldElement, | 22 FieldElement, |
| 23 FunctionElement, | 23 FunctionElement, |
| 24 FunctionSignature, | 24 FunctionSignature, |
| 25 GetterElement, | 25 GetterElement, |
| 26 LibraryElement, | 26 LibraryElement, |
| 27 MemberElement, |
| 27 MethodElement, | 28 MethodElement, |
| 28 ParameterElement, | 29 ParameterElement, |
| 29 TypedefElement, | 30 TypedefElement, |
| 30 VariableElement; | 31 VariableElement; |
| 31 import '../../js/js.dart' as js; | 32 import '../../js/js.dart' as js; |
| 32 import '../../js_backend/backend_helpers.dart' show BackendHelpers; | 33 import '../../js_backend/backend_helpers.dart' show BackendHelpers; |
| 33 import '../../js_backend/js_backend.dart' | 34 import '../../js_backend/js_backend.dart' |
| 34 show Namer, JavaScriptBackend, JavaScriptConstantCompiler, StringBackedName; | 35 show Namer, JavaScriptBackend, JavaScriptConstantCompiler, StringBackedName; |
| 35 import '../../universe/selector.dart' show Selector; | 36 import '../../universe/selector.dart' show Selector; |
| 36 import '../../universe/world_builder.dart' | 37 import '../../universe/world_builder.dart' |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 518 |
| 518 List<Method> methods = []; | 519 List<Method> methods = []; |
| 519 List<StubMethod> callStubs = <StubMethod>[]; | 520 List<StubMethod> callStubs = <StubMethod>[]; |
| 520 | 521 |
| 521 ClassStubGenerator classStubGenerator = new ClassStubGenerator( | 522 ClassStubGenerator classStubGenerator = new ClassStubGenerator( |
| 522 namer, backend, worldBuilder, closedWorld, | 523 namer, backend, worldBuilder, closedWorld, |
| 523 enableMinification: _compiler.options.enableMinification); | 524 enableMinification: _compiler.options.enableMinification); |
| 524 RuntimeTypeGenerator runtimeTypeGenerator = | 525 RuntimeTypeGenerator runtimeTypeGenerator = |
| 525 new RuntimeTypeGenerator(_compiler, _task, namer); | 526 new RuntimeTypeGenerator(_compiler, _task, namer); |
| 526 | 527 |
| 527 void visitMember(ClassElement enclosing, Element member) { | 528 void visitMember(ClassElement enclosing, MemberElement member) { |
| 528 assert(invariant(element, member.isDeclaration)); | 529 assert(invariant(element, member.isDeclaration)); |
| 529 assert(invariant(element, element == enclosing)); | 530 assert(invariant(element, element == enclosing)); |
| 530 | 531 |
| 531 if (Elements.isNonAbstractInstanceMember(member)) { | 532 if (Elements.isNonAbstractInstanceMember(member)) { |
| 532 // TODO(herhut): Remove once _buildMethod can no longer return null. | 533 // TODO(herhut): Remove once _buildMethod can no longer return null. |
| 533 Method method = _buildMethod(member); | 534 Method method = _buildMethod(member); |
| 534 if (method != null) methods.add(method); | 535 if (method != null) methods.add(method); |
| 535 } | 536 } |
| 536 if (member.isGetter || member.isField) { | 537 if (member.isGetter || member.isField) { |
| 537 Map<Selector, SelectorConstraints> selectors = | 538 Map<Selector, SelectorConstraints> selectors = |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 return names.map((js.Name name) { | 857 return names.map((js.Name name) { |
| 857 Set<ClassElement> classes = specializedGetInterceptors[name]; | 858 Set<ClassElement> classes = specializedGetInterceptors[name]; |
| 858 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes); | 859 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes); |
| 859 return new StaticStubMethod(name, holder, code); | 860 return new StaticStubMethod(name, holder, code); |
| 860 }); | 861 }); |
| 861 } | 862 } |
| 862 | 863 |
| 863 List<Field> _buildFields(Element holder, bool visitStatics) { | 864 List<Field> _buildFields(Element holder, bool visitStatics) { |
| 864 List<Field> fields = <Field>[]; | 865 List<Field> fields = <Field>[]; |
| 865 new FieldVisitor(_compiler, namer, closedWorld) | 866 new FieldVisitor(_compiler, namer, closedWorld) |
| 866 .visitFields(holder, visitStatics, (VariableElement field, | 867 .visitFields(holder, visitStatics, (FieldElement field, |
| 867 js.Name name, | 868 js.Name name, |
| 868 js.Name accessorName, | 869 js.Name accessorName, |
| 869 bool needsGetter, | 870 bool needsGetter, |
| 870 bool needsSetter, | 871 bool needsSetter, |
| 871 bool needsCheckedSetter) { | 872 bool needsCheckedSetter) { |
| 872 assert(invariant(field, field.isDeclaration)); | 873 assert(invariant(field, field.isDeclaration)); |
| 873 | 874 |
| 874 int getterFlags = 0; | 875 int getterFlags = 0; |
| 875 if (needsGetter) { | 876 if (needsGetter) { |
| 876 if (visitStatics || !backend.fieldHasInterceptedGetter(field)) { | 877 if (visitStatics || !backend.fieldHasInterceptedGetter(field)) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 Constant constant = new Constant(name, holder, constantValue); | 988 Constant constant = new Constant(name, holder, constantValue); |
| 988 _constants[constantValue] = constant; | 989 _constants[constantValue] = constant; |
| 989 } | 990 } |
| 990 } | 991 } |
| 991 | 992 |
| 992 Holder _registerStaticStateHolder() { | 993 Holder _registerStaticStateHolder() { |
| 993 return _registry.registerHolder(namer.staticStateHolder, | 994 return _registry.registerHolder(namer.staticStateHolder, |
| 994 isStaticStateHolder: true); | 995 isStaticStateHolder: true); |
| 995 } | 996 } |
| 996 } | 997 } |
| OLD | NEW |