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

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

Issue 871243003: dart2js: store adapters in the model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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) 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// This class should morph into something that makes it easy to build 7 /// This class should morph into something that makes it easy to build
8 /// JavaScript representations of libraries, class-sides, and instance-sides. 8 /// JavaScript representations of libraries, class-sides, and instance-sides.
9 /// Initially, it is just a placeholder for code that is moved from 9 /// Initially, it is just a placeholder for code that is moved from
10 /// [CodeEmitterTask]. 10 /// [CodeEmitterTask].
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias; 288 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias;
289 289
290 final bool needStructuredInfo = 290 final bool needStructuredInfo =
291 canTearOff || canBeReflected || canBeApplied || hasSuperAlias; 291 canTearOff || canBeReflected || canBeApplied || hasSuperAlias;
292 292
293 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); 293 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name);
294 294
295 if (!needStructuredInfo) { 295 if (!needStructuredInfo) {
296 compiler.dumpInfoTask.registerElementAst(member, 296 compiler.dumpInfoTask.registerElementAst(member,
297 builder.addProperty(name, code)); 297 builder.addProperty(name, code));
298 if (needsStubs) { 298 for (AdapterStubMethod adapter in method.adapterStubs) {
299 for (AdapterStubMethod adapter in 299 assert(adapter.callName == null);
300 generateParameterStubs(member, canTearOff: false)) { 300 String invocationName = adapter.name;
301 assert(adapter.callName == null); 301 emitter.interceptorEmitter
302 String invocationName = adapter.name; 302 .recordMangledNameOfMemberMethod(member, invocationName);
303 emitter.interceptorEmitter 303 compiler.dumpInfoTask.registerElementAst(
304 .recordMangledNameOfMemberMethod(member, invocationName); 304 member, builder.addProperty(invocationName, adapter.code));
305 compiler.dumpInfoTask.registerElementAst(
306 member, builder.addProperty(invocationName, adapter.code));
307 }
308 } 305 }
309 return; 306 return;
310 } 307 }
311 emitter.needsStructuredMemberInfo = true; 308 emitter.needsStructuredMemberInfo = true;
312 309
313 // This element is needed for reflection or needs additional stubs or has a 310 // This element is needed for reflection or needs additional stubs or has a
314 // super alias. So we need to retain additional information. 311 // super alias. So we need to retain additional information.
315 312
316 // The information is stored in an array with this format: 313 // The information is stored in an array with this format:
317 // 314 //
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 350
354 if (onlyNeedsSuperAlias) { 351 if (onlyNeedsSuperAlias) {
355 jsAst.ArrayInitializer arrayInit = 352 jsAst.ArrayInitializer arrayInit =
356 new jsAst.ArrayInitializer(expressions); 353 new jsAst.ArrayInitializer(expressions);
357 compiler.dumpInfoTask.registerElementAst(member, 354 compiler.dumpInfoTask.registerElementAst(member,
358 builder.addProperty(name, arrayInit)); 355 builder.addProperty(name, arrayInit));
359 return; 356 return;
360 } 357 }
361 358
362 String callSelectorString = 'null'; 359 String callSelectorString = 'null';
363 if (member.isFunction) { 360 if (method.callName != null) {
364 Selector callSelector = new Selector.fromElement(member).toCallSelector(); 361 callSelectorString = '"${method.callName}"';
365 callSelectorString = '"${namer.invocationName(callSelector)}"';
366 } 362 }
367 363
368 // On [requiredParameterCount], the lower bit is set if this method can be 364 // On [requiredParameterCount], the lower bit is set if this method can be
369 // called reflectively. 365 // called reflectively.
370 int requiredParameterCount = parameters.requiredParameterCount << 1; 366 int requiredParameterCount = parameters.requiredParameterCount << 1;
371 if (member.isAccessor) requiredParameterCount++; 367 if (member.isAccessor) requiredParameterCount++;
372 368
373 int optionalParameterCount = parameters.optionalParameterCount << 1; 369 int optionalParameterCount = parameters.optionalParameterCount << 1;
374 if (parameters.optionalParametersAreNamed) optionalParameterCount++; 370 if (parameters.optionalParametersAreNamed) optionalParameterCount++;
375 371
376 // TODO(sra): Don't use LiteralString for non-strings. 372 // TODO(sra): Don't use LiteralString for non-strings.
377 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; 373 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)];
378 374
379 if (needsStubs || canTearOff) { 375 for (AdapterStubMethod adapter in method.adapterStubs) {
380 for (AdapterStubMethod adapter in 376 String invocationName = adapter.name;
381 generateParameterStubs(member, canTearOff: canTearOff)) { 377 emitter.interceptorEmitter
382 String invocationName = adapter.name; 378 .recordMangledNameOfMemberMethod(member, invocationName);
383 emitter.interceptorEmitter
384 .recordMangledNameOfMemberMethod(member, invocationName);
385 379
386 expressions.add(adapter.code); 380 expressions.add(adapter.code);
387 if (member.isInstanceMember) { 381 if (member.isInstanceMember) {
388 expressions.add(js.string(invocationName)); 382 expressions.add(js.string(invocationName));
389 } else { 383 } else {
390 // TOOD(floitsch): Since we know when reading static data versus 384 // TOOD(floitsch): Since we know when reading static data versus
391 // instance data, we can eliminate this element. 385 // instance data, we can eliminate this element.
392 expressions.add(js('null')); 386 expressions.add(js('null'));
393 }
394 String callName = adapter.callName;
395 String callSelectorString = (callName == null) ? 'null' : '"$callName"';
396 tearOffInfo.add(new jsAst.LiteralString(callSelectorString));
397 } 387 }
388 String callName = adapter.callName;
389 String callSelectorString = (callName == null) ? 'null' : '"$callName"';
390 tearOffInfo.add(new jsAst.LiteralString(callSelectorString));
398 } 391 }
392
399 jsAst.Expression memberTypeExpression; 393 jsAst.Expression memberTypeExpression;
400 if (canTearOff || canBeReflected) { 394 if (canTearOff || canBeReflected) {
401 DartType memberType; 395 DartType memberType;
402 if (member.isGenerativeConstructorBody) { 396 if (member.isGenerativeConstructorBody) {
403 var body = member; 397 var body = member;
404 memberType = body.constructor.type; 398 memberType = body.constructor.type;
405 } else { 399 } else {
406 memberType = member.type; 400 memberType = member.type;
407 } 401 }
408 if (memberType.containsTypeVariables) { 402 if (memberType.containsTypeVariables) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 jsAst.ArrayInitializer arrayInit = 461 jsAst.ArrayInitializer arrayInit =
468 new jsAst.ArrayInitializer(expressions.toList()); 462 new jsAst.ArrayInitializer(expressions.toList());
469 compiler.dumpInfoTask.registerElementAst(member, 463 compiler.dumpInfoTask.registerElementAst(member,
470 builder.addProperty(name, arrayInit)); 464 builder.addProperty(name, arrayInit));
471 } 465 }
472 466
473 void addMemberField(Field field, ClassBuilder builder) { 467 void addMemberField(Field field, ClassBuilder builder) {
474 // For now, do nothing. 468 // For now, do nothing.
475 } 469 }
476 } 470 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698