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

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

Issue 2647793003: Use entities in some full_emitter sublibraries (Closed)
Patch Set: Created 3 years, 11 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/full_emitter/interceptor_emitter.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.full_emitter.nsm_emitter; 5 library dart2js.js_emitter.full_emitter.nsm_emitter;
6 6
7 import '../../elements/elements.dart' 7 import '../../elements/entities.dart';
8 show
9 ClassElement,
10 MemberElement;
11 import '../../js/js.dart' as jsAst; 8 import '../../js/js.dart' as jsAst;
12 import '../../js/js.dart' show js; 9 import '../../js/js.dart' show js;
13 import '../../js_backend/js_backend.dart' 10 import '../../js_backend/js_backend.dart' show GetterName, SetterName;
14 show
15 GetterName,
16 SetterName;
17 import '../../universe/selector.dart' show Selector; 11 import '../../universe/selector.dart' show Selector;
18 import '../../util/characters.dart' show $$, $A, $HASH, $Z, $a, $z; 12 import '../../util/characters.dart' show $$, $A, $HASH, $Z, $a, $z;
19 import '../../world.dart' show ClosedWorld; 13 import '../../world.dart' show ClosedWorld;
20 import '../js_emitter.dart' hide Emitter, EmitterFactory; 14 import '../js_emitter.dart' hide Emitter, EmitterFactory;
21 import '../model.dart'; 15 import '../model.dart';
22 import 'emitter.dart'; 16 import 'emitter.dart';
23 17
24 class NsmEmitter extends CodeEmitterHelper { 18 class NsmEmitter extends CodeEmitterHelper {
25 final ClosedWorld closedWorld; 19 final ClosedWorld closedWorld;
26 final List<Selector> trivialNsmHandlers = <Selector>[]; 20 final List<Selector> trivialNsmHandlers = <Selector>[];
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 isTrivialNsmHandler(type, argNames, selector, jsName) && 65 isTrivialNsmHandler(type, argNames, selector, jsName) &&
72 reflectionName == null) { 66 reflectionName == null) {
73 trivialNsmHandlers.add(selector); 67 trivialNsmHandlers.add(selector);
74 } else { 68 } else {
75 StubMethod method = 69 StubMethod method =
76 generator.generateStubForNoSuchMethod(jsName, selector); 70 generator.generateStubForNoSuchMethod(jsName, selector);
77 addProperty(method.name, method.code); 71 addProperty(method.name, method.code);
78 if (reflectionName != null) { 72 if (reflectionName != null) {
79 bool accessible = closedWorld.allFunctions 73 bool accessible = closedWorld.allFunctions
80 .filter(selector, null) 74 .filter(selector, null)
81 .any((MemberElement e) => backend.isAccessibleByReflection(e)); 75 .any(backend.isMemberAccessibleByReflection);
Siggi Cherem (dart-lang) 2017/01/20 17:10:01 am I understanding correctly that the extra check
Johnni Winther 2017/01/23 10:20:06 Yes. This was provoked by the type mismatch, but i
82 addProperty( 76 addProperty(
83 namer.asName('+$reflectionName'), js(accessible ? '2' : '0')); 77 namer.asName('+$reflectionName'), js(accessible ? '2' : '0'));
84 } 78 }
85 } 79 }
86 } 80 }
87 } 81 }
88 82
89 // Identify the noSuchMethod handlers that are so simple that we can 83 // Identify the noSuchMethod handlers that are so simple that we can
90 // generate them programatically. 84 // generate them programatically.
91 bool isTrivialNsmHandler( 85 bool isTrivialNsmHandler(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 js.stringPart(",")), 166 js.stringPart(",")),
173 addQuotes: true); 167 addQuotes: true);
174 168
175 if (!minify) { 169 if (!minify) {
176 sortedLongs = 170 sortedLongs =
177 sorted.map((selector) => selector.invocationMirrorMemberName); 171 sorted.map((selector) => selector.invocationMirrorMemberName);
178 } 172 }
179 } 173 }
180 // Startup code that loops over the method names and puts handlers on the 174 // Startup code that loops over the method names and puts handlers on the
181 // Object class to catch noSuchMethod invocations. 175 // Object class to catch noSuchMethod invocations.
182 ClassElement objectClass = compiler.commonElements.objectClass; 176 ClassEntity objectClass = compiler.commonElements.objectClass;
183 jsAst.Expression createInvocationMirror = backend.emitter 177 jsAst.Expression createInvocationMirror = backend.emitter
184 .staticFunctionAccess(backend.helpers.createInvocationMirror); 178 .staticFunctionAccess(backend.helpers.createInvocationMirror);
185 if (useDiffEncoding) { 179 if (useDiffEncoding) {
186 statements.add(js.statement( 180 statements.add(js.statement(
187 '''{ 181 '''{
188 var objectClassObject = processedClasses.collected[#objectClass], 182 var objectClassObject = processedClasses.collected[#objectClass],
189 nameSequences = #diffEncoding.split("."), 183 nameSequences = #diffEncoding.split("."),
190 shortNames = []; 184 shortNames = [];
191 if (objectClassObject instanceof Array) 185 if (objectClassObject instanceof Array)
192 objectClassObject = objectClassObject[1]; 186 objectClassObject = objectClassObject[1];
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 402 }
409 403
410 String get value { 404 String get value {
411 if (_cachedValue == null) { 405 if (_cachedValue == null) {
412 _cachedValue = _computeDiffEncoding(); 406 _cachedValue = _computeDiffEncoding();
413 } 407 }
414 408
415 return _cachedValue; 409 return _cachedValue;
416 } 410 }
417 } 411 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/full_emitter/interceptor_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698