From 349767cb7f90befc82559a7cb1dc885843595095 Mon Sep 17 00:00:00 2001 From: Jose Mendoza <56417208+StunxFS@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:57:18 +0000 Subject: [PATCH] rename --- lib/rivet/src/ast/Expr.ri | 12 ++++++------ lib/rivet/src/checker/exprs.ri | 22 +++++++++++----------- lib/rivet/src/parser/exprs.ri | 2 +- lib/rivet/src/resolver/exprs.ri | 4 ++-- rivetc/src/ast.py | 2 +- rivetc/src/checker.py | 2 +- rivetc/src/codegen/__init__.py | 2 +- rivetc/src/parser.py | 2 +- rivetc/src/resolver.py | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/rivet/src/ast/Expr.ri b/lib/rivet/src/ast/Expr.ri index 89e7119c9..9d4ce7370 100644 --- a/lib/rivet/src/ast/Expr.ri +++ b/lib/rivet/src/ast/Expr.ri @@ -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; @@ -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, @@ -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() diff --git a/lib/rivet/src/checker/exprs.ri b/lib/rivet/src/checker/exprs.ri index b30a7bd9f..b27bd0de4 100644 --- a/lib/rivet/src/checker/exprs.ri +++ b/lib/rivet/src/checker/exprs.ri @@ -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() @@ -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; @@ -271,7 +271,7 @@ 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); @@ -279,7 +279,7 @@ extend Checker { } 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" @@ -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 { diff --git a/lib/rivet/src/parser/exprs.ri b/lib/rivet/src/parser/exprs.ri index b0fef4a94..06d4d1acf 100644 --- a/lib/rivet/src/parser/exprs.ri +++ b/lib/rivet/src/parser/exprs.ri @@ -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" { diff --git a/lib/rivet/src/resolver/exprs.ri b/lib/rivet/src/resolver/exprs.ri index c30506c9b..ce512eae2 100644 --- a/lib/rivet/src/resolver/exprs.ri +++ b/lib/rivet/src/resolver/exprs.ri @@ -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); } }, diff --git a/rivetc/src/ast.py b/rivetc/src/ast.py index 93e5aae95..417682f3e 100644 --- a/rivetc/src/ast.py +++ b/rivetc/src/ast.py @@ -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 diff --git a/rivetc/src/checker.py b/rivetc/src/checker.py index c29219581..c30b9de53 100644 --- a/rivetc/src/checker.py +++ b/rivetc/src/checker.py @@ -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 diff --git a/rivetc/src/codegen/__init__.py b/rivetc/src/codegen/__init__.py index 3dbe78bb3..c5f5eea53 100644 --- a/rivetc/src/codegen/__init__.py +++ b/rivetc/src/codegen/__init__.py @@ -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: diff --git a/rivetc/src/parser.py b/rivetc/src/parser.py index a397d5673..a5d868898 100644 --- a/rivetc/src/parser.py +++ b/rivetc/src/parser.py @@ -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": diff --git a/rivetc/src/resolver.py b/rivetc/src/resolver.py index f37517693..963cd4d72 100644 --- a/rivetc/src/resolver.py +++ b/rivetc/src/resolver.py @@ -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):