v.ast: add .free() methods, so vls can be more decoupled

pull/9793/head
Delyan Angelov 2021-04-18 10:24:16 +03:00
parent eaf930aa8b
commit cfcecf898b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 48 additions and 0 deletions

View File

@ -564,6 +564,24 @@ pub mut:
global_labels []string // from `asm { .globl labelname }`
}
[unsafe]
pub fn (f &File) free() {
unsafe {
f.path.free()
f.path_base.free()
f.scope.free()
f.stmts.free()
f.imports.free()
f.auto_imports.free()
f.embedded_files.free()
f.imported_symbols.free()
f.errors.free()
f.warnings.free()
f.notices.free()
f.global_labels.free()
}
}
pub struct IdentFn {
pub mut:
typ Type

View File

@ -15,6 +15,18 @@ pub mut:
end_pos int
}
[unsafe]
pub fn (s &Scope) free() {
unsafe {
s.objects.free()
s.struct_fields.free()
for child in s.children {
child.free()
}
s.children.free()
}
}
pub fn new_scope(parent &Scope, start_pos int) &Scope {
return &Scope{
parent: parent

View File

@ -24,6 +24,24 @@ pub mut:
used_consts map[string]bool // filled in by the checker, when pref.skip_unused = true;
}
[unsafe]
pub fn (t &Table) free() {
unsafe {
t.type_symbols.free()
t.type_idxs.free()
t.fns.free()
t.dumps.free()
t.imports.free()
t.modules.free()
t.cflags.free()
t.redefined_fns.free()
t.fn_generic_types.free()
t.cmod_prefix.free()
t.used_fns.free()
t.used_consts.free()
}
}
pub struct Fn {
pub:
params []Param