diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-29 09:39:03 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-29 09:39:03 -0300 |
commit | 44fab2a44d06a956c3121ceba2b39ca7b00dc428 (patch) | |
tree | 9f492ba2ebaa4fb3cf6554fcb63f3fe026d43a5d /lpvm.h | |
parent | 460a35cbcb33fbc56f5a658b96a793b9bb8963e9 (diff) | |
download | lpeg-44fab2a44d06a956c3121ceba2b39ca7b00dc428.tar.gz lpeg-44fab2a44d06a956c3121ceba2b39ca7b00dc428.tar.bz2 lpeg-44fab2a44d06a956c3121ceba2b39ca7b00dc428.zip |
Code size stored in code itself
Most patterns do not have code, as they are not directly used for
a match; they are created only to compose larger patterns. So, we
shouldn't waste space to store the size of their code, as a NULL
pointer already indicates that the size is zero.
Diffstat (limited to 'lpvm.h')
-rw-r--r-- | lpvm.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -43,7 +43,11 @@ typedef enum Opcode { | |||
43 | } Opcode; | 43 | } Opcode; |
44 | 44 | ||
45 | 45 | ||
46 | 46 | /* | |
47 | ** All array of instructions has a 'codesize' as its first element | ||
48 | ** and is referred by a pointer to its second element, which is the | ||
49 | ** first actual opcode. | ||
50 | */ | ||
47 | typedef union Instruction { | 51 | typedef union Instruction { |
48 | struct Inst { | 52 | struct Inst { |
49 | byte code; | 53 | byte code; |
@@ -57,6 +61,7 @@ typedef union Instruction { | |||
57 | } aux2; | 61 | } aux2; |
58 | } i; | 62 | } i; |
59 | int offset; | 63 | int offset; |
64 | uint codesize; | ||
60 | byte buff[1]; | 65 | byte buff[1]; |
61 | } Instruction; | 66 | } Instruction; |
62 | 67 | ||
@@ -66,7 +71,6 @@ typedef union Instruction { | |||
66 | 71 | ||
67 | 72 | ||
68 | int charinset (const Instruction *i, const byte *buff, uint c); | 73 | int charinset (const Instruction *i, const byte *buff, uint c); |
69 | void printpatt (Instruction *p, int n); | ||
70 | const char *match (lua_State *L, const char *o, const char *s, const char *e, | 74 | const char *match (lua_State *L, const char *o, const char *s, const char *e, |
71 | Instruction *op, Capture *capture, int ptop); | 75 | Instruction *op, Capture *capture, int ptop); |
72 | 76 | ||