lvm.c
资源名称:wow.rar [点击查看]
上传用户:jxpjxmjjw
上传日期:2009-12-07
资源大小:5877k
文件大小:24k
源码类别:
模拟服务器
开发平台:
Visual C++
- /*
- ** $Id: lvm.c,v 1.1 2004/08/20 02:26:56 JH Exp $
- ** Lua virtual machine
- ** See Copyright Notice in lua.h
- */
- #include <stdarg.h>
- #include <stdlib.h>
- #include <string.h>
- /* needed only when `lua_number2str' uses `sprintf' */
- #include <stdio.h>
- #define lvm_c
- #include "lua.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"
- /* function to convert a lua_Number to a string */
- #ifndef lua_number2str
- #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
- #endif
- /* limit for table tag-method chains (to avoid loops) */
- #define MAXTAGLOOP 100
- const TObject *luaV_tonumber (const TObject *obj, TObject *n) {
- lua_Number num;
- if (ttisnumber(obj)) return obj;
- if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
- setnvalue(n, num);
- return n;
- }
- else
- return NULL;
- }
- int luaV_tostring (lua_State *L, StkId obj) {
- if (!ttisnumber(obj))
- return 0;
- else {
- char s[32]; /* 16 digits, sign, point and