当前位置: 首页>>代码示例>>C++>>正文


C++ sizeLclosure函数代码示例

本文整理汇总了C++中sizeLclosure函数的典型用法代码示例。如果您正苦于以下问题:C++ sizeLclosure函数的具体用法?C++ sizeLclosure怎么用?C++ sizeLclosure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sizeLclosure函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: freeobj

static void freeobj (lua_State *L, GCObject *o) {
	switch (gch(o)->tt) {
	case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
	case LUA_TLCL: {
		luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues));
		break;
	}
	case LUA_TCCL: {
		luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues));
		break;
	}
	case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break;
	case LUA_TTABLE: luaH_free(L, gco2t(o)); break;
	case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break;
	case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break;
	case LUA_TSHRSTR:
		G(L)->strt.nuse--;
		/* go through */
	case LUA_TLNGSTR: {
		luaM_freemem(L, o, sizestring(gco2ts(o)));
		break;
	}
	default: lua_assert(0);
	}
}
开发者ID:crazii,项目名称:mameplus,代码行数:25,代码来源:lgc.c

示例2: sizeLclosure

Closure *luaF_newLclosure (lua_State *L, int n) {
  Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl;
  c->l.p = NULL;
  c->l.nupvalues = cast_byte(n);
  while (n--) c->l.upvals[n] = NULL;
  return c;
}
开发者ID:iVideo,项目名称:weishao,代码行数:7,代码来源:lfunc.c

示例3: traverseLclosure

static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
	int i;
	markobject(g, cl->p);  /* mark its prototype */
	for (i = 0; i < cl->nupvalues; i++)  /* mark its upvalues */
	markobject(g, cl->upvals[i]);
	return sizeLclosure(cl->nupvalues);
}
开发者ID:crazii,项目名称:mameplus,代码行数:7,代码来源:lgc.c

示例4: main

int main(int argc, char const* argv[])
{
    int i;
    int n = 10;
    LClosure* c = (LClosure*) malloc(sizeLclosure(n));
    assert(c);

    c->foo = 0;
    c->goo = 0;

    for (i = 0; i < n; ++i) {
        c->num_array[i] = (Num*) malloc(sizeof(Num));
        assert(c->num_array[i]);
        c->num_array[i]->i = i;
    }

    dprint(c->foo);
    dprint(c->goo);

    for (i = 0; i < n; ++i) {
        dprint(c->num_array[i]->i);
    }

    return 0;
}
开发者ID:mrvon,项目名称:LuaSource,代码行数:25,代码来源:lclosure.c

示例5: debug_getsize

int debug_getsize(lua_State* L)
{
  TValue* o = L->base;
  switch (o->tt) {
    /* Container types */
    case LUA_TTABLE: {
      Table *h = hvalue(o);
      lua_pushinteger(L, sizeof(Table) + sizeof(TValue) * h->sizearray +
                             sizeof(Node) * sizenode(h));
      break;
    }
    case LUA_TFUNCTION: {
      Closure *cl = clvalue(o);
      lua_pushinteger(L, (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
                           sizeLclosure(cl->l.nupvalues));
      break;
    }
    case LUA_TTHREAD: {
      lua_State *th = thvalue(o);
      lua_pushinteger(L, sizeof(lua_State) + sizeof(TValue) * th->stacksize +
                                 sizeof(CallInfo) * th->size_ci);
      break;
    }
    case LUA_TPROTO: {
      Proto *p = pvalue(o);
      lua_pushinteger(L, sizeof(Proto) + sizeof(Instruction) * p->sizecode +
                             sizeof(Proto *) * p->sizep +
                             sizeof(TValue) * p->sizek + 
                             sizeof(int) * p->sizelineinfo +
                             sizeof(LocVar) * p->sizelocvars +
                             sizeof(TString *) * p->sizeupvalues);
     break;
    }
    /* Non-containers */
    case LUA_TUSERDATA: {
      lua_pushnumber(L, uvalue(o)->len);
      break;
    }
    case LUA_TLIGHTUSERDATA: {
      lua_pushnumber(L, sizeof(void*));
      break;
    }
    case LUA_TSTRING: {
      TString *s = rawtsvalue(o);
      lua_pushinteger(L, sizeof(TString) + s->tsv.len + 1);
      break;
    }
    case LUA_TNUMBER: {
      lua_pushinteger(L, sizeof(lua_Number));
      break;
    }
    case LUA_TBOOLEAN: {
      lua_pushinteger(L, sizeof(int));
      break;
    }
    default: return 0;
  }
  return 1;
}
开发者ID:987690183,项目名称:selfNote,代码行数:59,代码来源:getsize.c

示例6: luaC_newobj

LClosure *luaF_newLclosure (lua_State *L, int n) {
  GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n));
  LClosure *c = gco2lcl(o);
  c->p = NULL;
  c->nupvalues = cast_byte(n);
  while (n--) c->upvals[n] = NULL;
  return c;
}
开发者ID:141141,项目名称:nodemcu-firmware-lua5.3.0,代码行数:8,代码来源:lfunc.c

示例7: sizeLclosure

Closure *luaF_newLclosure (lua_State *L, Proto *p) {
  int n = p->sizeupvalues;
  Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl;
  c->l.isC = 0;
  c->l.p = p;
  c->l.nupvalues = cast_byte(n);
  while (n--) c->l.upvals[n] = NULL;
  return c;
}
开发者ID:minlexx,项目名称:l2-unlegits,代码行数:9,代码来源:lfunc.c

示例8: freeLclosure

static void freeLclosure (lua_State *L, LClosure *cl) {
  int i;
  for (i = 0; i < cl->nupvalues; i++) {
    UpVal *uv = cl->upvals[i];
    if (uv)
      luaC_upvdeccount(L, uv);
  }
  luaM_freemem(L, cl, sizeLclosure(cl->nupvalues));
}
开发者ID:charleeli,项目名称:srpc,代码行数:9,代码来源:lgc.c

示例9: traverseLclosure

/*
** open upvalues point to values in a thread, so those values should
** be marked when the thread is traversed except in the atomic phase
** (because then the value cannot be changed by the thread and the
** thread may not be traversed again)
*/
static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
  int i;
  markobjectN(g, cl->p);  /* mark its prototype */
  for (i = 0; i < cl->nupvalues; i++) {  /* mark its upvalues */
    UpVal *uv = cl->upvals[i];
    if (uv != NULL) {
      if (upisopen(uv) && g->gcstate != GCSinsideatomic)
        uv->u.open.touched = 1;  /* can be marked in 'remarkupvals' */
      else
        markvalue(g, uv->v);
    }
  }
  return sizeLclosure(cl->nupvalues);
}
开发者ID:charleeli,项目名称:srpc,代码行数:20,代码来源:lgc.c

示例10: sizeLclosure

Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) {
	Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements));
	lua_linkObjToGC(luaState, obj2gco(c), LUA_TFUNCTION);

	c->l.isC = 0;
	c->l.env = elementTable;
	c->l.nupvalues = cast_byte(numElements);

	while (numElements--) {
		c->l.upvals[numElements] = NULL;
	}

	return c;
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:14,代码来源:lua_persistence_util.cpp

示例11: propagatemark

/*
** traverse one gray object, turning it to black.
** Returns `quantity' traversed.
*/
static l_mem propagatemark (global_State *g) {
  GCObject *o = g->gray;
  lua_assert(isgray(o));
  gray2black(o);
  switch (o->gch.tt) {
    case LUA_TTABLE: {
      Table *h = gco2h(o);
      g->gray = h->gclist;
      if (traversetable(g, h))  /* table is weak? */
        black2gray(o);  /* keep it gray */
      return sizeof(Table) + sizeof(TValue) * h->sizearray +
                             sizeof(Node) * sizenode(h);
    }
    case LUA_TFUNCTION: {
      Closure *cl = gco2cl(o);
      g->gray = cl->c.gclist;
      traverseclosure(g, cl);
      return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) :
                           sizeLclosure(cl->l.nupvalues);
    }
    case LUA_TTHREAD: {
      lua_State *th = gco2th(o);
      g->gray = th->gclist;
      th->gclist = g->grayagain;
      g->grayagain = o;
      black2gray(o);
      traversestack(g, th);
      return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
                                 sizeof(CallInfo) * th->size_ci;
    }
    case LUA_TPROTO: {
      Proto *p = gco2p(o);
      g->gray = p->gclist;
      traverseproto(g, p);
      return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
                             sizeof(Proto *) * p->sizep +
                             sizeof(TValue) * p->sizek + 
                             sizeof(int) * p->sizelineinfo +
                             sizeof(LocVar) * p->sizelocvars +
                             sizeof(TString *) * p->sizeupvalues;
    }
    default: lua_assert(0); return 0;
  }
}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:48,代码来源:lgc.c

示例12: luaF_freeclosure

void luaF_freeclosure (lua_State *L, Closure *c) {
  int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
                          sizeLclosure(c->l.nupvalues);
  luaM_freemem(L, c, size);
}
开发者ID:minlexx,项目名称:l2-unlegits,代码行数:5,代码来源:lfunc.c


注:本文中的sizeLclosure函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。