Skip to content

Commit

Permalink
remove Object.is_hidden_ref field
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 2, 2024
1 parent eff3174 commit e3a7eb1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
10 changes: 1 addition & 9 deletions rivetc/src/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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():
Expand Down
10 changes: 1 addition & 9 deletions rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
5 changes: 0 additions & 5 deletions rivetc/src/sym.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e3a7eb1

Please sign in to comment.