Skip to content

Commit

Permalink
minor improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 23, 2024
1 parent 05d0907 commit aa713e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
4 changes: 0 additions & 4 deletions src/julec/compile.jule
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ fn gen_compile_cmd(source_path: str, &ir: &IR): (str, str) {
}

fn get_compile_path(): str {
// let mut path = join(PATH_WD, OUT_DIR)
// path = join(path, OUT_NAME)
// ret path

// Return command-line argument form
// instead of absolute path.
ret join(OUT_DIR, OUT_NAME)
Expand Down
24 changes: 7 additions & 17 deletions std/jule/build/env.jule
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,14 @@ fn init() {
panic("std::jule::build: executable file cannot found")
}

let pwd = env::working_dir() else {
panic("std::jule::build: working directory path cannot found")
ret // To avoid assignment error.
}

let path_exec = path::dir(path)

// Go to parent directory.
path = path::join(path_exec, "..")

// Break immutability to assign paths.
unsafe {
*(&PATH_WD) = pwd
*(&PATH_EXEC) = path_exec
*(&PATH_STDLIB) = path::join(path, STDLIB)

*(&PATH_API) = path::join(PATH_EXEC, "..")
*(&PATH_API) = path::join(PATH_API, "api")
*(&PATH_API) = path::join(PATH_API, "jule.hpp")
*(&PATH_WD) = env::working_dir() else {
panic("std::jule::build: working directory path cannot found")
ret // To avoid assignment error.
}
*(&PATH_EXEC) = path::dir(path)
*(&PATH_STDLIB) = path::join(PATH_EXEC, "..", STDLIB)
*(&PATH_API) = path::join(PATH_EXEC, "..", "api", "jule.hpp")
}
}
7 changes: 5 additions & 2 deletions std/strings/strings.jule
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,15 @@ pub fn trim(s: str, cutset: str): str {
// Concatenates the parts of its first argument to create a single string.
// The separator sep is placed between parts in the resulting string.
pub fn join(parts: []str, sep: str): str {
if parts.len == 0 {
match parts.len {
| 0:
ret ""
| 1:
ret parts[1]
}
let mut n = 0
if sep.len > 0 {
if sep.len >= int.MAX/parts.len-1 {
if sep.len >= int.MAX/(parts.len-1) {
panic("std::strings: join: output length overflow")
}
n += sep.len * (parts.len - 1)
Expand Down

0 comments on commit aa713e2

Please sign in to comment.