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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend_helpers.dart

Issue 1888803002: Support serialization of all resolved asts from dart:core (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup. Created 4 years, 8 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_backend.helpers; 5 library dart2js.js_backend.helpers;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Identifiers, Uris; 8 import '../common/names.dart' show Identifiers, Uris;
9 import '../common/resolution.dart' show Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
11 import '../core_types.dart' show CoreClasses; 11 import '../core_types.dart' show CoreClasses;
12 import '../elements/elements.dart' 12 import '../elements/elements.dart'
13 show 13 show
14 AbstractFieldElement, 14 AbstractFieldElement,
15 ClassElement, 15 ClassElement,
16 ConstructorElement, 16 ConstructorElement,
17 Element, 17 Element,
18 EnumClassElement, 18 EnumClassElement,
19 FunctionElement, 19 FunctionElement,
20 LibraryElement, 20 LibraryElement,
21 MethodElement; 21 MethodElement,
22 PublicName;
22 import '../library_loader.dart' show LoadedLibraries; 23 import '../library_loader.dart' show LoadedLibraries;
24 import '../universe/call_structure.dart' show CallStructure;
25 import '../universe/selector.dart' show Selector;
23 26
24 import 'js_backend.dart'; 27 import 'js_backend.dart';
25 28
26 /// Helper classes and functions for the JavaScript backend. 29 /// Helper classes and functions for the JavaScript backend.
27 class BackendHelpers { 30 class BackendHelpers {
28 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); 31 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper');
29 static final Uri DART_INTERCEPTORS = 32 static final Uri DART_INTERCEPTORS =
30 new Uri(scheme: 'dart', path: '_interceptors'); 33 new Uri(scheme: 'dart', path: '_interceptors');
31 static final Uri DART_FOREIGN_HELPER = 34 static final Uri DART_FOREIGN_HELPER =
32 new Uri(scheme: 'dart', path: '_foreign_helper'); 35 new Uri(scheme: 'dart', path: '_foreign_helper');
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 170
168 /// Holds the method "requiresPreamble" in _js_helper. 171 /// Holds the method "requiresPreamble" in _js_helper.
169 FunctionElement requiresPreambleMarker; 172 FunctionElement requiresPreambleMarker;
170 173
171 /// Holds the class for the [JsGetName] enum. 174 /// Holds the class for the [JsGetName] enum.
172 EnumClassElement jsGetNameEnum; 175 EnumClassElement jsGetNameEnum;
173 176
174 /// Holds the class for the [JsBuiltins] enum. 177 /// Holds the class for the [JsBuiltins] enum.
175 EnumClassElement jsBuiltinEnum; 178 EnumClassElement jsBuiltinEnum;
176 179
180 ClassElement _symbolImplementationClass;
181 ClassElement get symbolImplementationClass {
Siggi Cherem (dart-lang) 2016/04/14 15:38:20 nit - rewrite as: ClassElement get symbolImplemen
Johnni Winther 2016/04/15 07:27:42 Done.
182 if (_symbolImplementationClass == null) {
183 _symbolImplementationClass = find(internalLibrary, 'Symbol');
184 }
185 return _symbolImplementationClass;
186 }
187
188 final Selector symbolValidatedConstructorSelector =
189 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG);
190
191 ConstructorElement _symbolValidatedConstructor;
192 ConstructorElement get symbolValidatedConstructor {
193 if (_symbolValidatedConstructor == null) {
194 String name = symbolValidatedConstructorSelector.name;
Siggi Cherem (dart-lang) 2016/04/14 15:38:20 Maybe introduce a helper method for these lookups?
Johnni Winther 2016/04/15 07:27:42 Done.
195 symbolImplementationClass.ensureResolved(resolution);
196 _symbolValidatedConstructor =
197 symbolImplementationClass.lookupConstructor(name);
198 assert(invariant(
199 symbolImplementationClass, _symbolValidatedConstructor != null,
200 message: "Constructor '$name' not found in "
201 "'${symbolImplementationClass}'."));
202 }
203 return _symbolValidatedConstructor;
204 }
205
177 // TODO(johnniwinther): Make these private. 206 // TODO(johnniwinther): Make these private.
178 // TODO(johnniwinther): Split into findHelperFunction and findHelperClass and 207 // TODO(johnniwinther): Split into findHelperFunction and findHelperClass and
179 // add a check that the element has the expected kind. 208 // add a check that the element has the expected kind.
180 Element findHelper(String name) => find(jsHelperLibrary, name); 209 Element findHelper(String name) => find(jsHelperLibrary, name);
181 Element findAsyncHelper(String name) => find(asyncLibrary, name); 210 Element findAsyncHelper(String name) => find(asyncLibrary, name);
182 Element findInterceptor(String name) => find(interceptorsLibrary, name); 211 Element findInterceptor(String name) => find(interceptorsLibrary, name);
183 Element find(LibraryElement library, String name) { 212 Element find(LibraryElement library, String name) {
184 Element element = library.implementation.findLocal(name); 213 Element element = library.implementation.findLocal(name);
185 assert(invariant(library, element != null, 214 assert(invariant(library, element != null,
186 message: "Element '$name' not found in '${library.canonicalUri}'.")); 215 message: "Element '$name' not found in '${library.canonicalUri}'."));
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 MethodElement _objectNoSuchMethod; 702 MethodElement _objectNoSuchMethod;
674 703
675 MethodElement get objectNoSuchMethod { 704 MethodElement get objectNoSuchMethod {
676 if (_objectNoSuchMethod == null) { 705 if (_objectNoSuchMethod == null) {
677 _objectNoSuchMethod = 706 _objectNoSuchMethod =
678 coreClasses.objectClass.lookupLocalMember(Identifiers.noSuchMethod_); 707 coreClasses.objectClass.lookupLocalMember(Identifiers.noSuchMethod_);
679 } 708 }
680 return _objectNoSuchMethod; 709 return _objectNoSuchMethod;
681 } 710 }
682 } 711 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/backend_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698