Exemple #1
0
void luaG_ordererror (lua_State *L, StkId top) {
  const char *t1 = luaO_typename(top-2);
  const char *t2 = luaO_typename(top-1);
  if (t1[2] == t2[2])
    luaO_verror(L, "attempt to compare two %.10s values", t1);
  else
    luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2);
}
Exemple #2
0
static void DumpConstants(TProtoFunc* tf, FILE* D) {
 int i,n;
 n = tf->nconsts;
 DumpWord(n,D);
 for (i=0; i<n; i++) {
  TObject* o=tf->consts+i;
  switch (ttype(o)) {
   case LUA_T_NUMBER:
	fputc('N',D);
	DumpNumber(nvalue(o),D);
	break;
   case LUA_T_STRING:
	fputc('S',D);
	DumpTString(tsvalue(o),D);
	break;
   case LUA_T_PROTO:
	fputc('F',D);
	break;
   case LUA_T_NIL:
	fputc(-ttype(o),D);
	break;
   default:				/* cannot happen */
	luaL_verror("cannot dump constant #%d: type=%d [%s]",
		i,ttype(o),luaO_typename(o));
	break;
  }
 }
}
Exemple #3
0
void luaG_typeerror (lua_State *L, StkId o, const char *op) {
  const char *name;
  const char *kind = getobjname(L, o, &name);
  const char *t = luaO_typename(o);
  if (kind)
    luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)",
                op, kind, name, t);
  else
    luaO_verror(L, "attempt to %.30s a %.10s value", op, t);
}
Exemple #4
0
LUA_API void lua_settag (lua_State *L, int tag) {
  luaT_realtag(L, tag);
  switch (ttype(L->top-1)) {
    case LUA_TTABLE:
      hvalue(L->top-1)->htag = tag;
      break;
    case LUA_TUSERDATA:
      tsvalue(L->top-1)->u.d.tag = tag;
      break;
    default:
      luaO_verror(L, "cannot change the tag of a %.20s",
                  luaO_typename(L->top-1));
  }
}
Exemple #5
0
void lua_settag (int tag)
{
  checkCparams(1);
  luaT_realtag(tag);
  switch (ttype(L->stack.top-1)) {
    case LUA_T_ARRAY:
      (L->stack.top-1)->value.a->htag = tag;
      break;
    case LUA_T_USERDATA:
      (L->stack.top-1)->value.ts->u.d.tag = tag;
      break;
    default:
      luaL_verror("cannot change the tag of a %.20s",
                  luaO_typename(L->stack.top-1));
  }
  L->stack.top--;
}
Exemple #6
0
static void luaB_type (void) {
  lua_Object o = luaL_nonnullarg(1);
  lua_pushstring(luaO_typename(luaA_Address(o)));
  lua_pushnumber(lua_tag(o));
}