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

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

Issue 887853004: dart2js: Move parameterStub generation to parameter_stub_generator and add parameter stubs to 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 231 }
232 } 232 }
233 } 233 }
234 } 234 }
235 235
236 void addMemberMethod(DartMethod method, ClassBuilder builder) { 236 void addMemberMethod(DartMethod method, ClassBuilder builder) {
237 final FunctionElement member = method.element; 237 final FunctionElement member = method.element;
238 String name = method.name; 238 String name = method.name;
239 final FunctionSignature parameters = member.functionSignature; 239 final FunctionSignature parameters = member.functionSignature;
240 jsAst.Expression code = method.code; 240 jsAst.Expression code = method.code;
241 final bool needsStubs = method.needsStubs; 241 final bool needsStubs = !method.parameterStubs.isEmpty;
242 final bool canTearOff = method.needsTearOff; 242 final bool canTearOff = method.needsTearOff;
243 final String tearOffName = method.tearOffName; 243 final String tearOffName = method.tearOffName;
244 final bool canBeReflected = method.canBeReflected; 244 final bool canBeReflected = method.canBeReflected;
245 final bool canBeApplied = method.canBeApplied; 245 final bool canBeApplied = method.canBeApplied;
246 final bool isClosure = method is InstanceMethod && method.isClosure; 246 final bool isClosure = method is InstanceMethod && method.isClosure;
247 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias; 247 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias;
248 248
249 final bool needStructuredInfo = 249 final bool needStructuredInfo =
250 canTearOff || canBeReflected || canBeApplied || hasSuperAlias; 250 canTearOff || canBeReflected || canBeApplied || hasSuperAlias;
251 251
252 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); 252 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name);
253 253
254 if (!needStructuredInfo) { 254 if (!needStructuredInfo) {
255 compiler.dumpInfoTask.registerElementAst(member, 255 compiler.dumpInfoTask.registerElementAst(member,
256 builder.addProperty(name, code)); 256 builder.addProperty(name, code));
257 if (needsStubs) { 257
258 addParameterStubs( 258 for (ParameterStubMethod method in method.parameterStubs) {
259 member, 259 jsAst.Property property = builder.addProperty(method.name, method.code);
260 (Selector selector, jsAst.Fun function) { 260 compiler.dumpInfoTask.registerElementAst(member, property);
261 String invocationName = namer.invocationName(selector); 261 emitter.interceptorEmitter
262 emitter.interceptorEmitter 262 .recordMangledNameOfMemberMethod(member, method.name);
263 .recordMangledNameOfMemberMethod(member, invocationName);
264 compiler.dumpInfoTask.registerElementAst(member,
265 builder.addProperty(invocationName, function));
266 });
267 } 263 }
268 return; 264 return;
269 } 265 }
270 emitter.needsStructuredMemberInfo = true; 266 emitter.needsStructuredMemberInfo = true;
271 267
272 // This element is needed for reflection or needs additional stubs or has a 268 // This element is needed for reflection or needs additional stubs or has a
273 // super alias. So we need to retain additional information. 269 // super alias. So we need to retain additional information.
274 270
275 // The information is stored in an array with this format: 271 // The information is stored in an array with this format:
276 // 272 //
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 int requiredParameterCount = parameters.requiredParameterCount << 1; 325 int requiredParameterCount = parameters.requiredParameterCount << 1;
330 if (member.isAccessor) requiredParameterCount++; 326 if (member.isAccessor) requiredParameterCount++;
331 327
332 int optionalParameterCount = parameters.optionalParameterCount << 1; 328 int optionalParameterCount = parameters.optionalParameterCount << 1;
333 if (parameters.optionalParametersAreNamed) optionalParameterCount++; 329 if (parameters.optionalParametersAreNamed) optionalParameterCount++;
334 330
335 // TODO(sra): Don't use LiteralString for non-strings. 331 // TODO(sra): Don't use LiteralString for non-strings.
336 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; 332 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)];
337 333
338 if (needsStubs || canTearOff) { 334 if (needsStubs || canTearOff) {
339 addParameterStubs(member, (Selector selector, jsAst.Fun function) {
340 335
341 String invocationName = namer.invocationName(selector); 336 for (ParameterStubMethod method in method.parameterStubs) {
337 String invocationName = method.name;
342 emitter.interceptorEmitter. 338 emitter.interceptorEmitter.
343 recordMangledNameOfMemberMethod(member, invocationName); 339 recordMangledNameOfMemberMethod(member, invocationName);
344 expressions.add(function); 340 expressions.add(method.code);
345 if (member.isInstanceMember) { 341 if (member.isInstanceMember) {
346 Set invokedSelectors = 342 expressions.add(js.string(invocationName));
347 compiler.codegenWorld.invokedNames[member.name];
348 expressions.add(js.string(invocationName));
349 } else { 343 } else {
350 expressions.add(js('null')); 344 expressions.add(js('null'));
351 // TOOD(ahe): Since we know when reading static data versus instance 345 // TOOD(ahe): Since we know when reading static data versus instance
352 // data, we can eliminate this element. 346 // data, we can eliminate this element.
353 } 347 }
348
354 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[ 349 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[
355 namer.closureInvocationSelectorName]; 350 namer.closureInvocationSelectorName];
356 Selector callSelector = selector.toCallSelector(); 351 Selector callSelector = method.selector.toCallSelector();
357 String callSelectorString = 'null'; 352 String callSelectorString = 'null';
358 if (canTearOff && callSelectors != null && 353 if (canTearOff && callSelectors != null &&
359 callSelectors.contains(callSelector)) { 354 callSelectors.contains(callSelector)) {
360 callSelectorString = '"${namer.invocationName(callSelector)}"'; 355 callSelectorString = '"${namer.invocationName(callSelector)}"';
361 } 356 }
362 tearOffInfo.add(new jsAst.LiteralString(callSelectorString)); 357 tearOffInfo.add(new jsAst.LiteralString(callSelectorString));
363 }, canTearOff); 358 }
364 } 359 }
365 360
366 jsAst.Expression memberTypeExpression; 361 jsAst.Expression memberTypeExpression;
367 if (canTearOff || canBeReflected) { 362 if (canTearOff || canBeReflected) {
368 DartType memberType; 363 DartType memberType;
369 if (member.isGenerativeConstructorBody) { 364 if (member.isGenerativeConstructorBody) {
370 var body = member; 365 var body = member;
371 memberType = body.constructor.type; 366 memberType = body.constructor.type;
372 } else { 367 } else {
373 memberType = member.type; 368 memberType = member.type;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 jsAst.ArrayInitializer arrayInit = 429 jsAst.ArrayInitializer arrayInit =
435 new jsAst.ArrayInitializer(expressions.toList()); 430 new jsAst.ArrayInitializer(expressions.toList());
436 compiler.dumpInfoTask.registerElementAst(member, 431 compiler.dumpInfoTask.registerElementAst(member,
437 builder.addProperty(name, arrayInit)); 432 builder.addProperty(name, arrayInit));
438 } 433 }
439 434
440 void addMemberField(Field field, ClassBuilder builder) { 435 void addMemberField(Field field, ClassBuilder builder) {
441 // For now, do nothing. 436 // For now, do nothing.
442 } 437 }
443 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698