diff --git a/bsc/codegen.py b/bsc/codegen.py index a95c3a4..2333a76 100644 --- a/bsc/codegen.py +++ b/bsc/codegen.py @@ -31,7 +31,8 @@ def gen_file(self, file): module_fields = [] for sym in file.mod_sym.scope.syms: - if sym.access_modifier.is_public(): + if (file.mod_sym.is_pkg + and sym.name == "main") or sym.access_modifier.is_public(): module_fields.append( LuaTableField(LuaIdent(sym.name), LuaIdent(sym.name)) ) @@ -104,8 +105,7 @@ def gen_fn_decl(self, decl): for arg in decl.args: args.append(LuaIdent(arg.name)) luafn = LuaFunction( - decl.sym.codegen_qualname(), args, - is_associated = decl.sym.is_associated() + decl.sym.codegen_qualname(), args, is_static = decl.sym.is_static() ) for arg in decl.args: if arg.default_value != None: diff --git a/bsc/lua_ast/__init__.py b/bsc/lua_ast/__init__.py index 7cc7901..90624b2 100644 --- a/bsc/lua_ast/__init__.py +++ b/bsc/lua_ast/__init__.py @@ -19,10 +19,10 @@ def __init__(self, fields): self.fields = fields class LuaFunction: - def __init__(self, name, args, is_associated = False): + def __init__(self, name, args, is_static = False): self.name = name self.args = args - self.is_associated = is_associated + self.is_static = is_static self.block = LuaBlock() # Statements diff --git a/bsc/lua_ast/render.py b/bsc/lua_ast/render.py index 8bc101a..db5b18f 100644 --- a/bsc/lua_ast/render.py +++ b/bsc/lua_ast/render.py @@ -101,7 +101,7 @@ def render_mod(self, stmt): ) def render_fn_stmt(self, stmt): - if not stmt.is_associated: + if not stmt.is_static: self.write("local ") self.write(f"function {stmt.name}(") for i, arg in enumerate(stmt.args): diff --git a/bsc/sym.py b/bsc/sym.py index ab4f91f..6c76d7e 100644 --- a/bsc/sym.py +++ b/bsc/sym.py @@ -201,7 +201,7 @@ def __init__(self, access_modifier, name, args, scope, pos = None): scope.owner = self self.scope = scope - def is_associated(self): + def is_static(self): return isinstance(self.parent, TypeSym) class Scope: