Ejemplo n.º 1
0
void luaI_strfree (TaggedString *l)
{
  while (l) {
    TaggedString *next = l->next;
    luaI_free(l);
    l = next;
  }
}
Ejemplo n.º 2
0
/*
** Called to execute RESET opcode, this function pops a function from 
** function stack.
*/
void lua_popfunction (void)
{
 FuncStackNode *temp = funcStack;
 if (temp == NULL) return;
 --nfuncstack;
 lua_debugline = temp->line;
 funcStack = temp->next;
 luaI_free(temp);
}
Ejemplo n.º 3
0
/*
** Re-hash
*/
static void rehash (Hash *t)
{
 int i;
 int   nold = nhash(t);
 Node *vold = nodevector(t);
 nhash(t) = luaI_redimension(nhash(t));
 nodevector(t) = hashnodecreate(nhash(t));
 for (i=0; i<nold; i++)
 {
  Node *n = vold+i;
  if (tag(ref(n)) != LUA_T_NIL && tag(val(n)) != LUA_T_NIL)
   *node(t, present(t, ref(n))) = *n;  /* copy old node to new hahs */
 }
 luaI_free(vold);
}
Ejemplo n.º 4
0
static void grow (stringtable *tb)
{
  int newsize = luaI_redimension(tb->size);
  TaggedString **newhash = newvector(newsize, TaggedString *);
  int i;
  for (i=0; i<newsize; i++)
    newhash[i] = NULL;
  /* rehash */
  tb->nuse = 0;
  for (i=0; i<tb->size; i++)
    if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) {
      int h = tb->hash[i]->hash%newsize;
      while (newhash[h])
        h = (h+1)%newsize;
      newhash[h] = tb->hash[i];
      tb->nuse++;
    }
  luaI_free(tb->hash); 
  tb->size = newsize;
  tb->hash = newhash;
}
Ejemplo n.º 5
0
int lua_domain (void)
{
  TFunc tf;
  int status;
  jmp_buf myErrorJmp;
  jmp_buf *oldErr = errorJmp;
  errorJmp = &myErrorJmp;
  luaI_initTFunc(&tf);
  if (setjmp(myErrorJmp) == 0) {
    lua_parse(&tf);
    status = 0;
  }
  else {
    adjustC(0);  /* erase extra slot */
    status = 1;
  }
  if (status == 0)
    status = luaI_dorun(&tf);
  errorJmp = oldErr;
  luaI_free(tf.code);
  return status;
}
Ejemplo n.º 6
0
Archivo: opcode.c Proyecto: cskau/VM
static int do_protectedmain (void)
{
  TFunc tf;
  int status;
  jmp_buf myErrorJmp;
  jmp_buf *oldErr = errorJmp;
  errorJmp = &myErrorJmp;
  luaI_initTFunc(&tf);
  tf.fileName = lua_parsedfile;
  if (setjmp(myErrorJmp) == 0)
  {
    lua_parse(&tf);
    status = luaI_dorun(&tf);
  }
  else
  {
    status = 1;
    adjustC(0);  /* erase extra slot */
  }
  errorJmp = oldErr;
  luaI_free(tf.code);
  return status;
}
Ejemplo n.º 7
0
/*
** Delete a hash
*/
static void hashdelete (Hash *t)
{
 luaI_free (nodevector(t));
 luaI_free(t);
}