diff options
author | Gerard Goossen <gerard@ggoossen.net> | 2011-08-11 09:34:32 +0200 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-11 09:07:14 -0700 |
commit | 86a64801a038eae8c8c1c6f0ba6a8b40aeb8fa8d (patch) | |
tree | 102d71a80cd858fbfe116c3f3042030c3af587a0 /op.c | |
parent | e64345f82d66a32f6da47acf482e7e6c9282b433 (diff) | |
download | perl-86a64801a038eae8c8c1c6f0ba6a8b40aeb8fa8d.tar.gz |
Move context propagation and finalize_optree from do_eval to newPROG
Aborting after errors found by finalize_optree in do_eval wasn't done
properly and would cause memory problems.
This patch moves the context propagation and finalize_optree to
newPROG such that the normal error handling is done.
The eval context blk_gimme is used to communicate the context.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2704,11 +2704,23 @@ Perl_newPROG(pTHX_ OP *o) PERL_ARGS_ASSERT_NEWPROG; if (PL_in_eval) { + PERL_CONTEXT *cx; if (PL_eval_root) return; PL_eval_root = newUNOP(OP_LEAVEEVAL, ((PL_in_eval & EVAL_KEEPERR) ? OPf_SPECIAL : 0), o); + + cx = &cxstack[cxstack_ix]; + assert(CxTYPE(cx) == CXt_EVAL); + + if ((cx->blk_gimme & G_WANT) == G_VOID) + scalarvoid(PL_eval_root); + else if ((cx->blk_gimme & G_WANT) == G_ARRAY) + list(PL_eval_root); + else + scalar(PL_eval_root); + /* don't use LINKLIST, since PL_eval_root might indirect through * a rather expensive function call and LINKLIST evaluates its * argument more than once */ @@ -2717,6 +2729,8 @@ Perl_newPROG(pTHX_ OP *o) OpREFCNT_set(PL_eval_root, 1); PL_eval_root->op_next = 0; CALL_PEEP(PL_eval_start); + finalize_optree(PL_eval_root); + } else { if (o->op_type == OP_STUB) { |