Skip to content
Merged
16 changes: 8 additions & 8 deletions examples/complex/lvg/lvg.lv
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ string fn highlight(string line, string pattern):
string last_file = ""

void fn search_file(string path, string pattern):
auto lines = fs_read_lines(path)
auto lines = __fs_read_lines(path)
int local_count = 0

int line_num = 1
Expand All @@ -100,24 +100,24 @@ void fn search_file(string path, string pattern):

string colored_line = highlight(line, pattern)
if flag_line_numbers:
print(" ${C_LINE}${int_to_str(line_num)}${C_DIM}:${C_RESET} ${colored_line}")
print(" ${C_LINE}${__int_to_str(line_num)}${C_DIM}:${C_RESET} ${colored_line}")
else:
print(" ${colored_line}")
line_num += 1

if local_count > 0:
file_count += 1
if flag_count_only:
print("${C_FILE}${path}${C_DIM}:${C_RESET} ${C_BOLD}${int_to_str(local_count)}${C_RESET} matches")
print("${C_FILE}${path}${C_DIM}:${C_RESET} ${C_BOLD}${__int_to_str(local_count)}${C_RESET} matches")

void fn search_dir(string path, string pattern):
auto entries = fs_listdir(path)
auto entries = __fs_listdir(path)
for ref name in entries:
if name.substring(0, 1) == ".":
continue

string full = "${path}/${name}"
if fs_is_dir(full):
if __fs_is_dir(full):
search_dir(full, pattern)
else:
if is_binary_ext(name):
Expand All @@ -133,7 +133,7 @@ void fn search_dir(string path, string pattern):
void fn main():
init_colors()

auto args = os_args()
auto args = __os_args()
if args.len() < 2:
print("Usage: lvg <pattern> [path] [--ext .lv] [-i] [-c]")
exit(1)
Expand All @@ -156,10 +156,10 @@ void fn main():
path = args[i]
i += 1

if fs_is_dir(path):
if __fs_is_dir(path):
search_dir(path, pattern)
else:
search_file(path, pattern)

print("")
print("${C_SUMMARY}${int_to_str(match_count)} matches${C_RESET} in ${C_SUMMARY}${int_to_str(file_count)} files${C_RESET}")
print("${C_SUMMARY}${__int_to_str(match_count)} matches${C_RESET} in ${C_SUMMARY}${__int_to_str(file_count)} files${C_RESET}")
8 changes: 4 additions & 4 deletions examples/complex/tree/tree.lv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int dir_count = 0
int file_count = 0

void fn print_tree(string path, string prefix):
auto entries = fs_listdir(path)
auto entries = __fs_listdir(path)

int i = 0
int total = entries.len()
Expand All @@ -23,7 +23,7 @@ void fn print_tree(string path, string prefix):
child_prefix = " "

string full_path = "${path}/${name}"
if fs_is_dir(full_path):
if __fs_is_dir(full_path):
print("${prefix}${connector}${name}/")
dir_count += 1
print_tree(full_path, "${prefix}${child_prefix}")
Expand All @@ -35,11 +35,11 @@ void fn print_tree(string path, string prefix):

void fn main():
string root = "."
auto args = os_args()
auto args = __os_args()
if args.len() > 1:
root = args[1]

print(root)
print_tree(root, "")
print("")
print("${int_to_str(dir_count)} directories, ${int_to_str(file_count)} files")
print("${__int_to_str(dir_count)} directories, ${__int_to_str(file_count)} files")
2 changes: 1 addition & 1 deletion examples/complex/webserver/webserver.lv
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int fn str_to_int(string s):
void fn main():
vector[Todo] todos = []
int next_id = 1
string html = fs_read("index.html")
string html = __fs_read("index.html")

Server svr

Expand Down
16 changes: 8 additions & 8 deletions lvpkg/commands.lv
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void fn cmd_install():
warn("No dependencies found in ${PKG_FILE}")
return

print("${C_BOLD}Installing ${int_to_str(deps.len())} dependencies...${C_RESET}")
print("${C_BOLD}Installing ${__int_to_str(deps.len())} dependencies...${C_RESET}")
print("")

ensure_dir(DEPS_DIR)
Expand All @@ -78,7 +78,7 @@ void fn cmd_install():

for ref dep in deps:
string dest = "${DEPS_SRC}/${dep.name}"
if fs_is_dir(dest):
if __fs_is_dir(dest):
info("${dep.name}: already cloned, skipping (use 'update' to refresh)")
else:
git_clone(dep.url, dest, dep.version)
Expand All @@ -97,7 +97,7 @@ void fn cmd_update():
warn("No dependencies found in ${PKG_FILE}")
return

print("${C_BOLD}Updating ${int_to_str(deps.len())} dependencies...${C_RESET}")
print("${C_BOLD}Updating ${__int_to_str(deps.len())} dependencies...${C_RESET}")
print("")

ensure_dir(DEPS_DIR)
Expand All @@ -113,7 +113,7 @@ void fn cmd_update():

for ref dep in deps:
string dest = "${DEPS_SRC}/${dep.name}"
if fs_is_dir(dest):
if __fs_is_dir(dest):
git_update(dest, dep.version)
else:
git_clone(dep.url, dest, dep.version)
Expand All @@ -132,11 +132,11 @@ void fn cmd_list():
print("No dependencies found.")
return

print("${C_BOLD}Dependencies (${int_to_str(deps.len())}):${C_RESET}")
print("${C_BOLD}Dependencies (${__int_to_str(deps.len())}):${C_RESET}")
print("")
for ref dep in deps:
string status = "${C_DIM}[not installed]${C_RESET}"
if fs_is_dir("${DEPS_SRC}/${dep.name}"):
if __fs_is_dir("${DEPS_SRC}/${dep.name}"):
status = "${C_GREEN}[installed]${C_RESET}"

string path_info = ""
Expand All @@ -149,9 +149,9 @@ void fn cmd_list():

// Remove the deps/ directory entirely
void fn cmd_clean():
if fs_is_dir(DEPS_DIR):
if __fs_is_dir(DEPS_DIR):
step("Removing ${DEPS_DIR}/...")
os_exec("rm -rf ${DEPS_DIR}")
__os_exec("rm -rf ${DEPS_DIR}")
info("Cleaned.")
else:
warn("Nothing to clean — ${DEPS_DIR}/ does not exist.")
4 changes: 2 additions & 2 deletions lvpkg/dep.lv
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ struct Dep:
// lib <name> <url> <version> <lib_path> [header_path]
vector[Dep] fn parse_pkg_file():
vector[Dep] deps = []
if not fs_exists(PKG_FILE):
if not __fs_exists(PKG_FILE):
error("No ${PKG_FILE} found in current directory")
exit(1)

auto lines = fs_read_lines(PKG_FILE)
auto lines = __fs_read_lines(PKG_FILE)
for ref line in lines:
auto trimmed = line.trim()
if trimmed == "" or starts_with(trimmed, "#"):
Expand Down
10 changes: 5 additions & 5 deletions lvpkg/fsutil.lv
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

// Create a directory (and parents) if it doesn't exist
void fn ensure_dir(string path):
if not fs_is_dir(path):
if not __fs_is_dir(path):
cpp {
std::filesystem::create_directories(path);
}

// Copy a single file from src to dst
void fn copy_file(string src, string dst):
auto content = fs_read(src)
fs_write(dst, content)
auto content = __fs_read(src)
__fs_write(dst, content)

// Recursively copy a directory, skipping hidden files
void fn copy_dir_recursive(string src, string dst):
ensure_dir(dst)
auto entries = fs_listdir(src)
auto entries = __fs_listdir(src)
for ref name in entries:
if starts_with(name, "."):
continue
string src_path = "${src}/${name}"
string dst_path = "${dst}/${name}"
if fs_is_dir(src_path):
if __fs_is_dir(src_path):
copy_dir_recursive(src_path, dst_path)
else:
copy_file(src_path, dst_path)
10 changes: 5 additions & 5 deletions lvpkg/git.lv
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
// Clone a repository at a specific version (tag/branch/commit)
void fn git_clone(string url, string dest, string version):
step("Cloning ${url} @ ${version}")
int result = os_exec("git clone --quiet --depth 1 --branch ${version} ${url} ${dest} 2>&1")
int result = __os_exec("git clone --quiet --depth 1 --branch ${version} ${url} ${dest} 2>&1")
if result != 0:
// fallback: clone default branch and checkout
result = os_exec("git clone --quiet ${url} ${dest} 2>&1")
result = __os_exec("git clone --quiet ${url} ${dest} 2>&1")
if result != 0:
error("Failed to clone ${url}")
return
os_exec("cd ${dest} && git checkout --quiet ${version} 2>&1")
__os_exec("cd ${dest} && git checkout --quiet ${version} 2>&1")

// Fetch latest and checkout a specific version
void fn git_update(string dest, string version):
step("Updating ${dest} to ${version}")
os_exec("cd ${dest} && git fetch --quiet --all 2>&1")
os_exec("cd ${dest} && git checkout --quiet ${version} 2>&1")
__os_exec("cd ${dest} && git fetch --quiet --all 2>&1")
__os_exec("cd ${dest} && git checkout --quiet ${version} 2>&1")
2 changes: 1 addition & 1 deletion lvpkg/lvpkg.lv
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void fn print_help():
void fn main():
init_colors()

auto args = os_args()
auto args = __os_args()
if args.len() < 2:
print_help()
exit(0)
Expand Down
2 changes: 2 additions & 0 deletions runtime/liblavina/convert.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 54 additions & 8 deletions runtime/liblavina/io.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading