Skip to content

Commit

Permalink
fix checker
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 16, 2024
1 parent 6f7f121 commit 95acc34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,8 @@ def gen_expr(self, expr, custom_tmp = None):
expr.left.left.typ, expr.left.left
)
is_vtable_call = True
if not isinstance(self_expr.typ, ir.Pointer):
self_expr = ir.Inst(ir.InstKind.LoadPtr, [self_expr], self_expr.typ)
if isinstance(self_expr.typ, ir.Pointer):
self_expr = ir.Inst(ir.InstKind.LoadPtr, [self_expr], self_expr.typ.typ)
if left_sym.kind == TypeKind.Trait:
if left2_sym.kind == TypeKind.Trait and left_sym != left2_sym:
id_value = ir.Inst(
Expand Down Expand Up @@ -1470,21 +1470,21 @@ def gen_expr(self, expr, custom_tmp = None):
old_inside_selector_expr = self.inside_selector_expr
self.inside_selector_expr = True
left_sym = expr.left_typ.symbol()
left = self.gen_expr(expr.left)
self.inside_selector_expr = old_inside_selector_expr
ir_left_typ = self.ir_type(expr.left_typ)
ir_typ = self.ir_type(expr.typ)
if expr.is_indirect or expr.is_boxed_indirect:
return ir.Inst(ir.InstKind.LoadPtr, [left], ir_left_typ.typ)
elif expr.is_option_check:
if (expr.is_indirect or expr.is_boxed_indirect) or expr.is_option_check:
left = self.gen_expr(expr.left)
if expr.is_indirect or expr.is_boxed_indirect:
return ir.Inst(ir.InstKind.LoadPtr, [left], ir_left_typ.typ)
panic_l = self.cur_func.local_name()
exit_l = self.cur_func.local_name()
if expr.left_typ.is_pointer():
self.cur_func.add_cond_br(
ir.Inst(
ir.InstKind.Cmp,
[ir.Name("=="), left,
ir.NoneLit(ir.RAWPTR_T)]
ir.NoneLit(ir.RAWPTR_T)]
), panic_l, exit_l
)
value = left
Expand All @@ -1498,7 +1498,8 @@ def gen_expr(self, expr, custom_tmp = None):
self.runtime_error(f"attempt to use none value (`{expr.left}`)")
self.cur_func.add_label(exit_l)
return value
elif isinstance(left, ir.StringLit):
left = self.gen_expr(expr.left)
if isinstance(left, ir.StringLit):
if expr.field_name == "ptr":
return ir.StringLit(left.lit, left.len)
elif expr.field_name == "len":
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def resolve_decls(self, decls):
self_typ = type.Type(self.self_sym)
if decl.self_is_ptr:
self_typ = type.Ptr(self_typ, decl.self_is_mut)
elif decl.self_is_boxed and self.self_sym.kind != sym.TypeKind.Trait:
elif decl.self_is_boxed:
self_typ.is_boxed = True
self_typ.is_mut = decl.self_is_mut
try:
Expand Down

0 comments on commit 95acc34

Please sign in to comment.