slang_variable_destruct (&func->header);
return 0;
}
- if (!slang_variable_scope_construct (func->parameters))
- {
- slang_alloc_free (func->parameters);
- slang_variable_destruct (&func->header);
- return 0;
- }
+ _slang_variable_scope_ctr (func->parameters);
func->param_count = 0;
func->body = NULL;
func->address = ~0;
slang_fixup_table_free (&func->fixups);
}
-/* slang_function_scope */
+/*
+ * slang_function_scope
+ */
-int slang_function_scope_construct (slang_function_scope *scope)
+GLvoid
+_slang_function_scope_ctr (slang_function_scope *self)
{
- scope->functions = NULL;
- scope->num_functions = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->functions = NULL;
+ self->num_functions = 0;
+ self->outer_scope = NULL;
}
void slang_function_scope_destruct (slang_function_scope *scope)
* _slang_build_export_code_table()
*/
-GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
- slang_translation_unit *unit)
+GLboolean
+_slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
+ slang_code_unit *unit)
{
slang_atom mainAtom;
GLuint i;
e = slang_export_code_table_add (tbl);
if (e == NULL)
return GL_FALSE;
- e->address = unit->assembly->count;
+ e->address = unit->object->assembly.count;
e->name = slang_atom_pool_atom (tbl->atoms, "@main");
if (e->name == SLANG_ATOM_NULL)
return GL_FALSE;
- A.file = unit->assembly;
- A.mach = unit->machine;
- A.atoms = unit->atom_pool;
- A.space.funcs = &unit->functions;
- A.space.structs = &unit->structs;
- A.space.vars = &unit->globals;
- slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
- slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
+ A.file = &unit->object->assembly;
+ A.mach = &unit->object->machine;
+ A.atoms = &unit->object->atompool;
+ A.space.funcs = &unit->funs;
+ A.space.structs = &unit->structs;
+ A.space.vars = &unit->vars;
+ slang_assembly_file_push_label (&unit->object->assembly, slang_asm_local_alloc, 20);
+ slang_assembly_file_push_label (&unit->object->assembly, slang_asm_enter, 20);
_slang_assemble_function_call (&A, fun, NULL, 0, GL_FALSE);
- slang_assembly_file_push (unit->assembly, slang_asm_exit);
+ slang_assembly_file_push (&unit->object->assembly, slang_asm_exit);
}
}
return GL_TRUE;
typedef struct slang_function_scope_
{
slang_function *functions;
- unsigned int num_functions;
+ GLuint num_functions;
struct slang_function_scope_ *outer_scope;
} slang_function_scope;
-int slang_function_scope_construct (slang_function_scope *);
+extern GLvoid
+_slang_function_scope_ctr (slang_function_scope *);
+
void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
-GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
- struct slang_translation_unit_ *);
+extern GLboolean
+_slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
+ struct slang_code_unit_ *);
#ifdef __cplusplus
}
oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (oper->locals == NULL)
return 0;
- if (!slang_variable_scope_construct (oper->locals))
- {
- slang_alloc_free (oper->locals);
- return 0;
- }
+ _slang_variable_scope_ctr (oper->locals);
return 1;
}
#include "imports.h"
#include "slang_compile.h"
-/* slang_struct_scope */
+/*
+ * slang_struct_scope
+ */
-int slang_struct_scope_construct (slang_struct_scope *scope)
+GLvoid
+_slang_struct_scope_ctr (slang_struct_scope *self)
{
- scope->structs = NULL;
- scope->num_structs = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->structs = NULL;
+ self->num_structs = 0;
+ self->outer_scope = NULL;
}
void slang_struct_scope_destruct (slang_struct_scope *scope)
slang_struct_scope z;
unsigned int i;
- if (!slang_struct_scope_construct (&z))
- return 0;
+ _slang_struct_scope_ctr (&z);
z.structs = (slang_struct *) slang_alloc_malloc (y->num_structs * sizeof (slang_struct));
if (z.structs == NULL)
{
stru->fields = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (stru->fields == NULL)
return 0;
- if (!slang_variable_scope_construct (stru->fields))
- {
- slang_alloc_free (stru->fields);
- return 0;
- }
+ _slang_variable_scope_ctr (stru->fields);
stru->structs = (slang_struct_scope *) slang_alloc_malloc (sizeof (slang_struct_scope));
if (stru->structs == NULL)
{
slang_alloc_free (stru->fields);
return 0;
}
- if (!slang_struct_scope_construct (stru->structs))
- {
- slang_variable_scope_destruct (stru->fields);
- slang_alloc_free (stru->fields);
- slang_alloc_free (stru->structs);
- return 0;
- }
+ _slang_struct_scope_ctr (stru->structs);
return 1;
}
typedef struct slang_struct_scope_
{
struct slang_struct_ *structs;
- unsigned int num_structs;
+ GLuint num_structs;
struct slang_struct_scope_ *outer_scope;
} slang_struct_scope;
-int slang_struct_scope_construct (slang_struct_scope *);
+extern GLvoid
+_slang_struct_scope_ctr (slang_struct_scope *);
+
void slang_struct_scope_destruct (slang_struct_scope *);
int slang_struct_scope_copy (slang_struct_scope *, const slang_struct_scope *);
struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, slang_atom, int);
return 1;
}
-/* slang_variable_scope */
+/*
+ * slang_variable_scope
+ */
-int slang_variable_scope_construct (slang_variable_scope *scope)
+GLvoid
+_slang_variable_scope_ctr (slang_variable_scope *self)
{
- scope->variables = NULL;
- scope->num_variables = 0;
- scope->outer_scope = NULL;
- return 1;
+ self->variables = NULL;
+ self->num_variables = 0;
+ self->outer_scope = NULL;
}
void slang_variable_scope_destruct (slang_variable_scope *scope)
slang_variable_scope z;
unsigned int i;
- if (!slang_variable_scope_construct (&z))
- return 0;
+ _slang_variable_scope_ctr (&z);
z.variables = (slang_variable *) slang_alloc_malloc (y->num_variables * sizeof (slang_variable));
if (z.variables == NULL)
{
typedef struct slang_variable_scope_
{
struct slang_variable_ *variables;
- unsigned int num_variables;
+ GLuint num_variables;
struct slang_variable_scope_ *outer_scope;
} slang_variable_scope;
-int slang_variable_scope_construct (slang_variable_scope *);
+extern GLvoid
+_slang_variable_scope_ctr (slang_variable_scope *);
+
void slang_variable_scope_destruct (slang_variable_scope *);
int slang_variable_scope_copy (slang_variable_scope *, const slang_variable_scope *);