diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-08-16 17:52:00 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-08-16 17:52:00 -0300 |
commit | c787dccd9b5c3e55547a2c4bb598c0276de65034 (patch) | |
tree | c4cdf2f7319fee48e048472a2044119f541e8da2 /ldo.c | |
parent | b44e35b773bcaa9891d80a117392911ab5f656e5 (diff) | |
download | lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.gz lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.bz2 lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.zip |
"const" !!!
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.44 1999/06/17 17:04:03 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.45 1999/06/22 20:37:23 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -159,7 +159,7 @@ static StkId callCclosure (struct Closure *cl, lua_CFunction f, StkId base) { | |||
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void luaD_callTM (TObject *f, int nParams, int nResults) { | 162 | void luaD_callTM (const TObject *f, int nParams, int nResults) { |
163 | luaD_openstack(nParams); | 163 | luaD_openstack(nParams); |
164 | *(L->stack.top-nParams-1) = *f; | 164 | *(L->stack.top-nParams-1) = *f; |
165 | luaD_calln(nParams, nResults); | 165 | luaD_calln(nParams, nResults); |
@@ -199,7 +199,7 @@ void luaD_calln (int nArgs, int nResults) { | |||
199 | } | 199 | } |
200 | default: { /* func is not a function */ | 200 | default: { /* func is not a function */ |
201 | /* Check the tag method for invalid functions */ | 201 | /* Check the tag method for invalid functions */ |
202 | TObject *im = luaT_getimbyObj(func, IM_FUNCTION); | 202 | const TObject *im = luaT_getimbyObj(func, IM_FUNCTION); |
203 | if (ttype(im) == LUA_T_NIL) | 203 | if (ttype(im) == LUA_T_NIL) |
204 | lua_error("call expression not a function"); | 204 | lua_error("call expression not a function"); |
205 | luaD_callTM(im, (S->top-S->stack)-(base-1), nResults); | 205 | luaD_callTM(im, (S->top-S->stack)-(base-1), nResults); |
@@ -222,8 +222,7 @@ void luaD_calln (int nArgs, int nResults) { | |||
222 | /* | 222 | /* |
223 | ** Traverse all objects on L->stack.stack | 223 | ** Traverse all objects on L->stack.stack |
224 | */ | 224 | */ |
225 | void luaD_travstack (int (*fn)(TObject *)) | 225 | void luaD_travstack (int (*fn)(TObject *)) { |
226 | { | ||
227 | StkId i; | 226 | StkId i; |
228 | for (i = (L->stack.top-1)-L->stack.stack; i>=0; i--) | 227 | for (i = (L->stack.top-1)-L->stack.stack; i>=0; i--) |
229 | fn(L->stack.stack+i); | 228 | fn(L->stack.stack+i); |
@@ -231,8 +230,8 @@ void luaD_travstack (int (*fn)(TObject *)) | |||
231 | 230 | ||
232 | 231 | ||
233 | 232 | ||
234 | static void message (char *s) { | 233 | static void message (const char *s) { |
235 | TObject *em = &(luaS_new("_ERRORMESSAGE")->u.s.globalval); | 234 | const TObject *em = &(luaS_new("_ERRORMESSAGE")->u.s.globalval); |
236 | if (ttype(em) == LUA_T_PROTO || ttype(em) == LUA_T_CPROTO || | 235 | if (ttype(em) == LUA_T_PROTO || ttype(em) == LUA_T_CPROTO || |
237 | ttype(em) == LUA_T_CLOSURE) { | 236 | ttype(em) == LUA_T_CLOSURE) { |
238 | *L->stack.top = *em; | 237 | *L->stack.top = *em; |
@@ -245,7 +244,7 @@ static void message (char *s) { | |||
245 | /* | 244 | /* |
246 | ** Reports an error, and jumps up to the available recover label | 245 | ** Reports an error, and jumps up to the available recover label |
247 | */ | 246 | */ |
248 | void lua_error (char *s) { | 247 | void lua_error (const char *s) { |
249 | if (s) message(s); | 248 | if (s) message(s); |
250 | if (L->errorJmp) | 249 | if (L->errorJmp) |
251 | longjmp(L->errorJmp->b, 1); | 250 | longjmp(L->errorJmp->b, 1); |
@@ -335,9 +334,8 @@ static int do_main (ZIO *z, int bin) { | |||
335 | } | 334 | } |
336 | 335 | ||
337 | 336 | ||
338 | void luaD_gcIM (TObject *o) | 337 | void luaD_gcIM (const TObject *o) { |
339 | { | 338 | const TObject *im = luaT_getimbyObj(o, IM_GC); |
340 | TObject *im = luaT_getimbyObj(o, IM_GC); | ||
341 | if (ttype(im) != LUA_T_NIL) { | 339 | if (ttype(im) != LUA_T_NIL) { |
342 | *L->stack.top = *o; | 340 | *L->stack.top = *o; |
343 | incr_top; | 341 | incr_top; |
@@ -348,7 +346,7 @@ void luaD_gcIM (TObject *o) | |||
348 | 346 | ||
349 | #define MAXFILENAME 260 /* maximum part of a file name kept */ | 347 | #define MAXFILENAME 260 /* maximum part of a file name kept */ |
350 | 348 | ||
351 | int lua_dofile (char *filename) { | 349 | int lua_dofile (const char *filename) { |
352 | ZIO z; | 350 | ZIO z; |
353 | int status; | 351 | int status; |
354 | int c; | 352 | int c; |
@@ -371,12 +369,12 @@ int lua_dofile (char *filename) { | |||
371 | } | 369 | } |
372 | 370 | ||
373 | 371 | ||
374 | int lua_dostring (char *str) { | 372 | int lua_dostring (const char *str) { |
375 | return lua_dobuffer(str, strlen(str), str); | 373 | return lua_dobuffer(str, strlen(str), str); |
376 | } | 374 | } |
377 | 375 | ||
378 | 376 | ||
379 | int lua_dobuffer (char *buff, int size, char *name) { | 377 | int lua_dobuffer (const char *buff, int size, const char *name) { |
380 | ZIO z; | 378 | ZIO z; |
381 | if (!name) name = "?"; | 379 | if (!name) name = "?"; |
382 | luaZ_mopen(&z, buff, size, name); | 380 | luaZ_mopen(&z, buff, size, name); |