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

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

Issue 1221333015: dart2js: Move field-visiting code to the program-builder. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove bad show line. Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '../js_emitter.dart' show computeMixinClass, Emitter; 7 import '../js_emitter.dart' show computeMixinClass, Emitter;
8 import '../model.dart'; 8 import '../model.dart';
9 9
10 import '../../common.dart'; 10 import '../../common.dart';
11 import '../../closure.dart' show ClosureFieldElement;
11 import '../../js/js.dart' as js; 12 import '../../js/js.dart' as js;
12 13
13 import '../../js_backend/js_backend.dart' show 14 import '../../js_backend/js_backend.dart' show
14 Namer, 15 Namer,
15 JavaScriptBackend, 16 JavaScriptBackend,
16 JavaScriptConstantCompiler; 17 JavaScriptConstantCompiler;
17 18
18 import '../js_emitter.dart' show 19 import '../js_emitter.dart' show
19 ClassStubGenerator, 20 ClassStubGenerator,
20 CodeEmitterTask, 21 CodeEmitterTask,
21 InterceptorStubGenerator, 22 InterceptorStubGenerator,
22 MainCallStubGenerator, 23 MainCallStubGenerator,
23 ParameterStubGenerator, 24 ParameterStubGenerator,
24 RuntimeTypeGenerator, 25 RuntimeTypeGenerator,
25 TypeTestProperties; 26 TypeTestProperties;
26 27
27 import '../../elements/elements.dart' show ParameterElement, MethodElement; 28 import '../../elements/elements.dart' show
29 FieldElement,
30 ParameterElement,
31 MethodElement;
28 32
29 import '../../universe/universe.dart' show Universe, TypeMaskSet; 33 import '../../universe/universe.dart' show Universe, TypeMaskSet;
30 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit; 34 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit;
31 35
32 part 'collector.dart'; 36 part 'collector.dart';
33 part 'registry.dart'; 37 part 'registry.dart';
38 part 'field_visitor.dart';
34 39
35 /// Builds a self-contained representation of the program that can then be 40 /// Builds a self-contained representation of the program that can then be
36 /// emitted more easily by the individual emitters. 41 /// emitted more easily by the individual emitters.
37 class ProgramBuilder { 42 class ProgramBuilder {
38 final Compiler _compiler; 43 final Compiler _compiler;
39 final Namer namer; 44 final Namer namer;
40 final CodeEmitterTask _task; 45 final CodeEmitterTask _task;
41 46
42 /// Contains the collected information the program builder used to build 47 /// Contains the collected information the program builder used to build
43 /// the model. 48 /// the model.
44 // The collector will be filled on the first call to `buildProgram`. 49 // The collector will be filled on the first call to `buildProgram`.
45 // It is stored and publicly exposed for backwards compatibility. 50 // It is stored and publicly exposed for backwards compatibility. New code
51 // (and in particular new emitters) should not use it.
46 final Collector collector; 52 final Collector collector;
47 53
48 final Registry _registry; 54 final Registry _registry;
49 55
50 /// True if the program should store function types in the metadata. 56 /// True if the program should store function types in the metadata.
51 bool _storeFunctionTypesInMetadata = false; 57 bool _storeFunctionTypesInMetadata = false;
52 58
53 ProgramBuilder(Compiler compiler, 59 ProgramBuilder(Compiler compiler,
54 Namer namer, 60 Namer namer,
55 this._task, 61 this._task,
56 Emitter emitter, 62 Emitter emitter,
57 Emitter oldEmitter,
58 Set<ClassElement> rtiNeededClasses) 63 Set<ClassElement> rtiNeededClasses)
59 : this._compiler = compiler, 64 : this._compiler = compiler,
60 this.namer = namer, 65 this.namer = namer,
61 this.collector = new Collector( 66 this.collector =
62 compiler, namer, rtiNeededClasses, emitter, oldEmitter), 67 new Collector(compiler, namer, rtiNeededClasses, emitter),
63 this._registry = new Registry(compiler); 68 this._registry = new Registry(compiler);
64 69
65 JavaScriptBackend get backend => _compiler.backend; 70 JavaScriptBackend get backend => _compiler.backend;
66 Universe get universe => _compiler.codegenWorld; 71 Universe get universe => _compiler.codegenWorld;
67 72
68 /// Mapping from [ClassElement] to constructed [Class]. We need this to 73 /// Mapping from [ClassElement] to constructed [Class]. We need this to
69 /// update the superclass in the [Class]. 74 /// update the superclass in the [Class].
70 final Map<ClassElement, Class> _classes = <ClassElement, Class>{}; 75 final Map<ClassElement, Class> _classes = <ClassElement, Class>{};
71 76
72 /// Mapping from [OutputUnit] to constructed [Fragment]. We need this to 77 /// Mapping from [OutputUnit] to constructed [Fragment]. We need this to
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 List<js.Name> names = specializedGetInterceptors.keys.toList()..sort(); 659 List<js.Name> names = specializedGetInterceptors.keys.toList()..sort();
655 return names.map((js.Name name) { 660 return names.map((js.Name name) {
656 Set<ClassElement> classes = specializedGetInterceptors[name]; 661 Set<ClassElement> classes = specializedGetInterceptors[name];
657 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes); 662 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes);
658 return new StaticStubMethod(name, holder, code); 663 return new StaticStubMethod(name, holder, code);
659 }); 664 });
660 } 665 }
661 666
662 List<Field> _buildFields(Element holder, bool visitStatics) { 667 List<Field> _buildFields(Element holder, bool visitStatics) {
663 List<Field> fields = <Field>[]; 668 List<Field> fields = <Field>[];
664 _task.oldEmitter.classEmitter.visitFields( 669 new FieldVisitor(_compiler, namer).visitFields(
665 holder, visitStatics, (VariableElement field, 670 holder, visitStatics, (VariableElement field,
666 js.Name name, 671 js.Name name,
667 js.Name accessorName, 672 js.Name accessorName,
668 bool needsGetter, 673 bool needsGetter,
669 bool needsSetter, 674 bool needsSetter,
670 bool needsCheckedSetter) { 675 bool needsCheckedSetter) {
671 assert(invariant(field, field.isDeclaration)); 676 assert(invariant(field, field.isDeclaration));
672 677
673 int getterFlags = 0; 678 int getterFlags = 0;
674 if (needsGetter) { 679 if (needsGetter) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 _registry.registerConstant(outputUnit, constantValue); 790 _registry.registerConstant(outputUnit, constantValue);
786 assert(!_constants.containsKey(constantValue)); 791 assert(!_constants.containsKey(constantValue));
787 js.Name name = namer.constantName(constantValue); 792 js.Name name = namer.constantName(constantValue);
788 String constantObject = namer.globalObjectForConstant(constantValue); 793 String constantObject = namer.globalObjectForConstant(constantValue);
789 Holder holder = _registry.registerHolder(constantObject); 794 Holder holder = _registry.registerHolder(constantObject);
790 Constant constant = new Constant(name, holder, constantValue); 795 Constant constant = new Constant(name, holder, constantValue);
791 _constants[constantValue] = constant; 796 _constants[constantValue] = constant;
792 } 797 }
793 } 798 }
794 } 799 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698