Changeset 782
- Timestamp:
- 12/06/10 00:30:59 (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
r781 r782 1532 1532 * place by definition, since it's an overriding function. The problem is 1533 1533 * getting the 'this' pointer in the same place, since it is a local variable. 1534 1534 * We did some hacks in the code generator to make this happen: 1535 1535 * 1. always generate exception handler frame, or at least leave space for it 1536 1536 * in the frame (Windows 32 SEH only) 1537 1537 * 2. always generate an EBP style frame 1538 1538 * 3. since 'this' is passed in a register that is subsequently copied into 1539 1539 * a stack local, allocate that local immediately following the exception 1540 1540 * handler block, so it is always at the same offset from EBP. 1541 1541 */ 1542 1542 for (int i = 0; i < foverrides.dim; i++) 1543 1543 { 1544 1544 FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 1545 1545 1546 1546 /* The semantic pass on the contracts of the overridden functions must 1547 1547 * be completed before code generation occurs (bug 3602). 1548 1548 */ 1549 1549 if (fdv->fdrequire && fdv->fdrequire->semanticRun != PASSsemantic3done) 1550 1550 { 1551 1551 assert(fdv->scope); 1552 fdv->semantic3(fdv->scope); 1552 Scope *sc = fdv->scope->push(); 1553 sc->stc &= ~STCoverride; 1554 fdv->semantic3(sc); 1555 sc->pop(); 1553 1556 } 1554 1557 1555 1558 sf = fdv->mergeFrequire(sf); 1556 1559 if (fdv->fdrequire) 1557 1560 { 1558 1561 //printf("fdv->frequire: %s\n", fdv->frequire->toChars()); 1559 1562 /* Make the call: 1560 1563 * try { __require(); } 1561 1564 * catch { frequire; } 1562 1565 */ 1563 1566 Expression *eresult = NULL; 1564 1567 Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdrequire), eresult); 1565 1568 Statement *s2 = new ExpStatement(loc, e); 1566 1569 1567 1570 if (sf) 1568 1571 { Catch *c = new Catch(loc, NULL, NULL, sf); 1569 1572 Array *catches = new Array(); 1570 1573 catches->push(c); 1571 1574 sf = new TryCatchStatement(loc, s2, catches); 1572 1575 } trunk/src/func.c
r781 r782 1675 1675 * place by definition, since it's an overriding function. The problem is 1676 1676 * getting the 'this' pointer in the same place, since it is a local variable. 1677 1677 * We did some hacks in the code generator to make this happen: 1678 1678 * 1. always generate exception handler frame, or at least leave space for it 1679 1679 * in the frame (Windows 32 SEH only) 1680 1680 * 2. always generate an EBP style frame 1681 1681 * 3. since 'this' is passed in a register that is subsequently copied into 1682 1682 * a stack local, allocate that local immediately following the exception 1683 1683 * handler block, so it is always at the same offset from EBP. 1684 1684 */ 1685 1685 for (int i = 0; i < foverrides.dim; i++) 1686 1686 { 1687 1687 FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; 1688 1688 1689 1689 /* The semantic pass on the contracts of the overridden functions must 1690 1690 * be completed before code generation occurs (bug 3602). 1691 1691 */ 1692 1692 if (fdv->fdrequire && fdv->fdrequire->semanticRun != PASSsemantic3done) 1693 1693 { 1694 1694 assert(fdv->scope); 1695 fdv->semantic3(fdv->scope); 1695 Scope *sc = fdv->scope->push(); 1696 sc->stc &= ~STCoverride; 1697 fdv->semantic3(sc); 1698 sc->pop(); 1696 1699 } 1697 1700 1698 1701 sf = fdv->mergeFrequire(sf); 1699 1702 if (fdv->fdrequire) 1700 1703 { 1701 1704 //printf("fdv->frequire: %s\n", fdv->frequire->toChars()); 1702 1705 /* Make the call: 1703 1706 * try { __require(); } 1704 1707 * catch { frequire; } 1705 1708 */ 1706 1709 Expression *eresult = NULL; 1707 1710 Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdrequire, 0), eresult); 1708 1711 Statement *s2 = new ExpStatement(loc, e); 1709 1712 1710 1713 if (sf) 1711 1714 { Catch *c = new Catch(loc, NULL, NULL, sf); 1712 1715 Array *catches = new Array(); 1713 1716 catches->push(c); 1714 1717 sf = new TryCatchStatement(loc, s2, catches); 1715 1718 }
