Permalink
Browse files

initial and untested implementation of return with multiple values

  • Loading branch information...
1 parent d670257 commit 4eeeee6d1568edd16926bca972717346cc6a1a4a @NotFound committed Jun 13, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 winxedxx.winxed
View
@@ -1743,22 +1743,26 @@ function emit_foreachstatement(out, forst)
out.print("}\n}\n");
}
-function emit_returnstatement(out, returnst)
+function emit_ReturnStatement(out, returnst)
{
var values = returnst.values;
int nargs = values == null ? 0 : int(values.numargs());
+ out.print("return ");
switch (nargs) {
case 0:
- out.print("return ", Type_PMC, "()");
+ out.print(Type_PMC, "()");
break;
case 1:
var expr = values.getfreearg(0);
- out.print("return ");
emit_expr(out, expr);
break;
default:
- if (__DEBUG__) cry("In " + __FUNCTION__);
- throw WxxUnsupported(returnst);
+ out.print(Type_PMCArray, "()");
+ for (int i = 0; i < nargs; ++i) {
+ out.print(".push(");
+ emit_expr(out, values.getfreearg(i));
+ out.print(")");
+ }
}
}
@@ -1833,7 +1837,7 @@ function emit_statement(out, st)
else if (st instanceof ForeachStatement)
emit_foreachstatement(out, st);
else if (st instanceof ReturnStatement)
- emit_returnstatement(out, st);
+ emit_ReturnStatement(out, st);
else if (st instanceof ExprStatement)
emit_exprst(out, st);
else if (st instanceof EmptyStatement)

0 comments on commit 4eeeee6

Please sign in to comment.