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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 12086062: Rename mappedBy to map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Undo change to test-script. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 void potentiallyConvertDartClosuresToJs(List<js.Statement> statements, 156 void potentiallyConvertDartClosuresToJs(List<js.Statement> statements,
157 FunctionElement member, 157 FunctionElement member,
158 List<js.Parameter> stubParameters) { 158 List<js.Parameter> stubParameters) {
159 FunctionSignature parameters = member.computeSignature(compiler); 159 FunctionSignature parameters = member.computeSignature(compiler);
160 Element converter = 160 Element converter =
161 compiler.findHelper(const SourceString('convertDartClosureToJS')); 161 compiler.findHelper(const SourceString('convertDartClosureToJS'));
162 String closureConverter = backend.namer.isolateAccess(converter); 162 String closureConverter = backend.namer.isolateAccess(converter);
163 Set<String> stubParameterNames = new Set<String>.from( 163 Set<String> stubParameterNames = new Set<String>.from(
164 stubParameters.mappedBy((param) => param.name)); 164 stubParameters.map((param) => param.name));
165 parameters.forEachParameter((Element parameter) { 165 parameters.forEachParameter((Element parameter) {
166 String name = parameter.name.slowToString(); 166 String name = parameter.name.slowToString();
167 // If [name] is not in [stubParameters], then the parameter is an optional 167 // If [name] is not in [stubParameters], then the parameter is an optional
168 // parameter that was not provided for this stub. 168 // parameter that was not provided for this stub.
169 for (js.Parameter stubParameter in stubParameters) { 169 for (js.Parameter stubParameter in stubParameters) {
170 if (stubParameter.name == name) { 170 if (stubParameter.name == name) {
171 DartType type = parameter.computeType(compiler).unalias(compiler); 171 DartType type = parameter.computeType(compiler).unalias(compiler);
172 if (type is FunctionType) { 172 if (type is FunctionType) {
173 // The parameter type is a function type either directly or through 173 // The parameter type is a function type either directly or through
174 // typedef(s). 174 // typedef(s).
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 List<js.Parameter> parameters) { 248 List<js.Parameter> parameters) {
249 return js.if_( 249 return js.if_(
250 js.use('Object').dot('getPrototypeOf') 250 js.use('Object').dot('getPrototypeOf')
251 .callWith([js.use('this')]) 251 .callWith([js.use('this')])
252 .dot('hasOwnProperty').callWith([js.string(methodName)]), 252 .dot('hasOwnProperty').callWith([js.string(methodName)]),
253 body, 253 body,
254 js.return_( 254 js.return_(
255 js.use('Object').dot('prototype').dot(methodName).dot('call') 255 js.use('Object').dot('prototype').dot(methodName).dot('call')
256 .callWith( 256 .callWith(
257 <js.Expression>[js.use('this')]..addAll( 257 <js.Expression>[js.use('this')]..addAll(
258 parameters.mappedBy((param) => js.use(param.name)))))); 258 parameters.map((param) => js.use(param.name))))));
259 } 259 }
260 260
261 js.Block generateMethodBodyWithPrototypeCheckForElement( 261 js.Block generateMethodBodyWithPrototypeCheckForElement(
262 FunctionElement element, 262 FunctionElement element,
263 js.Block body, 263 js.Block body,
264 List<js.Parameter> parameters) { 264 List<js.Parameter> parameters) {
265 ElementKind kind = element.kind; 265 ElementKind kind = element.kind;
266 if (kind != ElementKind.FUNCTION && 266 if (kind != ElementKind.FUNCTION &&
267 kind != ElementKind.GETTER && 267 kind != ElementKind.GETTER &&
268 kind != ElementKind.SETTER) { 268 kind != ElementKind.SETTER) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 new js.ExpressionStatement( 399 new js.ExpressionStatement(
400 new js.VariableDeclarationList(initializations))); 400 new js.VariableDeclarationList(initializations)));
401 } 401 }
402 402
403 // [table] is a list of lists, each inner list of the form: 403 // [table] is a list of lists, each inner list of the form:
404 // [dynamic-dispatch-tag, tags-of-classes-implementing-dispatch-tag] 404 // [dynamic-dispatch-tag, tags-of-classes-implementing-dispatch-tag]
405 // E.g. 405 // E.g.
406 // [['Node', 'Text|HTMLElement|HTMLDivElement|...'], ...] 406 // [['Node', 'Text|HTMLElement|HTMLDivElement|...'], ...]
407 js.Expression table = 407 js.Expression table =
408 new js.ArrayInitializer.from( 408 new js.ArrayInitializer.from(
409 preorderDispatchClasses.mappedBy((cls) => 409 preorderDispatchClasses.map((cls) =>
410 new js.ArrayInitializer.from([ 410 new js.ArrayInitializer.from([
411 js.string(toNativeTag(cls)), 411 js.string(toNativeTag(cls)),
412 tagDefns[cls]]))); 412 tagDefns[cls]])));
413 413
414 // $.dynamicSetMetadata(table); 414 // $.dynamicSetMetadata(table);
415 statements.add( 415 statements.add(
416 new js.ExpressionStatement( 416 new js.ExpressionStatement(
417 new js.Call( 417 new js.Call(
418 new js.VariableUse(dynamicSetMetadataName), 418 new js.VariableUse(dynamicSetMetadataName),
419 [table]))); 419 [table])));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (emitter.compiler.enableMinification) targetBuffer.add(';'); 537 if (emitter.compiler.enableMinification) targetBuffer.add(';');
538 targetBuffer.add(js.prettyPrint( 538 targetBuffer.add(js.prettyPrint(
539 new js.ExpressionStatement(init), compiler)); 539 new js.ExpressionStatement(init), compiler));
540 targetBuffer.add('\n'); 540 targetBuffer.add('\n');
541 } 541 }
542 542
543 targetBuffer.add(nativeBuffer); 543 targetBuffer.add(nativeBuffer);
544 targetBuffer.add('\n'); 544 targetBuffer.add('\n');
545 } 545 }
546 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698