aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-09 13:59:10 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-09 13:59:10 -0200
commitad6c7b0dd4b31965ccf6f1c02448f4c306cc316b (patch)
treee1f3cb627bcf327578bfcbd8cefdf55d66802ae4 /lparser.c
parent8b2d97d1871147c730a986656907837458b601f8 (diff)
downloadlua-ad6c7b0dd4b31965ccf6f1c02448f4c306cc316b.tar.gz
lua-ad6c7b0dd4b31965ccf6f1c02448f4c306cc316b.tar.bz2
lua-ad6c7b0dd4b31965ccf6f1c02448f4c306cc316b.zip
small corrections in opcodes.
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lparser.c b/lparser.c
index be44c693..c41f8b49 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.17 1999/02/08 17:07:59 roberto Exp roberto $ 2** $Id: lparser.c,v 1.18 1999/02/08 18:54:19 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -267,9 +267,11 @@ static int real_constant (FuncState *fs, real r) {
267 267
268 268
269static void code_number (LexState *ls, real f) { 269static void code_number (LexState *ls, real f) {
270 if (-NUMOFFSET <= f && f <= (real)(MAX_WORD-NUMOFFSET) && 270 real af = (f<0) ? -f : f;
271 (int)f == f) /* f+NUMOFFSET has a short integer value? */ 271 if (0 <= af && af <= (real)MAX_WORD && (int)af == af) {
272 code_oparg(ls, PUSHNUMBER, (int)f+NUMOFFSET, 1); 272 /* abs(f) has a short integer value */
273 code_oparg(ls, (f<0) ? PUSHNEG : PUSHNUMBER, (int)af, 1);
274 }
273 else 275 else
274 code_constant(ls, real_constant(ls->fs, f)); 276 code_constant(ls, real_constant(ls->fs, f));
275} 277}
@@ -474,7 +476,7 @@ static void lua_pushvar (LexState *ls, vardesc *var) {
474 476
475/* to be used by "storevar" and assignment */ 477/* to be used by "storevar" and assignment */
476static OpCode set_pop[] = {SETLOCAL, SETGLOBAL, SETTABLEPOP, SETTABLE}; 478static OpCode set_pop[] = {SETLOCAL, SETGLOBAL, SETTABLEPOP, SETTABLE};
477static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABPPDUP, 479static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABLEPOPDUP,
478 SETTABLEDUP}; 480 SETTABLEDUP};
479 481
480 482
@@ -563,6 +565,7 @@ static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) {
563 incr_top; 565 incr_top;
564} 566}
565 567
568
566static void close_func (LexState *ls) { 569static void close_func (LexState *ls) {
567 FuncState *fs = ls->fs; 570 FuncState *fs = ls->fs;
568 TProtoFunc *f = fs->f; 571 TProtoFunc *f = fs->f;