| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 List<jsAst.Expression> argumentsBuffer = | 55 List<jsAst.Expression> argumentsBuffer = |
| 56 new List<jsAst.Expression>( | 56 new List<jsAst.Expression>( |
| 57 parameters.parameterCount + extraArgumentCount); | 57 parameters.parameterCount + extraArgumentCount); |
| 58 String invocationName = namer.invocationName(selector); | 58 String invocationName = namer.invocationName(selector); |
| 59 | 59 |
| 60 int count = 0; | 60 int count = 0; |
| 61 if (isInterceptedMethod) { | 61 if (isInterceptedMethod) { |
| 62 count++; | 62 count++; |
| 63 parametersBuffer[0] = new jsAst.Parameter(receiverArgumentName); | 63 parametersBuffer[0] = new jsAst.Parameter(receiverArgumentName); |
| 64 argumentsBuffer[0] = js('#', receiverArgumentName); | 64 argumentsBuffer[0] = js('#', receiverArgumentName); |
| 65 emitter.interceptorEmitter.interceptorInvocationNames.add(invocationName); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 int optionalParameterStart = positionalArgumentCount + extraArgumentCount; | 67 int optionalParameterStart = positionalArgumentCount + extraArgumentCount; |
| 69 // Includes extra receiver argument when using interceptor convention | 68 // Includes extra receiver argument when using interceptor convention |
| 70 int indexOfLastOptionalArgumentInParameters = optionalParameterStart - 1; | 69 int indexOfLastOptionalArgumentInParameters = optionalParameterStart - 1; |
| 71 | 70 |
| 72 int parameterIndex = 0; | 71 int parameterIndex = 0; |
| 73 parameters.orderedForEachParameter((ParameterElement element) { | 72 parameters.orderedForEachParameter((ParameterElement element) { |
| 74 String jsName = backend.namer.safeName(element.name); | 73 String jsName = backend.namer.safeName(element.name); |
| 75 assert(jsName != receiverArgumentName); | 74 assert(jsName != receiverArgumentName); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 251 |
| 253 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); | 252 emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name); |
| 254 | 253 |
| 255 if (!needStructuredInfo) { | 254 if (!needStructuredInfo) { |
| 256 compiler.dumpInfoTask.registerElementAst(member, | 255 compiler.dumpInfoTask.registerElementAst(member, |
| 257 builder.addProperty(name, code)); | 256 builder.addProperty(name, code)); |
| 258 if (needsStubs) { | 257 if (needsStubs) { |
| 259 addParameterStubs( | 258 addParameterStubs( |
| 260 member, | 259 member, |
| 261 (Selector selector, jsAst.Fun function) { | 260 (Selector selector, jsAst.Fun function) { |
| 261 String invocationName = namer.invocationName(selector); |
| 262 emitter.interceptorEmitter |
| 263 .recordMangledNameOfMemberMethod(member, invocationName); |
| 262 compiler.dumpInfoTask.registerElementAst(member, | 264 compiler.dumpInfoTask.registerElementAst(member, |
| 263 builder.addProperty(namer.invocationName(selector), | 265 builder.addProperty(invocationName, function)); |
| 264 function)); | |
| 265 }); | 266 }); |
| 266 } | 267 } |
| 267 return; | 268 return; |
| 268 } | 269 } |
| 269 emitter.needsStructuredMemberInfo = true; | 270 emitter.needsStructuredMemberInfo = true; |
| 270 | 271 |
| 271 // This element is needed for reflection or needs additional stubs or has a | 272 // This element is needed for reflection or needs additional stubs or has a |
| 272 // super alias. So we need to retain additional information. | 273 // super alias. So we need to retain additional information. |
| 273 | 274 |
| 274 // The information is stored in an array with this format: | 275 // The information is stored in an array with this format: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (member.isAccessor) requiredParameterCount++; | 330 if (member.isAccessor) requiredParameterCount++; |
| 330 | 331 |
| 331 int optionalParameterCount = parameters.optionalParameterCount << 1; | 332 int optionalParameterCount = parameters.optionalParameterCount << 1; |
| 332 if (parameters.optionalParametersAreNamed) optionalParameterCount++; | 333 if (parameters.optionalParametersAreNamed) optionalParameterCount++; |
| 333 | 334 |
| 334 // TODO(sra): Don't use LiteralString for non-strings. | 335 // TODO(sra): Don't use LiteralString for non-strings. |
| 335 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; | 336 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; |
| 336 | 337 |
| 337 if (needsStubs || canTearOff) { | 338 if (needsStubs || canTearOff) { |
| 338 addParameterStubs(member, (Selector selector, jsAst.Fun function) { | 339 addParameterStubs(member, (Selector selector, jsAst.Fun function) { |
| 340 |
| 341 String invocationName = namer.invocationName(selector); |
| 342 emitter.interceptorEmitter. |
| 343 recordMangledNameOfMemberMethod(member, invocationName); |
| 339 expressions.add(function); | 344 expressions.add(function); |
| 340 if (member.isInstanceMember) { | 345 if (member.isInstanceMember) { |
| 341 Set invokedSelectors = | 346 Set invokedSelectors = |
| 342 compiler.codegenWorld.invokedNames[member.name]; | 347 compiler.codegenWorld.invokedNames[member.name]; |
| 343 expressions.add(js.string(namer.invocationName(selector))); | 348 expressions.add(js.string(invocationName)); |
| 344 } else { | 349 } else { |
| 345 expressions.add(js('null')); | 350 expressions.add(js('null')); |
| 346 // TOOD(ahe): Since we know when reading static data versus instance | 351 // TOOD(ahe): Since we know when reading static data versus instance |
| 347 // data, we can eliminate this element. | 352 // data, we can eliminate this element. |
| 348 } | 353 } |
| 349 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[ | 354 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[ |
| 350 namer.closureInvocationSelectorName]; | 355 namer.closureInvocationSelectorName]; |
| 351 Selector callSelector = selector.toCallSelector(); | 356 Selector callSelector = selector.toCallSelector(); |
| 352 String callSelectorString = 'null'; | 357 String callSelectorString = 'null'; |
| 353 if (canTearOff && callSelectors != null && | 358 if (canTearOff && callSelectors != null && |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 jsAst.ArrayInitializer arrayInit = | 434 jsAst.ArrayInitializer arrayInit = |
| 430 new jsAst.ArrayInitializer(expressions.toList()); | 435 new jsAst.ArrayInitializer(expressions.toList()); |
| 431 compiler.dumpInfoTask.registerElementAst(member, | 436 compiler.dumpInfoTask.registerElementAst(member, |
| 432 builder.addProperty(name, arrayInit)); | 437 builder.addProperty(name, arrayInit)); |
| 433 } | 438 } |
| 434 | 439 |
| 435 void addMemberField(Field field, ClassBuilder builder) { | 440 void addMemberField(Field field, ClassBuilder builder) { |
| 436 // For now, do nothing. | 441 // For now, do nothing. |
| 437 } | 442 } |
| 438 } | 443 } |
| OLD | NEW |