#include "slang_storage.h"
#include "slang_error.h"
#include "slang_emit.h"
+#include "slang_vartable.h"
#include "slang_print.h"
for (i = 0; i < SLANG_BUILTIN_TOTAL; i++)
_slang_code_unit_ctr(&self->builtin[i], self);
_slang_code_unit_ctr(&self->unit, self);
+#if 01
_slang_assembly_file_ctr(&self->assembly);
+#endif
slang_machine_ctr(&self->machine);
self->varpool.next_addr = 0;
slang_atom_pool_construct(&self->atompool);
for (i = 0; i < SLANG_BUILTIN_TOTAL; i++)
_slang_code_unit_dtr(&self->builtin[i]);
_slang_code_unit_dtr(&self->unit);
+#if 01
slang_assembly_file_destruct(&self->assembly);
+#endif
slang_machine_dtr(&self->machine);
slang_atom_pool_destruct(&self->atompool);
slang_export_data_table_dtr(&self->expdata);
slang_var_pool *global_pool;
slang_machine *machine;
struct gl_program *program;
- slang_gen_context *codegen;
+ slang_var_table *vartable;
} slang_output_ctx;
/* _slang_compile() */
slang_operation *o = &oper->children[i - first_var];
o->type = slang_oper_variable_decl;
o->locals->outer_scope = O->vars;
- o->a_id = O->vars->variables[i].a_name;
+ o->a_id = O->vars->variables[i]->a_name;
}
}
}
*/
oper->type = slang_oper_asm;
oper->a_id = parse_identifier(C);
- if (strcmp((char*)oper->a_id, "dot") == 0) {
- printf("Assemble dot! **************************\n");
- }
if (oper->a_id == SLANG_ATOM_NULL)
return 0;
while (*C->I != OP_END) {
static GLboolean
initialize_global(slang_assemble_ctx * A, slang_variable * var)
{
+#if 01
slang_assembly_file_restore_point point;
+#endif
slang_machine mach;
slang_assembly_local_info save_local = A->local;
slang_operation op_id, op_assign;
GLboolean result;
+#if 01
/* save the current assembly */
if (!slang_assembly_file_restore_point_save(A->file, &point))
return GL_FALSE;
+#endif
/* setup the machine */
mach = *A->mach;
/* put the variable into operation's scope */
op_id.locals->variables =
- (slang_variable *) slang_alloc_malloc(sizeof(slang_variable));
+ (slang_variable **) slang_alloc_malloc(sizeof(slang_variable *));
if (op_id.locals->variables == NULL) {
slang_operation_destruct(&op_id);
return GL_FALSE;
}
op_id.locals->num_variables = 1;
- op_id.locals->variables[0] = *var;
+ op_id.locals->variables[0] = var;
/* construct the assignment expression */
if (!slang_operation_construct(&op_assign)) {
op_assign.children[0] = op_id;
op_assign.children[1] = *var->initializer;
+#if 0 /* this should go away */
/* insert the actual expression */
result = _slang_assemble_operation(A, &op_assign, slang_ref_forbid);
+#else
+ result = 1;
+#endif
/* carefully destroy the operations */
op_assign.num_children = 0;
return GL_FALSE;
#endif
+#if 01
/* restore the old assembly */
if (!slang_assembly_file_restore_point_load(A->file, &point))
return GL_FALSE;
+#endif
A->local = save_local;
/* now we copy the contents of the initialized variable back to the original machine */
A.space.funcs = O->funs;
A.space.structs = O->structs;
A.space.vars = O->vars;
- A.codegen = O->codegen;
A.program = O->program;
+#if 0
+ A.codegen = O->codegen;
+#endif
+ A.vartable = O->vartable;
_slang_codegen_global_variable(&A, var, C->type);
}
A.space.structs = O->structs;
A.space.vars = O->vars;
A.program = O->program;
+#if 0
A.codegen = O->codegen;
+#endif
+ A.vartable = O->vartable;
_slang_reset_error();
(*parsed_func_ret)->param_count);
#endif
-
+#if 0
if (!_slang_assemble_function(&A, *parsed_func_ret)) {
/* propogate the error message back through the info log */
C->L->text = _mesa_strdup(_slang_error_text());
C->L->dont_free_text = GL_FALSE;
return GL_FALSE;
}
-
+#endif
#if 0
printf("**************************************\n");
struct gl_program *program)
{
slang_output_ctx o;
+ GLboolean success;
/* setup output context */
o.funs = &unit->funs;
o.global_pool = &unit->object->varpool;
o.machine = &unit->object->machine;
o.program = program;
- o.codegen = _slang_new_codegen_context();
+ o.vartable = _slang_push_var_table(NULL);
/* parse individual functions and declarations */
while (*C->I != EXTERNAL_NULL) {
case EXTERNAL_FUNCTION_DEFINITION:
{
slang_function *func;
-
- if (!parse_function(C, &o, 1, &func))
- return GL_FALSE;
+ success = parse_function(C, &o, 1, &func);
}
break;
case EXTERNAL_DECLARATION:
- if (!parse_declaration(C, &o))
- return GL_FALSE;
+ success = parse_declaration(C, &o);
break;
default:
+ success = GL_FALSE;
+ }
+
+ if (!success) {
+ /* xxx free codegen */
+ _slang_pop_var_table(o.vartable);
return GL_FALSE;
}
}
C->I++;
+
+ _slang_pop_var_table(o.vartable);
return GL_TRUE;
}