Skip to content

Commit

Permalink
fix more warns
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 28, 2024
1 parent 78f5587 commit 0af0824
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 117 deletions.
6 changes: 3 additions & 3 deletions lib/rivet/src/ast/Builtin.ri
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ pub enum Builtin {
Invalid,
Const {
name: string;
type: ^mut Type;
type: ^mut Type := ^mut .Void;
},
Func {
name: string;
args: []BuiltinArg;
type: ^mut Type;
type: ^mut Type := ^mut .Void;
is_unsafe: bool;
checks: []BuiltinFuncCheck;

Expand Down Expand Up @@ -42,7 +42,7 @@ struct BuiltinArg {
pub name: string;
pub is_mut: bool;
pub is_any: bool; // any type
pub type: ^mut Type;
pub type: ^mut Type := ^mut .Void;
pub is_optional: bool;
}

Expand Down
14 changes: 7 additions & 7 deletions lib/rivet/src/ast/Decl.ri
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum Decl {
is_typealias: bool;
mut parent_type: ^mut Type;
pos: token.Pos;
mut sym: ^mut Sym:= INVALID_SYM;
mut sym: ^mut Sym:= invalid_sym;
},
Trait {
docs: []Comment;
Expand All @@ -36,7 +36,7 @@ pub enum Decl {
mut bases: []^mut Type;
mut decls: []^mut Decl;
pos: token.Pos;
mut sym: ^mut Sym:= INVALID_SYM;
mut sym: ^mut Sym:= invalid_sym;
},
Enum {
docs: []Comment;
Expand All @@ -49,7 +49,7 @@ pub enum Decl {
is_tagged: bool;
mut decls: []^mut Decl;
pos: token.Pos;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
},
Struct {
docs: []Comment;
Expand All @@ -60,7 +60,7 @@ pub enum Decl {
mut decls: []^mut Decl;
is_opaque: bool;
pos: token.Pos;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
},
Field {
docs: []Comment;
Expand Down Expand Up @@ -89,7 +89,7 @@ pub enum Decl {
mut type: ^mut Type;
mut expr: ^mut Expr;
pos: token.Pos;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
},
Var {
docs: []Comment;
Expand All @@ -100,7 +100,7 @@ pub enum Decl {
mut lefts: []^mut ObjectData;
mut right: ^mut Expr;
pos: token.Pos;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
scope: ^mut Scope;
},
Func {
Expand Down Expand Up @@ -128,7 +128,7 @@ pub enum Decl {
mut self_type: ^mut Type;
pos: token.Pos;
self_pos: token.Pos;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
mut defer_stmts: []mut Stmt.Defer;
},
Test {
Expand Down
78 changes: 39 additions & 39 deletions lib/rivet/src/ast/Env.ri
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,57 @@ pub struct Env {

/// `.universe` is the mega-module where all the modules being
/// compiled reside.
pub universe: ^mut Module;
pub universe: ^mut Module := empty_module;

pub mut c_defines: CDefines;
pub mut c_include_paths: []string;
pub mut c_user_include_paths: []string;

pub core_mod: ^mut Module;
pub core_mod: ^mut Module := empty_module;
pub mut throwable_sym_is_set: bool;

pub mut builtins: []Builtin;

/// Primitive type, Throwable and DynArray symbols.
pub mut bool_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut rune_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut int8_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut int16_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut int32_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut int64_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut int_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut uint8_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut uint16_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut uint32_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut uint64_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut uint_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut comptime_int_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut comptime_float_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut float32_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut float64_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut string_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut throwable_sym: ^mut TypeSym := INVALID_TYPE_SYM;
pub mut dyn_array_sym: ^mut TypeSym := INVALID_TYPE_SYM; // from `core` module
pub mut bool_sym: ^mut TypeSym := invalid_type_sym;
pub mut rune_sym: ^mut TypeSym := invalid_type_sym;
pub mut int8_sym: ^mut TypeSym := invalid_type_sym;
pub mut int16_sym: ^mut TypeSym := invalid_type_sym;
pub mut int32_sym: ^mut TypeSym := invalid_type_sym;
pub mut int64_sym: ^mut TypeSym := invalid_type_sym;
pub mut int_sym: ^mut TypeSym := invalid_type_sym;
pub mut uint8_sym: ^mut TypeSym := invalid_type_sym;
pub mut uint16_sym: ^mut TypeSym := invalid_type_sym;
pub mut uint32_sym: ^mut TypeSym := invalid_type_sym;
pub mut uint64_sym: ^mut TypeSym := invalid_type_sym;
pub mut uint_sym: ^mut TypeSym := invalid_type_sym;
pub mut comptime_int_sym: ^mut TypeSym := invalid_type_sym;
pub mut comptime_float_sym: ^mut TypeSym := invalid_type_sym;
pub mut float32_sym: ^mut TypeSym := invalid_type_sym;
pub mut float64_sym: ^mut TypeSym := invalid_type_sym;
pub mut string_sym: ^mut TypeSym := invalid_type_sym;
pub mut throwable_sym: ^mut TypeSym := invalid_type_sym;
pub mut dyn_array_sym: ^mut TypeSym := invalid_type_sym; // from `core` module

/// Primitive types.
pub mut bool_t: ^mut Type;
pub mut rune_t: ^mut Type;
pub mut int8_t: ^mut Type;
pub mut int16_t: ^mut Type;
pub mut int32_t: ^mut Type;
pub mut int64_t: ^mut Type;
pub mut int_t: ^mut Type;
pub mut uint8_t: ^mut Type;
pub mut uint16_t: ^mut Type;
pub mut uint32_t: ^mut Type;
pub mut uint64_t: ^mut Type;
pub mut uint_t: ^mut Type;
pub mut comptime_int_t: ^mut Type;
pub mut comptime_float_t: ^mut Type;
pub mut float32_t: ^mut Type;
pub mut float64_t: ^mut Type;
pub mut string_t: ^mut Type;
pub mut throwable_t: ^mut Type;
pub mut bool_t: ^mut Type := ^mut .Void;
pub mut rune_t: ^mut Type := ^mut .Void;
pub mut int8_t: ^mut Type := ^mut .Void;
pub mut int16_t: ^mut Type := ^mut .Void;
pub mut int32_t: ^mut Type := ^mut .Void;
pub mut int64_t: ^mut Type := ^mut .Void;
pub mut int_t: ^mut Type := ^mut .Void;
pub mut uint8_t: ^mut Type := ^mut .Void;
pub mut uint16_t: ^mut Type := ^mut .Void;
pub mut uint32_t: ^mut Type := ^mut .Void;
pub mut uint64_t: ^mut Type := ^mut .Void;
pub mut uint_t: ^mut Type := ^mut .Void;
pub mut comptime_int_t: ^mut Type := ^mut .Void;
pub mut comptime_float_t: ^mut Type := ^mut .Void;
pub mut float32_t: ^mut Type := ^mut .Void;
pub mut float64_t: ^mut Type := ^mut .Void;
pub mut string_t: ^mut Type := ^mut .Void;
pub mut throwable_t: ^mut Type := ^mut .Void;

#[inline]
pub func new(prefs_: ^mut prefs.Prefs) -> ^mut Self {
Expand Down
14 changes: 7 additions & 7 deletions lib/rivet/src/ast/Expr.ri
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum Expr < traits.Stringable {
mut is_obj: bool;
mut is_sym: bool;
mut found: bool;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
mut builtin: Builtin := .Invalid;
pos: token.Pos;
mut type: ^mut Type;
Expand All @@ -46,13 +46,13 @@ pub enum Expr < traits.Stringable {
scope: ^mut Scope;
pos: token.Pos;
mut found: bool;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
},
SelfLiteral {
mut scope: ^mut Scope;
pos: token.Pos;
mut found: bool;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
mut obj: ^mut Var;
mut type: ^mut Type;
},
Expand Down Expand Up @@ -93,7 +93,7 @@ pub enum Expr < traits.Stringable {
from_is_cmp: bool;
pos: token.Pos;
mut type: ^mut Type;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
mut variant: EnumVariant;
},
TupleLiteral {
Expand Down Expand Up @@ -121,14 +121,14 @@ pub enum Expr < traits.Stringable {
Selector {
mut left: ^mut Expr;
mut left_type: ^mut Type;
mut left_sym: ^mut Sym := INVALID_SYM;
mut left_sym: ^mut Sym := invalid_sym;
field_name: string;
field_pos: token.Pos;
mut field_is_mut: bool;
mut field_type: ^mut Type;
mut is_path: bool;
mut found: bool;
mut sym: ^mut Sym := INVALID_SYM;
mut sym: ^mut Sym := invalid_sym;
pos: token.Pos;
mut type: ^mut Type;
},
Expand Down Expand Up @@ -182,7 +182,7 @@ pub enum Expr < traits.Stringable {
mut is_constructor: bool;

mut is_enum_variant: bool;
mut enum_variant_sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut enum_variant_sym: ^mut TypeSym := invalid_type_sym;

func has_named_args(&self) -> bool {
for arg in self.args {
Expand Down
4 changes: 3 additions & 1 deletion lib/rivet/src/ast/Scope.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import std/process;

#[boxed]
pub var empty_scope := ^mut Scope();

#[boxed; default_value(empty_scope)]
pub struct Scope {
pub start: uint;
pub mut end: uint;
Expand Down
6 changes: 4 additions & 2 deletions lib/rivet/src/ast/SourceFile.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import ../token;

#[boxed]
pub var empty_source_file := ^mut SourceFile();

#[boxed; default_value(empty_source_file)]
pub struct SourceFile {
pub path: string;
pub decls: []^mut Decl;
pub mut mod: ^mut Module;
pub mut mod: ^mut Module := empty_module;
pub mut imported_symbols: ImportedSymbols;
pub pos: token.Pos;
}
37 changes: 4 additions & 33 deletions lib/rivet/src/ast/Sym.ri
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,7 @@ pub struct DuplicateSymbolError < Throwable {
}
}

pub enum ABI as uint8 < traits.Stringable {
Rivet,
C;

#[inline]
pub func from_string(abi: string) -> ?ABI {
return match abi {
"C" -> .C,
"Rivet" -> .Rivet,
else -> none
};
}

// TODO: remove, use `.to_lower()` instead
#[inline]
pub func lower(&self) -> string {
return match self.* {
.C -> "c",
.Rivet -> "rivet"
};
}

#[inline]
pub func to_string(&self) -> string {
return match self.* {
.C -> "C",
.Rivet -> "Rivet"
};
}
}

pub var INVALID_SYM := ^mut InvalidSym();
pub var invalid_sym := ^mut InvalidSym();

pub trait Sym {
id: uint := new_sym_id();
Expand Down Expand Up @@ -142,11 +111,13 @@ pub struct InvalidSym < Sym {}

#[boxed]
pub struct SymRef < Sym {
pub mut ref: ^mut Sym;
pub mut ref: ^mut Sym := invalid_sym;
pub mut ref_expr: ^mut Expr;
pub mut ref_resolved: bool;
}

pub var empty_module := ^mut Module();

#[boxed]
pub struct Module < Sym {
pub func add_or_get_slice(^mut self, elem_type: ^mut Type, is_mut: bool) -> ^mut TypeSym {
Expand Down
17 changes: 8 additions & 9 deletions lib/rivet/src/ast/Type.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import std/{ traits, process, strings.Builder };

import ../token;
import ../utils;
import ../{token, utils};

#[boxed; default_value(^mut .Void)]
pub enum Type < traits.Stringable {
Basic {
mut sym: ?^mut TypeSym;
mut is_unresolved: bool;
mut expr: ^mut Expr;
mut expr: ^mut Expr := ^mut .Empty(token.no_pos);
pos: token.Pos;
},
Boxed {
Expand Down Expand Up @@ -45,7 +44,7 @@ pub enum Type < traits.Stringable {
},
Tuple {
inners: []^mut Type;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
pos: token.Pos;

func ==(&self, other: &Self) -> bool {
Expand All @@ -63,27 +62,27 @@ pub enum Type < traits.Stringable {
Variadic {
inner: ^mut Type;
is_mut: bool;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
pos: token.Pos;
},
Slice {
inner: ^mut Type;
is_mut: bool;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
pos: token.Pos;
},
DynArray {
inner: ^mut Type;
is_mut: bool;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
pos: token.Pos;
},
Array {
inner: ^mut Type;
is_mut: bool;
mut size: ^mut Expr;
mut size_value: uint;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
pos: token.Pos;
},
Func {
Expand All @@ -93,7 +92,7 @@ pub enum Type < traits.Stringable {
args: []^mut Arg;
ret_type: ^mut Type;
pos: token.Pos;
mut sym: ^mut TypeSym := INVALID_TYPE_SYM;
mut sym: ^mut TypeSym := invalid_type_sym;
mut has_sym: bool;

#[inline]
Expand Down
Loading

0 comments on commit 0af0824

Please sign in to comment.