Ejemplo n.º 1
0
void
_slang_label_delete(slang_label *l)
{
   if (l->Name) {
      _slang_free(l->Name);
      l->Name = NULL;
   }
   if (l->References) {
      _slang_free(l->References);
      l->References = NULL;
   }
   _slang_free(l);
}
Ejemplo n.º 2
0
int
slang_variable_copy(slang_variable * x, const slang_variable * y)
{
   slang_variable z;

   if (!slang_variable_construct(&z))
      return 0;
   if (!slang_fully_specified_type_copy(&z.type, &y->type)) {
      slang_variable_destruct(&z);
      return 0;
   }
   z.a_name = y->a_name;
   z.array_len = y->array_len;
   if (y->initializer != NULL) {
      z.initializer
         = (slang_operation *) _slang_alloc(sizeof(slang_operation));
      if (z.initializer == NULL) {
         slang_variable_destruct(&z);
         return 0;
      }
      if (!slang_operation_construct(z.initializer)) {
         _slang_free(z.initializer);
         slang_variable_destruct(&z);
         return 0;
      }
      if (!slang_operation_copy(z.initializer, y->initializer)) {
         slang_variable_destruct(&z);
         return 0;
      }
   }
   z.size = y->size;
   slang_variable_destruct(x);
   *x = z;
   return 1;
}
Ejemplo n.º 3
0
void
slang_atom_pool_destruct (slang_atom_pool * pool)
{
   GLuint i;

   for (i = 0; i < SLANG_ATOM_POOL_SIZE; i++) {
      slang_atom_entry * entry;
		
      entry = pool->entries[i];
      while (entry != NULL) {
         slang_atom_entry *next = entry->next;
         _slang_free(entry->id);
         _slang_free(entry);
         entry = next;
      }
   }
}
Ejemplo n.º 4
0
static slang_variable *
slang_variable_new(void)
{
   slang_variable *v = (slang_variable *) _slang_alloc(sizeof(slang_variable));
   if (v) {
      if (!slang_variable_construct(v)) {
         _slang_free(v);
         v = NULL;
      }
   }
   return v;
}
Ejemplo n.º 5
0
static void
_slang_free_ir(slang_ir_node *n)
{
   GLuint i;
   if (!n)
      return;

#if 0
   if (n->Store) {
      n->Store->RefCount--;
      if (n->Store->RefCount == 0) {
         _slang_free(n->Store);
         n->Store = NULL;
      }
   }
#endif

   for (i = 0; i < 3; i++)
      _slang_free_ir(n->Children[i]);
   /* Do not free n->List since it's a child elsewhere */
   _slang_free(n);
}
Ejemplo n.º 6
0
void
slang_variable_scope_destruct(slang_variable_scope * scope)
{
   unsigned int i;

   if (!scope)
      return;
   for (i = 0; i < scope->num_variables; i++) {
      if (scope->variables[i])
         slang_variable_delete(scope->variables[i]);
   }
   _slang_free(scope->variables);
   /* do not free scope->outer_scope */
}
Ejemplo n.º 7
0
void
slang_variable_destruct(slang_variable * var)
{
   slang_fully_specified_type_destruct(&var->type);
   if (var->initializer != NULL) {
      slang_operation_destruct(var->initializer);
      _slang_free(var->initializer);
   }
#if 0
   if (var->aux) {
      free(var->aux);
   }
#endif
}
Ejemplo n.º 8
0
void
_slang_label_set_location(slang_label *l, GLint location,
                          struct gl_program *prog)
{
   GLuint i;

   assert(l->Location < 0);
   assert(location >= 0);

   l->Location = location;

   /* for the instructions that were waiting to learn the label's location: */
   for (i = 0; i < l->NumReferences; i++) {
      const GLuint j = l->References[i];
      prog->Instructions[j].BranchTarget = location;
   }

   if (l->References) {
      _slang_free(l->References);
      l->References = NULL;
   }
}
Ejemplo n.º 9
0
static void
slang_variable_delete(slang_variable * var)
{
   slang_variable_destruct(var);
   _slang_free(var);
}