X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/af097752b446f87855473ee776be3a2d7b735986..dcffd848632af2c7eabc52ed591fab35f1e73a7f:/scope.h diff --git a/scope.h b/scope.h index 7517798..113f4e8 100644 --- a/scope.h +++ b/scope.h @@ -55,10 +55,17 @@ #define SAVEt_STACK_CXPOS 44 #define SAVEt_PARSER 45 #define SAVEt_ADELETE 46 +#define SAVEt_I32_SMALL 47 +#define SAVEt_INT_SMALL 48 +#define SAVEt_GVSV 49 +#define SAVEt_FREECOPHH 50 #define SAVEf_SETMAGIC 1 #define SAVEf_KEEPOLDELEM 2 +#define SAVE_TIGHT_SHIFT 6 +#define SAVE_MASK 0x3F + #define save_aelem(av,idx,sptr) save_aelem_flags(av,idx,sptr,SAVEf_SETMAGIC) #define save_helem(hv,key,sptr) save_helem_flags(hv,key,sptr,SAVEf_SETMAGIC) @@ -72,6 +79,7 @@ #define SSPUSHLONG(i) (PL_savestack[PL_savestack_ix++].any_long = (long)(i)) #define SSPUSHBOOL(p) (PL_savestack[PL_savestack_ix++].any_bool = (p)) #define SSPUSHIV(i) (PL_savestack[PL_savestack_ix++].any_iv = (IV)(i)) +#define SSPUSHUV(u) (PL_savestack[PL_savestack_ix++].any_uv = (UV)(u)) #define SSPUSHPTR(p) (PL_savestack[PL_savestack_ix++].any_ptr = (void*)(p)) #define SSPUSHDPTR(p) (PL_savestack[PL_savestack_ix++].any_dptr = (p)) #define SSPUSHDXPTR(p) (PL_savestack[PL_savestack_ix++].any_dxptr = (p)) @@ -79,6 +87,7 @@ #define SSPOPLONG (PL_savestack[--PL_savestack_ix].any_long) #define SSPOPBOOL (PL_savestack[--PL_savestack_ix].any_bool) #define SSPOPIV (PL_savestack[--PL_savestack_ix].any_iv) +#define SSPOPUV (PL_savestack[--PL_savestack_ix].any_uv) #define SSPOPPTR (PL_savestack[--PL_savestack_ix].any_ptr) #define SSPOPDPTR (PL_savestack[--PL_savestack_ix].any_dptr) #define SSPOPDXPTR (PL_savestack[--PL_savestack_ix].any_dxptr) @@ -100,6 +109,20 @@ Opening bracket on a callback. See C and L. =for apidoc Ams||LEAVE Closing bracket on a callback. See C and L. +=over + +=item ENTER_with_name(name) + +Same as C, but when debugging is enabled it also associates the +given literal string with the new scope. + +=item LEAVE_with_name(name) + +Same as C, but when debugging is enabled it first checks that the +scope has the given name. Name must be a literal string. + +=back + =cut */ @@ -117,9 +140,28 @@ Closing bracket on a callback. See C and L. DEBUG_SCOPE("LEAVE") \ pop_scope(); \ } STMT_END +#define ENTER_with_name(name) \ + STMT_START { \ + push_scope(); \ + if (PL_scopestack_name) \ + PL_scopestack_name[PL_scopestack_ix-1] = name; \ + DEBUG_SCOPE("ENTER \"" name "\"") \ + } STMT_END +#define LEAVE_with_name(name) \ + STMT_START { \ + DEBUG_SCOPE("LEAVE \"" name "\"") \ + if (PL_scopestack_name) { \ + assert(((char*)PL_scopestack_name[PL_scopestack_ix-1] \ + == (char*)name) \ + || strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \ + } \ + pop_scope(); \ + } STMT_END #else #define ENTER push_scope() #define LEAVE pop_scope() +#define ENTER_with_name(name) ENTER +#define LEAVE_with_name(name) LEAVE #endif #define LEAVE_SCOPE(old) if (PL_savestack_ix > old) leave_scope(old) @@ -129,7 +171,7 @@ Closing bracket on a callback. See C and L. #define SAVEINT(i) save_int((int*)&(i)) #define SAVEIV(i) save_iv((IV*)&(i)) #define SAVELONG(l) save_long((long*)&(l)) -#define SAVEBOOL(b) save_bool((bool*)&(b)) +#define SAVEBOOL(b) save_bool(&(b)) #define SAVESPTR(s) save_sptr((SV**)&(s)) #define SAVEPPTR(s) save_pptr((char**)&(s)) #define SAVEVPTR(s) save_vptr((void*)&(s)) @@ -143,6 +185,7 @@ Closing bracket on a callback. See C and L. #define SAVEGENERICPV(s) save_generic_pvref((char**)&(s)) #define SAVESHAREDPV(s) save_shared_pvref((char**)&(s)) #define SAVESETSVFLAGS(sv,mask,val) save_set_svflags(sv,mask,val) +#define SAVEFREECOPHH(h) save_pushptr((void *)(h), SAVEt_FREECOPHH) #define SAVEDELETE(h,k,l) \ save_delete(MUTABLE_HV(h), (char*)(k), (I32)(l)) #define SAVEHDELETE(h,s) \ @@ -159,7 +202,7 @@ Closing bracket on a callback. See C and L. STMT_START { \ SSCHECK(2); \ SSPUSHINT(PL_stack_sp - PL_stack_base); \ - SSPUSHINT(SAVEt_STACK_POS); \ + SSPUSHUV(SAVEt_STACK_POS); \ } STMT_END #define SAVEOP() save_op() @@ -189,7 +232,7 @@ Closing bracket on a callback. See C and L. SSCHECK(3); \ SSPUSHINT(cxstack[cxstack_ix].blk_oldsp); \ SSPUSHINT(cxstack_ix); \ - SSPUSHINT(SAVEt_STACK_CXPOS); \ + SSPUSHUV(SAVEt_STACK_CXPOS); \ } STMT_END #define SAVEPARSER(p) save_pushptr((p), SAVEt_PARSER) @@ -213,7 +256,7 @@ Closing bracket on a callback. See C and L. * pointer would get broken if the savestack is moved on reallocation. * SSNEWa() works like SSNEW(), but also aligns the data to the specified * number of bytes. MEM_ALIGNBYTES is perhaps the most useful. The - * alignment will be preserved therough savestack reallocation *only* if + * alignment will be preserved through savestack reallocation *only* if * realloc returns data aligned to a size divisible by "align"! * * SSPTR() converts the index returned by SSNEW/SSNEWa() into a pointer.