2009-09-01から1ヶ月間の記事一覧

Lua処理系コード読み(10) UpVal

lobject.h /* ** Upvalues */ typedef struct UpVal { CommonHeader; TValue *v; /* points to stack or to its own value */ union { TValue value; /* the value (when closed) */ struct { /* double linked list (when open) */ struct UpVal *prev; str…

Lua処理系コード読み(9) Proto

lobject.h /* ** Function Prototypes */ typedef struct Proto { CommonHeader; TValue *k; /* constants used by the function */ Instruction *code; struct Proto **p; /* functions defined inside the function */ int *lineinfo; /* map from opcodes…

Lua処理系コード読み(8) Closure, LClosure, CClosure

lobject.h /* ** Closures */ #define ClosureHeader \ CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ struct Table *env typedef struct CClosure { ClosureHeader; lua_CFunction f; TValue upvalue[1]; } CClosure; typedef struct…

Lua処理系コード読み(7) luaC_checkGC

lgc.h #define luaC_checkGC(L) { \ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ if (G(L)->totalbytes >= G(L)->GCthreshold) \ luaC_step(L); } 総アロケート量が閾値を超えているときにGCステップの呼び出し。超えてな…

Lua処理系コード読み(6) luaM_realloc_

lmem.c /* ** generic allocation routine. */ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { global_State *g = G(L); lua_assert((osize == 0) == (block == NULL)); block = (*g->frealloc)(g->ud, block, osize, nsiz…

Lua処理系コード読み(4) luaV_execute

lvm.c void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; StkId base; TValue *k; const Instruction *pc; reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; cl = &clvalue(L->ci->func)->l; base = L->base; k = c…

Lua処理系コード読み(4) Instruction

llimits.h /* ** type for virtual-machine instructions ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) */ typedef lu_int32 Instruction; Lua VM命令の型。4バイト(=32ビット)。lopcodes.hに /*==========================…

Lua処理系コード読み(3) StkId

lobject.h typedef TValue *StkId; /* index to stack elements */ Lua VMのスタック要素を示す型。実質TValueのポインタ。

test