misc/liblua/lundump.c
author nemo
Sat, 27 Apr 2013 17:02:26 -0400
changeset 8940 181ea27122da
parent 2812 0a24853de796
child 10017 de822cd3df3a
permissions -rw-r--r--
This is something we need to check in all translations. Occasionally the source phrase ends w/ a space. Need to make sure translations take this into account.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** load precompiled Lua chunks
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
#include <string.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
#define lundump_c
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
#define LUA_CORE
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
#include "ldebug.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
#include "ldo.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
#include "lfunc.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
#include "lmem.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
#include "lobject.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
#include "lstring.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    20
#include "lundump.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
#include "lzio.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
typedef struct {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
 lua_State* L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
 ZIO* Z;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
 Mbuffer* b;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
 const char* name;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
} LoadState;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
#ifdef LUAC_TRUST_BINARIES
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
#define IF(c,s)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
#define error(S,s)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
#else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
#define IF(c,s)		if (c) error(S,s)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
static void error(LoadState* S, const char* why)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
 luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
 luaD_throw(S->L,LUA_ERRSYNTAX);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
#endif
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
#define LoadMem(S,b,n,size)	LoadBlock(S,b,(n)*(size))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
#define	LoadByte(S)		(lu_byte)LoadChar(S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
#define LoadVar(S,x)		LoadMem(S,&x,1,sizeof(x))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
#define LoadVector(S,b,n,size)	LoadMem(S,b,n,size)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
static void LoadBlock(LoadState* S, void* b, size_t size)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
 size_t r=luaZ_read(S->Z,b,size);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
 IF (r!=0, "unexpected end");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
static int LoadChar(LoadState* S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
 char x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    57
 LoadVar(S,x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    58
 return x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    60
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    61
static int LoadInt(LoadState* S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
 int x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
 LoadVar(S,x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
 IF (x<0, "bad integer");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
 return x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    69
static lua_Number LoadNumber(LoadState* S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    70
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
 lua_Number x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
 LoadVar(S,x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
 return x;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
static TString* LoadString(LoadState* S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
 size_t size;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
 LoadVar(S,size);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
 if (size==0)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
  return NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
 else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
  char* s=luaZ_openspace(S->L,S->b,size);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
  LoadBlock(S,s,size);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
  return luaS_newlstr(S->L,s,size-1);		/* remove trailing '\0' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
static void LoadCode(LoadState* S, Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
 int n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
 f->code=luaM_newvector(S->L,n,Instruction);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
 f->sizecode=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
 LoadVector(S,f->code,n,sizeof(Instruction));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
static Proto* LoadFunction(LoadState* S, TString* p);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
static void LoadConstants(LoadState* S, Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
 int i,n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
 n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
 f->k=luaM_newvector(S->L,n,TValue);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
 f->sizek=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
  TValue* o=&f->k[i];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
  int t=LoadChar(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
  switch (t)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
  {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
   case LUA_TNIL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
   	setnilvalue(o);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
	break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
   case LUA_TBOOLEAN:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
   	setbvalue(o,LoadChar(S)!=0);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
	break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
   case LUA_TNUMBER:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
	setnvalue(o,LoadNumber(S));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
	break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
   case LUA_TSTRING:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
	setsvalue2n(S->L,o,LoadString(S));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
	break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
   default:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
	error(S,"bad constant");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
	break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
 n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
 f->p=luaM_newvector(S->L,n,Proto*);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
 f->sizep=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
 for (i=0; i<n; i++) f->p[i]=NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
static void LoadDebug(LoadState* S, Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
 int i,n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
 n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
 f->lineinfo=luaM_newvector(S->L,n,int);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
 f->sizelineinfo=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
 LoadVector(S,f->lineinfo,n,sizeof(int));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
 n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
 f->locvars=luaM_newvector(S->L,n,LocVar);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
 f->sizelocvars=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
 for (i=0; i<n; i++) f->locvars[i].varname=NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
  f->locvars[i].varname=LoadString(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
  f->locvars[i].startpc=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
  f->locvars[i].endpc=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
 n=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
 f->upvalues=luaM_newvector(S->L,n,TString*);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
 f->sizeupvalues=n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
 for (i=0; i<n; i++) f->upvalues[i]=NULL;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   158
 for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   159
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
static Proto* LoadFunction(LoadState* S, TString* p)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
 Proto* f;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
 if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
 f=luaF_newproto(S->L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
 setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
 f->source=LoadString(S); if (f->source==NULL) f->source=p;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
 f->linedefined=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
 f->lastlinedefined=LoadInt(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
 f->nups=LoadByte(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   171
 f->numparams=LoadByte(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   172
 f->is_vararg=LoadByte(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   173
 f->maxstacksize=LoadByte(S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174
 LoadCode(S,f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   175
 LoadConstants(S,f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   176
 LoadDebug(S,f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   177
 IF (!luaG_checkcode(f), "bad code");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   178
 S->L->top--;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   179
 S->L->nCcalls--;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   180
 return f;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   181
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   182
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   183
static void LoadHeader(LoadState* S)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   184
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   185
 char h[LUAC_HEADERSIZE];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   186
 char s[LUAC_HEADERSIZE];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   187
 luaU_header(h);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   188
 LoadBlock(S,s,LUAC_HEADERSIZE);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   189
 IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   190
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   191
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   192
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   193
** load precompiled chunk
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   194
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   195
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   196
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   197
 LoadState S;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   198
 if (*name=='@' || *name=='=')
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   199
  S.name=name+1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   200
 else if (*name==LUA_SIGNATURE[0])
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   201
  S.name="binary string";
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   202
 else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   203
  S.name=name;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   204
 S.L=L;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   205
 S.Z=Z;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   206
 S.b=buff;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   207
 LoadHeader(&S);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   208
 return LoadFunction(&S,luaS_newliteral(L,"=?"));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   209
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   210
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   211
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   212
* make header
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   213
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   214
void luaU_header (char* h)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   215
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   216
 int x=1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   217
 memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   218
 h+=sizeof(LUA_SIGNATURE)-1;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   219
 *h++=(char)LUAC_VERSION;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   220
 *h++=(char)LUAC_FORMAT;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   221
 *h++=(char)*(char*)&x;				/* endianness */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   222
 *h++=(char)sizeof(int);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   223
 *h++=(char)sizeof(size_t);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   224
 *h++=(char)sizeof(Instruction);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   225
 *h++=(char)sizeof(lua_Number);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   226
 *h++=(char)(((lua_Number)0.5)==0);		/* is lua_Number integral? */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   227
}