Commit Graph

9 Commits

Author SHA1 Message Date
dimgigov 7b32cad3e9 fix(hir_lower): generic monomorphization for cross-module generic calls
The old findGenericCalls second-pass only looked in non-generic functions
and generated unresolved instances like Array_Get_T when generic funcs
called other generic funcs. Removed it entirely.

lowerExpr for ekCall now invokes generateMethodInstance directly for
both explicit (ekGenericCall) and inferred generic calls. This ensures
concrete instantiations are generated on-demand with correct typeSubst.

Also added guard in resolveTypeExpr/substituteType to skip emitting C
struct definitions for unresolved type parameters (e.g. Array<T> inside
a generic function body before monomorphization).

feat(std): add Std::Iter module
- Array_Iter, Iter_Next, Iter_HasNext, Iter_Peek, Iter_Reset
- Iter_Pos, Iter_Len, Iter_Count, Iter_Skip, Iter_Take

docs: document Std::Iter in Stdlib.md
examples: add iter.bux example
tests: add _test_array regression test
2026-06-05 23:39:41 +03:00
dimgigov 154579b30d feat: String_ToFloat + Json escape sequence support
- Add bux_str_to_float() C runtime wrapper (strtod)
- Add String_ToFloat() in library/std/String.bux
- Update JsonParser_ParseNumber to use String_ToFloat (decimals now work)
- Update JsonParser_ParseString to decode escape sequences (\n, \t, \r, \", \\, \b, \f)
- Fix use-after-free in JsonParser_ParseString: String_Copy before StringBuilder_Free
2026-06-05 22:35:50 +03:00
dimgigov d0de9c2abf feat: Std::Sync — Mutex and RwLock primitives
- Add bux_mutex_* and bux_rwlock_* C runtime functions
- Add library/std/Sync.bux with Mutex and RwLock wrappers
- Add examples/sync.bux — threaded counter with Mutex
- Update docs/Stdlib.md with Sync section and example
- Update README.md feature table
2026-06-05 22:30:44 +03:00
dimgigov 809785711c docs: add missing stdlib modules and update language reference
Stdlib.md:
- Add Std::Task (thread spawn/join/sleep)
- Add Std::Channel (generic channels + wrappers)
- Add Std::Net (TCP sockets)
- Add Std::Json (parser/serializer)
- Add Std::Crypto (SHA-256, HMAC, Base64, random)
- Add Std::Fmt (formatting wrappers)
- Add Std::Math (Sqrt, Pow, Abs, Min, Max)
- Add String_FromFloat to String docs
- Update Future Modules list

LanguageRef.md:
- Add Concurrency section (threads + channels)
- Update Ownership with move semantics and own T

BuildAndTest.md:
- Add libssl-dev/openssl prerequisite note
- Mention -lcrypto auto-linking
2026-06-05 22:19:46 +03:00
dimgigov 9c6b516453 feat: restructure repo, borrow checker, expanded stdlib
- Reorganize repository to Rust-style layout:
  compiler/bootstrap/  compiler/selfhost/  compiler/tests/
  library/std/  library/runtime/  tests/  tools/
- Add buxs/ Windows-compatible project root
- Add borrow checker tests and implement:
  - Alias analysis (double mutable borrow detection)
  - Use-after-move detection for own T
- Expand standard library:
  - Std::Os: Args, Env, Cwd, Chdir
  - Std::Time: NowMs, NowUs, SleepMs
  - Std::Process: Run, Output
  - Std::Io: PrintInt64 (fixes 32-bit truncation bug)
- Add examples: os_time.bux, process.bux
- Fix PrintInt to use int64_t in C runtime
2026-06-05 20:08:17 +03:00
dimgigov 291de88506 docs: update README, Stdlib, BuildAndTest, PLAN for new std modules
Added documentation for:
- Std::Fs (DirExists, Mkdir, ListDir)
- Std::Mem (Alloc, Free, MemEq, New)
- Std::Set<T> (Set_New, Set_Add, Set_Has)
- String_Find, String_Replace, String_Format

Updated PLAN.md blockers (all resolved) and self-host status.
Updated README.md project structure and feature table.
Updated BuildAndTest.md with new stdlib modules and path syntax.

Also includes:
- CLI path argument fix (build/check/run accept project path)
- Remove dummyFunc from parser
- Fix String_Replace to use String_Concat instead of buggy str_join2
2026-06-02 18:46:03 +03:00
dimgigov 21f8b2e85a feat: async/await/spawn + fix else-if lowering bug
Self-hosted compiler (buxc2):
- Add async/await/spawn tokens, parsing, HIR, lowering, C emission
- Fix pointer type emission (*T -> T*) in C backend
- Fix sizeof(Type) parsing with parentheses
- Fix import ::{...} infinite loop guard
- Fix int64 emission by avoiding else-if chain workaround
- Add debug-free cli and hir_lower

Bootstrap compiler (Nim):
- Fix critical else-if lowering bug in hir_lower.nim:
  when both elseIfs and else block exist, elseIfs were dropped
  causing all else-if chains to collapse to if+else only

Runtime:
- Fix bux_async_await memory corruption (don't free in run)
- Add bux_remove_from_ready for safe cleanup
- Fix forward declaration and deduplicate bux_now_ms

Docs & examples:
- Update async.bux example with proper int64 params
- Update README, LanguageRef, Stdlib, PLAN for async features
- Mark Phase 7.10 bootstrap loop as completed

All 27 examples pass. buxc2 check/build work on all examples.
2026-06-01 02:57:46 +03:00
dimgigov 5c1a00cbd6 Phase 5-7: generic inference, extend Type<T>, String stdlib, Map<K,V>, self-hosting audit, docs update 2026-05-31 13:06:29 +03:00
dimgigov 7ee6a73ea4 feat: Std::String, Std::Map, Result/Option, ? operator, sizeof fix, docs
Add standard library modules:
- Std::String: strlen, strcmp, concat, copy, starts_with wrappers
- Std::Map: linear-probing hash map with String keys, int values

Add error handling:
- Result and Option algebraic enum examples
- ? try operator for automatic error propagation in HIR lowering

Compiler bugfixes:
- Fix sizeof() for user-defined structs (new hSizeOf HIR node)
- Fix HIR type lowering for char8, bool8, int8, uint8, etc.
- Fix let statement lowering for pointer types (*char8 → int* bug)
- Fix PrintInt ABI mismatch (int64_t → int in io.c)
- Fix Makefile test bug (_test_tmp_pkg already exists)

Documentation:
- Rewrite README.md with features, examples, project structure
- Add docs/LanguageRef.md — complete language reference
- Add docs/Stdlib.md — standard library documentation
- Add docs/BuildAndTest.md — build and test guide

New examples: strings, map, result_option, try_operator (13 total)
2026-05-31 10:15:44 +03:00