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

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

Issue 2935663002: Remove Compiler.commonElements (Closed)
Patch Set: Remove Compiler._commonElements 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.startup_emitter; 5 library dart2js.js_emitter.startup_emitter;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' 7 import 'package:js_runtime/shared/embedded_names.dart'
8 show JsBuiltin, METADATA, STATIC_FUNCTION_NAME_TO_CLOSURE, TYPES; 8 show JsBuiltin, METADATA, STATIC_FUNCTION_NAME_TO_CLOSURE, TYPES;
9 9
10 import '../../common.dart'; 10 import '../../common.dart';
(...skipping 22 matching lines...) Expand all
33 @override 33 @override
34 Emitter createEmitter( 34 Emitter createEmitter(
35 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) { 35 CodeEmitterTask task, Namer namer, ClosedWorld closedWorld) {
36 return new Emitter(task.compiler, namer, task.nativeEmitter, closedWorld, 36 return new Emitter(task.compiler, namer, task.nativeEmitter, closedWorld,
37 task, generateSourceMap); 37 task, generateSourceMap);
38 } 38 }
39 } 39 }
40 40
41 class Emitter extends emitterTask.EmitterBase { 41 class Emitter extends emitterTask.EmitterBase {
42 final Compiler _compiler; 42 final Compiler _compiler;
43 final ClosedWorld _closedWorld;
43 final Namer namer; 44 final Namer namer;
44 final ModelEmitter _emitter; 45 final ModelEmitter _emitter;
45 46
46 JavaScriptBackend get _backend => _compiler.backend; 47 JavaScriptBackend get _backend => _compiler.backend;
47 48
48 Emitter( 49 Emitter(this._compiler, this.namer, NativeEmitter nativeEmitter,
49 Compiler compiler, 50 this._closedWorld, CodeEmitterTask task, bool shouldGenerateSourceMap)
50 Namer namer, 51 : _emitter = new ModelEmitter(_compiler, namer, nativeEmitter,
51 NativeEmitter nativeEmitter, 52 _closedWorld, task, shouldGenerateSourceMap);
52 ClosedWorld closedWorld,
53 CodeEmitterTask task,
54 bool shouldGenerateSourceMap)
55 : this._compiler = compiler,
56 this.namer = namer,
57 _emitter = new ModelEmitter(compiler, namer, nativeEmitter, closedWorld,
58 task, shouldGenerateSourceMap);
59 53
60 DiagnosticReporter get reporter => _compiler.reporter; 54 DiagnosticReporter get reporter => _compiler.reporter;
61 55
62 @override 56 @override
63 int emitProgram(ProgramBuilder programBuilder) { 57 int emitProgram(ProgramBuilder programBuilder) {
64 Program program = programBuilder.buildProgram(); 58 Program program = programBuilder.buildProgram();
65 return _emitter.emitProgram(program); 59 return _emitter.emitProgram(program);
66 } 60 }
67 61
68 @override 62 @override
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 hasBeenInstantiated ? constructorAccess(element) : typeAccess(element); 105 hasBeenInstantiated ? constructorAccess(element) : typeAccess(element);
112 return js.js('#.prototype', constructor); 106 return js.js('#.prototype', constructor);
113 } 107 }
114 108
115 @override 109 @override
116 js.Template templateForBuiltin(JsBuiltin builtin) { 110 js.Template templateForBuiltin(JsBuiltin builtin) {
117 String typeNameProperty = ModelEmitter.typeNameProperty; 111 String typeNameProperty = ModelEmitter.typeNameProperty;
118 112
119 switch (builtin) { 113 switch (builtin) {
120 case JsBuiltin.dartObjectConstructor: 114 case JsBuiltin.dartObjectConstructor:
121 ClassElement objectClass = _compiler.commonElements.objectClass; 115 ClassElement objectClass = _closedWorld.commonElements.objectClass;
122 return js.js.expressionTemplateYielding(typeAccess(objectClass)); 116 return js.js.expressionTemplateYielding(typeAccess(objectClass));
123 117
124 case JsBuiltin.isCheckPropertyToJsConstructorName: 118 case JsBuiltin.isCheckPropertyToJsConstructorName:
125 int isPrefixLength = namer.operatorIsPrefix.length; 119 int isPrefixLength = namer.operatorIsPrefix.length;
126 return js.js.expressionTemplateFor('#.substring($isPrefixLength)'); 120 return js.js.expressionTemplateFor('#.substring($isPrefixLength)');
127 121
128 case JsBuiltin.isFunctionType: 122 case JsBuiltin.isFunctionType:
129 return _backend.rtiEncoder.templateForIsFunctionType; 123 return _backend.rtiEncoder.templateForIsFunctionType;
130 124
131 case JsBuiltin.rawRtiToJsConstructorName: 125 case JsBuiltin.rawRtiToJsConstructorName:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 161 }
168 } 162 }
169 163
170 @override 164 @override
171 int generatedSize(OutputUnit unit) { 165 int generatedSize(OutputUnit unit) {
172 Fragment key = _emitter.outputBuffers.keys 166 Fragment key = _emitter.outputBuffers.keys
173 .firstWhere((Fragment fragment) => fragment.outputUnit == unit); 167 .firstWhere((Fragment fragment) => fragment.outputUnit == unit);
174 return _emitter.outputBuffers[key].length; 168 return _emitter.outputBuffers[key].length;
175 } 169 }
176 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698