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

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

Issue 2907373002: Use entities for globals in Namer. (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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 ClosureTask, ClosureFieldElement; 10 import '../../closure.dart' show ClosureTask, ClosureFieldElement;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 436
437 StaticField _buildStaticField(FieldElement element) { 437 StaticField _buildStaticField(FieldElement element) {
438 ConstantValue initialValue = 438 ConstantValue initialValue =
439 _constantHandler.getConstantValue(element.constant); 439 _constantHandler.getConstantValue(element.constant);
440 // TODO(zarah): The holder should not be registered during building of 440 // TODO(zarah): The holder should not be registered during building of
441 // a static field. 441 // a static field.
442 _registry.registerHolder(_namer.globalObjectForConstant(initialValue), 442 _registry.registerHolder(_namer.globalObjectForConstant(initialValue),
443 isConstantsHolder: true); 443 isConstantsHolder: true);
444 js.Expression code = _task.emitter.constantReference(initialValue); 444 js.Expression code = _task.emitter.constantReference(initialValue);
445 js.Name name = _namer.globalPropertyName(element); 445 js.Name name = _namer.globalPropertyNameForMember(element);
446 bool isFinal = false; 446 bool isFinal = false;
447 bool isLazy = false; 447 bool isLazy = false;
448 448
449 // TODO(floitsch): we shouldn't update the registry in the middle of 449 // TODO(floitsch): we shouldn't update the registry in the middle of
450 // building a static field. (Note that the static-state holder was 450 // building a static field. (Note that the static-state holder was
451 // already registered earlier, and that we just call the register to get 451 // already registered earlier, and that we just call the register to get
452 // the holder-instance. 452 // the holder-instance.
453 return new StaticField( 453 return new StaticField(
454 element, name, _registerStaticStateHolder(), code, isFinal, isLazy); 454 element, name, _registerStaticStateHolder(), code, isFinal, isLazy);
455 } 455 }
(...skipping 12 matching lines...) Expand all
468 .toList(growable: false); 468 .toList(growable: false);
469 } 469 }
470 470
471 StaticField _buildLazyField(FieldElement element) { 471 StaticField _buildLazyField(FieldElement element) {
472 js.Expression code = _generatedCode[element]; 472 js.Expression code = _generatedCode[element];
473 // The code is null if we ended up not needing the lazily 473 // The code is null if we ended up not needing the lazily
474 // initialized field after all because of constant folding 474 // initialized field after all because of constant folding
475 // before code generation. 475 // before code generation.
476 if (code == null) return null; 476 if (code == null) return null;
477 477
478 js.Name name = _namer.globalPropertyName(element); 478 js.Name name = _namer.globalPropertyNameForMember(element);
479 bool isFinal = element.isFinal; 479 bool isFinal = element.isFinal;
480 bool isLazy = true; 480 bool isLazy = true;
481 // TODO(floitsch): we shouldn't update the registry in the middle of 481 // TODO(floitsch): we shouldn't update the registry in the middle of
482 // building a static field. (Note that the static-state holder was 482 // building a static field. (Note that the static-state holder was
483 // already registered earlier, and that we just call the register to get 483 // already registered earlier, and that we just call the register to get
484 // the holder-instance. 484 // the holder-instance.
485 return new StaticField( 485 return new StaticField(
486 element, name, _registerStaticStateHolder(), code, isFinal, isLazy); 486 element, name, _registerStaticStateHolder(), code, isFinal, isLazy);
487 } 487 }
488 488
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 checkedSetters.add(_buildStubMethod(name, code, element: element)); 780 checkedSetters.add(_buildStubMethod(name, code, element: element));
781 } 781 }
782 } 782 }
783 783
784 typeTests.properties.forEach((js.Name name, js.Node code) { 784 typeTests.properties.forEach((js.Name name, js.Node code) {
785 isChecks.add(_buildStubMethod(name, code)); 785 isChecks.add(_buildStubMethod(name, code));
786 }); 786 });
787 } 787 }
788 788
789 js.Name name = _namer.className(element); 789 js.Name name = _namer.className(element);
790 String holderName = _namer.globalObjectFor(element); 790 String holderName = _namer.globalObjectForClass(element);
791 // TODO(floitsch): we shouldn't update the registry in the middle of 791 // TODO(floitsch): we shouldn't update the registry in the middle of
792 // building a class. 792 // building a class.
793 Holder holder = _registry.registerHolder(holderName); 793 Holder holder = _registry.registerHolder(holderName);
794 bool isInstantiated = !_nativeData.isJsInteropClass(element) && 794 bool isInstantiated = !_nativeData.isJsInteropClass(element) &&
795 _worldBuilder.directlyInstantiatedClasses.contains(element); 795 _worldBuilder.directlyInstantiatedClasses.contains(element);
796 796
797 Class result; 797 Class result;
798 if (element.isMixinApplication && !onlyForRti) { 798 if (element.isMixinApplication && !onlyForRti) {
799 assert(!_nativeData.isNativeClass(element)); 799 assert(!_nativeData.isNativeClass(element));
800 assert(methods.isEmpty); 800 assert(methods.isEmpty);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 List<js.Name> names = _oneShotInterceptorData.oneShotInterceptorNames; 1108 List<js.Name> names = _oneShotInterceptorData.oneShotInterceptorNames;
1109 return names.map((js.Name name) { 1109 return names.map((js.Name name) {
1110 js.Expression code = stubGenerator.generateOneShotInterceptor(name); 1110 js.Expression code = stubGenerator.generateOneShotInterceptor(name);
1111 return new StaticStubMethod(name, holder, code); 1111 return new StaticStubMethod(name, holder, code);
1112 }); 1112 });
1113 } 1113 }
1114 1114
1115 StaticDartMethod _buildStaticMethod(MethodElement element) { 1115 StaticDartMethod _buildStaticMethod(MethodElement element) {
1116 js.Name name = _namer.methodPropertyName(element); 1116 js.Name name = _namer.methodPropertyName(element);
1117 String holder = _namer.globalObjectFor(element); 1117 String holder = _namer.globalObjectForMember(element);
1118 js.Expression code = _generatedCode[element]; 1118 js.Expression code = _generatedCode[element];
1119 1119
1120 bool isApplyTarget = !element.isConstructor && !element.isAccessor; 1120 bool isApplyTarget = !element.isConstructor && !element.isAccessor;
1121 bool canBeApplied = _methodCanBeApplied(element); 1121 bool canBeApplied = _methodCanBeApplied(element);
1122 bool canBeReflected = _methodCanBeReflected(element); 1122 bool canBeReflected = _methodCanBeReflected(element);
1123 1123
1124 bool needsTearOff = isApplyTarget && 1124 bool needsTearOff = isApplyTarget &&
1125 (canBeReflected || 1125 (canBeReflected ||
1126 _worldBuilder.staticFunctionsNeedingGetter.contains(element)); 1126 _worldBuilder.staticFunctionsNeedingGetter.contains(element));
1127 1127
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 Constant constant = new Constant(name, holder, constantValue); 1177 Constant constant = new Constant(name, holder, constantValue);
1178 _constants[constantValue] = constant; 1178 _constants[constantValue] = constant;
1179 } 1179 }
1180 } 1180 }
1181 1181
1182 Holder _registerStaticStateHolder() { 1182 Holder _registerStaticStateHolder() {
1183 return _registry.registerHolder(_namer.staticStateHolder, 1183 return _registry.registerHolder(_namer.staticStateHolder,
1184 isStaticStateHolder: true); 1184 isStaticStateHolder: true);
1185 } 1185 }
1186 } 1186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698