diff options
| -rw-r--r-- | lapi.c | 8 | ||||
| -rw-r--r-- | lauxlib.c | 8 | ||||
| -rw-r--r-- | lauxlib.h | 6 | ||||
| -rw-r--r-- | lcode.c | 10 | ||||
| -rw-r--r-- | lcode.h | 4 | ||||
| -rw-r--r-- | lfunc.c | 4 | ||||
| -rw-r--r-- | liolib.c | 4 | ||||
| -rw-r--r-- | llex.h | 4 | ||||
| -rw-r--r-- | llimits.h | 16 | ||||
| -rw-r--r-- | lmathlib.c | 12 | ||||
| -rw-r--r-- | lobject.c | 6 | ||||
| -rw-r--r-- | lobject.h | 8 | ||||
| -rw-r--r-- | lopcodes.h | 4 | ||||
| -rw-r--r-- | lparser.c | 6 | ||||
| -rw-r--r-- | ltable.c | 6 | ||||
| -rw-r--r-- | ltable.h | 6 | ||||
| -rw-r--r-- | lua.h | 9 | ||||
| -rw-r--r-- | lundump.c | 12 | ||||
| -rw-r--r-- | lvm.c | 8 |
19 files changed, 67 insertions, 74 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.110 2000/10/30 12:50:09 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.111 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -154,7 +154,7 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { | |||
| 154 | 154 | ||
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | LUA_API double lua_tonumber (lua_State *L, int index) { | 157 | LUA_API lua_Number lua_tonumber (lua_State *L, int index) { |
| 158 | StkId o = luaA_indexAcceptable(L, index); | 158 | StkId o = luaA_indexAcceptable(L, index); |
| 159 | return (o == NULL || tonumber(o)) ? 0 : nvalue(o); | 159 | return (o == NULL || tonumber(o)) ? 0 : nvalue(o); |
| 160 | } | 160 | } |
| @@ -205,7 +205,7 @@ LUA_API void lua_pushnil (lua_State *L) { | |||
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | LUA_API void lua_pushnumber (lua_State *L, double n) { | 208 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { |
| 209 | nvalue(L->top) = n; | 209 | nvalue(L->top) = n; |
| 210 | ttype(L->top) = LUA_TNUMBER; | 210 | ttype(L->top) = LUA_TNUMBER; |
| 211 | api_incr_top(L); | 211 | api_incr_top(L); |
| @@ -461,7 +461,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 461 | if (ttype(value) == LUA_TNUMBER) | 461 | if (ttype(value) == LUA_TNUMBER) |
| 462 | return (int)nvalue(value); | 462 | return (int)nvalue(value); |
| 463 | else { | 463 | else { |
| 464 | Number max = 0; | 464 | lua_Number max = 0; |
| 465 | int i = h->size; | 465 | int i = h->size; |
| 466 | Node *n = h->node; | 466 | Node *n = h->node; |
| 467 | while (i--) { | 467 | while (i--) { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.42 2000/10/30 12:38:50 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.43 2000/10/30 13:07:48 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -84,15 +84,15 @@ LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, s | |||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | LUALIB_API double luaL_check_number (lua_State *L, int narg) { | 87 | LUALIB_API lua_Number luaL_check_number (lua_State *L, int narg) { |
| 88 | double d = lua_tonumber(L, narg); | 88 | lua_Number d = lua_tonumber(L, narg); |
| 89 | if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ | 89 | if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ |
| 90 | type_error(L, narg, LUA_TNUMBER); | 90 | type_error(L, narg, LUA_TNUMBER); |
| 91 | return d; | 91 | return d; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | 94 | ||
| 95 | LUALIB_API double luaL_opt_number (lua_State *L, int narg, double def) { | 95 | LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) { |
| 96 | if (lua_isnull(L, narg)) return def; | 96 | if (lua_isnull(L, narg)) return def; |
| 97 | else return luaL_check_number(L, narg); | 97 | else return luaL_check_number(L, narg); |
| 98 | } | 98 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.29 2000/10/27 16:15:53 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.30 2000/10/30 12:38:50 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -30,8 +30,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const struct luaL_reg *l, int n); | |||
| 30 | LUALIB_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); | 30 | LUALIB_API void luaL_argerror (lua_State *L, int numarg, const char *extramsg); |
| 31 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); | 31 | LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg, size_t *len); |
| 32 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, size_t *len); | 32 | LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg, const char *def, size_t *len); |
| 33 | LUALIB_API double luaL_check_number (lua_State *L, int numArg); | 33 | LUALIB_API lua_Number luaL_check_number (lua_State *L, int numArg); |
| 34 | LUALIB_API double luaL_opt_number (lua_State *L, int numArg, double def); | 34 | LUALIB_API lua_Number luaL_opt_number (lua_State *L, int nArg, lua_Number def); |
| 35 | 35 | ||
| 36 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg); | 36 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg); |
| 37 | LUALIB_API void luaL_checktype (lua_State *L, int narg, int t); | 37 | LUALIB_API void luaL_checktype (lua_State *L, int narg, int t); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.51 2000/09/29 12:42:13 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.52 2000/11/30 18:50:47 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -99,7 +99,7 @@ void luaK_kstr (LexState *ls, int c) { | |||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | static int number_constant (FuncState *fs, Number r) { | 102 | static int number_constant (FuncState *fs, lua_Number r) { |
| 103 | /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ | 103 | /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ |
| 104 | Proto *f = fs->f; | 104 | Proto *f = fs->f; |
| 105 | int c = f->nknum; | 105 | int c = f->nknum; |
| @@ -107,7 +107,7 @@ static int number_constant (FuncState *fs, Number r) { | |||
| 107 | while (--c >= lim) | 107 | while (--c >= lim) |
| 108 | if (f->knum[c] == r) return c; | 108 | if (f->knum[c] == r) return c; |
| 109 | /* not found; create a new entry */ | 109 | /* not found; create a new entry */ |
| 110 | luaM_growvector(fs->L, f->knum, f->nknum, 1, Number, | 110 | luaM_growvector(fs->L, f->knum, f->nknum, 1, lua_Number, |
| 111 | "constant table overflow", MAXARG_U); | 111 | "constant table overflow", MAXARG_U); |
| 112 | c = f->nknum++; | 112 | c = f->nknum++; |
| 113 | f->knum[c] = r; | 113 | f->knum[c] = r; |
| @@ -115,8 +115,8 @@ static int number_constant (FuncState *fs, Number r) { | |||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | void luaK_number (FuncState *fs, Number f) { | 118 | void luaK_number (FuncState *fs, lua_Number f) { |
| 119 | if (f <= (Number)MAXARG_S && (Number)(int)f == f) | 119 | if (f <= (lua_Number)MAXARG_S && (lua_Number)(int)f == f) |
| 120 | luaK_code1(fs, OP_PUSHINT, (int)f); /* f has a short integer value */ | 120 | luaK_code1(fs, OP_PUSHINT, (int)f); /* f has a short integer value */ |
| 121 | else | 121 | else |
| 122 | luaK_code1(fs, OP_PUSHNUM, number_constant(fs, f)); | 122 | luaK_code1(fs, OP_PUSHNUM, number_constant(fs, f)); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.h,v 1.16 2000/08/09 14:49:13 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.17 2000/11/30 18:50:47 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -58,7 +58,7 @@ void luaK_goiftrue (FuncState *fs, expdesc *v, int keepvalue); | |||
| 58 | int luaK_getlabel (FuncState *fs); | 58 | int luaK_getlabel (FuncState *fs); |
| 59 | void luaK_deltastack (FuncState *fs, int delta); | 59 | void luaK_deltastack (FuncState *fs, int delta); |
| 60 | void luaK_kstr (LexState *ls, int c); | 60 | void luaK_kstr (LexState *ls, int c); |
| 61 | void luaK_number (FuncState *fs, Number f); | 61 | void luaK_number (FuncState *fs, lua_Number f); |
| 62 | void luaK_adjuststack (FuncState *fs, int n); | 62 | void luaK_adjuststack (FuncState *fs, int n); |
| 63 | int luaK_lastisopen (FuncState *fs); | 63 | int luaK_lastisopen (FuncState *fs); |
| 64 | void luaK_setcallreturns (FuncState *fs, int nresults); | 64 | void luaK_setcallreturns (FuncState *fs, int nresults); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 1.33 2000/10/18 17:19:09 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.34 2000/10/30 12:20:29 roberto Exp roberto $ |
| 3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -57,7 +57,7 @@ Proto *luaF_newproto (lua_State *L) { | |||
| 57 | 57 | ||
| 58 | static size_t protosize (Proto *f) { | 58 | static size_t protosize (Proto *f) { |
| 59 | return sizeof(Proto) | 59 | return sizeof(Proto) |
| 60 | + f->nknum*sizeof(Number) | 60 | + f->nknum*sizeof(lua_Number) |
| 61 | + f->nkstr*sizeof(TString *) | 61 | + f->nkstr*sizeof(TString *) |
| 62 | + f->nkproto*sizeof(Proto *) | 62 | + f->nkproto*sizeof(Proto *) |
| 63 | + f->ncode*sizeof(Instruction) | 63 | + f->ncode*sizeof(Instruction) |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 1.91 2000/10/31 13:10:24 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.92 2000/11/23 13:49:35 roberto Exp roberto $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -476,7 +476,7 @@ static int io_getenv (lua_State *L) { | |||
| 476 | 476 | ||
| 477 | 477 | ||
| 478 | static int io_clock (lua_State *L) { | 478 | static int io_clock (lua_State *L) { |
| 479 | lua_pushnumber(L, ((double)clock())/CLOCKS_PER_SEC); | 479 | lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); |
| 480 | return 1; | 480 | return 1; |
| 481 | } | 481 | } |
| 482 | 482 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.h,v 1.30 2000/06/21 18:13:56 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.31 2000/09/27 17:41:58 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -36,7 +36,7 @@ enum RESERVED { | |||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | typedef union { | 38 | typedef union { |
| 39 | Number r; | 39 | lua_Number r; |
| 40 | TString *ts; | 40 | TString *ts; |
| 41 | } SemInfo; /* semantics information */ | 41 | } SemInfo; /* semantics information */ |
| 42 | 42 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.19 2000/10/26 12:47:05 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.20 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Limits, basic types, and some other "installation-dependent" definitions | 3 | ** Limits, basic types, and some other "installation-dependent" definitions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -31,21 +31,11 @@ | |||
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | /* | 34 | /* function to convert a lua_Number to a string */ |
| 35 | ** Define the type `number' of Lua | ||
| 36 | ** GREP LUA_NUMBER to change that | ||
| 37 | */ | ||
| 38 | #ifndef LUA_NUM_TYPE | ||
| 39 | #define LUA_NUM_TYPE double | ||
| 40 | #endif | ||
| 41 | |||
| 42 | typedef LUA_NUM_TYPE Number; | ||
| 43 | |||
| 44 | /* function to convert a Number to a string */ | ||
| 45 | #define NUMBER_FMT "%.16g" /* LUA_NUMBER */ | 35 | #define NUMBER_FMT "%.16g" /* LUA_NUMBER */ |
| 46 | #define lua_number2str(s,n) sprintf((s), NUMBER_FMT, (n)) | 36 | #define lua_number2str(s,n) sprintf((s), NUMBER_FMT, (n)) |
| 47 | 37 | ||
| 48 | /* function to convert a string to a Number */ | 38 | /* function to convert a string to a lua_Number */ |
| 49 | #define lua_str2number(s,p) strtod((s), (p)) | 39 | #define lua_str2number(s,p) strtod((s), (p)) |
| 50 | 40 | ||
| 51 | 41 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.31 2000/10/27 16:15:53 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.32 2000/10/31 13:10:24 roberto Exp roberto $ |
| 3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -139,10 +139,10 @@ static int math_ldexp (lua_State *L) { | |||
| 139 | 139 | ||
| 140 | static int math_min (lua_State *L) { | 140 | static int math_min (lua_State *L) { |
| 141 | int n = lua_gettop(L); /* number of arguments */ | 141 | int n = lua_gettop(L); /* number of arguments */ |
| 142 | double dmin = luaL_check_number(L, 1); | 142 | lua_Number dmin = luaL_check_number(L, 1); |
| 143 | int i; | 143 | int i; |
| 144 | for (i=2; i<=n; i++) { | 144 | for (i=2; i<=n; i++) { |
| 145 | double d = luaL_check_number(L, i); | 145 | lua_Number d = luaL_check_number(L, i); |
| 146 | if (d < dmin) | 146 | if (d < dmin) |
| 147 | dmin = d; | 147 | dmin = d; |
| 148 | } | 148 | } |
| @@ -153,10 +153,10 @@ static int math_min (lua_State *L) { | |||
| 153 | 153 | ||
| 154 | static int math_max (lua_State *L) { | 154 | static int math_max (lua_State *L) { |
| 155 | int n = lua_gettop(L); /* number of arguments */ | 155 | int n = lua_gettop(L); /* number of arguments */ |
| 156 | double dmax = luaL_check_number(L, 1); | 156 | lua_Number dmax = luaL_check_number(L, 1); |
| 157 | int i; | 157 | int i; |
| 158 | for (i=2; i<=n; i++) { | 158 | for (i=2; i<=n; i++) { |
| 159 | double d = luaL_check_number(L, i); | 159 | lua_Number d = luaL_check_number(L, i); |
| 160 | if (d > dmax) | 160 | if (d > dmax) |
| 161 | dmax = d; | 161 | dmax = d; |
| 162 | } | 162 | } |
| @@ -168,7 +168,7 @@ static int math_max (lua_State *L) { | |||
| 168 | static int math_random (lua_State *L) { | 168 | static int math_random (lua_State *L) { |
| 169 | /* the '%' avoids the (rare) case of r==1, and is needed also because on | 169 | /* the '%' avoids the (rare) case of r==1, and is needed also because on |
| 170 | some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ | 170 | some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */ |
| 171 | double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX; | 171 | lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; |
| 172 | switch (lua_gettop(L)) { /* check number of arguments */ | 172 | switch (lua_gettop(L)) { /* check number of arguments */ |
| 173 | case 0: { /* no arguments */ | 173 | case 0: { /* no arguments */ |
| 174 | lua_pushnumber(L, r); /* Number between 0 and 1 */ | 174 | lua_pushnumber(L, r); /* Number between 0 and 1 */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 1.55 2000/10/20 16:36:32 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.56 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -65,9 +65,9 @@ char *luaO_openspace (lua_State *L, size_t n) { | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | int luaO_str2d (const char *s, Number *result) { /* LUA_NUMBER */ | 68 | int luaO_str2d (const char *s, lua_Number *result) { /* LUA_NUMBER */ |
| 69 | char *endptr; | 69 | char *endptr; |
| 70 | Number res = lua_str2number(s, &endptr); | 70 | lua_Number res = lua_str2number(s, &endptr); |
| 71 | if (endptr == s) return 0; /* no conversion */ | 71 | if (endptr == s) return 0; /* no conversion */ |
| 72 | while (isspace((unsigned char)*endptr)) endptr++; | 72 | while (isspace((unsigned char)*endptr)) endptr++; |
| 73 | if (*endptr != '\0') return 0; /* invalid trailing characters? */ | 73 | if (*endptr != '\0') return 0; /* invalid trailing characters? */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 1.82 2000/10/30 17:49:19 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.83 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -48,7 +48,7 @@ typedef union { | |||
| 48 | struct Closure *cl; /* LUA_TFUNCTION */ | 48 | struct Closure *cl; /* LUA_TFUNCTION */ |
| 49 | struct Hash *a; /* LUA_TTABLE */ | 49 | struct Hash *a; /* LUA_TTABLE */ |
| 50 | struct CallInfo *i; /* LUA_TLMARK */ | 50 | struct CallInfo *i; /* LUA_TLMARK */ |
| 51 | Number n; /* LUA_TNUMBER */ | 51 | lua_Number n; /* LUA_TNUMBER */ |
| 52 | } Value; | 52 | } Value; |
| 53 | 53 | ||
| 54 | 54 | ||
| @@ -101,7 +101,7 @@ typedef struct TString { | |||
| 101 | ** Function Prototypes | 101 | ** Function Prototypes |
| 102 | */ | 102 | */ |
| 103 | typedef struct Proto { | 103 | typedef struct Proto { |
| 104 | Number *knum; /* Number numbers used by the function */ | 104 | lua_Number *knum; /* numbers used by the function */ |
| 105 | int nknum; /* size of `knum' */ | 105 | int nknum; /* size of `knum' */ |
| 106 | struct TString **kstr; /* strings used by the function */ | 106 | struct TString **kstr; /* strings used by the function */ |
| 107 | int nkstr; /* size of `kstr' */ | 107 | int nkstr; /* size of `kstr' */ |
| @@ -195,7 +195,7 @@ luint32 luaO_power2 (luint32 n); | |||
| 195 | char *luaO_openspace (lua_State *L, size_t n); | 195 | char *luaO_openspace (lua_State *L, size_t n); |
| 196 | 196 | ||
| 197 | int luaO_equalObj (const TObject *t1, const TObject *t2); | 197 | int luaO_equalObj (const TObject *t1, const TObject *t2); |
| 198 | int luaO_str2d (const char *s, Number *result); | 198 | int luaO_str2d (const char *s, lua_Number *result); |
| 199 | 199 | ||
| 200 | void luaO_verror (lua_State *L, const char *fmt, ...); | 200 | void luaO_verror (lua_State *L, const char *fmt, ...); |
| 201 | void luaO_chunkid (char *out, const char *source, int len); | 201 | void luaO_chunkid (char *out, const char *source, int len); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.67 2000/08/29 14:48:16 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.68 2000/10/24 16:05:59 roberto Exp roberto $ |
| 3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -91,7 +91,7 @@ OP_TAILCALL,/* A B v_n-v_1 f(at a) (return) f(v1,...,v_n) */ | |||
| 91 | OP_PUSHNIL,/* U - nil_1-nil_u */ | 91 | OP_PUSHNIL,/* U - nil_1-nil_u */ |
| 92 | OP_POP,/* U a_u-a_1 - */ | 92 | OP_POP,/* U a_u-a_1 - */ |
| 93 | 93 | ||
| 94 | OP_PUSHINT,/* S - (Number)s */ | 94 | OP_PUSHINT,/* S - (lua_Number)s */ |
| 95 | OP_PUSHSTRING,/* K - KSTR[k] */ | 95 | OP_PUSHSTRING,/* K - KSTR[k] */ |
| 96 | OP_PUSHNUM,/* N - KNUM[n] */ | 96 | OP_PUSHNUM,/* N - KNUM[n] */ |
| 97 | OP_PUSHNEGNUM,/* N - -KNUM[n] */ | 97 | OP_PUSHNEGNUM,/* N - -KNUM[n] */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 1.117 2000/11/29 11:57:42 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.118 2000/11/30 18:50:47 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 | */ |
| @@ -332,7 +332,7 @@ static void close_func (LexState *ls) { | |||
| 332 | luaK_getlabel(fs); /* close eventual list of pending jumps */ | 332 | luaK_getlabel(fs); /* close eventual list of pending jumps */ |
| 333 | luaM_reallocvector(L, f->code, fs->pc, Instruction); | 333 | luaM_reallocvector(L, f->code, fs->pc, Instruction); |
| 334 | luaM_reallocvector(L, f->kstr, f->nkstr, TString *); | 334 | luaM_reallocvector(L, f->kstr, f->nkstr, TString *); |
| 335 | luaM_reallocvector(L, f->knum, f->nknum, Number); | 335 | luaM_reallocvector(L, f->knum, f->nknum, lua_Number); |
| 336 | luaM_reallocvector(L, f->kproto, f->nkproto, Proto *); | 336 | luaM_reallocvector(L, f->kproto, f->nkproto, Proto *); |
| 337 | removelocalvars(ls, fs->nactloc); | 337 | removelocalvars(ls, fs->nactloc); |
| 338 | luaM_reallocvector(L, f->locvars, f->nlocvars, LocVar); | 338 | luaM_reallocvector(L, f->locvars, f->nlocvars, LocVar); |
| @@ -608,7 +608,7 @@ static void simpleexp (LexState *ls, expdesc *v) { | |||
| 608 | FuncState *fs = ls->fs; | 608 | FuncState *fs = ls->fs; |
| 609 | switch (ls->t.token) { | 609 | switch (ls->t.token) { |
| 610 | case TK_NUMBER: { /* simpleexp -> NUMBER */ | 610 | case TK_NUMBER: { /* simpleexp -> NUMBER */ |
| 611 | Number r = ls->t.seminfo.r; | 611 | lua_Number r = ls->t.seminfo.r; |
| 612 | next(ls); | 612 | next(ls); |
| 613 | luaK_number(fs, r); | 613 | luaK_number(fs, r); |
| 614 | break; | 614 | break; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 1.58 2000/10/26 12:47:05 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.59 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -81,7 +81,7 @@ static const TObject *luaH_getany (lua_State *L, const Hash *t, | |||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | /* specialized version for numbers */ | 83 | /* specialized version for numbers */ |
| 84 | const TObject *luaH_getnum (const Hash *t, Number key) { | 84 | const TObject *luaH_getnum (const Hash *t, lua_Number key) { |
| 85 | Node *n = &t->node[(luint32)(lint32)key&(t->size-1)]; | 85 | Node *n = &t->node[(luint32)(lint32)key&(t->size-1)]; |
| 86 | do { | 86 | do { |
| 87 | if (ttype(&n->key) == LUA_TNUMBER && nvalue(&n->key) == key) | 87 | if (ttype(&n->key) == LUA_TNUMBER && nvalue(&n->key) == key) |
| @@ -290,7 +290,7 @@ TObject *luaH_setint (lua_State *L, Hash *t, int key) { | |||
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | 292 | ||
| 293 | void luaH_setstrnum (lua_State *L, Hash *t, TString *key, Number val) { | 293 | void luaH_setstrnum (lua_State *L, Hash *t, TString *key, lua_Number val) { |
| 294 | TObject *value, index; | 294 | TObject *value, index; |
| 295 | ttype(&index) = LUA_TSTRING; | 295 | ttype(&index) = LUA_TSTRING; |
| 296 | tsvalue(&index) = key; | 296 | tsvalue(&index) = key; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.h,v 1.24 2000/08/31 14:08:27 roberto Exp roberto $ | 2 | ** $Id: ltable.h,v 1.25 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -17,13 +17,13 @@ | |||
| 17 | Hash *luaH_new (lua_State *L, int nhash); | 17 | Hash *luaH_new (lua_State *L, int nhash); |
| 18 | void luaH_free (lua_State *L, Hash *t); | 18 | void luaH_free (lua_State *L, Hash *t); |
| 19 | const TObject *luaH_get (lua_State *L, const Hash *t, const TObject *key); | 19 | const TObject *luaH_get (lua_State *L, const Hash *t, const TObject *key); |
| 20 | const TObject *luaH_getnum (const Hash *t, Number key); | 20 | const TObject *luaH_getnum (const Hash *t, lua_Number key); |
| 21 | const TObject *luaH_getstr (const Hash *t, TString *key); | 21 | const TObject *luaH_getstr (const Hash *t, TString *key); |
| 22 | void luaH_remove (Hash *t, TObject *key); | 22 | void luaH_remove (Hash *t, TObject *key); |
| 23 | TObject *luaH_set (lua_State *L, Hash *t, const TObject *key); | 23 | TObject *luaH_set (lua_State *L, Hash *t, const TObject *key); |
| 24 | Node * luaH_next (lua_State *L, const Hash *t, const TObject *r); | 24 | Node * luaH_next (lua_State *L, const Hash *t, const TObject *r); |
| 25 | TObject *luaH_setint (lua_State *L, Hash *t, int key); | 25 | TObject *luaH_setint (lua_State *L, Hash *t, int key); |
| 26 | void luaH_setstrnum (lua_State *L, Hash *t, TString *key, Number val); | 26 | void luaH_setstrnum (lua_State *L, Hash *t, TString *key, lua_Number val); |
| 27 | luint32 luaH_hash (lua_State *L, const TObject *key); | 27 | luint32 luaH_hash (lua_State *L, const TObject *key); |
| 28 | const TObject *luaH_getglobal (lua_State *L, const char *name); | 28 | const TObject *luaH_getglobal (lua_State *L, const char *name); |
| 29 | 29 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.78 2000/10/30 12:38:50 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.79 2000/10/31 12:44:07 roberto Exp roberto $ |
| 3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
| 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
| 5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
| @@ -57,6 +57,9 @@ | |||
| 57 | #define LUA_ERRERR 5 | 57 | #define LUA_ERRERR 5 |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | /* Lua numerical type */ | ||
| 61 | typedef double lua_Number; | ||
| 62 | |||
| 60 | typedef struct lua_State lua_State; | 63 | typedef struct lua_State lua_State; |
| 61 | 64 | ||
| 62 | typedef int (*lua_CFunction) (lua_State *L); | 65 | typedef int (*lua_CFunction) (lua_State *L); |
| @@ -107,7 +110,7 @@ LUA_API int lua_tag (lua_State *L, int index); | |||
| 107 | LUA_API int lua_equal (lua_State *L, int index1, int index2); | 110 | LUA_API int lua_equal (lua_State *L, int index1, int index2); |
| 108 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); | 111 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); |
| 109 | 112 | ||
| 110 | LUA_API double lua_tonumber (lua_State *L, int index); | 113 | LUA_API lua_Number lua_tonumber (lua_State *L, int index); |
| 111 | LUA_API const char *lua_tostring (lua_State *L, int index); | 114 | LUA_API const char *lua_tostring (lua_State *L, int index); |
| 112 | LUA_API size_t lua_strlen (lua_State *L, int index); | 115 | LUA_API size_t lua_strlen (lua_State *L, int index); |
| 113 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); | 116 | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); |
| @@ -119,7 +122,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index); | |||
| 119 | ** push functions (C -> stack) | 122 | ** push functions (C -> stack) |
| 120 | */ | 123 | */ |
| 121 | LUA_API void lua_pushnil (lua_State *L); | 124 | LUA_API void lua_pushnil (lua_State *L); |
| 122 | LUA_API void lua_pushnumber (lua_State *L, double n); | 125 | LUA_API void lua_pushnumber (lua_State *L, lua_Number n); |
| 123 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); | 126 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); |
| 124 | LUA_API void lua_pushstring (lua_State *L, const char *s); | 127 | LUA_API void lua_pushstring (lua_State *L, const char *s); |
| 125 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); | 128 | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lundump.c,v 1.33 2000/10/31 16:57:23 lhf Exp $ | 2 | ** $Id: lundump.c,v 1.34 2000/11/07 12:44:44 roberto Exp roberto $ |
| 3 | ** load bytecodes from files | 3 | ** load bytecodes from files |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -82,9 +82,9 @@ static size_t LoadSize (lua_State* L, ZIO* Z, int swap) | |||
| 82 | return x; | 82 | return x; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | static Number LoadNumber (lua_State* L, ZIO* Z, int swap) | 85 | static lua_Number LoadNumber (lua_State* L, ZIO* Z, int swap) |
| 86 | { | 86 | { |
| 87 | Number x; | 87 | lua_Number x; |
| 88 | LoadBlock(L,&x,sizeof(x),Z,swap); | 88 | LoadBlock(L,&x,sizeof(x),Z,swap); |
| 89 | return x; | 89 | return x; |
| 90 | } | 90 | } |
| @@ -142,7 +142,7 @@ static void LoadConstants (lua_State* L, Proto* tf, ZIO* Z, int swap) | |||
| 142 | for (i=0; i<n; i++) | 142 | for (i=0; i<n; i++) |
| 143 | tf->kstr[i]=LoadString(L,Z,swap); | 143 | tf->kstr[i]=LoadString(L,Z,swap); |
| 144 | tf->nknum=n=LoadInt(L,Z,swap); | 144 | tf->nknum=n=LoadInt(L,Z,swap); |
| 145 | tf->knum=luaM_newvector(L,n,Number); | 145 | tf->knum=luaM_newvector(L,n,lua_Number); |
| 146 | LoadVector(L,tf->knum,n,sizeof(*tf->knum),Z,swap); | 146 | LoadVector(L,tf->knum,n,sizeof(*tf->knum),Z,swap); |
| 147 | tf->nkproto=n=LoadInt(L,Z,swap); | 147 | tf->nkproto=n=LoadInt(L,Z,swap); |
| 148 | tf->kproto=luaM_newvector(L,n,Proto*); | 148 | tf->kproto=luaM_newvector(L,n,Proto*); |
| @@ -187,7 +187,7 @@ static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) | |||
| 187 | static int LoadHeader (lua_State* L, ZIO* Z) | 187 | static int LoadHeader (lua_State* L, ZIO* Z) |
| 188 | { | 188 | { |
| 189 | int version,swap; | 189 | int version,swap; |
| 190 | Number f=0,tf=TEST_NUMBER; | 190 | lua_Number f=0,tf=TEST_NUMBER; |
| 191 | LoadSignature(L,Z); | 191 | LoadSignature(L,Z); |
| 192 | version=ezgetc(L,Z); | 192 | version=ezgetc(L,Z); |
| 193 | if (version>VERSION) | 193 | if (version>VERSION) |
| @@ -205,7 +205,7 @@ static int LoadHeader (lua_State* L, ZIO* Z) | |||
| 205 | TESTSIZE(SIZE_INSTRUCTION); | 205 | TESTSIZE(SIZE_INSTRUCTION); |
| 206 | TESTSIZE(SIZE_OP); | 206 | TESTSIZE(SIZE_OP); |
| 207 | TESTSIZE(SIZE_B); | 207 | TESTSIZE(SIZE_B); |
| 208 | TESTSIZE(sizeof(Number)); | 208 | TESTSIZE(sizeof(lua_Number)); |
| 209 | f=LoadNumber(L,Z,swap); | 209 | f=LoadNumber(L,Z,swap); |
| 210 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ | 210 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ |
| 211 | luaO_verror(L,"unknown number format in `%.99s':\n" | 211 | luaO_verror(L,"unknown number format in `%.99s':\n" |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.146 2000/10/26 12:47:05 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.147 2000/11/24 17:39:56 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -402,7 +402,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
| 402 | } | 402 | } |
| 403 | case OP_PUSHINT: { | 403 | case OP_PUSHINT: { |
| 404 | ttype(top) = LUA_TNUMBER; | 404 | ttype(top) = LUA_TNUMBER; |
| 405 | nvalue(top) = (Number)GETARG_S(i); | 405 | nvalue(top) = (lua_Number)GETARG_S(i); |
| 406 | top++; | 406 | top++; |
| 407 | break; | 407 | break; |
| 408 | } | 408 | } |
| @@ -523,11 +523,11 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
| 523 | case OP_ADDI: { | 523 | case OP_ADDI: { |
| 524 | if (tonumber(top-1)) { | 524 | if (tonumber(top-1)) { |
| 525 | ttype(top) = LUA_TNUMBER; | 525 | ttype(top) = LUA_TNUMBER; |
| 526 | nvalue(top) = (Number)GETARG_S(i); | 526 | nvalue(top) = (lua_Number)GETARG_S(i); |
| 527 | call_arith(L, top+1, TM_ADD); | 527 | call_arith(L, top+1, TM_ADD); |
| 528 | } | 528 | } |
| 529 | else | 529 | else |
| 530 | nvalue(top-1) += (Number)GETARG_S(i); | 530 | nvalue(top-1) += (lua_Number)GETARG_S(i); |
| 531 | break; | 531 | break; |
| 532 | } | 532 | } |
| 533 | case OP_SUB: { | 533 | case OP_SUB: { |
