Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Issue 2954463002: Refactoring to prepare for kernel based jump targets (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'dart:io'; 7 import 'dart:io';
8 import 'dart:convert' show JSON; 8 import 'dart:convert' show JSON;
9 9
10 import '../../closure.dart' show ClosureConversionTask, ClosureFieldElement; 10 import '../../closure.dart' show ClosureConversionTask, ClosureFieldElement;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // tearing off JavaScript methods as we cannot distinguish between calling 518 // tearing off JavaScript methods as we cannot distinguish between calling
519 // a regular getter that returns a JavaScript function and tearing off 519 // a regular getter that returns a JavaScript function and tearing off
520 // a method in the case where there exist multiple JavaScript classes 520 // a method in the case where there exist multiple JavaScript classes
521 // that conflict on whether the member is a getter or a method. 521 // that conflict on whether the member is a getter or a method.
522 var interceptorClass = _classes[_commonElements.jsJavaScriptObjectClass]; 522 var interceptorClass = _classes[_commonElements.jsJavaScriptObjectClass];
523 var stubNames = new Set<String>(); 523 var stubNames = new Set<String>();
524 librariesMap 524 librariesMap
525 .forEach((LibraryEntity library, List<ClassEntity> classElements, _) { 525 .forEach((LibraryEntity library, List<ClassEntity> classElements, _) {
526 for (ClassEntity cls in classElements) { 526 for (ClassEntity cls in classElements) {
527 if (_nativeData.isJsInteropClass(cls)) { 527 if (_nativeData.isJsInteropClass(cls)) {
528 // TODO(johnniwinther): Handle class entities. 528 // TODO(redemption): Handle class entities.
529 ClassElement e = cls; 529 ClassElement e = cls;
530 e.declaration.forEachMember((_, _member) { 530 e.declaration.forEachMember((_, _member) {
531 MemberElement member = _member; 531 MemberElement member = _member;
532 var jsName = _nativeData.computeUnescapedJSInteropName(member.name); 532 var jsName = _nativeData.computeUnescapedJSInteropName(member.name);
533 if (!member.isInstanceMember) return; 533 if (!member.isInstanceMember) return;
534 if (member.isGetter || member.isField || member.isFunction) { 534 if (member.isGetter || member.isField || member.isFunction) {
535 var selectors = 535 var selectors =
536 _worldBuilder.getterInvocationsByName(member.name); 536 _worldBuilder.getterInvocationsByName(member.name);
537 if (selectors != null && !selectors.isEmpty) { 537 if (selectors != null && !selectors.isEmpty) {
538 for (var selector in selectors.keys) { 538 for (var selector in selectors.keys) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 js.Name name = _namer.getterForMember(Names.call); 748 js.Name name = _namer.getterForMember(Names.call);
749 js.Fun function = js.js('function() { return this; }'); 749 js.Fun function = js.js('function() { return this; }');
750 callStubs.add(_buildStubMethod(name, function)); 750 callStubs.add(_buildStubMethod(name, function));
751 } 751 }
752 752
753 // MixinApplications run through the members of their mixin. Here, we are 753 // MixinApplications run through the members of their mixin. Here, we are
754 // only interested in direct members. 754 // only interested in direct members.
755 if (!onlyForRti && !_elementEnvironment.isMixinApplication(cls)) { 755 if (!onlyForRti && !_elementEnvironment.isMixinApplication(cls)) {
756 _elementEnvironment.forEachClassMember(cls, visitMember); 756 _elementEnvironment.forEachClassMember(cls, visitMember);
757 if (cls is ClassElement) { 757 if (cls is ClassElement) {
758 // TODO(johnniwinther): Support constructor bodies for entities. 758 // TODO(redemption): Support constructor bodies for entities.
759 cls.forEachConstructorBody((ConstructorBodyElement constructorBody) => 759 cls.forEachConstructorBody((ConstructorBodyElement constructorBody) =>
760 visitMember(cls, constructorBody)); 760 visitMember(cls, constructorBody));
761 } 761 }
762 } 762 }
763 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls); 763 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls);
764 List<Field> instanceFields = onlyForRti 764 List<Field> instanceFields = onlyForRti
765 ? const <Field>[] 765 ? const <Field>[]
766 : _buildFields( 766 : _buildFields(
767 cls: cls, 767 cls: cls,
768 visitStatics: false, 768 visitStatics: false,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 DartType memberType = _elementEnvironment.getFunctionType(element); 940 DartType memberType = _elementEnvironment.getFunctionType(element);
941 js.Expression functionType; 941 js.Expression functionType;
942 if (canTearOff || canBeReflected) { 942 if (canTearOff || canBeReflected) {
943 OutputUnit outputUnit = _deferredLoadTask.outputUnitForMember(element); 943 OutputUnit outputUnit = _deferredLoadTask.outputUnitForMember(element);
944 functionType = _generateFunctionType(memberType, outputUnit); 944 functionType = _generateFunctionType(memberType, outputUnit);
945 } 945 }
946 946
947 int requiredParameterCount; 947 int requiredParameterCount;
948 var /* List | Map */ optionalParameterDefaultValues; 948 var /* List | Map */ optionalParameterDefaultValues;
949 if (canBeApplied || canBeReflected) { 949 if (canBeApplied || canBeReflected) {
950 // TODO(johnniwinther): Handle function entities. 950 // TODO(redemption): Handle function entities.
951 MethodElement method = element; 951 MethodElement method = element;
952 FunctionSignature signature = method.functionSignature; 952 FunctionSignature signature = method.functionSignature;
953 requiredParameterCount = signature.requiredParameterCount; 953 requiredParameterCount = signature.requiredParameterCount;
954 optionalParameterDefaultValues = 954 optionalParameterDefaultValues =
955 _computeParameterDefaultValues(signature); 955 _computeParameterDefaultValues(signature);
956 } 956 }
957 957
958 return new InstanceMethod(element, name, code, 958 return new InstanceMethod(element, name, code,
959 _generateParameterStubs(element, canTearOff), callName, 959 _generateParameterStubs(element, canTearOff), callName,
960 needsTearOff: canTearOff, 960 needsTearOff: canTearOff,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 js.Expression functionType; 1148 js.Expression functionType;
1149 DartType type = _elementEnvironment.getFunctionType(element); 1149 DartType type = _elementEnvironment.getFunctionType(element);
1150 if (needsTearOff || canBeReflected) { 1150 if (needsTearOff || canBeReflected) {
1151 OutputUnit outputUnit = _deferredLoadTask.outputUnitForMember(element); 1151 OutputUnit outputUnit = _deferredLoadTask.outputUnitForMember(element);
1152 functionType = _generateFunctionType(type, outputUnit); 1152 functionType = _generateFunctionType(type, outputUnit);
1153 } 1153 }
1154 1154
1155 int requiredParameterCount; 1155 int requiredParameterCount;
1156 var /* List | Map */ optionalParameterDefaultValues; 1156 var /* List | Map */ optionalParameterDefaultValues;
1157 if (canBeApplied || canBeReflected) { 1157 if (canBeApplied || canBeReflected) {
1158 // TODO(johnniwinther): Support entities; 1158 // TODO(redemption): Support entities;
1159 MethodElement method = element; 1159 MethodElement method = element;
1160 FunctionSignature signature = method.functionSignature; 1160 FunctionSignature signature = method.functionSignature;
1161 requiredParameterCount = signature.requiredParameterCount; 1161 requiredParameterCount = signature.requiredParameterCount;
1162 optionalParameterDefaultValues = 1162 optionalParameterDefaultValues =
1163 _computeParameterDefaultValues(signature); 1163 _computeParameterDefaultValues(signature);
1164 } 1164 }
1165 1165
1166 // TODO(floitsch): we shouldn't update the registry in the middle of 1166 // TODO(floitsch): we shouldn't update the registry in the middle of
1167 // building a static method. 1167 // building a static method.
1168 return new StaticDartMethod(element, name, _registry.registerHolder(holder), 1168 return new StaticDartMethod(element, name, _registry.registerHolder(holder),
(...skipping 21 matching lines...) Expand all
1190 Constant constant = new Constant(name, holder, constantValue); 1190 Constant constant = new Constant(name, holder, constantValue);
1191 _constants[constantValue] = constant; 1191 _constants[constantValue] = constant;
1192 } 1192 }
1193 } 1193 }
1194 1194
1195 Holder _registerStaticStateHolder() { 1195 Holder _registerStaticStateHolder() {
1196 return _registry.registerHolder(_namer.staticStateHolder, 1196 return _registry.registerHolder(_namer.staticStateHolder,
1197 isStaticStateHolder: true); 1197 isStaticStateHolder: true);
1198 } 1198 }
1199 } 1199 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/metadata_collector.dart ('k') | pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698