Skip to content

Commit

Permalink
Start implementing relocation
Browse files Browse the repository at this point in the history
Start with nested for loops that iterate over segments and cells.
  • Loading branch information
gabrielbosio committed Jul 27, 2023
1 parent 951606b commit c09c7cd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/cairo_runner.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "cairo_runner.h"
#include "clist.h"
#include "memory.h"
#include "program.h"
#include "relocatable.h"
#include "vm.h"
#include <assert.h>
#include <stdio.h>

cairo_runner runner_new(struct program program) {
virtual_machine vm = vm_new();
Expand Down Expand Up @@ -84,4 +87,18 @@ relocatable runner_initialize(cairo_runner *runner) {
return end;
}

void runner_relocate_memory(cairo_runner *runner) { (void)runner; }
void runner_relocate_memory(cairo_runner *runner) {
assert(runner->relocated_memory->count(runner->relocated_memory) == 0);
relocated_memory_cell first_cell = {.memory_value = {.none = 0}, .is_some = false};
runner->relocated_memory->add(runner->relocated_memory, &first_cell);

int num_segments = runner->vm.memory.num_segments;
for (int i = 0; i < num_segments; i++) {
CList *segment = runner->vm.memory.data->at(runner->vm.memory.data, i);
int segment_size = segment->count(segment);
for (int j = 0; j < segment_size; j++) {
memory_cell *cell = segment->at(segment, j);
(void)cell;
}
}
}

0 comments on commit c09c7cd

Please sign in to comment.