| OLD | NEW |
| 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 /** | 5 /** |
| 6 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // (4) foo$3$c(a, b, c) => foo$4(a, b, c, null); | 332 // (4) foo$3$c(a, b, c) => foo$4(a, b, c, null); |
| 333 // (5) foo$3$d(a, b, d) => foo$4(a, b, null, d); | 333 // (5) foo$3$d(a, b, d) => foo$4(a, b, null, d); |
| 334 // (6) foo$4$c$d(a, b, c, d) => foo$4(a, b, c, d); | 334 // (6) foo$4$c$d(a, b, c, d) => foo$4(a, b, c, d); |
| 335 // (7) Same as (5). | 335 // (7) Same as (5). |
| 336 // | 336 // |
| 337 // We need to generate a stub for (5) because the order of the | 337 // We need to generate a stub for (5) because the order of the |
| 338 // stub arguments and the real method may be different. | 338 // stub arguments and the real method may be different. |
| 339 | 339 |
| 340 int count = 0; | 340 int count = 0; |
| 341 int indexOfLastOptionalArgumentInParameters = positionalArgumentCount - 1; | 341 int indexOfLastOptionalArgumentInParameters = positionalArgumentCount - 1; |
| 342 TreeElements elements = | 342 TreeElements elements = |
| 343 compiler.enqueuer.resolution.getCachedElements(member); | 343 compiler.enqueuer.resolution.getCachedElements(member); |
| 344 | 344 |
| 345 parameters.forEachParameter((Element element) { | 345 parameters.forEachParameter((Element element) { |
| 346 String jsName = JsNames.getValid(element.name.slowToString()); | 346 String jsName = JsNames.getValid(element.name.slowToString()); |
| 347 if (count < positionalArgumentCount) { | 347 if (count < positionalArgumentCount) { |
| 348 parametersBuffer[count] = jsName; | 348 parametersBuffer[count] = jsName; |
| 349 argumentsBuffer[count] = jsName; | 349 argumentsBuffer[count] = jsName; |
| 350 } else { | 350 } else { |
| 351 int index = names.indexOf(element.name); | 351 int index = names.indexOf(element.name); |
| 352 if (index != -1) { | 352 if (index != -1) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 addParameterStubs(member, defineInstanceMember); | 444 addParameterStubs(member, defineInstanceMember); |
| 445 } | 445 } |
| 446 } else if (member.kind !== ElementKind.FIELD) { | 446 } else if (member.kind !== ElementKind.FIELD) { |
| 447 compiler.internalError('unexpected kind: "${member.kind}"', | 447 compiler.internalError('unexpected kind: "${member.kind}"', |
| 448 element: member); | 448 element: member); |
| 449 } | 449 } |
| 450 emitExtraAccessors(member, defineInstanceMember); | 450 emitExtraAccessors(member, defineInstanceMember); |
| 451 } | 451 } |
| 452 | 452 |
| 453 String generateCheckedSetter(Element member, String fieldName) { | 453 String generateCheckedSetter(Element member, String fieldName) { |
| 454 Type type = member.computeType(compiler); | 454 DartType type = member.computeType(compiler); |
| 455 if (type.element.isTypeVariable() | 455 if (type.element.isTypeVariable() |
| 456 || type.element == compiler.dynamicClass | 456 || type.element == compiler.dynamicClass |
| 457 || type.element == compiler.objectClass) { | 457 || type.element == compiler.objectClass) { |
| 458 // TODO(ngeoffray): Support type checks on type parameters. | 458 // TODO(ngeoffray): Support type checks on type parameters. |
| 459 return null; | 459 return null; |
| 460 } else { | 460 } else { |
| 461 SourceString helper = compiler.backend.getCheckedModeHelper(type); | 461 SourceString helper = compiler.backend.getCheckedModeHelper(type); |
| 462 Element helperElement = compiler.findHelper(helper); | 462 Element helperElement = compiler.findHelper(helper); |
| 463 String helperName = compiler.namer.isolateAccess(helperElement); | 463 String helperName = compiler.namer.isolateAccess(helperElement); |
| 464 String additionalArgument = compiler.namer.operatorIs(type.element); | 464 String additionalArgument = compiler.namer.operatorIs(type.element); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 sourceName = token.slowToString(); | 1215 sourceName = token.slowToString(); |
| 1216 } | 1216 } |
| 1217 int totalOffset = bufferOffset + offset; | 1217 int totalOffset = bufferOffset + offset; |
| 1218 sourceMapBuilder.addMapping( | 1218 sourceMapBuilder.addMapping( |
| 1219 sourceFile, token.charOffset, sourceName, totalOffset); | 1219 sourceFile, token.charOffset, sourceName, totalOffset); |
| 1220 }); | 1220 }); |
| 1221 } | 1221 } |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); | 1224 typedef void DefineMemberFunction(String invocationName, CodeBuffer definition); |
| OLD | NEW |