| 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 433 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 if (!checkedSetters.isEmpty()) { | 615 if (!checkedSetters.isEmpty()) { |
| 616 buffer.add(',\n'); | 616 buffer.add(',\n'); |
| 617 buffer.add('${Strings.join(checkedSetters, ",\n")}'); | 617 buffer.add('${Strings.join(checkedSetters, ",\n")}'); |
| 618 } | 618 } |
| 619 emitInstanceMembers(classElement, buffer, true); | 619 emitInstanceMembers(classElement, buffer, true); |
| 620 buffer.add('\n};\n\n'); | 620 buffer.add('\n};\n\n'); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void generateTypeTests(ClassElement cls, | 623 void generateTypeTests(ClassElement cls, |
| 624 void generateTypeTest(ClassElement element)) { | 624 void generateTypeTest(ClassElement element)) { |
| 625 if (compiler.codegenWorld.isChecks.contains(cls)) { | 625 if (compiler.codegenWorld.checkedClasses.contains(cls)) { |
| 626 generateTypeTest(cls); | 626 generateTypeTest(cls); |
| 627 } | 627 } |
| 628 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); | 628 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); |
| 629 } | 629 } |
| 630 | 630 |
| 631 void generateInterfacesIsTests(ClassElement cls, | 631 void generateInterfacesIsTests(ClassElement cls, |
| 632 void generateTypeTest(ClassElement element), | 632 void generateTypeTest(ClassElement element), |
| 633 Set<Element> alreadyGenerated) { | 633 Set<Element> alreadyGenerated) { |
| 634 for (DartType interfaceType in cls.interfaces) { | 634 for (DartType interfaceType in cls.interfaces) { |
| 635 Element element = interfaceType.element; | 635 Element element = interfaceType.element; |
| 636 if (!alreadyGenerated.contains(element) && | 636 if (!alreadyGenerated.contains(element) && |
| 637 compiler.codegenWorld.isChecks.contains(element)) { | 637 compiler.codegenWorld.checkedClasses.contains(element)) { |
| 638 alreadyGenerated.add(element); | 638 alreadyGenerated.add(element); |
| 639 generateTypeTest(element); | 639 generateTypeTest(element); |
| 640 } | 640 } |
| 641 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); | 641 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 | 644 |
| 645 void emitClasses(CodeBuffer buffer) { | 645 void emitClasses(CodeBuffer buffer) { |
| 646 Set<ClassElement> instantiatedClasses = | 646 Set<ClassElement> instantiatedClasses = |
| 647 compiler.codegenWorld.instantiatedClasses; | 647 compiler.codegenWorld.instantiatedClasses; |
| (...skipping 567 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 |