Changeset 586
- Timestamp:
- 07/24/10 23:23:26 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/statement.c (modified) (1 diff)
- trunk/src/statement.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/statement.c
r567 r586 1812 1812 int j = sprintf(fdname, "_aApply%s%.*s%zd", r, 2, fntab[flag], dim); 1813 1813 assert(j < sizeof(fdname)); 1814 1814 FuncDeclaration *fdapply = FuncDeclaration::genCfunc(Type::tindex, fdname); 1815 1815 1816 1816 ec = new VarExp(0, fdapply); 1817 1817 Expressions *exps = new Expressions(); 1818 1818 if (tab->ty == Tsarray) 1819 1819 aggr = aggr->castTo(sc, tn->arrayOf()); 1820 1820 exps->push(aggr); 1821 1821 exps->push(flde); 1822 1822 e = new CallExp(loc, ec, exps); 1823 1823 e->type = Type::tindex; // don't run semantic() on e 1824 1824 } 1825 1825 else if (tab->ty == Tdelegate) 1826 1826 { 1827 1827 /* Call: 1828 1828 * aggr(flde) 1829 1829 */ 1830 1830 Expressions *exps = new Expressions(); 1831 1831 exps->push(flde); 1832 e = new CallExp(loc, aggr, exps); 1832 if (aggr->op == TOKdelegate && 1833 ((DelegateExp *)aggr)->func->isNested()) 1834 // See Bugzilla 3560 1835 e = new CallExp(loc, ((DelegateExp *)aggr)->e1, exps); 1836 else 1837 e = new CallExp(loc, aggr, exps); 1833 1838 e = e->semantic(sc); 1834 1839 if (e->type != Type::tint32) 1835 1840 error("opApply() function for %s must return an int", tab->toChars()); 1836 1841 } 1837 1842 else 1838 1843 { 1839 1844 /* Call: 1840 1845 * aggr.apply(flde) 1841 1846 */ 1842 1847 ec = new DotIdExp(loc, aggr, 1843 1848 (op == TOKforeach_reverse) ? Id::applyReverse 1844 1849 : Id::apply); 1845 1850 Expressions *exps = new Expressions(); 1846 1851 exps->push(flde); 1847 1852 e = new CallExp(loc, ec, exps); 1848 1853 e = e->semantic(sc); 1849 1854 if (e->type != Type::tint32) 1850 1855 error("opApply() function for %s must return an int", tab->toChars()); 1851 1856 } 1852 1857 trunk/src/statement.c
r567 r586 1878 1878 int j = sprintf(fdname, "_aApply%s%.*s%zd", r, 2, fntab[flag], dim); 1879 1879 assert(j < sizeof(fdname)); 1880 1880 FuncDeclaration *fdapply = FuncDeclaration::genCfunc(Type::tindex, fdname); 1881 1881 1882 1882 ec = new VarExp(0, fdapply); 1883 1883 Expressions *exps = new Expressions(); 1884 1884 if (tab->ty == Tsarray) 1885 1885 aggr = aggr->castTo(sc, tn->arrayOf()); 1886 1886 exps->push(aggr); 1887 1887 exps->push(flde); 1888 1888 e = new CallExp(loc, ec, exps); 1889 1889 e->type = Type::tindex; // don't run semantic() on e 1890 1890 } 1891 1891 else if (tab->ty == Tdelegate) 1892 1892 { 1893 1893 /* Call: 1894 1894 * aggr(flde) 1895 1895 */ 1896 1896 Expressions *exps = new Expressions(); 1897 1897 exps->push(flde); 1898 e = new CallExp(loc, aggr, exps); 1898 if (aggr->op == TOKdelegate && 1899 ((DelegateExp *)aggr)->func->isNested()) 1900 // See Bugzilla 3560 1901 e = new CallExp(loc, ((DelegateExp *)aggr)->e1, exps); 1902 else 1903 e = new CallExp(loc, aggr, exps); 1899 1904 e = e->semantic(sc); 1900 1905 if (e->type != Type::tint32) 1901 1906 error("opApply() function for %s must return an int", tab->toChars()); 1902 1907 } 1903 1908 else 1904 1909 { 1905 1910 assert(tab->ty == Tstruct || tab->ty == Tclass); 1906 1911 Expressions *exps = new Expressions(); 1907 1912 if (!sapply) 1908 1913 sapply = search_function((AggregateDeclaration *)tab->toDsymbol(sc), idapply); 1909 1914 #if 0 1910 1915 TemplateDeclaration *td; 1911 1916 if (sapply && 1912 1917 (td = sapply->isTemplateDeclaration()) != NULL) 1913 1918 { /* Call: 1914 1919 * aggr.apply!(fld)() 1915 1920 */ 1916 1921 Objects *tiargs = new Objects(); 1917 1922 tiargs->push(fld); 1918 1923 ec = new DotTemplateInstanceExp(loc, aggr, idapply, tiargs);
