diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b0992c0e..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.lx linguist-language=Lua diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..34c253b2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. Windows] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..24473dee --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b6633e89 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install Meson & Ninja + run: pip install meson ninja + + - name: Install LLVM (Linux) + if: runner.os == 'Linux' + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 20 + sudo apt-get install -y llvm-20-dev + + - name: Install LLVM (macOS) + if: runner.os == 'macOS' + run: | + brew install llvm@20 + echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH + + - name: Install LLVM (Windows) + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: mingw-w64-x86_64-llvm + + - name: Find llvm-config (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + Get-ChildItem -Path C:\ -Recurse -Filter "llvm-config.exe" -ErrorAction SilentlyContinue | Select-Object FullName + + - name: Configure (release) + if: runner.os != 'Windows' + run: meson setup build/ --buildtype=release + + - name: Build (release) + run: meson compile -C build/ + + - name: Smoke test + shell: bash + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + ./build/luma.exe --help || true + else + ./build/luma --help || true + fi \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82c63ac7..567609b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,41 +1 @@ -build -obj -lux - -# autotools -autom4te.cache - -# Linux executables (files without extensions) -* -!*/ -!*.* - -# Ignore Windows executables -*.exe - -# Ignore Doxygen output -docs/doxygen/ -docs/html/ -docs/latex/ -docs/xml/ - -# Ignore output from llvm -*.bc -*.ll -*.o -*.s - -# Ignore IDE directories -.vscode - -# ignore the lsp-client server node modules -node_modules -package-lock.json -tsconfig.tsbuildinfo -src/lsp/language-support/client/out - -# ignore macOS hidden files -.DS_Store - -# Bear / clangd -compile_commands.json +build/ diff --git a/docs/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 100% rename from docs/CONTRIBUTING.md rename to CONTRIBUTING.md diff --git a/docs/INSTALL.md b/INSTALL.md similarity index 100% rename from docs/INSTALL.md rename to INSTALL.md diff --git a/Makefile b/Makefile deleted file mode 100644 index 0d523018..00000000 --- a/Makefile +++ /dev/null @@ -1,156 +0,0 @@ -# ============================================================ -# Luma / Lux Build System (Cross-Platform) -# Works on Linux, macOS, and Windows -# ============================================================ - -# Define target executable (must be defined before config.mk is included) -BIN := luma - -# Include default config -include config.default.mk - -# Optional: include user config if present -ifneq ($(wildcard config.mk),) -include config.mk -endif - -# ------------------------------------------------------------ -# Paths & Files -# ------------------------------------------------------------ - -# Detect OS and set appropriate commands -ifeq ($(OS),Windows_NT) - # Windows commands - SHELL := cmd.exe - MKDIR = if not exist "$(subst /,\,$(1))" mkdir "$(subst /,\,$(1))" - RMDIR = if exist "$(subst /,\,$(1))" rmdir /s /q "$(subst /,\,$(1))" - DEL = if exist "$(1)" del /q "$(1)" - RM = del /q - EXE = .exe -else - # Unix commands - SHELL := /bin/bash - MKDIR = mkdir -p $(1) - RMDIR = rm -rf $(1) - DEL = rm -f $(1) - RM = rm -f - EXE = -endif - -# ------------------------------------------------------------ -# Targets -# ------------------------------------------------------------ - -.PHONY: all clean debug test check llvm-test view-ir run-llvm compile-native help - -# Default target -all: $(BIN)$(EXE) - -# Build binary -$(BIN)$(EXE): $(OBJ_FILES) -ifeq ($(OS),Windows_NT) - @if not exist "$(dir $@)" mkdir "$(subst /,\,$(dir $@))" -else - @mkdir -p $(dir $@) -endif - $(CC) -o $@ $^ $(LDFLAGS) - -# Compile .c → .o -ifeq ($(OS),Windows_NT) -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c - @if not exist "$(subst /,\,$(dir $@))" mkdir "$(subst /,\,$(dir $@))" - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ -else -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c - @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ -endif - -# Debug build -debug: CFLAGS += -g -debug: all - -# ------------------------------------------------------------ -# Testing & LLVM Targets -# ------------------------------------------------------------ - -test: $(BIN)$(EXE) - @echo "Running basic tests..." -ifeq ($(OS),Windows_NT) - $(BIN)$(EXE) --help || exit 0 -else - ./$(BIN) --help || true -endif - -check: test - -llvm-test: $(BIN)$(EXE) - @echo "Testing LLVM IR generation..." - @echo fn add(a: int, b: int) -^> int { return a + b; } > test_simple.lx - @echo fn main() -^> int { let x: int = 42; let y: int = 24; return add(x, y); } >> test_simple.lx -ifeq ($(OS),Windows_NT) - $(BIN)$(EXE) test_simple.luma --save - @dir *.bc *.ll 2>nul || echo No LLVM output files generated - @del /q test_simple.lx 2>nul -else - ./$(BIN) test_simple.luma --save - @ls -la *.bc *.ll 2>/dev/null || echo "No LLVM output files generated" - @rm -f test_simple.lx -endif - -view-ir: output.ll - @echo === Generated LLVM IR === -ifeq ($(OS),Windows_NT) - @type output.ll -else - @cat output.ll -endif - -run-llvm: output.bc - @echo Running with LLVM interpreter... - lli output.bc - -compile-native: output.ll - @echo Compiling LLVM IR to native executable... - llc output.ll -o output.s - gcc output.s -o program - @echo Native executable created: ./program - -# ------------------------------------------------------------ -# Cleanup -# ------------------------------------------------------------ - -clean: - @echo Cleaning build artifacts... -ifeq ($(OS),Windows_NT) - @if exist "build" rmdir /s /q "build" - @if exist "$(BIN).exe" del /q "$(BIN).exe" - @if exist "$(BIN)" del /q "$(BIN)" - @echo Cleaning LLVM output files... - @if exist "output.bc" del /q "output.bc" - @if exist "output.ll" del /q "output.ll" - @if exist "output.s" del /q "output.s" - @if exist "program.exe" del /q "program.exe" - @if exist "program" del /q "program" -else - @rm -rf $(OBJ_DIR) - @rm -f $(BIN) - @echo "Cleaning LLVM output files..." - @rm -f output.bc output.ll output.s program -endif - -# ------------------------------------------------------------ -# Help -# ------------------------------------------------------------ - -help: - @echo Available targets: - @echo all - Build the compiler - @echo debug - Build with debug symbols - @echo test - Run basic tests - @echo llvm-test - Test LLVM IR generation - @echo view-ir - View generated LLVM IR - @echo run-llvm - Run generated bitcode with lli - @echo compile-native - Compile LLVM IR to native executable - @echo clean - Remove all build artifacts - @echo help - Show this help diff --git a/docs/README.md b/README.md similarity index 100% rename from docs/README.md rename to README.md diff --git a/config.default.mk b/config.default.mk deleted file mode 100644 index 897d0d43..00000000 --- a/config.default.mk +++ /dev/null @@ -1,62 +0,0 @@ -# config.default.mk - -CC := gcc -CFLAGS ?= -Wall -Wextra -std=c17 -Wno-unused-variable -g -O0 -fno-omit-frame-pointer -INCLUDES ?= -Isrc - -# -rdynamic is a Linux/macOS linker flag (exposes symbols for backtrace). -# MinGW/Windows does not support it. -ifeq ($(OS),Windows_NT) - LDFLAGS ?= -else - LDFLAGS ?= -rdynamic -endif - -# Detect llvm-config (allow override via environment or command-line) -LLVM_CONFIG ?= llvm-config - -ifeq ($(OS),Windows_NT) -LLVM_CONFIG ?= llvm-config.exe -else -# Non-Windows (macOS / Linux) -LLVM_CONFIG_AVAILABLE := $(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo yes || echo no) -ifeq ($(LLVM_CONFIG_AVAILABLE),no) -# macOS Homebrew fallback -BREW_LLVM_CONFIG := $(shell brew --prefix llvm 2>/dev/null)/bin/llvm-config -BREW_LLVM_AVAILABLE := $(shell $(BREW_LLVM_CONFIG) --version >/dev/null 2>&1 && echo yes || echo no) -ifeq ($(BREW_LLVM_AVAILABLE),yes) -LLVM_CONFIG := $(BREW_LLVM_CONFIG) -else -$(error llvm-config not found. Install LLVM or set LLVM_CONFIG=/path/to/llvm-config) -endif -endif -endif - -# LLVM configuration - request all necessary components -LLVM_CFLAGS := $(shell $(LLVM_CONFIG) --cflags) -LLVM_LDFLAGS := $(shell $(LLVM_CONFIG) --ldflags) -LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs --system-libs all) - -# Add LLVM flags to existing flags -override CFLAGS += $(LLVM_CFLAGS) -override LDFLAGS += $(LLVM_LDFLAGS) $(LLVM_LIBS) -lstdc++ - -UNAME_S := $(shell uname -s 2>/dev/null) -ifeq ($(UNAME_S),Darwin) -override LDFLAGS := $(filter-out -lstdc++,$(LDFLAGS)) -lc++ -endif - -SRC_DIR = src -OBJ_DIR = build - -# Recursive function to find all .c files -define find_c_sources -$(wildcard $(1)/*.c) \ -$(foreach d,$(wildcard $(1)/*),$(call find_c_sources,$(d))) -endef - -# Find all source files recursively -SRC_FILES := $(call find_c_sources,$(SRC_DIR)) - -# Generate object file paths -OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES)) \ No newline at end of file diff --git a/config.mk.in b/config.mk.in deleted file mode 100644 index bc5018f2..00000000 --- a/config.mk.in +++ /dev/null @@ -1,14 +0,0 @@ -CC = @CC@ -CFLAGS += @CXXFLAGS@ -LDFLAGS += @LDFLAGS@ -PREFIX = @prefix@ - -INSTALL ?= install -DESTDIR ?= $(PREFIX)/bin - -.PHONY: install - -install: $(BIN) - $(INSTALL) -d $(DESTDIR) - $(INSTALL) -s -m 0755 $(BIN) $(DESTDIR)/$(BIN) - @echo "Installed to $(DESTDIR)/$(BIN)" diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 0de8e859..00000000 --- a/configure.ac +++ /dev/null @@ -1,21 +0,0 @@ -AC_INIT([luma], [git], [https://github.com/TheDevConnor/Luma]) -AC_PREREQ([2.69]) -AC_CONFIG_SRCDIR([src/main.c]) # sanity check to make sure someone didn't pass a garbage --srcdir -#AM_INIT_AUTOMAKE([foreign 1.16 dist-bzip2]) - -AC_PROG_CC -AC_LANG(C) -AC_SUBST(CC) -# connor, i have no idea why you're expecting CC to be a C++ compiler. -# that's what CXX is for. - -CXXFLAGS="$CXXFLAGS $CFLAGS $CPPFLAGS" # grab any env for flags -LDFLAGS="$LDFLAGS" -AC_SUBST(CXXFLAGS) -AC_SUBST(LDFLAGS) - -AC_PREFIX_DEFAULT(/usr/local) -AC_SUBST(prefix) - -AC_CONFIG_FILES([config.mk]) -AC_OUTPUT diff --git a/default.nix b/default.nix deleted file mode 100644 index 09acb8b6..00000000 --- a/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ stdenv -, pkg-config -, llvmPackages -, autoconf -, doxygen -, graphviz-nox -}: - -llvmPackages.stdenv.mkDerivation { - pname = "luma"; - version = "0.0.0"; # TODO: versioning - - src = ./.; - - nativeBuildInputs = [ - pkg-config - autoconf - doxygen - graphviz-nox - ]; - - outputs = [ - "out" - "doc" - ]; - - preConfigure = '' - autoconf - ''; - - postInstall = '' - doxygen Doxyfile - mv docs/doxygen $doc - ''; - - buildInputs = [ - llvmPackages.libllvm - ]; - - doCheck = true; -} diff --git a/examples/hello.lx b/examples/hello.lx deleted file mode 100644 index 7c2d82fe..00000000 --- a/examples/hello.lx +++ /dev/null @@ -1,6 +0,0 @@ -@module "hello" - -pub const main -> fn () int { - output("Hello, World!\n"); - return 0; -} diff --git a/examples/hello_io.lx b/examples/hello_io.lx deleted file mode 100644 index 2c64776a..00000000 --- a/examples/hello_io.lx +++ /dev/null @@ -1,8 +0,0 @@ -@module "main" - -@use "io" as io - -pub const main -> fn () int { - io::print("%s\n", [io::str_arg("Hello, macOS!")]); - return 0; -} diff --git a/flake.lock b/flake.lock deleted file mode 100644 index e54e9ae7..00000000 --- a/flake.lock +++ /dev/null @@ -1,61 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1762361079, - "narHash": "sha256-lz718rr1BDpZBYk7+G8cE6wee3PiBUpn8aomG/vLLiY=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "ffcdcf99d65c61956d882df249a9be53e5902ea5", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 1112ddb1..00000000 --- a/flake.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - description = "Luma"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - packages = rec { - default = luma; - luma = pkgs.callPackage ./default.nix { }; - }; - } - ); -} diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..edc4cd7f --- /dev/null +++ b/meson.build @@ -0,0 +1,106 @@ +project('luma', 'c', + version : 'git', + license : 'MIT', + default_options : [ + 'c_std=c11', + 'warning_level=2', + 'buildtype=release', + ] +) + +add_languages('cpp', native : false, required : true) + +cc = meson.get_compiler('c') + +llvm_dep = dependency('llvm', + modules : ['core', 'support', 'irreader'], + required : true, + version : get_option('llvm'), + method : 'config-tool', +) + +sources = files( + 'src/main.c', + + # AST + 'src/ast/ast.c', + 'src/ast/ast_definistions/expr.c', + 'src/ast/ast_definistions/preprocessor.c', + 'src/ast/ast_definistions/stmt.c', + 'src/ast/ast_definistions/type.c', + 'src/ast/ast_utils.c', + + # Auto docs + 'src/auto_docs/doc_generator.c', + + # C libs + 'src/c_libs/color/color.c', + 'src/c_libs/error/error.c', + 'src/c_libs/memory/memory.c', + + # Helper + 'src/helper/help.c', + 'src/helper/run.c', + 'src/helper/std_path.c', + + # Lexer + 'src/lexer/lexer.c', + + # LLVM backend + 'src/llvm/core/llvm.c', + 'src/llvm/core/lookup.c', + 'src/llvm/expr/arrays.c', + 'src/llvm/expr/binary_ops.c', + 'src/llvm/expr/defer.c', + 'src/llvm/expr/expr.c', + 'src/llvm/module/member_access.c', + 'src/llvm/module/module_handles.c', + 'src/llvm/stmt/stmt.c', + 'src/llvm/struct/struct_access.c', + 'src/llvm/struct/struct.c', + 'src/llvm/struct/struct_expr.c', + 'src/llvm/struct/struct_helpers.c', + 'src/llvm/types/type.c', + 'src/llvm/types/type_cache.c', + 'src/llvm/util/helpers.c', + + # LSP server + 'src/lsp/formatter/expr.c', + 'src/lsp/formatter/formatter.c', + 'src/lsp/formatter/stmt.c', + 'src/lsp/lsp_diagnostics.c', + 'src/lsp/lsp_document.c', + 'src/lsp/lsp_features.c', + 'src/lsp/lsp_json.c', + 'src/lsp/lsp_message.c', + 'src/lsp/lsp_module.c', + 'src/lsp/lsp_semantic_tokens.c', + 'src/lsp/lsp_server.c', + 'src/lsp/lsp_symbols.c', + + # Parser + 'src/parser/expr.c', + 'src/parser/parser.c', + 'src/parser/parser_utils.c', + 'src/parser/stmt.c', + 'src/parser/type.c', + + # Typechecker + 'src/typechecker/array.c', + 'src/typechecker/error.c', + 'src/typechecker/expr.c', + 'src/typechecker/lookup.c', + 'src/typechecker/module.c', + 'src/typechecker/scope.c', + 'src/typechecker/static_mem_tracker.c', + 'src/typechecker/stmt.c', + 'src/typechecker/tc.c', + 'src/typechecker/type.c', +) + +executable('luma', + sources, + dependencies : llvm_dep, + install : true, + install_dir : get_option('bindir'), +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..676e86c3 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('llvm', + type : 'string', + value : '>=20.0', + description : 'Minimum required LLVM version. Luma requires 20.0+ due to bug fixes in constant generation.', +) \ No newline at end of file diff --git a/project/build.bolt b/project/build.bolt deleted file mode 100644 index 70e6a83d..00000000 --- a/project/build.bolt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijklmnop \ No newline at end of file diff --git a/releases/v0-1-0/luma-v0.1.0-linux-x86_64.tar.gz b/releases/v0-1-0/luma-v0.1.0-linux-x86_64.tar.gz deleted file mode 100644 index 00dbf35a..00000000 Binary files a/releases/v0-1-0/luma-v0.1.0-linux-x86_64.tar.gz and /dev/null differ diff --git a/releases/v0-1-0/luma-v0.1.0-windows.zip b/releases/v0-1-0/luma-v0.1.0-windows.zip deleted file mode 100644 index d60ea537..00000000 Binary files a/releases/v0-1-0/luma-v0.1.0-windows.zip and /dev/null differ diff --git a/releases/v0-1-0/v0-1-0.md b/releases/v0-1-0/v0-1-0.md deleted file mode 100644 index dfc8601b..00000000 --- a/releases/v0-1-0/v0-1-0.md +++ /dev/null @@ -1,292 +0,0 @@ -# Luma v0.1.0 - Initial Release - -We're excited to announce the first public release of **Luma**, a statically typed, compiled systems programming language designed for simplicity, safety, and performance. - -## What is Luma? - -Luma combines the low-level control of C with modern safety features and a clean, consistent syntax. It's designed for systems programmers who want predictable performance without sacrificing code clarity or safety. - -### Core Principles - -- **Simplicity**: Minimal syntax with consistent patterns -- **Safety**: Strong typing and compile-time memory safety verification -- **Performance**: Zero-cost abstractions and predictable performance - -### Key Features - -- **Strong Static Type System** with explicit typing -- **Manual Memory Management** with compile-time static analysis -- **Struct Methods** for clean object-oriented patterns -- **Ownership Annotations** for clear memory semantics -- **Modern Safety Features** including defer statements and pointer aliasing tracking -- **Simple Module System** for code organization -- **Pattern Matching** via exhaustive switch statements -- **Direct System Calls** for low-level control - -## What's New in v0.1.0 - -### Static Memory Analyzer - -The compiler now validates heap operations at compile time: -- Detects **use-after-free**, **double-free**, and **memory leaks** -- Integrates with `defer` for automatic cleanup tracking -- Tracks **ownership transfers** between variables -- Performs analysis at the end of type checking (no runtime cost) -- Reports exact source locations for memory safety issues - -**Example:** -```luma -let p = alloc(32); -free(p); -use(p); // Error: use-after-free (caught at compile time) -``` - -### Pointer Aliasing Support - -Ownership and lifetime tracking now correctly handle pointer aliasing: - -```luma -let c: *char = cast<*char>(alloc(6 * sizeof)); -let b: *char = c; -defer { free(b); } -``` - -The analyzer recognizes `b` as an alias of `c` and ensures they share the same ownership record, preventing double-free errors and memory leaks. - -### Ownership Annotations - -Two new function attributes help the analyzer understand memory semantics: - -**`#returns_ownership`** - Marks functions that return owned memory: - -```luma -#returns_ownership -pub const make_buffer -> fn(size: int) *char { - return alloc(size); -} -``` - -**`#takes_ownership`** - Marks parameters that consume ownership: - -```luma -#takes_ownership -pub const consume -> fn(ptr: *char) void { - free(ptr); -} -``` - -These annotations make ownership intent explicit while avoiding a full borrow/lifetime system. - -## What's Included - -### Language Features - -- Complete type system (primitives, structs, enums, arrays, pointers) -- Struct methods -- Pattern matching with switch statements -- Defer statements for resource cleanup -- Static memory analysis (leak detection, double-free prevention) -- Ownership attributes (`#returns_ownership`, `#takes_ownership`) -- Module system with `@use` and `@module` - -### Standard Library - -The v0.1.0 release includes several essential modules: - -- **`math`** - Mathematical operations, trigonometry, constants -- **`memory`** - Low-level memory operations (memcpy, memset, calloc, etc.) -- **`string`** - String manipulation and conversion functions -- **`sys`** - Linux system call wrappers (x86_64 only) -- **`terminal`** - Interactive terminal input (getch, getpass, etc.) -- **`termfx`** - ANSI terminal formatting and colors -- **`time`** - Timing and sleep functions -- **`io`** - Formatted I/O operations - -### Example Programs - -This release includes several fully working example programs: - -1. **Chess Engine** - Complete chess implementation with move validation and check detection -2. **Tetris** - Full terminal-based Tetris game with colors and scoring -3. **3D Spinning Cube** - Real-time 3D rendering in the terminal -4. **Bubble Sort** - Classic sorting algorithm demonstration -5. **Test Suites** - Comprehensive tests for memory, string, and system operations - -## Quick Start - -```luma -@module "main" - -@use "math" as math -@use "termfx" as fx - -const Point -> struct { - x: int, - y: int -}; - -pub const main -> fn () int { - let origin: Point = Point { x: 0, y: 0 }; - let destination: Point = Point { x: 3, y: 4 }; - - let distance: double = math::sqrt( - cast((destination.x - origin.x) * (destination.x - origin.x) + - (destination.y - origin.y) * (destination.y - origin.y)) - ); - - output(fx::GREEN, "Distance: ", fx::RESET, distance, "\n"); - return 0; -} -``` - -Compile and run: -```bash -luma main.lx -name program -l std/math.lx std/termfx.lx std/string.lx -./program -``` - -## Installation - -### Pre-built Binaries - -Download the latest release for your platform: -- [Linux x86_64](https://github.com/Luma-Programming-Language/Luma/releases/download/v0.1.0/luma-linux-x86_64) - -### From Source - -Requires: GCC/Clang, Make, LLVM - -```bash -git clone https://github.com/Luma-Programming-Language/Luma.git -cd luma -make -sudo ./install.sh -``` - -## Platform Support - -**Current Release:** -- Linux x86_64 - -**Planned:** -- macOS (ARM64 and x86_64) -- Windows -- Linux ARM64 - -The system call interface (`sys.lx`) is currently Linux-specific. Other modules are platform-agnostic. - -## Known Limitations - -This is an early release. Please be aware of these current limitations: - -### Language -- No generics yet (planned for future release) -- No function overloading -- Limited operator overloading -- No compile-time evaluation beyond constants -- No module exports beyond `pub` keyword - -### Standard Library -- `sys.lx` is Linux x86_64 only -- `terminal.lx` uses shell commands (may not work in all environments) -- Limited string formatting capabilities -- No networking or file I/O abstractions (use `sys` module directly) - -### Tooling -- No package manager yet -- Limited error messages -- No LSP or IDE support -- Manual compilation only (no build system beyond makefiles) - -### Known Bugs -- Pipe operations in `sys.lx` may block indefinitely (marked in tests) -- Some terminal operations might not work on all terminal emulators -- Memory analyzer may have false positives with complex ownership patterns - -## Example Programs - -Try these example programs to see Luma in action: - -```bash -# Terminal Tetris -luma tetris.lx -name tetris -l std/string.lx std/terminal.lx std/termfx.lx std/math.lx std/time.lx && ./tetris - -# 3D Spinning Cube -luma 3d_spinning_cube.lx -name cube -l std/math.lx std/memory.lx std/string.lx std/termfx.lx std/time.lx std/io.lx && ./cube - -# Memory Tests (with Valgrind) -luma mem_test.lx -name mem_test -l std/memory.lx && valgrind --leak-check=full ./mem_test - -# Chess Game -luma main.lx -l board.lx piece.lx std/terminal.lx std/string.lx std/termfx.lx std/memory.lx -name chess && ./chess -``` - -## Documentation - -Complete language documentation is included in `docs.md`, covering: -- Language philosophy and design -- Complete type system reference -- Memory management guide -- Standard library API reference -- Example programs and patterns - -## Verified Behavior - -- All test cases pass under Valgrind (no leaks) -- Analyzer successfully detects invalid frees and missing frees -- Pointer aliasing merges ownership safely -- Deferred frees resolve correctly across scopes - -## Roadmap - -Future releases will focus on: - -1. **v0.2.0** - Cross-platform support (macOS) -2. **v0.3.0** - Package manager and build system -3. **v0.4.0** - Language Server Protocol (LSP) support -4. **v0.5.0** - Advanced features (traits, interfaces, compile-time functions) - -## Contributing - -We welcome contributions! This is an early-stage project and there's plenty to do: - -- Report bugs via GitHub Issues -- Suggest features via GitHub Discussions -- Improve documentation -- Add test cases -- Fix known issues -- Create standard library modules - -Please see `CONTRIBUTING.md` for guidelines. - -## Philosophy - -Luma's goal is to stay low-level and explicit - no garbage collector, no runtime lifetimes - just pure manual memory control with a static verifier ensuring it's safe. - -> "You choose when to free - Luma just makes sure you do it right." - -## License - -Luma is released under the MIT License. - -## Acknowledgments - -Thank you to everyone who provided feedback during development and to the systems programming community for inspiration from languages like C, Rust, and Zig. - -## Getting Help - -- **Documentation**: See `docs.md` in the repository -- **Issues**: https://github.com/Luma-Programming-Language/Luma/issues -- **Discussions**: https://github.com/Luma-Programming-Language/Luma/discussions -- **Examples**: Check the `tests/` and `examples/` directories - ---- - -**Note**: This is an alpha-quality release intended for experimentation and feedback. It is **not recommended for production use** at this time. APIs may change between releases. - -We're excited to share Luma with the community and look forward to your feedback! - ---- - -Made with care by the Luma Team -GitHub: [Luma-Programming-Language/Luma](https://github.com/Luma-Programming-Language/Luma) diff --git a/releases/v0-1-2/luma-v0.1.2-linux-x86_64.tar b/releases/v0-1-2/luma-v0.1.2-linux-x86_64.tar deleted file mode 100644 index 29a9b865..00000000 Binary files a/releases/v0-1-2/luma-v0.1.2-linux-x86_64.tar and /dev/null differ diff --git a/releases/v0-1-2/luma-v0.1.2-windows.zip b/releases/v0-1-2/luma-v0.1.2-windows.zip deleted file mode 100644 index ad051975..00000000 Binary files a/releases/v0-1-2/luma-v0.1.2-windows.zip and /dev/null differ diff --git a/releases/v0-1-2/v0-1-2.md b/releases/v0-1-2/v0-1-2.md deleted file mode 100644 index 8dea498c..00000000 --- a/releases/v0-1-2/v0-1-2.md +++ /dev/null @@ -1,88 +0,0 @@ -# Luma v0.1.2 - Enhanced Error Reporting - -A maintenance release improving compiler diagnostics and refining type semantics. - -## What's New - -### Improved Error Messages - -The compiler now provides detailed, actionable error messages with source context: -``` -error: could not compile due to 2 previous errors - -error[TypeError]: Array types must declare a size, expected ';' after element type - --> tests/test.lx:3:27 - | - 3 | pub const foo -> fn () [int] { - | ^ Parser Error - | - -error[TypeError]: Expected return type after function parameters - --> tests/test.lx:3:27 - | - 3 | pub const foo -> fn () [int] { - | ^ Parser Error - | -``` - -**Improvements:** -- Error counts showing total issues before compilation fails -- Categorized errors (TypeError, SyntaxError, etc.) -- Visual indicators pointing to exact problem locations -- Clear messages explaining what was expected - -### Type Refinement: `char` → `byte` - -The `char` type has been renamed to **`byte`** for clarity: -```luma -// Before -let c: char = 'A'; -let buffer: *char = alloc(256); - -// Now -let c: byte = 'A'; -let buffer: *byte = alloc(256); -``` - -This better represents 8-bit values and aligns with systems programming conventions. - -## Breaking Changes - -⚠️ **`char` renamed to `byte`** - Update all occurrences in your code: -```bash -# Quick migration -find . -name "*.lx" -exec sed -i 's/\bchar\b/byte/g' {} + -``` - -## Standard Library - -All standard library modules updated to use `byte`: -- `string.lx` - String functions use `*byte` -- `memory.lx` - Memory operations updated -- `sys.lx` - System calls use `*byte` for buffers -- `io.lx` - I/O functions adapted - -## Installation - -**Pre-built:** -- [Linux x86_64](https://github.com/Luma-Programming-Language/Luma/releases/download/v0.1.2/luma-linux-x86_64) -- [Windows x86_64](https://github.com/Luma-Programming-Language/Luma/releases/download/v0.1.2/luma-windows-x86_64.exe) - -**From source:** -```bash -git clone https://github.com/Luma-Programming-Language/Luma.git -cd luma -git checkout v0.1.2 -make -sudo ./install.sh -``` - -## Community - -- **Issues:** https://github.com/Luma-Programming-Language/Luma/issues -- **Discord:** https://discord.gg/gqnwasvqd9 - ---- - -Made with care by the Luma Team -GitHub: [Luma-Programming-Language/Luma](https://github.com/Luma-Programming-Language/Luma) diff --git a/releases/v0-1-6/luma-v0.1.6-linux.tar.gz b/releases/v0-1-6/luma-v0.1.6-linux.tar.gz deleted file mode 100644 index 270fb7ca..00000000 Binary files a/releases/v0-1-6/luma-v0.1.6-linux.tar.gz and /dev/null differ diff --git a/releases/v0-1-6/luma-v0.1.6-windows.zip b/releases/v0-1-6/luma-v0.1.6-windows.zip deleted file mode 100644 index 93cb1337..00000000 Binary files a/releases/v0-1-6/luma-v0.1.6-windows.zip and /dev/null differ diff --git a/releases/v0-1-6/v0-1-6.md b/releases/v0-1-6/v0-1-6.md deleted file mode 100644 index df05014f..00000000 --- a/releases/v0-1-6/v0-1-6.md +++ /dev/null @@ -1,23 +0,0 @@ -Changelog for Bugfix Release (v0.1.6) - -Fixes: - -Resolved an issue where struct functions were not being called correctly from modules. - -Corrected static analyzer behavior to only track pointer returns from #returns_ownership functions, preventing false positive memory leak warnings for structs with pointer fields. - -Minor fixes for 2D matrix byte access on very large inputs. - -Other Updates: - -Updated README for clarity. - -Added arena library and vector library. - -Improved LSP support: correct path resolution for standard library files, better code completion, and added string_add function to the standard library. - -Notes: - -Static memory ownership tracking enhancements remain, including improved detection for memory leaks, double-free, and use-after-free within function scope. - -Known limitations: struct field allocations tracked at the struct level; conditional allocation paths may still produce false positives; array-of-pointers patterns not fully tracked. \ No newline at end of file diff --git a/test.lx b/test.lx deleted file mode 100644 index 633e96aa..00000000 --- a/test.lx +++ /dev/null @@ -1,32 +0,0 @@ -@module "thread_test" - -@use "std_thread" as thread -@use "std_libc" as c - -pub const main -> fn () int { - // pthread_mutex_t is 40 bytes on Linux x86_64 - // allocate on heap so it has proper size - let mutex: *int = cast<*int>(c::malloc(40)); - - let r: int = thread::pthread_mutex_init(mutex, cast<*void>(0)); - if (r != 0) { - c::puts("FAIL mutex init"); - free(cast<*void>(mutex)); - return 1; - } - c::puts("PASS mutex init"); - - thread::pthread_mutex_lock(mutex); - c::puts("PASS mutex lock"); - thread::pthread_mutex_unlock(mutex); - c::puts("PASS mutex unlock"); - - thread::pthread_mutex_destroy(mutex); - c::puts("PASS mutex destroy"); - - free(cast<*void>(mutex)); - c::puts("PASS cleanup"); - - return 0; -} -