Mercurial > projects > ldc
comparison dmd/statement.c @ 1607:207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
---
dmd/arrayop.c | 30 ++++----
dmd/arraytypes.h | 2 +-
dmd/class.c | 8 +-
dmd/declaration.c | 10 ++--
dmd/declaration.h | 16 ++--
dmd/doc.c | 12 ++--
dmd/dsymbol.c | 4 +-
dmd/expression.c | 48 +++++++-------
dmd/expression.h | 32 +++++-----
dmd/func.c | 78 +++++++++++-----------
dmd/init.c | 2 +-
dmd/interpret.c | 8 +-
dmd/mtype.c | 190 ++++++++++++++++++++++++++--------------------------
dmd/mtype.h | 32 +++++-----
dmd/opover.c | 34 +++++-----
dmd/parse.c | 40 ++++++------
dmd/parse.h | 2 +-
dmd/statement.c | 90 +++++++++++++-------------
dmd/statement.h | 14 ++--
dmd/struct.c | 8 +-
dmd/template.c | 30 ++++----
gen/functions.cpp | 10 ++--
gen/functions.h | 2 +-
gen/tocall.cpp | 10 ++--
gen/typinf.cpp | 6 +-
25 files changed, 359 insertions(+), 359 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:20 -0300 |
parents | def7a1d494fd |
children | 44b145be2ef5 |
comparison
equal
deleted
inserted
replaced
1606:1b24e9c7cc26 | 1607:207a8a438dea |
---|---|
1252 buf->writenl(); | 1252 buf->writenl(); |
1253 } | 1253 } |
1254 | 1254 |
1255 /******************************** ForeachStatement ***************************/ | 1255 /******************************** ForeachStatement ***************************/ |
1256 | 1256 |
1257 ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, | 1257 ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, |
1258 Expression *aggr, Statement *body) | 1258 Expression *aggr, Statement *body) |
1259 : Statement(loc) | 1259 : Statement(loc) |
1260 { | 1260 { |
1261 this->op = op; | 1261 this->op = op; |
1262 this->arguments = arguments; | 1262 this->arguments = arguments; |
1269 this->func = NULL; | 1269 this->func = NULL; |
1270 } | 1270 } |
1271 | 1271 |
1272 Statement *ForeachStatement::syntaxCopy() | 1272 Statement *ForeachStatement::syntaxCopy() |
1273 { | 1273 { |
1274 Arguments *args = Argument::arraySyntaxCopy(arguments); | 1274 Parameters *args = Parameter::arraySyntaxCopy(arguments); |
1275 Expression *exp = aggr->syntaxCopy(); | 1275 Expression *exp = aggr->syntaxCopy(); |
1276 ForeachStatement *s = new ForeachStatement(loc, op, args, exp, | 1276 ForeachStatement *s = new ForeachStatement(loc, op, args, exp, |
1277 body ? body->syntaxCopy() : NULL); | 1277 body ? body->syntaxCopy() : NULL); |
1278 return s; | 1278 return s; |
1279 } | 1279 } |
1332 { te = (TupleExp *)aggr; | 1332 { te = (TupleExp *)aggr; |
1333 n = te->exps->dim; | 1333 n = te->exps->dim; |
1334 } | 1334 } |
1335 else if (aggr->op == TOKtype) // type tuple | 1335 else if (aggr->op == TOKtype) // type tuple |
1336 { | 1336 { |
1337 n = Argument::dim(tuple->arguments); | 1337 n = Parameter::dim(tuple->arguments); |
1338 } | 1338 } |
1339 else | 1339 else |
1340 assert(0); | 1340 assert(0); |
1341 for (size_t j = 0; j < n; j++) | 1341 for (size_t j = 0; j < n; j++) |
1342 { size_t k = (op == TOKforeach) ? j : n - 1 - j; | 1342 { size_t k = (op == TOKforeach) ? j : n - 1 - j; |
1343 Expression *e; | 1343 Expression *e; |
1344 Type *t; | 1344 Type *t; |
1345 if (te) | 1345 if (te) |
1346 e = (Expression *)te->exps->data[k]; | 1346 e = (Expression *)te->exps->data[k]; |
1347 else | 1347 else |
1348 t = Argument::getNth(tuple->arguments, k)->type; | 1348 t = Parameter::getNth(tuple->arguments, k)->type; |
1349 Argument *arg = (Argument *)arguments->data[0]; | 1349 Parameter *arg = (Parameter *)arguments->data[0]; |
1350 Statements *st = new Statements(); | 1350 Statements *st = new Statements(); |
1351 | 1351 |
1352 if (dim == 2) | 1352 if (dim == 2) |
1353 { // Declare key | 1353 { // Declare key |
1354 if (arg->storageClass & (STCout | STCref | STClazy)) | 1354 if (arg->storageClass & (STCout | STCref | STClazy)) |
1367 Initializer *ie = new ExpInitializer(0, new IntegerExp(k)); | 1367 Initializer *ie = new ExpInitializer(0, new IntegerExp(k)); |
1368 VarDeclaration *var = new VarDeclaration(loc, arg->type, arg->ident, ie); | 1368 VarDeclaration *var = new VarDeclaration(loc, arg->type, arg->ident, ie); |
1369 var->storage_class |= STCconst; | 1369 var->storage_class |= STCconst; |
1370 DeclarationExp *de = new DeclarationExp(loc, var); | 1370 DeclarationExp *de = new DeclarationExp(loc, var); |
1371 st->push(new ExpStatement(loc, de)); | 1371 st->push(new ExpStatement(loc, de)); |
1372 arg = (Argument *)arguments->data[1]; // value | 1372 arg = (Parameter *)arguments->data[1]; // value |
1373 } | 1373 } |
1374 // Declare value | 1374 // Declare value |
1375 if (arg->storageClass & (STCout | STCref | STClazy)) | 1375 if (arg->storageClass & (STCout | STCref | STClazy)) |
1376 error("no storage class for value %s", arg->ident->toChars()); | 1376 error("no storage class for value %s", arg->ident->toChars()); |
1377 Dsymbol *var; | 1377 Dsymbol *var; |
1408 s = s->semantic(sc); | 1408 s = s->semantic(sc); |
1409 return s; | 1409 return s; |
1410 } | 1410 } |
1411 | 1411 |
1412 for (size_t i = 0; i < dim; i++) | 1412 for (size_t i = 0; i < dim; i++) |
1413 { Argument *arg = (Argument *)arguments->data[i]; | 1413 { Parameter *arg = (Parameter *)arguments->data[i]; |
1414 if (!arg->type) | 1414 if (!arg->type) |
1415 { | 1415 { |
1416 error("cannot infer type for %s", arg->ident->toChars()); | 1416 error("cannot infer type for %s", arg->ident->toChars()); |
1417 return this; | 1417 return this; |
1418 } | 1418 } |
1437 /* Look for special case of parsing char types out of char type | 1437 /* Look for special case of parsing char types out of char type |
1438 * array. | 1438 * array. |
1439 */ | 1439 */ |
1440 tn = tab->nextOf()->toBasetype(); | 1440 tn = tab->nextOf()->toBasetype(); |
1441 if (tn->ty == Tchar || tn->ty == Twchar || tn->ty == Tdchar) | 1441 if (tn->ty == Tchar || tn->ty == Twchar || tn->ty == Tdchar) |
1442 { Argument *arg; | 1442 { Parameter *arg; |
1443 | 1443 |
1444 int i = (dim == 1) ? 0 : 1; // index of value | 1444 int i = (dim == 1) ? 0 : 1; // index of value |
1445 arg = (Argument *)arguments->data[i]; | 1445 arg = (Parameter *)arguments->data[i]; |
1446 arg->type = arg->type->semantic(loc, sc); | 1446 arg->type = arg->type->semantic(loc, sc); |
1447 tnv = arg->type->toBasetype(); | 1447 tnv = arg->type->toBasetype(); |
1448 if (tnv->ty != tn->ty && | 1448 if (tnv->ty != tn->ty && |
1449 (tnv->ty == Tchar || tnv->ty == Twchar || tnv->ty == Tdchar)) | 1449 (tnv->ty == Tchar || tnv->ty == Twchar || tnv->ty == Tdchar)) |
1450 { | 1450 { |
1451 if (arg->storageClass & STCref) | 1451 if (arg->storageClass & STCref) |
1452 error("foreach: value of UTF conversion cannot be ref"); | 1452 error("foreach: value of UTF conversion cannot be ref"); |
1453 if (dim == 2) | 1453 if (dim == 2) |
1454 { arg = (Argument *)arguments->data[0]; | 1454 { arg = (Parameter *)arguments->data[0]; |
1455 if (arg->storageClass & STCref) | 1455 if (arg->storageClass & STCref) |
1456 error("foreach: key cannot be ref"); | 1456 error("foreach: key cannot be ref"); |
1457 } | 1457 } |
1458 goto Lapply; | 1458 goto Lapply; |
1459 } | 1459 } |
1460 } | 1460 } |
1461 | 1461 |
1462 for (size_t i = 0; i < dim; i++) | 1462 for (size_t i = 0; i < dim; i++) |
1463 { // Declare args | 1463 { // Declare args |
1464 Argument *arg = (Argument *)arguments->data[i]; | 1464 Parameter *arg = (Parameter *)arguments->data[i]; |
1465 Type *argtype = arg->type->semantic(loc, sc); | 1465 Type *argtype = arg->type->semantic(loc, sc); |
1466 VarDeclaration *var; | 1466 VarDeclaration *var; |
1467 | 1467 |
1468 var = new VarDeclaration(loc, argtype, arg->ident, NULL); | 1468 var = new VarDeclaration(loc, argtype, arg->ident, NULL); |
1469 var->storage_class |= STCforeach; | 1469 var->storage_class |= STCforeach; |
1637 * auto e = __r.idhead; | 1637 * auto e = __r.idhead; |
1638 */ | 1638 */ |
1639 e = new VarExp(loc, r); | 1639 e = new VarExp(loc, r); |
1640 Expression *einit = new DotIdExp(loc, e, idhead); | 1640 Expression *einit = new DotIdExp(loc, e, idhead); |
1641 // einit = einit->semantic(sc); | 1641 // einit = einit->semantic(sc); |
1642 Argument *arg = (Argument *)arguments->data[0]; | 1642 Parameter *arg = (Parameter *)arguments->data[0]; |
1643 VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit)); | 1643 VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit)); |
1644 ve->storage_class |= STCforeach; | 1644 ve->storage_class |= STCforeach; |
1645 ve->storage_class |= arg->storageClass & (STCin | STCout | STCref | STC_TYPECTOR); | 1645 ve->storage_class |= arg->storageClass & (STCin | STCout | STCref | STC_TYPECTOR); |
1646 | 1646 |
1647 DeclarationExp *de = new DeclarationExp(loc, ve); | 1647 DeclarationExp *de = new DeclarationExp(loc, ve); |
1661 } | 1661 } |
1662 #endif | 1662 #endif |
1663 case Tdelegate: | 1663 case Tdelegate: |
1664 Lapply: | 1664 Lapply: |
1665 { FuncDeclaration *fdapply; | 1665 { FuncDeclaration *fdapply; |
1666 Arguments *args; | 1666 Parameters *args; |
1667 Expression *ec; | 1667 Expression *ec; |
1668 Expression *e; | 1668 Expression *e; |
1669 FuncLiteralDeclaration *fld; | 1669 FuncLiteralDeclaration *fld; |
1670 Argument *a; | 1670 Parameter *a; |
1671 Type *t; | 1671 Type *t; |
1672 Expression *flde; | 1672 Expression *flde; |
1673 Identifier *id; | 1673 Identifier *id; |
1674 Type *tret; | 1674 Type *tret; |
1675 TypeDelegate* dgty; | 1675 TypeDelegate* dgty; |
1692 } | 1692 } |
1693 | 1693 |
1694 /* Turn body into the function literal: | 1694 /* Turn body into the function literal: |
1695 * int delegate(ref T arg) { body } | 1695 * int delegate(ref T arg) { body } |
1696 */ | 1696 */ |
1697 args = new Arguments(); | 1697 args = new Parameters(); |
1698 for (size_t i = 0; i < dim; i++) | 1698 for (size_t i = 0; i < dim; i++) |
1699 { Argument *arg = (Argument *)arguments->data[i]; | 1699 { Parameter *arg = (Parameter *)arguments->data[i]; |
1700 | 1700 |
1701 arg->type = arg->type->semantic(loc, sc); | 1701 arg->type = arg->type->semantic(loc, sc); |
1702 if (arg->storageClass & STCref) | 1702 if (arg->storageClass & STCref) |
1703 id = arg->ident; | 1703 id = arg->ident; |
1704 else | 1704 else |
1712 ie = new ExpInitializer(0, new IdentifierExp(0, id)); | 1712 ie = new ExpInitializer(0, new IdentifierExp(0, id)); |
1713 v = new VarDeclaration(0, arg->type, arg->ident, ie); | 1713 v = new VarDeclaration(0, arg->type, arg->ident, ie); |
1714 s = new DeclarationStatement(0, v); | 1714 s = new DeclarationStatement(0, v); |
1715 body = new CompoundStatement(loc, s, body); | 1715 body = new CompoundStatement(loc, s, body); |
1716 } | 1716 } |
1717 a = new Argument(STCref, arg->type, id, NULL); | 1717 a = new Parameter(STCref, arg->type, id, NULL); |
1718 args->push(a); | 1718 args->push(a); |
1719 } | 1719 } |
1720 t = new TypeFunction(args, Type::tint32, 0, LINKd); | 1720 t = new TypeFunction(args, Type::tint32, 0, LINKd); |
1721 fld = new FuncLiteralDeclaration(loc, 0, t, TOKdelegate, this); | 1721 fld = new FuncLiteralDeclaration(loc, 0, t, TOKdelegate, this); |
1722 fld->fbody = body; | 1722 fld->fbody = body; |
1737 } | 1737 } |
1738 | 1738 |
1739 if (tab->ty == Taarray) | 1739 if (tab->ty == Taarray) |
1740 { | 1740 { |
1741 // Check types | 1741 // Check types |
1742 Argument *arg = (Argument *)arguments->data[0]; | 1742 Parameter *arg = (Parameter *)arguments->data[0]; |
1743 if (dim == 2) | 1743 if (dim == 2) |
1744 { | 1744 { |
1745 if (arg->storageClass & STCref) | 1745 if (arg->storageClass & STCref) |
1746 error("foreach: index cannot be ref"); | 1746 error("foreach: index cannot be ref"); |
1747 if (!arg->type->equals(taa->index)) | 1747 if (!arg->type->equals(taa->index)) |
1748 error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars()); | 1748 error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars()); |
1749 arg = (Argument *)arguments->data[1]; | 1749 arg = (Parameter *)arguments->data[1]; |
1750 } | 1750 } |
1751 if (!arg->type->equals(taa->nextOf())) | 1751 if (!arg->type->equals(taa->nextOf())) |
1752 error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars()); | 1752 error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars()); |
1753 | 1753 |
1754 /* Call: | 1754 /* Call: |
1756 */ | 1756 */ |
1757 //LDC: Build arguments. | 1757 //LDC: Build arguments. |
1758 static FuncDeclaration *aaApply2_fd = NULL; | 1758 static FuncDeclaration *aaApply2_fd = NULL; |
1759 static TypeDelegate* aaApply2_dg; | 1759 static TypeDelegate* aaApply2_dg; |
1760 if(!aaApply2_fd) { | 1760 if(!aaApply2_fd) { |
1761 Arguments* args = new Arguments; | 1761 Parameters* args = new Parameters; |
1762 args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL)); | 1762 args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL)); |
1763 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); | 1763 args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL)); |
1764 Arguments* dgargs = new Arguments; | 1764 Parameters* dgargs = new Parameters; |
1765 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1765 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1766 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1766 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1767 aaApply2_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); | 1767 aaApply2_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); |
1768 args->push(new Argument(STCin, aaApply2_dg, NULL, NULL)); | 1768 args->push(new Parameter(STCin, aaApply2_dg, NULL, NULL)); |
1769 aaApply2_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2"); | 1769 aaApply2_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2"); |
1770 } | 1770 } |
1771 static FuncDeclaration *aaApply_fd = NULL; | 1771 static FuncDeclaration *aaApply_fd = NULL; |
1772 static TypeDelegate* aaApply_dg; | 1772 static TypeDelegate* aaApply_dg; |
1773 if(!aaApply_fd) { | 1773 if(!aaApply_fd) { |
1774 Arguments* args = new Arguments; | 1774 Parameters* args = new Parameters; |
1775 args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL)); | 1775 args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL)); |
1776 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); | 1776 args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL)); |
1777 Arguments* dgargs = new Arguments; | 1777 Parameters* dgargs = new Parameters; |
1778 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1778 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1779 aaApply_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); | 1779 aaApply_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); |
1780 args->push(new Argument(STCin, aaApply_dg, NULL, NULL)); | 1780 args->push(new Parameter(STCin, aaApply_dg, NULL, NULL)); |
1781 aaApply_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply"); | 1781 aaApply_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply"); |
1782 } | 1782 } |
1783 if (dim == 2) { | 1783 if (dim == 2) { |
1784 fdapply = aaApply2_fd; | 1784 fdapply = aaApply2_fd; |
1785 fldeTy = aaApply2_dg; | 1785 fldeTy = aaApply2_dg; |
1837 #else | 1837 #else |
1838 int j = sprintf(fdname, "_aApply%s%.*s%zu", r, 2, fntab[flag], dim); | 1838 int j = sprintf(fdname, "_aApply%s%.*s%zu", r, 2, fntab[flag], dim); |
1839 #endif | 1839 #endif |
1840 assert(j < sizeof(fdname)); | 1840 assert(j < sizeof(fdname)); |
1841 //LDC: Build arguments. | 1841 //LDC: Build arguments. |
1842 Arguments* args = new Arguments; | 1842 Parameters* args = new Parameters; |
1843 args->push(new Argument(STCin, tn->arrayOf(), NULL, NULL)); | 1843 args->push(new Parameter(STCin, tn->arrayOf(), NULL, NULL)); |
1844 if (dim == 2) { | 1844 if (dim == 2) { |
1845 Arguments* dgargs = new Arguments; | 1845 Parameters* dgargs = new Parameters; |
1846 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1846 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1847 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1847 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1848 dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); | 1848 dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); |
1849 args->push(new Argument(STCin, dgty, NULL, NULL)); | 1849 args->push(new Parameter(STCin, dgty, NULL, NULL)); |
1850 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname); | 1850 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname); |
1851 } else { | 1851 } else { |
1852 Arguments* dgargs = new Arguments; | 1852 Parameters* dgargs = new Parameters; |
1853 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL)); | 1853 dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL)); |
1854 dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); | 1854 dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd)); |
1855 args->push(new Argument(STCin, dgty, NULL, NULL)); | 1855 args->push(new Parameter(STCin, dgty, NULL, NULL)); |
1856 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname); | 1856 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname); |
1857 } | 1857 } |
1858 | 1858 |
1859 ec = new VarExp(0, fdapply); | 1859 ec = new VarExp(0, fdapply); |
1860 Expressions *exps = new Expressions(); | 1860 Expressions *exps = new Expressions(); |
1978 { | 1978 { |
1979 buf->writestring(Token::toChars(op)); | 1979 buf->writestring(Token::toChars(op)); |
1980 buf->writestring(" ("); | 1980 buf->writestring(" ("); |
1981 for (int i = 0; i < arguments->dim; i++) | 1981 for (int i = 0; i < arguments->dim; i++) |
1982 { | 1982 { |
1983 Argument *a = (Argument *)arguments->data[i]; | 1983 Parameter *a = (Parameter *)arguments->data[i]; |
1984 if (i) | 1984 if (i) |
1985 buf->writestring(", "); | 1985 buf->writestring(", "); |
1986 if (a->storageClass & STCref) | 1986 if (a->storageClass & STCref) |
1987 buf->writestring((global.params.Dversion == 1) | 1987 buf->writestring((global.params.Dversion == 1) |
1988 ? (char*)"inout " : (char*)"ref "); | 1988 ? (char*)"inout " : (char*)"ref "); |
2005 | 2005 |
2006 /**************************** ForeachRangeStatement ***************************/ | 2006 /**************************** ForeachRangeStatement ***************************/ |
2007 | 2007 |
2008 #if DMDV2 | 2008 #if DMDV2 |
2009 | 2009 |
2010 ForeachRangeStatement::ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | 2010 ForeachRangeStatement::ForeachRangeStatement(Loc loc, enum TOK op, Parameter *arg, |
2011 Expression *lwr, Expression *upr, Statement *body) | 2011 Expression *lwr, Expression *upr, Statement *body) |
2012 : Statement(loc) | 2012 : Statement(loc) |
2013 { | 2013 { |
2014 this->op = op; | 2014 this->op = op; |
2015 this->arg = arg; | 2015 this->arg = arg; |
2213 | 2213 |
2214 #endif | 2214 #endif |
2215 | 2215 |
2216 /******************************** IfStatement ***************************/ | 2216 /******************************** IfStatement ***************************/ |
2217 | 2217 |
2218 IfStatement::IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody) | 2218 IfStatement::IfStatement(Loc loc, Parameter *arg, Expression *condition, Statement *ifbody, Statement *elsebody) |
2219 : Statement(loc) | 2219 : Statement(loc) |
2220 { | 2220 { |
2221 this->arg = arg; | 2221 this->arg = arg; |
2222 this->condition = condition; | 2222 this->condition = condition; |
2223 this->ifbody = ifbody; | 2223 this->ifbody = ifbody; |
2233 | 2233 |
2234 Statement *e = NULL; | 2234 Statement *e = NULL; |
2235 if (elsebody) | 2235 if (elsebody) |
2236 e = elsebody->syntaxCopy(); | 2236 e = elsebody->syntaxCopy(); |
2237 | 2237 |
2238 Argument *a = arg ? arg->syntaxCopy() : NULL; | 2238 Parameter *a = arg ? arg->syntaxCopy() : NULL; |
2239 IfStatement *s = new IfStatement(loc, a, condition->syntaxCopy(), i, e); | 2239 IfStatement *s = new IfStatement(loc, a, condition->syntaxCopy(), i, e); |
2240 return s; | 2240 return s; |
2241 } | 2241 } |
2242 | 2242 |
2243 Statement *IfStatement::semantic(Scope *sc) | 2243 Statement *IfStatement::semantic(Scope *sc) |