Skip to content

Commit

Permalink
Check in accidentally missed file-change
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Aug 19, 2024
1 parent 93f1fb0 commit e95b835
Showing 1 changed file with 0 additions and 95 deletions.
95 changes: 0 additions & 95 deletions Sources/backends/glsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,101 +85,6 @@ static void write_code(char *glsl, char *directory, const char *filename, const
}
}

static void find_referenced_functions(function *f, function **functions, size_t *functions_size) {
if (f->block == NULL) {
// built-in
return;
}

uint8_t *data = f->code.o;
size_t size = f->code.size;

size_t index = 0;
while (index < size) {
opcode *o = (opcode *)&data[index];
switch (o->type) {
case OPCODE_CALL: {
for (function_id i = 0; get_function(i) != NULL; ++i) {
function *f = get_function(i);
if (f->name == o->op_call.func) {
if (f->block == NULL) {
// built-in
break;
}

bool found = false;
for (size_t j = 0; j < *functions_size; ++j) {
if (functions[j]->name == o->op_call.func) {
found = true;
break;
}
}
if (!found) {
functions[*functions_size] = f;
*functions_size += 1;
find_referenced_functions(f, functions, functions_size);
}
break;
}
}
break;
}
}

index += o->size;
}
}

static void add_found_type(type_id t, type_id *types, size_t *types_size) {
for (size_t i = 0; i < *types_size; ++i) {
if (types[i] == t) {
return;
}
}

types[*types_size] = t;
*types_size += 1;
}

static void find_referenced_types(function *f, type_id *types, size_t *types_size) {
if (f->block == NULL) {
// built-in
return;
}

function *functions[256];
size_t functions_size = 0;

functions[functions_size] = f;
functions_size += 1;

find_referenced_functions(f, functions, &functions_size);

for (size_t l = 0; l < functions_size; ++l) {
function *func = functions[l];
debug_context context = {0};
check(func->parameter_type.type != NO_TYPE, context, "Function parameter type not found");
add_found_type(func->parameter_type.type, types, types_size);
check(func->return_type.type != NO_TYPE, context, "Function return type missing");
add_found_type(func->return_type.type, types, types_size);

uint8_t *data = functions[l]->code.o;
size_t size = functions[l]->code.size;

size_t index = 0;
while (index < size) {
opcode *o = (opcode *)&data[index];
switch (o->type) {
case OPCODE_VAR:
add_found_type(o->op_var.var.type.type, types, types_size);
break;
}

index += o->size;
}
}
}

static void find_referenced_global_for_var(variable v, global_id *globals, size_t *globals_size) {
for (global_id j = 0; get_global(j).type != NO_TYPE; ++j) {
global g = get_global(j);
Expand Down

0 comments on commit e95b835

Please sign in to comment.