diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-12-17 11:23:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-12-17 11:23:22 -0300 |
commit | 1c40ff9faafed620aa0458b397bcbfbe19e0f663 (patch) | |
tree | edfb96022feb99244a7a6c4c9d28525e141b783e /lparser.h | |
parent | 7538f3886dfa091d661c56e48ebb1578ced8e467 (diff) | |
download | lua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.tar.gz lua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.tar.bz2 lua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.zip |
Scanner and parser use different tables for constants
Moreover, each function being parsed has its own table.
The code is cleaner when each table is used for one specific purpose:
The scanner uses its table to anchor and unify strings, mapping strings
to themselves; the parser uses it to reuse constants in the code,
mapping constants to their indices in the constant table. A different
table for each task avoids false collisions.
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -146,6 +146,7 @@ typedef struct FuncState { | |||
146 | struct FuncState *prev; /* enclosing function */ | 146 | struct FuncState *prev; /* enclosing function */ |
147 | struct LexState *ls; /* lexical state */ | 147 | struct LexState *ls; /* lexical state */ |
148 | struct BlockCnt *bl; /* chain of current blocks */ | 148 | struct BlockCnt *bl; /* chain of current blocks */ |
149 | Table *kcache; /* cache for reusing constants */ | ||
149 | int pc; /* next position to code (equivalent to 'ncode') */ | 150 | int pc; /* next position to code (equivalent to 'ncode') */ |
150 | int lasttarget; /* 'label' of last 'jump label' */ | 151 | int lasttarget; /* 'label' of last 'jump label' */ |
151 | int previousline; /* last line that was saved in 'lineinfo' */ | 152 | int previousline; /* last line that was saved in 'lineinfo' */ |