From e3a7eb1d68bcf99e08bad68f04cc5b91697825b3 Mon Sep 17 00:00:00 2001 From: StunxFS Date: Tue, 2 Jan 2024 09:17:50 -0400 Subject: [PATCH] remove `Object.is_hidden_ref` field --- rivetc/src/checker.py | 10 +--------- rivetc/src/codegen/__init__.py | 10 +--------- rivetc/src/sym.py | 5 ----- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/rivetc/src/checker.py b/rivetc/src/checker.py index 940acb2d4..797711eae 100644 --- a/rivetc/src/checker.py +++ b/rivetc/src/checker.py @@ -313,9 +313,6 @@ def check_stmt(self, stmt): if stmt.index != None: stmt.scope.update_type(stmt.index.name, self.comp.uint_t) stmt.scope.update_type(stmt.value.name, elem_typ) - stmt.scope.update_is_hidden_ref( - stmt.value.name, stmt.value.is_mut - ) self.check_stmt(stmt.stmt) else: report.error( @@ -816,7 +813,6 @@ def check_expr(self, expr): if not expr.var.is_ref: report.error("invalid syntax for typematching", expr.var.pos) report.help("use `&mut` instead") - expr.scope.update_is_hidden_ref(expr.var.name, True) if lsym.kind == TypeKind.Enum: if lsym.info.is_tagged and expr.op not in ( Kind.KwIs, Kind.KwNotIs @@ -1483,7 +1479,7 @@ def check_expr(self, expr): if b.var_is_ref: self.check_expr_is_mut(expr.expr) else: - report.error("invalid syntax for typematching", expr.var_pos) + report.error("invalid syntax for typematching", b.var_pos) report.help("use `&mut` instead") if len(b.pats) == 1: var_t = self.comp.void_t @@ -1500,10 +1496,6 @@ def check_expr(self, expr): "cannot use void expression", b.var_pos ) - if not b.var_is_ref: - b.scope.update_is_hidden_ref( - b.var_name, b.var_is_mut - ) else: var_t = b.pats[0].typ if b.var_is_ref and var_t.value_is_boxed(): diff --git a/rivetc/src/codegen/__init__.py b/rivetc/src/codegen/__init__.py index 9fb3d9395..2c90725ae 100644 --- a/rivetc/src/codegen/__init__.py +++ b/rivetc/src/codegen/__init__.py @@ -761,15 +761,7 @@ def gen_expr(self, expr, custom_tmp = None): elif expr.name == "_RIVET_VERSION_": return self.gen_string_literal(utils.full_version()) # runtime object - i_typ = self.ir_type(expr.typ) - if ( - expr.obj.level == sym.ObjLevel.Arg and expr.obj.is_mut - and not expr.typ.symbol().is_primitive() - ) or ( - expr.obj.is_hidden_ref and not isinstance(i_typ, ir.Pointer) - ): - i_typ = i_typ.ptr() - return ir.Ident(i_typ, expr.obj.ir_name) + return ir.Ident(self.ir_type(expr.typ), expr.obj.ir_name) elif isinstance(expr, ast.BuiltinCallExpr): if expr.name == "set_enum_ref_value": arg0 = self.gen_expr(expr.args[0]) diff --git a/rivetc/src/sym.py b/rivetc/src/sym.py index 49e980d29..66c2f82b9 100644 --- a/rivetc/src/sym.py +++ b/rivetc/src/sym.py @@ -27,7 +27,6 @@ def __init__(self, is_mut, name, typ, level, pos): self.is_mut = is_mut self.is_used = False self.is_changed = False - self.is_hidden_ref = False self.level = level self.pos = pos self.typ = typ @@ -71,10 +70,6 @@ def update_type(self, name, typ): if obj := self.lookup(name): obj.typ = typ - def update_is_hidden_ref(self, name, val): - if obj := self.lookup(name): - obj.is_hidden_ref = val - def update_ir_name(self, name, ir_name): if obj := self.lookup(name): obj.ir_name = ir_name