Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Dec 8, 2023
1 parent 7ccb581 commit 349767c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions lib/rivet/src/ast/Expr.ri
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub enum Expr < traits.Stringable {
pos: token.Pos;
mut type: Type;
},
DynArrayLiteral {
ArrayLiteral {
values: []mut Expr;
is_arr: bool;
pos: token.Pos;
Expand Down Expand Up @@ -302,7 +302,7 @@ pub enum Expr < traits.Stringable {
.StringLiteral(string_lit) -> string_lit.pos,
.EnumLiteral(enum_lit) -> enum_lit.pos,
.TupleLiteral(tuple_lit) -> tuple_lit.pos,
.DynArrayLiteral(dyn_array_lit) -> dyn_array_lit.pos,
.ArrayLiteral(array_lit) -> array_lit.pos,
.Index(index) -> index.pos,
.Selector(selector) -> selector.pos,
.Indirect(indirect) -> indirect.pos,
Expand Down Expand Up @@ -366,16 +366,16 @@ pub enum Expr < traits.Stringable {
sb.write_byte(b')');
sb.to_string()
},
.DynArrayLiteral(dyn_array_lit) -> {
.ArrayLiteral(array_lit) -> {
mut sb := strings.Builder.from_string("[");
for i, value in dyn_array_lit.values {
for i, value in array_lit.values {
sb.write_string(value.to_string());
if i < dyn_array_lit.values.len - 1 {
if i < array_lit.values.len - 1 {
sb.write_string(", ");
}
}
sb.write_byte(b']');
if dyn_array_lit.is_arr {
if array_lit.is_arr {
sb.write_byte(b'!');
}
sb.to_string()
Expand Down
22 changes: 11 additions & 11 deletions lib/rivet/src/checker/exprs.ri
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extend Checker {
enum_lit.type
},
.TupleLiteral(mut tuple_lit) -> self.check_tuple_literal(tuple_lit),
.DynArrayLiteral(mut dyn_array_lit) -> self.check_dyn_array_literal(dyn_array_lit),
.ArrayLiteral(mut array_lit) -> self.check_array_literal(array_lit),
.Ident(ident) -> {
ident.type = if ident.name == "_" {
.Void()
Expand Down Expand Up @@ -249,7 +249,7 @@ extend Checker {
return tuple_lit.type;
}

func check_dyn_array_literal(mut self, mut dyn_array_lit: ast.Expr.DynArrayLiteral) -> ast.Type {
func check_array_literal(mut self, mut array_lit: ast.Expr.ArrayLiteral) -> ast.Type {
old_expected_type := self.expected_type;
mut size: uint := 0;
mut is_mut := false;
Expand All @@ -271,15 +271,15 @@ extend Checker {
if has_expected_type {
value_type = self.table.comptime_number_to_type(value_type);
}
for i, mut value in dyn_array_lit.values {
for i, mut value in array_lit.values {
type := self.check_expr(value);
if i == 0 and !has_expected_type {
value_type = self.table.comptime_number_to_type(type);
self.expected_type = value_type;
} else {
self.check_types(type, value_type) catch |err| {
mut err_b := report.error_builder(err.to_string(), value.position());
err_b.add_note(if dyn_array_lit.is_arr {
err_b.add_note(if array_lit.is_arr {
"in element {} of array literal"
} else {
"in element {} of dynamic array literal"
Expand All @@ -289,23 +289,23 @@ extend Checker {
}
}
self.expected_type = old_expected_type;
dyn_array_lit.type = if dyn_array_lit.is_arr {
arr_len := if dyn_array_lit.values.len > 0 {
dyn_array_lit.values.len
array_lit.type = if array_lit.is_arr {
arr_len := if array_lit.values.len > 0 {
array_lit.values.len
} else {
if !has_expected_type {
report.error("could not infer type and size of array", dyn_array_lit.pos);
report.error("could not infer type and size of array", array_lit.pos);
}
size
};
.Basic(
self.table.universe.add_or_get_array(value_type, arr_len, is_mut),
pos: dyn_array_lit.pos
pos: array_lit.pos
)
} else {
.Basic(self.table.universe.add_or_get_dyn_array(value_type, is_mut), pos: dyn_array_lit.pos)
.Basic(self.table.universe.add_or_get_dyn_array(value_type, is_mut), pos: array_lit.pos)
};
return dyn_array_lit.type;
return array_lit.type;
}

func check_selector(mut self, mut selector: ast.Expr.Selector) -> ast.Type {
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/parser/exprs.ri
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ extend Parser {
}
pos += self.tok.pos;
self.expect(.Rbracket);
.DynArrayLiteral(elems, self.accept(.Bang), pos)
.ArrayLiteral(elems, self.accept(.Bang), pos)
},
self.tok.kind == .Name -> if self.peek_tok.kind == .Char {
if self.tok.lit == "b" {
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/resolver/exprs.ri
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ extend Resolver {
self.resolve_expr(value);
}
},
.DynArrayLiteral(dyn_array_lit) -> {
for mut value in dyn_array_lit.values {
.ArrayLiteral(array_lit) -> {
for mut value in array_lit.values {
self.resolve_expr(value);
}
},
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def __repr__(self):
def __str__(self):
return self.__repr__()

class DynArrayLiteral:
class ArrayLiteral:
def __init__(self, elems, is_arr, pos):
self.elems = elems
self.pos = pos
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def check_expr(self, expr):
types.append(tt)
expr.typ = type.Type(self.comp.universe.add_or_get_tuple(types))
return expr.typ
elif isinstance(expr, ast.DynArrayLiteral):
elif isinstance(expr, ast.ArrayLiteral):
old_expected_type = self.expected_type
size = ""
is_mut = False
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ def gen_expr(self, expr, custom_tmp = None):
TypeKind.Tuple else expr.field_name
)
)
elif isinstance(expr, ast.DynArrayLiteral):
elif isinstance(expr, ast.ArrayLiteral):
typ_sym = expr.typ.symbol()
if len(expr.elems) == 0:
if expr.is_arr:
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def parse_primary_expr(self):
break
self.expect(Kind.Rbracket)
is_arr = self.accept(Kind.Bang)
expr = ast.DynArrayLiteral(elems, is_arr, pos)
expr = ast.ArrayLiteral(elems, is_arr, pos)
elif self.tok.kind == Kind.Name:
if self.peek_tok.kind == Kind.Char:
if self.tok.lit == "b":
Expand Down
2 changes: 1 addition & 1 deletion rivetc/src/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def resolve_expr(self, expr):
elif isinstance(expr, ast.TupleLiteral):
for e in expr.exprs:
self.resolve_expr(e)
elif isinstance(expr, ast.DynArrayLiteral):
elif isinstance(expr, ast.ArrayLiteral):
for e in expr.elems:
self.resolve_expr(e)
elif isinstance(expr, ast.GuardExpr):
Expand Down

0 comments on commit 349767c

Please sign in to comment.