summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-09-16 22:58:23 -0600
committerKarl Williamson <khw@cpan.org>2018-10-20 00:09:54 -0600
commitf55b7b26c4afa4768435a9da9f0798829bbf41f7 (patch)
tree6a1627fd12baa3b34adf7a5d5a4e7f8bcca2b82c /regcomp.h
parent46fc0c4304793e740ce6eefd1561a6bb9cb9a6c8 (diff)
downloadperl-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.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/regcomp.h b/regcomp.h
index 45d24c2599..f2ce68fb71 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -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)