Skip to content

Commit

Permalink
fix importing global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Dec 14, 2023
1 parent 064e51b commit 80f468c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions self_hosted/runs_wrong.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ tests/other_errors/noreturn_but_return_with_value.jou
tests/other_errors/noreturn_but_return_without_value.jou
tests/should_succeed/compiler_cli.jou
tests/should_succeed/pointer.jou
tests/should_succeed/printf.jou
tests/other_errors/return_void.jou
tests/should_succeed/stderr.jou
tests/should_succeed/unused_import.jou
tests/wrong_type/cannot_be_indexed.jou
tests/wrong_type/index.jou
tests/syntax_error/assign_to_None.jou
Expand Down
6 changes: 5 additions & 1 deletion self_hosted/typecheck.jou
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def can_cast_implicitly(from: Type*, to: Type*) -> bool:
or (from->is_pointer_type() and to->is_pointer_type() and (from == &void_ptr_type or to == &void_ptr_type))
)


def can_cast_explicitly(from: Type*, to: Type*) -> bool:
return (
from == to
Expand All @@ -53,6 +54,7 @@ def can_cast_explicitly(from: Type*, to: Type*) -> bool:
or (from == &bool_type and to->is_integer_type())
)


# Implicit casts are used in many places, e.g. function arguments.
#
# When you pass an argument of the wrong type, it's best to give an error message
Expand Down Expand Up @@ -115,6 +117,7 @@ class ExportSymbol:
else:
assert False


class ExpressionTypes:
expression: AstExpression*
original_type: Type*
Expand Down Expand Up @@ -237,7 +240,8 @@ class FileTypes:
self->all_functions = realloc(self->all_functions, sizeof self->all_functions[0] * (self->n_all_functions + 1))
self->all_functions[self->n_all_functions++] = symbol->signature.copy()
elif symbol->kind == ExportSymbolKind::GlobalVariable:
pass # TODO
self->globals = realloc(self->globals, sizeof(self->globals[0]) * (self->nglobals + 1))
self->globals[self->nglobals++] = GlobalVariable{name = symbol->name, type = symbol->type}
else:
symbol->print()
assert False
Expand Down

0 comments on commit 80f468c

Please sign in to comment.