Skip to content

Commit

Permalink
handle globals
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Aug 23, 2024
1 parent 0a8787d commit 36002fa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ fn (mut app App) gen_decl(decl Decl) {
} else if spec.node_type_str == 'ImportSpec' && spec.path.value != '' {
app.import_spec(spec)
} else if spec.node_type_str == 'ValueSpec' {
app.const_decl(spec)
if decl.tok == 'var' {
app.global_decl(spec)
} else {
app.const_decl(spec)
}
}
}
}
Expand All @@ -54,6 +58,14 @@ fn (mut app App) const_block(decl Decl) {
}
}

fn (mut app App) global_decl(spec Spec) {
for name in spec.names {
app.gen('__global ${name.name} ')
app.typ(spec.typ)
app.genln('')
}
}

fn (mut app App) const_decl(spec Spec) {
// Handle iota (V enuma)
if spec.values.len > 0 {
Expand Down

0 comments on commit 36002fa

Please sign in to comment.