lvm.c
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:20k
- /*
- ** $Id: lvm.c,v 1.146 2000/10/26 12:47:05 roberto Exp $
- ** Lua virtual machine
- ** See Copyright Notice in lua.h
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "lua.h"
- #include "lapi.h"
- #include "ldebug.h"
- #include "ldo.h"
- #include "lfunc.h"
- #include "lgc.h"
- #include "lobject.h"
- #include "lopcodes.h"
- #include "lstate.h"
- #include "lstring.h"
- #include "ltable.h"
- #include "ltm.h"
- #include "lvm.h"
- #ifdef OLD_ANSI
- #define strcoll(a,b) strcmp(a,b)
- #endif
- /*
- ** Extra stack size to run a function:
- ** TAG_LINE(1), NAME(1), TM calls(3) (plus some extra...)
- */
- #define EXTRA_STACK 8
- int luaV_tonumber (TObject *obj) {
- if (ttype(obj) != LUA_TSTRING)
- return 1;
- else {
- if (!luaO_str2d(svalue(obj), &nvalue(obj)))
- return 2;
- ttype(obj) = LUA_TNUMBER;
- return 0;
- }
- }
- int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */
- if (ttype(obj) != LUA_TNUMBER)
- return 1;
- else {
- char s[32]; /* 16 digits, sign, point and