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

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

Issue 2595493002: Merge CoreTypes and CoreClasses into CommonElements. (Closed)
Patch Set: Updated cf. comment Created 3 years, 12 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 '../../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 CoreClasses; 13 import '../../core_types.dart' show CommonElements;
14 import '../../dart_types.dart' show DartType, FunctionType, TypedefType; 14 import '../../dart_types.dart' show DartType, FunctionType, TypedefType;
15 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit; 15 import '../../deferred_load.dart' show DeferredLoadTask, OutputUnit;
16 import '../../elements/elements.dart' 16 import '../../elements/elements.dart'
17 show 17 show
18 ClassElement, 18 ClassElement,
19 Element, 19 Element,
20 Elements, 20 Elements,
21 FieldElement, 21 FieldElement,
22 FunctionElement, 22 FunctionElement,
23 FunctionSignature, 23 FunctionSignature,
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 List<Library> _buildLibraries(LibrariesMap librariesMap) { 320 List<Library> _buildLibraries(LibrariesMap librariesMap) {
321 List<Library> libraries = new List<Library>(librariesMap.length); 321 List<Library> libraries = new List<Library>(librariesMap.length);
322 int count = 0; 322 int count = 0;
323 librariesMap.forEach((LibraryElement library, List<Element> elements) { 323 librariesMap.forEach((LibraryElement library, List<Element> elements) {
324 libraries[count++] = _buildLibrary(library, elements); 324 libraries[count++] = _buildLibrary(library, elements);
325 }); 325 });
326 return libraries; 326 return libraries;
327 } 327 }
328 328
329 void _addJsInteropStubs(LibrariesMap librariesMap) { 329 void _addJsInteropStubs(LibrariesMap librariesMap) {
330 if (_classes.containsKey(_compiler.coreClasses.objectClass)) { 330 if (_classes.containsKey(_compiler.commonElements.objectClass)) {
331 var toStringInvocation = namer.invocationName(Selectors.toString_); 331 var toStringInvocation = namer.invocationName(Selectors.toString_);
332 // TODO(jacobr): register toString as used so that it is always accessible 332 // TODO(jacobr): register toString as used so that it is always accessible
333 // from JavaScript. 333 // from JavaScript.
334 _classes[_compiler.coreClasses.objectClass].callStubs.add( 334 _classes[_compiler.commonElements.objectClass].callStubs.add(
335 _buildStubMethod(new StringBackedName("toString"), 335 _buildStubMethod(new StringBackedName("toString"),
336 js.js('function() { return this.#(this) }', toStringInvocation))); 336 js.js('function() { return this.#(this) }', toStringInvocation)));
337 } 337 }
338 338
339 // We add all members from classes marked with isJsInterop to the base 339 // We add all members from classes marked with isJsInterop to the base
340 // Interceptor class with implementations that directly call the 340 // Interceptor class with implementations that directly call the
341 // corresponding JavaScript member. We do not attempt to bind this when 341 // corresponding JavaScript member. We do not attempt to bind this when
342 // tearing off JavaScript methods as we cannot distinguish between calling 342 // tearing off JavaScript methods as we cannot distinguish between calling
343 // a regular getter that returns a JavaScript function and tearing off 343 // a regular getter that returns a JavaScript function and tearing off
344 // a method in the case where there exist multiple JavaScript classes 344 // a method in the case where there exist multiple JavaScript classes
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 FunctionElement fn = member; 389 FunctionElement fn = member;
390 functionType = fn.type; 390 functionType = fn.type;
391 } else if (member.isGetter) { 391 } else if (member.isGetter) {
392 if (_compiler.options.trustTypeAnnotations) { 392 if (_compiler.options.trustTypeAnnotations) {
393 GetterElement getter = member; 393 GetterElement getter = member;
394 DartType returnType = getter.type.returnType; 394 DartType returnType = getter.type.returnType;
395 if (returnType.isFunctionType) { 395 if (returnType.isFunctionType) {
396 functionType = returnType; 396 functionType = returnType;
397 } else if (returnType.treatAsDynamic || 397 } else if (returnType.treatAsDynamic ||
398 _compiler.types.isSubtype( 398 _compiler.types.isSubtype(
399 returnType, backend.coreTypes.functionType)) { 399 returnType, backend.commonElements.functionType)) {
400 if (returnType.isTypedef) { 400 if (returnType.isTypedef) {
401 TypedefType typedef = returnType; 401 TypedefType typedef = returnType;
402 // TODO(jacobr): can we just use typdef.unaliased instead? 402 // TODO(jacobr): can we just use typdef.unaliased instead?
403 functionType = typedef.element.functionSignature.type; 403 functionType = typedef.element.functionSignature.type;
404 } else { 404 } else {
405 // Other misc function type such as coreTypes.Function. 405 // Other misc function type such as commonElements.Function.
406 // Allow any number of arguments. 406 // Allow any number of arguments.
407 isFunctionLike = true; 407 isFunctionLike = true;
408 } 408 }
409 } 409 }
410 } else { 410 } else {
411 isFunctionLike = true; 411 isFunctionLike = true;
412 } 412 }
413 } // TODO(jacobr): handle field elements. 413 } // TODO(jacobr): handle field elements.
414 414
415 if (isFunctionLike || functionType != null) { 415 if (isFunctionLike || functionType != null) {
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 Constant constant = new Constant(name, holder, constantValue); 988 Constant constant = new Constant(name, holder, constantValue);
989 _constants[constantValue] = constant; 989 _constants[constantValue] = constant;
990 } 990 }
991 } 991 }
992 992
993 Holder _registerStaticStateHolder() { 993 Holder _registerStaticStateHolder() {
994 return _registry.registerHolder(namer.staticStateHolder, 994 return _registry.registerHolder(namer.staticStateHolder,
995 isStaticStateHolder: true); 995 isStaticStateHolder: true);
996 } 996 }
997 } 997 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698