diff options
author | Karl Williamson <khw@cpan.org> | 2018-09-16 22:58:23 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-10-20 00:09:54 -0600 |
commit | f55b7b26c4afa4768435a9da9f0798829bbf41f7 (patch) | |
tree | 6a1627fd12baa3b34adf7a5d5a4e7f8bcca2b82c /regcomp.h | |
parent | 46fc0c4304793e740ce6eefd1561a6bb9cb9a6c8 (diff) | |
download | perl-f55b7b26c4afa4768435a9da9f0798829bbf41f7.tar.gz |
regcomp.c: Use regnode offsets during parsing
This changes the pattern parsing to use offsets from the first node in
the pattern program, rather than direct addresses of such nodes. This
is in preparation for a later change in which more mallocs will be done
which will change those addresses, whereas the offsets will remain
constant. Once the final program space is allocated, real addresses are
used as currently. This limits the necessary changes to a few
functions. Also, real addresses are used if they are constant across a
function; again this limits the changes.
Doing this introduces a new typedef for clarity 'regnode_offset' which
is not a pointer, but a count. This necessitates changing a bunch of
things to use 0 instead of NULL to indicate an error.
A new boolean is also required to indicate if we are in the first or
second passes of the pattern. And separate heap space is allocated for
scratch during the first pass.
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -353,35 +353,35 @@ struct regnode_ssc { #define NEXTOPER(p) ((p) + NODE_STEP_REGNODE) #define PREVOPER(p) ((p) - NODE_STEP_REGNODE) -#define FILL_NODE(ptr, op) \ - STMT_START { \ - OP(ptr) = op; \ - NEXT_OFF(ptr) = 0; \ +#define FILL_NODE(offset, op) \ + STMT_START { \ + OP(REGNODE_p(offset)) = op; \ + NEXT_OFF(REGNODE_p(offset)) = 0; \ } STMT_END -#define FILL_ADVANCE_NODE(ptr, op) \ - STMT_START { \ - FILL_NODE(ptr, op); \ - (ptr)++; \ +#define FILL_ADVANCE_NODE(offset, op) \ + STMT_START { \ + FILL_NODE(offset, op); \ + (offset)++; \ } STMT_END -#define FILL_ADVANCE_NODE_ARG(ptr, op, arg) \ - STMT_START { \ - ARG_SET(ptr, arg); \ - FILL_ADVANCE_NODE(ptr, op); \ - /* This is used generically for other operations\ - * that have a longer argument */ \ - (ptr) += regarglen[op]; \ +#define FILL_ADVANCE_NODE_ARG(offset, op, arg) \ + STMT_START { \ + ARG_SET(REGNODE_p(offset), arg); \ + FILL_ADVANCE_NODE(offset, op); \ + /* This is used generically for other operations \ + * that have a longer argument */ \ + (offset) += regarglen[op]; \ } STMT_END -#define FILL_ADVANCE_NODE_2L_ARG(ptr, op, arg1, arg2) \ - STMT_START { \ - ARG_SET(ptr, arg1); \ - ARG2L_SET(ptr, arg2); \ - FILL_ADVANCE_NODE(ptr, op); \ - (ptr) += 2; \ +#define FILL_ADVANCE_NODE_2L_ARG(offset, op, arg1, arg2) \ + STMT_START { \ + ARG_SET(REGNODE_p(offset), arg1); \ + ARG2L_SET(REGNODE_p(offset), arg2); \ + FILL_ADVANCE_NODE(offset, op); \ + (offset) += 2; \ } STMT_END #define REG_MAGIC 0234 -#define SIZE_ONLY cBOOL(RExC_emit == (regnode *) & RExC_emit_dummy) +#define SIZE_ONLY RExC_pass1 #define PASS1 SIZE_ONLY #define PASS2 (! SIZE_ONLY) |