mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:37:18 +00:00
Production pass: floats, GC, type checking, and tooling
Adds floats, bitwise ops, UTF-8 strings with methods, try/catch, closures, generics validation, a compile-time type checker, a mark-and-sweep GC, source-level debug info, constant folding, and the repl/fmt/package-manager commands. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import obj
|
||||
pub fn compile(src string) !obj.Obj {
|
||||
toks := tokenize(src)!
|
||||
prog := parse(toks)!
|
||||
// conservative compile-time type check; catches provable errors early
|
||||
check(prog)!
|
||||
return gen(prog)
|
||||
}
|
||||
|
||||
@@ -15,3 +17,18 @@ pub fn compile_file(path string) !obj.Obj {
|
||||
src := os.read_file(path)!
|
||||
return compile(src)!
|
||||
}
|
||||
|
||||
// resolve_import turns an import path into a readable source file. It tries
|
||||
// the path as given first, then falls back to the package-manager layout so
|
||||
// `import "pkg/file.vr"` finds vendor/pkg/file.vr.
|
||||
pub fn resolve_import(path string) !string {
|
||||
if os.exists(path) {
|
||||
return path
|
||||
}
|
||||
for cand in ['vendor/${path}', 'vendor/${path}.vr', 'vendor/${path}/main.vr', 'vendor/${path}/src/main.vr'] {
|
||||
if os.exists(cand) {
|
||||
return cand
|
||||
}
|
||||
}
|
||||
return error('cannot resolve import "${path}" (tried vendor/)"')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user