Skip to content

Commit

Permalink
fix resolver module
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 3, 2024
1 parent 4d61e18 commit 41dbdc9
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 145 deletions.
10 changes: 5 additions & 5 deletions lib/rivet/src/ast/Decl.ri
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub enum Decl {
is_public: bool;
is_extern: bool;
abi: ABI;
mut lefts: []+ObjectData;
mut lefts: []+mut ObjectData;
mut right: +mut Expr;
pos: token.Pos;
mut sym: Sym;
Expand All @@ -116,11 +116,11 @@ pub enum Decl {
is_operator: bool;
abi: ABI;
name: string;
mut args: []+Arg;
args: []+mut Arg;
has_named_args: bool;
mut ret_type: +mut Type;
mut stmts: []+mut Stmt;
mut scope: +Scope;
ret_type: +mut Type;
stmts: []+mut Stmt;
scope: +mut Scope;
has_body: bool;
self_is_ptr: bool;
self_is_boxed: bool;
Expand Down
6 changes: 3 additions & 3 deletions lib/rivet/src/ast/Expr.ri
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ pub enum Expr < traits.Stringable {

pub struct CallArg {
pub name: string;
pub mut expr: +mut Expr;
pub expr: +mut Expr;
pub is_named: bool;
pub pos: token.Pos;
pub mut type: +mut Type;
Expand All @@ -633,9 +633,9 @@ pub struct CallErrorHandler {
pub varname_pos: token.Pos;
pub has_varname: bool;
pub is_propagate: bool;
pub mut expr: +mut Expr;
pub expr: +mut Expr;
pub has_expr: bool;
pub mut scope: +Scope;
pub scope: +mut Scope;
pub pos: token.Pos;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/rivet/src/ast/SourceFile.ri
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import ../token;
#[boxed]
pub struct SourceFile {
pub path: string;
pub mut decls: []+mut Decl;
pub mut mod: +Module;
pub mut imported_symbols: +ImportedSymbols;
pub mut pos: token.Pos;
pub decls: []+mut Decl;
pub mut mod: +mut Module;
pub imported_symbols: +mut ImportedSymbols;
pub pos: token.Pos;
}
18 changes: 9 additions & 9 deletions lib/rivet/src/ast/Stmt.ri
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub enum Stmt {
ComptimeIf(ComptimeIf),
Expr(+mut Expr),
VarDecl {
mut lefts: []+ObjectData;
mut right: +mut Expr;
mut scope: +Scope;
lefts: []+mut ObjectData;
right: +mut Expr;
scope: +mut Scope;
pos: token.Pos;
},
While {
Expand All @@ -27,12 +27,12 @@ pub enum Stmt {
pos: token.Pos;
},
For {
mut index: +ObjectData;
index: +mut ObjectData;
has_index: bool;
mut values: []+ObjectData;
mut iterable: +mut Expr;
mut stmt: +mut Stmt;
mut scope: +Scope;
values: []+mut ObjectData;
iterable: +mut Expr;
stmt: +mut Stmt;
scope: +mut Scope;
pos: token.Pos;
},
Defer {
Expand All @@ -42,7 +42,7 @@ pub enum Stmt {
Success
}

mut expr: +mut Expr;
expr: +mut Expr;
mode: Mode;
pos: token.Pos;
};
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/ast/Sym.ri
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ pub struct Module < Sym {
return type_sym;
}

pub func add_or_get_func(+mut self, func_sym: +Func) -> +mut TypeSym {
pub func add_or_get_func(+mut self, func_sym: +mut Func) -> +mut TypeSym {
unique_name := {
mut sb := strings.Builder.from_string("func(");
if func_sym.is_method {
Expand Down Expand Up @@ -418,7 +418,7 @@ pub struct Func < Sym {
}

#[inline]
pub func type(+self, universe: +mut Module) -> +mut Type {
pub func type(+mut self, universe: +mut Module) -> +mut Type {
return +mut .Func(
is_method: self.is_method,
self_is_ptr: self.self_is_ptr,
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/ast/Type.ri
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ pub enum Type < traits.Stringable {
mut has_sym: bool;

#[inline]
func symbol(&self) -> +Func {
func symbol(&self) -> +mut Func {
return if self.has_sym && self.sym.info is .Func(func_sym) {
func_sym
} else {
+Func(
+mut Func(
is_method: self.is_method,
self_type: +mut .Void,
self_is_mut: self.self_is_mut,
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/ast/TypeInfo.ri
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum TypeInfo < traits.Stringable {
size: uint;
},
String,
Func(+Func),
Func(+mut Func),
Alias {
parent: +mut Type;
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/ast/comptime.ri
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct ComptimeIfBranch {
}

extend Env {
pub func evalue_comptime_if(+self, mut comptime_if: ComptimeIf) -> []+mut Node {
pub func evalue_comptime_if(+self, comptime_if: &mut ComptimeIf) -> []+mut Node {
if branch_idx := comptime_if.branch_idx {
return comptime_if.branches[branch_idx].nodes;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/rivet/src/ast/imports.ri
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ pub struct ImportedSymbol {
}

pub struct ImportedSymbols {
pub mut syms: []+ImportedSymbol;
pub mut syms: []+mut ImportedSymbol;

#[inline]
pub func add(mut self, name: string, sym: Sym, pos: token.Pos, is_used: bool := false) {
self.syms.push(+ImportedSymbol(name, sym, pos, is_used));
pub func add(&mut self, name: string, sym: Sym, pos: token.Pos, is_used: bool := false) {
self.syms.push(+mut ImportedSymbol(name, sym, pos, is_used));
}

pub func find(&self, name: string) -> ?+ImportedSymbol {
pub func find(&self, name: string) -> ?+mut ImportedSymbol {
for imported_sym in self.syms {
if name == imported_sym.name {
return imported_sym;
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/checker/builtin_call.ri
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extend Checker {
), builtin_call.pos
);
}
} else if mut from_ts := from_type.symbol() {
} else if from_ts := from_type.symbol() {
match from_ts.info {
.Trait(trait_info) -> if to_ts := to_type.symbol() {
if to_ts in trait_info.implements {
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/checker/decls.ri
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extend Checker {
old_sym := self.sym;
if decl is .Const || decl is .Var {
self.check_decl(decl);
} else if mut decl_decls := decl.decls() {
} else if decl_decls := decl.decls() {
self.check_global_vars(decl_decls);
}
self.sym = old_sym;
Expand Down
6 changes: 3 additions & 3 deletions lib/rivet/src/checker/exprs.ri
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extend Checker {
},
.TupleLiteral(tuple_lit) -> self.check_tuple_literal(tuple_lit),
.ArrayCtor(array_ctor) -> {
if mut init_value := array_ctor.init_value {
if init_value := array_ctor.init_value {
init_t := self.check_expr(init_value);
if !self.check_compatible_types(init_t, array_ctor.elem_type) {
report.error(
Expand All @@ -131,7 +131,7 @@ extend Checker {
);
}
}
if mut len_value := array_ctor.len_value {
if len_value := array_ctor.len_value {
len_t := self.check_expr(len_value);
if !(len_t == self.env.uint_t || len_t == self.env.comptime_int_t) {
report.error(
Expand All @@ -140,7 +140,7 @@ extend Checker {
);
}
}
if mut cap_value := array_ctor.cap_value {
if cap_value := array_ctor.cap_value {
cap_t := self.check_expr(cap_value);
if !(cap_t == self.env.uint_t || cap_t == self.env.comptime_int_t) {
report.error(
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/checker/match_expr.ri
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extend Checker {
}
}
}
if mut branch_var := branch.branch_var {
if branch_var := branch.branch_var {
self.check_name_case(
.Snake, "branch variable", branch_var.name, branch_var.pos
);
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/checker/types.ri
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extend Checker {
+self, got: +mut ast.Type, expected: +mut ast.Type, pos: token.Pos, arg_name: string,
func_kind: string, func_name: string
) {
if mut expected_sym := expected.symbol(); expected_sym.info is .Trait(trait_info)
if expected_sym := expected.symbol(); expected_sym.info is .Trait(trait_info)
&& expected != got {
got_t := self.env.comptime_number_to_type(got);
if got_t.symbol()? in trait_info.implements {
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/codegen/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct Codegen {
},
else -> {
prefix_type := self.prefix_type(type);
if mut type_sym := type.symbol() {
if type_sym := type.symbol() {
if type_sym.is_primitive() {
"{}{}".fmt(type_sym.name.len, type_sym.name)
} else {
Expand All @@ -157,7 +157,7 @@ pub struct Codegen {
return sym.mangled_name;
}
mut sb := strings.Builder.new();
if mut parent := sym.parent; !parent.is_universe {
if parent := sym.parent; !parent.is_universe {
sb.write(self.mangle_symbol(parent));
} else if insert_r {
sb.write("_R");
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/codegen/types.ri
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extend Codegen {
} else {
.SizedUint(bits, size)
}
} else if mut type_sym := type.symbol() {
} else if type_sym := type.symbol() {
if type_sym.is_primitive() {
return .Basic(type_sym.name, size, true);
}
Expand Down
Loading

0 comments on commit 41dbdc9

Please sign in to comment.