From ad6c7b0dd4b31965ccf6f1c02448f4c306cc316b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 9 Feb 1999 13:59:10 -0200 Subject: small corrections in opcodes. --- lparser.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index be44c693..c41f8b49 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.17 1999/02/08 17:07:59 roberto Exp roberto $ +** $Id: lparser.c,v 1.18 1999/02/08 18:54:19 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -267,9 +267,11 @@ static int real_constant (FuncState *fs, real r) { static void code_number (LexState *ls, real f) { - if (-NUMOFFSET <= f && f <= (real)(MAX_WORD-NUMOFFSET) && - (int)f == f) /* f+NUMOFFSET has a short integer value? */ - code_oparg(ls, PUSHNUMBER, (int)f+NUMOFFSET, 1); + real af = (f<0) ? -f : f; + if (0 <= af && af <= (real)MAX_WORD && (int)af == af) { + /* abs(f) has a short integer value */ + code_oparg(ls, (f<0) ? PUSHNEG : PUSHNUMBER, (int)af, 1); + } else code_constant(ls, real_constant(ls->fs, f)); } @@ -474,7 +476,7 @@ static void lua_pushvar (LexState *ls, vardesc *var) { /* to be used by "storevar" and assignment */ static OpCode set_pop[] = {SETLOCAL, SETGLOBAL, SETTABLEPOP, SETTABLE}; -static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABPPDUP, +static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABLEPOPDUP, SETTABLEDUP}; @@ -563,6 +565,7 @@ static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) { incr_top; } + static void close_func (LexState *ls) { FuncState *fs = ls->fs; TProtoFunc *f = fs->f; -- cgit v1.2.3-55-g6feb