diff options
author | Jan Dubois <jand@activestate.com> | 1998-03-15 20:09:05 +0100 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1998-03-16 16:18:35 +0000 |
commit | 5476c4332a5540db7fc38bfabed95022b6c04b1b (patch) | |
tree | 151a7f6b71dfab363c9ed5dbf468b9c674b8ab36 /op.c | |
parent | 2ce36478e58aef6258082c58568c0f469f8eb69c (diff) | |
download | perl-5476c4332a5540db7fc38bfabed95022b6c04b1b.tar.gz |
newCONSTSUB added (XSUB equivalent for inlinable sub () { 123 }).
Subject: Bundling builtin.pm and newCONSTSUB with the core?
p4raw-id: //depot/perl@821
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -3516,6 +3516,33 @@ newSUB(I32 floor, OP *o, OP *proto, OP *block) return cv; } +void +newCONSTSUB(HV *stash, char *name, SV *sv) +{ + dTHR; + U32 oldhints = hints; + HV *old_cop_stash = curcop->cop_stash; + HV *old_curstash = curstash; + line_t oldline = curcop->cop_line; + curcop->cop_line = copline; + + hints &= ~HINT_BLOCK_SCOPE; + if(stash) + curstash = curcop->cop_stash = stash; + + newSUB( + MY_start_subparse(FALSE, 0), + newSVOP(OP_CONST, 0, newSVpv(name,0)), + newSVOP(OP_CONST, 0, &sv_no), /* SvPV(&sv_no) == "" -- GMB */ + newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) + ); + + hints = oldhints; + curcop->cop_stash = old_cop_stash; + curstash = old_curstash; + curcop->cop_line = oldline; +} + CV * newXS(char *name, void (*subaddr) (CV *), char *filename) { |