Skip to content

Commit

Permalink
Refactor: writing of ARAY chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed May 19, 2017
1 parent 3cd1284 commit 095cca2
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/codegen/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,19 +542,11 @@ static void write_mini_value( struct codegen* codegen, struct value* value ) {
}

static void do_aray( struct codegen* codegen ) {
int count = 0;
struct list_iter i;
list_iterate( &codegen->vars, &i );
while ( ! list_end( &i ) ) {
if ( aray_var( list_data( &i ) ) ) {
++count;
}
list_next( &i );
}
int count = list_size( &codegen->arrays );
if ( codegen->shary.used ) {
++count;
}
if ( ! count ) {
if ( count == 0 ) {
return;
}
struct {
Expand All @@ -563,14 +555,13 @@ static void do_aray( struct codegen* codegen ) {
} entry;
c_add_str( codegen, "ARAY" );
c_add_int( codegen, sizeof( entry ) * count );
list_iterate( &codegen->vars, &i );
struct list_iter i;
list_iterate( &codegen->arrays, &i );
while ( ! list_end( &i ) ) {
struct var* var = list_data( &i );
if ( aray_var( var ) ) {
entry.number = var->index;
entry.size = var->size;
c_add_sized( codegen, &entry, sizeof( entry ) );
}
entry.number = var->index;
entry.size = var->size;
c_add_sized( codegen, &entry, sizeof( entry ) );
list_next( &i );
}
if ( codegen->shary.used ) {
Expand Down

0 comments on commit 095cca2

Please sign in to comment.