Skip to content

Commit

Permalink
refact: rename static to var
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Nov 29, 2023
1 parent 9a0fe78 commit 9d00135
Show file tree
Hide file tree
Showing 45 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion cmd/src/main.ri
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import rivet/utils;

import ./tools;

static help := "Rivet is a tool for managing Rivet source code.
var help := "Rivet is a tool for managing Rivet source code.
Usage: rivet [COMMAND] [OPTIONS]
Expand Down
8 changes: 4 additions & 4 deletions cmd/src/tools/cmd_new.ri
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import rivet/utils;

import ./templates;

static newDescription := "Sets up a new Rivet project and performs `git init` (if `git` is installed
var newDescription := "Sets up a new Rivet project and performs `git init` (if `git` is installed
on the system).";

static newDescription2 := "If [NAME] is given, the project will be setup in a new directory with that
var newDescription2 := "If [NAME] is given, the project will be setup in a new directory with that
name, and that name will be added to the `project.json` file. If no name is
given, the user will be prompted for a name.";

static initDescription := "If no `project.json` file exists, one will be created.
var initDescription := "If no `project.json` file exists, one will be created.
If the current directory is not already controlled with `git`, will perform
`git init` (if `git` is installed on the system).";

static availableTemplates := "Available templates:
var availableTemplates := "Available templates:
bin A simple binary project (default).
lib A simple library project.";

Expand Down
10 changes: 5 additions & 5 deletions cmd/src/tools/templates/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

public static mainFile := "import std/console;
public var mainFile := "import std/console;
func main() {
console.writeln(\"Hello World!\");
}
";

public static libFile := "public func add(a: int32, b: int32) -> int32 {
public var libFile := "public func add(a: int32, b: int32) -> int32 {
return a + b;
}
Expand All @@ -18,7 +18,7 @@ test \"test `add` function\" {
}
";

public static gitignoreFile := "# Binaries for programs and plugins
public var gitignoreFile := "# Binaries for programs and plugins
{}
*.exe
*.exe~
Expand All @@ -39,12 +39,12 @@ bin/
.env
";

public static gitattributesFile := "* text=auto eol=lf
public var gitattributesFile := "* text=auto eol=lf
*.bat eol=crlf
*.ri linguist-language=Rivet text=auto eol=lf
";

public static editorConfigFile := "[*]
public var editorConfigFile := "[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
Expand Down
2 changes: 1 addition & 1 deletion lib/c/src/libc/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// be found in the LICENSE file.

extern (C) {
public static environ: [&][&]uint8;
public var environ: [&][&]uint8;
}
12 changes: 6 additions & 6 deletions lib/c/src/libc/stdio.ri
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public struct FILE;

#if _LINUX_
extern (C) {
public static stdin: &mut FILE;
public static stdout: &mut FILE;
public static stderr: &mut FILE;
public var stdin: &mut FILE;
public var stdout: &mut FILE;
public var stderr: &mut FILE;
}

public struct fpos_t {
Expand Down Expand Up @@ -86,9 +86,9 @@ public struct FILE;

public const TMP_MAX := 32767; // SHRT_MAX

public static stdin: &mut FILE := unsafe { __acrt_iob_fn(0) };
public static stdout: &mut FILE := unsafe { __acrt_iob_fn(1) };
public static stderr: &mut FILE := unsafe { __acrt_iob_fn(2) };
public var stdin: &mut FILE := unsafe { __acrt_iob_fn(0) };
public var stdout: &mut FILE := unsafe { __acrt_iob_fn(1) };
public var stderr: &mut FILE := unsafe { __acrt_iob_fn(2) };
#endif

extern (C) {
Expand Down
2 changes: 1 addition & 1 deletion lib/c/src/wyhash.ri
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

extern (C) {
// the default secret parameters
public static _wyp: [4]uint64;
public var _wyp: [4]uint64;

func _wyrot(x: uint64) -> uint64;
func _wymum(a: &uint64, b: &uint64);
Expand Down
10 changes: 5 additions & 5 deletions lib/core/src/TestRunner.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#if _TESTS_

static supportColor := console_is_atty(1);
var supportColor := console_is_atty(1);

static okStatus := bold(green("-> OK"));
static failedStatus := bold(red("-> FAIL"));
static skipStatus := bold(yellow("-> SKIP"));
var okStatus := bold(green("-> OK"));
var failedStatus := bold(red("-> FAIL"));
var skipStatus := bold(yellow("-> SKIP"));

extern (Rivet) {
static testRunner: TestRunner;
var testRunner: TestRunner;
}

func bold(msg: string) -> string {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/backtrace.c.ri
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern (C) {
) -> int32;
}

static state := unsafe {
var state := unsafe {
backtrace_create_state(ARGS[0].ptr, true, bt_error_handler, none)?
};

Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/entry_point.ri
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// be found in the LICENSE file.

extern (Rivet) {
public static mut ARGS: []string;
public var mut ARGS: []string;

func init_string_lits();
func init_globals();
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/errors.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

static returnTrace := ReturnTrace();
var returnTrace := ReturnTrace();

/// This trait is used for errors throwed with result types (!T).
public trait Throwable < Stringable { }
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/int.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

static digitPairs := "0010203040506070809001112131415161718191021222324252627"
var digitPairs := "0010203040506070809001112131415161718191021222324252627"
"28292031323334353637383930414243444546474849405152535455565758595061626364656667"
"68696071727374757677787970818283848586878889809192939495969798999";

Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/lib.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

static mut libcoreIsStarted := false;
var mut libcoreIsStarted := false;

func panic_if(cond: bool, msg: string) {
if cond {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/string.c.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import c/libc;

static emptyString := string(c"", 0, true);
var emptyString := string(c"", 0, true);
#[boxed]
public struct string < Stringable, Hashable, Throwable {
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 @@ -7,7 +7,7 @@ import std/strings;

import ../token;

static mut symIds: uint := 0;
var mut symIds: uint := 0;

func new_sym_id() -> uint {
res := symIds;
Expand Down Expand Up @@ -296,7 +296,7 @@ public struct Const < Sym {
}

public enum VarLevel as uint8 {
Module, // module-level, `static`
Module, // module-level, `var`
Receiver, // receiver: `self`
Argument, // argument-level
Local // inside function
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/codegen/mir/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public struct Global < traits.Stringable {
if self.is_extern {
sb.write_string("extern ");
}
sb.write_fmt("static @{}: {};", self.name, self.type);
sb.write_fmt("var @{}: {};", self.name, self.type);
return sb.to_string();
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public struct Func < traits.Stringable {
if self.blocks.len > 0 {
locals := self.locals[self.args_len..];
for local in locals {
sb.writeln_fmt(" static %{}: {};", local.dbg_name, local.type);
sb.writeln_fmt(" var %{}: {};", local.dbg_name, local.type);
}
if self.blocks.len > 0 {
if locals.len > 0 {
Expand Down
4 changes: 2 additions & 2 deletions lib/rivet/src/parser/decls.ri
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ extend Parser {
},
self.accept(.KwExtern) -> {
self.inside_extern = true;
// extern function or static
// extern function or var
abi := self.parse_abi();
mut decls := @vec(ast.Decl);
if self.accept(.Lbrace) {
Expand Down Expand Up @@ -250,7 +250,7 @@ extend Parser {
pos
);
},
self.accept(.KwStatic) -> {
self.accept(.KwVar) -> {
// variable declarations
mut lefts := @vec(ast.ObjectData);
if self.accept(.Lparen) {
Expand Down
12 changes: 6 additions & 6 deletions lib/rivet/src/prefs/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { Path } from std/fs;

import ../utils;

public static rivetDir := Path.join(env.homeDir, ".rivet_lang")!;
public static rivetcDir := Path.dir_name(process.executable()!)?;
public var rivetDir := Path.join(env.homeDir, ".rivet_lang")!;
public var rivetcDir := Path.dir_name(process.executable()!)?;

public static objDir := Path.join(rivetDir, "obj")!;
public static libDir := Path.join(rivetDir, "lib")!;
public static rivetcLibDir := Path.join(rivetcDir, "lib")!;
public var objDir := Path.join(rivetDir, "obj")!;
public var libDir := Path.join(rivetDir, "lib")!;
public var rivetcLibDir := Path.join(rivetcDir, "lib")!;

public enum Backend as uint8 {
C;
Expand All @@ -38,7 +38,7 @@ public enum OptimizeMode as uint8 {
}

public enum LinkMode as uint8 {
Static,
Var,
Dynamic
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/report/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ../prefs;
import ../token;
import ../utils;

public static mut reportTable := ReportTable();
public var mut reportTable := ReportTable();

#[inline]
public func total_errors() -> uint {
Expand Down
30 changes: 15 additions & 15 deletions lib/rivet/src/token/Kind.ri
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct KindMap {
value: string;
}

static kindStrings := [
var kindStrings := [
KindMap(.Unknown, "unknown"),
KindMap(.EndOfFile, "end of file"),
KindMap(.DocComment, "doc-comment"),
Expand Down Expand Up @@ -94,18 +94,18 @@ static kindStrings := [
KindMap(.KwReturn, "return"),
KindMap(.KwSelf, "self"),
KindMap(.KwSelfTy, "Self"),
KindMap(.KwStatic, "static"),
KindMap(.KwStruct, "struct"),
KindMap(.KwMatch, "match"),
KindMap(.KwTest, "test"),
KindMap(.KwThrow, "throw"),
KindMap(.KwTrait, "trait"),
KindMap(.KwTrue, "true"),
KindMap(.KwUnsafe, "unsafe"),
KindMap(.KwVar, "var"),
KindMap(.KwWhile, "while")
];

static keywordsTable := kindStrings[@as(uint, Kind.KeywordBegin)..];
var keywordsTable := kindStrings[@as(uint, Kind.KeywordBegin)..];

public enum Kind < traits.Stringable {
Unknown, // unknown
Expand Down Expand Up @@ -193,19 +193,29 @@ public enum Kind < traits.Stringable {
KwReturn, // return
KwSelf, // self
KwSelfTy, // Self
KwStatic, // static
KwStruct, // struct
KwMatch, // match
KwTest, // test
KwThrow, // throw
KwTrait, // trait
KwTrue, // true
KwUnsafe, // unsafe
KwVar, // var
KwWhile, // while
// ==============================

KeywordEnd;

#[inline]
public func lookup(str: string) -> Self {
for &km in keywordsTable {
if km.value == str {
return km.key;
}
}
return .Name;
}

#[inline]
public func single(self) -> Kind {
return match self {
Expand Down Expand Up @@ -254,19 +264,9 @@ public enum Kind < traits.Stringable {
}
}

#[inline]
public func lookup(str: string) -> Kind {
for &km in keywordsTable {
if km.value == str {
return km.key;
}
}
return .Name;
}

#[inline]
public func is_keyword(lit: string) -> bool {
return lookup(lit) != .Name;
return Kind.lookup(lit) != .Name;
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/token/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import std/traits;

import ../utils;

public static noPos := Pos();
public var noPos := Pos();

public struct Pos < traits.Stringable {
public file: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/rivet/src/tokenizer/next.ri
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extend Tokenizer {
nextc := self.look_ahead(1);
if utils.is_name_char(ch) {
name := self.read_name();
return self.new_token(token.lookup(name), name, name.len);
return self.new_token(token.Kind.lookup(name), name, name.len);
} else if ch.is_digit() {
// decimals with 0 prefix = error
if ch == b'0' and nextc.is_digit() {
Expand Down
6 changes: 3 additions & 3 deletions lib/rivet/src/utils/file.ri
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import std/env;
import std/process;
import { Path, self } from std/fs;

static normalizedWorkdir := process.wdAtStartup.replace("\\", "/").concat("/");
static errorPathsAbsolute := (env.get("RIVET_ERROR_PATHS") ?? "relative") == "absolute";
var normalizedWorkdir := process.wdAtStartup.replace("\\", "/").concat("/");
var errorPathsAbsolute := (env.get("RIVET_ERROR_PATHS") ?? "relative") == "absolute";

// NOTE: path_styled_for_error_messages will *always* use `/` in the error paths, no
// matter the OS, to ensure stable compiler error output in the tests.
Expand Down Expand Up @@ -85,7 +85,7 @@ struct SourceCache {
}
}

public static mut sourceCache: SourceCache := SourceCache();
public var mut sourceCache: SourceCache := SourceCache();

#[inline]
public func read_file(path_: string) -> !string {
Expand Down
Loading

0 comments on commit 9d00135

Please sign in to comment.