rehsack has asked for the wisdom of the Perl Monks concerning the following question:
Why is it necessary to save ax and why isn't it documented in perlcall (http://search.cpan.org/~rgarcia/perl-5.10.0/pod/perlcall.pod#Using_Perl_to_dispose_of_temporaries)? Did I understand sth. wrong and made another mistake?void _INSTANCE(ref,type) SV *ref; char *type; PROTOTYPE: $$ CODE: { STRLEN len; if( SvROK(ref) && type && ( ( len = strlen(type) ) > 0 ) ) { if( SvMAGICAL(ref) ) mg_get(ref); if( sv_isobject(ref) ) { if( sv_derived_from(ref,type) ) { ST(0) = ref; XSRETURN(1); } else { I32 isa_type = 0; int count; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( sv_2mortal( newSVsv( ref ) ) ); XPUSHs( sv_2mortal( newSVpv( type, len ) ) ); PUTBACK; if( ( count = call_method("isa", G_SCALAR) ) ) { I32 oldax = ax; SPAGAIN; SP -= count; ax = (SP - PL_stack_base) + 1; isa_type = SvIV(ST(0)); ax = oldax; } PUTBACK; FREETMPS; LEAVE; if( isa_type ) { ST(0) = ref; XSRETURN(1); } } } } XSRETURN_UNDEF; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why do I need storing ax over ENTER/SAVETMPS -- FREETMPS/LEAVE?
by almut (Canon) on Oct 22, 2008 at 23:35 UTC | |
|
Re: Why do I need storing ax over ENTER/SAVETMPS -- FREETMPS/LEAVE?
by Anonymous Monk on Oct 23, 2008 at 00:49 UTC | |
|
Re: Why do I need storing ax over ENTER/SAVETMPS -- FREETMPS/LEAVE?
by gone2015 (Deacon) on Oct 22, 2008 at 23:29 UTC |