diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:26:56 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:26:56 -0300 |
commit | d6af81084df569bc8e3bd0949ad6fc0b40c8468d (patch) | |
tree | 103b92a3fd9b1164763500054f7979f51f9aa4b4 /lparser.c | |
parent | 4846f7e3bb1397142ab0de808ae59c08db9832a6 (diff) | |
download | lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.tar.gz lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.tar.bz2 lua-d6af81084df569bc8e3bd0949ad6fc0b40c8468d.zip |
New kind of expression VKSTR
String literal expressions have their own kind VKSTR, instead of the
generic VK. This allows strings to "cross" functions without entering
their constant tables (e.g., if they are used only by some nested
function).
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -156,13 +156,15 @@ static void init_exp (expdesc *e, expkind k, int i) { | |||
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | static void codestring (LexState *ls, expdesc *e, TString *s) { | 159 | static void codestring (expdesc *e, TString *s) { |
160 | init_exp(e, VK, luaK_stringK(ls->fs, s)); | 160 | e->f = e->t = NO_JUMP; |
161 | e->k = VKSTR; | ||
162 | e->u.strval = s; | ||
161 | } | 163 | } |
162 | 164 | ||
163 | 165 | ||
164 | static void codename (LexState *ls, expdesc *e) { | 166 | static void codename (LexState *ls, expdesc *e) { |
165 | codestring(ls, e, str_checkname(ls)); | 167 | codestring(e, str_checkname(ls)); |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
@@ -445,7 +447,7 @@ static void singlevar (LexState *ls, expdesc *var) { | |||
445 | expdesc key; | 447 | expdesc key; |
446 | singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ | 448 | singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ |
447 | lua_assert(var->k != VVOID); /* this one must exist */ | 449 | lua_assert(var->k != VVOID); /* this one must exist */ |
448 | codestring(ls, &key, varname); /* key is variable name */ | 450 | codestring(&key, varname); /* key is variable name */ |
449 | luaK_indexed(fs, var, &key); /* env[varname] */ | 451 | luaK_indexed(fs, var, &key); /* env[varname] */ |
450 | } | 452 | } |
451 | } | 453 | } |
@@ -1019,7 +1021,7 @@ static void funcargs (LexState *ls, expdesc *f, int line) { | |||
1019 | break; | 1021 | break; |
1020 | } | 1022 | } |
1021 | case TK_STRING: { /* funcargs -> STRING */ | 1023 | case TK_STRING: { /* funcargs -> STRING */ |
1022 | codestring(ls, &args, ls->t.seminfo.ts); | 1024 | codestring(&args, ls->t.seminfo.ts); |
1023 | luaX_next(ls); /* must use 'seminfo' before 'next' */ | 1025 | luaX_next(ls); /* must use 'seminfo' before 'next' */ |
1024 | break; | 1026 | break; |
1025 | } | 1027 | } |
@@ -1127,7 +1129,7 @@ static void simpleexp (LexState *ls, expdesc *v) { | |||
1127 | break; | 1129 | break; |
1128 | } | 1130 | } |
1129 | case TK_STRING: { | 1131 | case TK_STRING: { |
1130 | codestring(ls, v, ls->t.seminfo.ts); | 1132 | codestring(v, ls->t.seminfo.ts); |
1131 | break; | 1133 | break; |
1132 | } | 1134 | } |
1133 | case TK_NIL: { | 1135 | case TK_NIL: { |