diff options
author | Karl Williamson <khw@cpan.org> | 2020-02-17 11:24:19 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-02-19 18:18:40 -0700 |
commit | 86451f01babb7e6115c520111d32b1128dcc8f57 (patch) | |
tree | 3eb6740b2a8b4d9e8234f60a4e1c8d7e8e092d11 /regcomp.h | |
parent | f1f5d51d61d3b95058950a4835a9cadfd8f2ad28 (diff) | |
download | perl-86451f01babb7e6115c520111d32b1128dcc8f57.tar.gz |
regcomp.sym: Add new regnode type for (?[])
This new regnode is used to handle interpolated already-compiled regex
sets inside outer regex sets.
If it isn't present, it will mean that what appears to be a nested,
interpolated set really isn't.
I created a new regnode structure to hold a pointer. This has to be
temporary as pointers can be invalidated. I thought of just having a
regnode without a pointer as a marker, and using a parallel array to
store the data, rather than creating a whole new regnode structure for
just pointers, but parallel data structures can get out of sync, so this
seemed best.
This commit just sets up the regnode; a future commit will actually use
it.
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -181,6 +181,16 @@ struct regnode_1 { U32 arg1; }; +/* Node whose argument is 'void *', a pointer to void. This needs to be used + * very carefully in situations where pointers won't become invalid because of, + * say re-mallocs */ +struct regnode_p { + U8 flags; + U8 type; + U16 next_off; + void * arg1; +}; + /* Similar to a regnode_1 but with an extra signed argument */ struct regnode_2L { U8 flags; @@ -296,11 +306,13 @@ struct regnode_ssc { #undef ARG2 #define ARG(p) ARG_VALUE(ARG_LOC(p)) +#define ARGp(p) ARG_VALUE(ARGp_LOC(p)) #define ARG1(p) ARG_VALUE(ARG1_LOC(p)) #define ARG2(p) ARG_VALUE(ARG2_LOC(p)) #define ARG2L(p) ARG_VALUE(ARG2L_LOC(p)) #define ARG_SET(p, val) ARG__SET(ARG_LOC(p), (val)) +#define ARGp_SET(p, val) ARG__SET(ARGp_LOC(p), (val)) #define ARG1_SET(p, val) ARG__SET(ARG1_LOC(p), (val)) #define ARG2_SET(p, val) ARG__SET(ARG2_LOC(p), (val)) #define ARG2L_SET(p, val) ARG__SET(ARG2L_LOC(p), (val)) @@ -388,6 +400,7 @@ struct regnode_ssc { #define NODE_ALIGN(node) #define ARG_LOC(p) (((struct regnode_1 *)p)->arg1) +#define ARGp_LOC(p) (((struct regnode_p *)p)->arg1) #define ARG1_LOC(p) (((struct regnode_2 *)p)->arg1) #define ARG2_LOC(p) (((struct regnode_2 *)p)->arg2) #define ARG2L_LOC(p) (((struct regnode_2L *)p)->arg2) @@ -416,6 +429,12 @@ struct regnode_ssc { * that have a longer argument */ \ (offset) += regarglen[op]; \ } STMT_END +#define FILL_ADVANCE_NODE_ARGp(offset, op, arg) \ + STMT_START { \ + ARGp_SET(REGNODE_p(offset), arg); \ + FILL_ADVANCE_NODE(offset, op); \ + (offset) += regarglen[op]; \ + } STMT_END #define FILL_ADVANCE_NODE_2L_ARG(offset, op, arg1, arg2) \ STMT_START { \ ARG_SET(REGNODE_p(offset), arg1); \ |