Skip to content

Commit

Permalink
free_file_types
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Jan 10, 2025
1 parent f131a8a commit 79855cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
23 changes: 0 additions & 23 deletions compiler/free.jou

This file was deleted.

3 changes: 1 addition & 2 deletions compiler/main.jou
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import "./typecheck/step3_function_and_method_bodies.jou"
import "./target.jou"
import "./types.jou"
import "./token.jou"
import "./free.jou"
import "./parser.jou"
import "./paths.jou"
import "./errors_and_warnings.jou"
Expand Down Expand Up @@ -190,7 +189,7 @@ class FileState:
def free(self) -> None:
self->ast.free()
free(self->path)
free_file_types(&self->types)
self->types.free()

def add_imported_symbol(self, es: ExportSymbol*, imp: AstImport*) -> None:
for i = 0; i < self->ast.body.nstatements; i++:
Expand Down
17 changes: 17 additions & 0 deletions compiler/typecheck/common.jou
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ class FileTypes:
functions: SignatureAndUsedPtr*
nfunctions: int

def free(self) -> None:
for t = self->owned_types; t < &self->owned_types[self->n_owned_types]; t++:
free_type(*t)
for func = self->functions; func < &self->functions[self->nfunctions]; func++:
func->signature.free()
for fom = self->fomtypes; fom < &self->fomtypes[self->nfomtypes]; fom++:
for et = fom->expr_types; et < &fom->expr_types[fom->n_expr_types]; et++:
free(*et)
free(fom->expr_types)
free(fom->locals) # Don't free individual locals because they're owned by CFG now
fom->signature.free()
free(self->globals)
free(self->types)
free(self->owned_types)
free(self->functions)
free(self->fomtypes)

def find_type(self, name: byte*) -> Type*:
for t = self->types; t < &self->types[self->ntypes]; t++:
if strcmp(t->type->name, name) == 0:
Expand Down

0 comments on commit 79855cf

Please sign in to comment.