Changeset 783
- Timestamp:
- 12/06/10 05:18:33 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/func.c (modified) (1 diff)
- trunk/src/func.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/func.c
r782 r783 1582 1582 1583 1583 /**************************************************** 1584 1584 * Merge into this function the 'out' contracts of all it overrides. 1585 1585 * 'out's are AND'd together, i.e. all of them need to pass. 1586 1586 */ 1587 1587 1588 1588 Statement *FuncDeclaration::mergeFensure(Statement *sf) 1589 1589 { 1590 1590 /* Same comments as for mergeFrequire(), except that we take care 1591 1591 * of generating a consistent reference to the 'result' local by 1592 1592 * explicitly passing 'result' to the nested function as a reference 1593 1593 * argument. 1594 1594 * This won't work for the 'this' parameter as it would require changing 1595 1595 * the semantic code for the nested function so that it looks on the parameter 1596 1596 * list for the 'this' pointer, something that would need an unknown amount 1597 1597 * of tweaking of various parts of the compiler that I'd rather leave alone. 1598 1598 */ 1599 1599 for (int i = 0; i < foverrides.dim; i++) 1600 1600 { 1601 1601 FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 1602 1603 /* The semantic pass on the contracts of the overridden functions must 1604 * be completed before code generation occurs (bug 3602 and 5230). 1605 */ 1606 if (fdv->fdensure && fdv->fdensure->semanticRun != PASSsemantic3done) 1607 { 1608 assert(fdv->scope); 1609 Scope *sc = fdv->scope->push(); 1610 sc->stc &= ~STCoverride; 1611 fdv->semantic3(sc); 1612 sc->pop(); 1613 } 1614 1602 1615 sf = fdv->mergeFensure(sf); 1603 1616 if (fdv->fdensure) 1604 1617 { 1605 1618 //printf("fdv->fensure: %s\n", fdv->fensure->toChars()); 1606 1619 // Make the call: __ensure(result) 1607 1620 Expression *eresult = NULL; 1608 1621 if (outId) 1609 1622 eresult = new IdentifierExp(loc, outId); 1610 1623 Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdensure), eresult); 1611 1624 Statement *s2 = new ExpStatement(loc, e); 1612 1625 1613 1626 if (sf) 1614 1627 { 1615 1628 sf = new CompoundStatement(fensure->loc, s2, sf); 1616 1629 } 1617 1630 else 1618 1631 sf = s2; 1619 1632 } 1620 1633 } 1621 1634 return sf; trunk/src/func.c
r782 r783 1725 1725 1726 1726 /**************************************************** 1727 1727 * Merge into this function the 'out' contracts of all it overrides. 1728 1728 * 'out's are AND'd together, i.e. all of them need to pass. 1729 1729 */ 1730 1730 1731 1731 Statement *FuncDeclaration::mergeFensure(Statement *sf) 1732 1732 { 1733 1733 /* Same comments as for mergeFrequire(), except that we take care 1734 1734 * of generating a consistent reference to the 'result' local by 1735 1735 * explicitly passing 'result' to the nested function as a reference 1736 1736 * argument. 1737 1737 * This won't work for the 'this' parameter as it would require changing 1738 1738 * the semantic code for the nested function so that it looks on the parameter 1739 1739 * list for the 'this' pointer, something that would need an unknown amount 1740 1740 * of tweaking of various parts of the compiler that I'd rather leave alone. 1741 1741 */ 1742 1742 for (int i = 0; i < foverrides.dim; i++) 1743 1743 { 1744 1744 FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 1745 1746 /* The semantic pass on the contracts of the overridden functions must 1747 * be completed before code generation occurs (bug 3602 and 5230). 1748 */ 1749 if (fdv->fdensure && fdv->fdensure->semanticRun != PASSsemantic3done) 1750 { 1751 assert(fdv->scope); 1752 Scope *sc = fdv->scope->push(); 1753 sc->stc &= ~STCoverride; 1754 fdv->semantic3(sc); 1755 sc->pop(); 1756 } 1757 1745 1758 sf = fdv->mergeFensure(sf); 1746 1759 if (fdv->fdensure) 1747 1760 { 1748 1761 //printf("fdv->fensure: %s\n", fdv->fensure->toChars()); 1749 1762 // Make the call: __ensure(result) 1750 1763 Expression *eresult = NULL; 1751 1764 if (outId) 1752 1765 eresult = new IdentifierExp(loc, outId); 1753 1766 Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdensure, 0), eresult); 1754 1767 Statement *s2 = new ExpStatement(loc, e); 1755 1768 1756 1769 if (sf) 1757 1770 { 1758 1771 sf = new CompoundStatement(fensure->loc, s2, sf); 1759 1772 } 1760 1773 else 1761 1774 sf = s2; 1762 1775 } 1763 1776 } 1764 1777 return sf;
