Skip to content

Commit

Permalink
initial and untested implementation of return with multiple values
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFound committed Jun 13, 2012
1 parent d670257 commit 4eeeee6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions winxedxx.winxed
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1743,22 +1743,26 @@ function emit_foreachstatement(out, forst)
out.print("}\n}\n"); out.print("}\n}\n");
} }


function emit_returnstatement(out, returnst) function emit_ReturnStatement(out, returnst)
{ {
var values = returnst.values; var values = returnst.values;
int nargs = values == null ? 0 : int(values.numargs()); int nargs = values == null ? 0 : int(values.numargs());
out.print("return ");
switch (nargs) { switch (nargs) {
case 0: case 0:
out.print("return ", Type_PMC, "()"); out.print(Type_PMC, "()");
break; break;
case 1: case 1:
var expr = values.getfreearg(0); var expr = values.getfreearg(0);
out.print("return ");
emit_expr(out, expr); emit_expr(out, expr);
break; break;
default: default:
if (__DEBUG__) cry("In " + __FUNCTION__); out.print(Type_PMCArray, "()");
throw WxxUnsupported(returnst); for (int i = 0; i < nargs; ++i) {
out.print(".push(");
emit_expr(out, values.getfreearg(i));
out.print(")");
}
} }
} }


Expand Down Expand Up @@ -1833,7 +1837,7 @@ function emit_statement(out, st)
else if (st instanceof ForeachStatement) else if (st instanceof ForeachStatement)
emit_foreachstatement(out, st); emit_foreachstatement(out, st);
else if (st instanceof ReturnStatement) else if (st instanceof ReturnStatement)
emit_returnstatement(out, st); emit_ReturnStatement(out, st);
else if (st instanceof ExprStatement) else if (st instanceof ExprStatement)
emit_exprst(out, st); emit_exprst(out, st);
else if (st instanceof EmptyStatement) else if (st instanceof EmptyStatement)
Expand Down

0 comments on commit 4eeeee6

Please sign in to comment.