Remove Cranelift JIT compiler and expose the existing C backend as the
compilation target. Generated C code can be compiled with GCC/Clang.
Changes:
- Remove cranelift-* dependencies from Cargo.toml
- Delete src/compiler.rs (565 lines of Cranelift code)
- Add compile_to_c() function with -o and --run flags
- Fix C backend name mangling (main -> main_lux) to avoid conflicts
- Update CLI help text and documentation
Usage:
lux compile <file.lux> # Output C to stdout
lux compile <file.lux> -o out.c # Write to file
lux compile <file.lux> --run # Compile and execute
C backend supports: functions, basic types, operators, if/then/else,
records, enums, Console.print. Future work: closures, lists, patterns.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Schema Evolution:
- Preserve version info in type resolution (Type::Versioned)
- Track versioned type declarations in typechecker
- Detect version mismatches at compile time (@v1 vs @v2 errors)
- Support @v2+ (at least) and @latest version constraints
- Store migrations for future auto-migration support
- Fix let bindings to preserve declared type annotations
HTTP Server Effect:
- Add HttpServer effect with listen, accept, respond, respondWithHeaders, stop
- Implement blocking request handling via tiny_http
- Request record includes method, path, body, headers
- Add http_server.lux example with routing via pattern matching
- Add type-checking test for HttpServer effect
Tests: 222 passing (up from 217)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a JIT compiler using Cranelift that compiles Lux functions to native
machine code. Achieves ~160x speedup over the tree-walking interpreter
(fib(30): 11.59ms JIT vs 1.87s interpreter).
Supports: arithmetic, comparisons, conditionals, let bindings, function
calls, and recursion. Compile time overhead is minimal (~500µs).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Http effect for making HTTP requests:
- Http.get(url) - GET request
- Http.post(url, body) - POST with string body
- Http.postJson(url, json) - POST with JSON body
- Http.put(url, body) - PUT request
- Http.delete(url) - DELETE request
Returns Result<HttpResponse, String> where HttpResponse contains
status code, body, and headers.
Includes reqwest dependency with blocking client, OpenSSL support
in flake.nix, and example at examples/http.lux demonstrating
API requests with JSON parsing.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Random and Time effects for random number generation and
time-based operations. These effects can be used in any
effectful code block.
Random effect operations:
- Random.int(min, max) - random integer in range [min, max]
- Random.float() - random float in range [0.0, 1.0)
- Random.bool() - random boolean
Time effect operations:
- Time.now() - current Unix timestamp in milliseconds
- Time.sleep(ms) - sleep for specified milliseconds
Changes:
- Add rand crate dependency
- Add Random and Time effect definitions to types.rs
- Add effects to built-in effects list in typechecker
- Implement effect handlers in interpreter
- Add 4 new tests for Random and Time effects
- Add examples/random.lux demonstrating usage
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a Language Server Protocol (LSP) server to enable IDE integration.
The server provides:
- Real-time diagnostics (parse errors and type errors)
- Basic hover information
- Keyword completions (fn, let, if, match, type, effect, etc.)
- Go-to-definition stub (ready for implementation)
Usage: lux --lsp
The LSP server can be integrated with any editor that supports LSP,
including VS Code, Neovim, Emacs, and others.
Dependencies added:
- lsp-server 0.7
- lsp-types 0.94
- serde with derive feature
- serde_json
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>