{"id":22862775,"url":"https://github.com/coffeeeatnight/lunavm","last_synced_at":"2025-06-13T19:05:29.753Z","repository":{"id":264719460,"uuid":"882867343","full_name":"CoffeeeAtNight/LunaVM","owner":"CoffeeeAtNight","description":"🌕 LunaVM – A lightweight virtual machine with a custom memory allocator and MoonlightScript integration, designed for executing compiled opcodes or creating an extensible virtualized platform for 2D and 3D applications! 🚀✨","archived":false,"fork":false,"pushed_at":"2024-12-01T16:34:27.000Z","size":53495,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T19:05:11.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoffeeeAtNight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-04T00:11:37.000Z","updated_at":"2024-12-01T16:34:31.000Z","dependencies_parsed_at":"2025-05-07T09:46:45.392Z","dependency_job_id":"70fdc7b8-251b-4b29-80eb-2348770a904e","html_url":"https://github.com/CoffeeeAtNight/LunaVM","commit_stats":null,"previous_names":["coffeeeatnight/lunavm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CoffeeeAtNight/LunaVM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoffeeeAtNight%2FLunaVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoffeeeAtNight%2FLunaVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoffeeeAtNight%2FLunaVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoffeeeAtNight%2FLunaVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoffeeeAtNight","download_url":"https://codeload.github.com/CoffeeeAtNight/LunaVM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoffeeeAtNight%2FLunaVM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259704410,"owners_count":22898858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T10:14:44.785Z","updated_at":"2025-06-13T19:05:29.721Z","avatar_url":"https://github.com/CoffeeeAtNight.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌙 LunaVM\n\nWelcome to **LunaVM**, a unique virtual machine built from scratch in **C**, designed to execute **MoonlightScript** programs, manage memory efficiently, and act as a foundation for a lightweight operating system or a virtualized platform. 🚀\n\n---\n\n## 🖥️ Features\n\n### **1. MoonlightScript Integration**\nLunaVM serves as the runtime environment for **MoonlightScript**, a statically typed, lightweight programming language designed to create system-level applications for LunarVM. MoonlightScript compiles to LunarVM opcodes, which the VM executes, providing a seamless bridge between high-level scripting and low-level execution.\n\nKey features of MoonlightScript:\n- Static typing with type inference.\n- Clean, intuitive syntax for systems programming.\n- Compiles to binary opcodes for LunarVM (`.lvmb` format).\n- MoonlightScript programs can manipulate memory, render graphics, and even build multi-app systems.\n\n---\n\n### **2. Custom Memory Management with Starlock**\nLunaVM uses a custom-built **Starlock allocator** for dynamic memory management. Unlike traditional `malloc`-based allocation, Starlock:\n- Allocates memory in arenas to prevent fragmentation.\n- Tracks ownership and lifetimes of memory blocks to minimize memory leaks.\n- Ensures optimal performance for LunarVM programs.\n\n---\n\n### **3. Lightweight Virtual Machine**\nLunaVM interprets opcodes generated by the **MoonlightScript Compiler (MLSC)** and executes them in a secure, isolated environment. The VM provides:\n- A fetch-decode-execute cycle to handle instructions.\n- A stack-based and register-based hybrid architecture for flexibility.\n- Built-in support for key opcodes like `MOV`, `ADD`, `PRINT`, `HLT`.\n\n---\n\n### **4. Graphics Rendering with Raylib (Planned Integration)**\nFuture versions of LunaVM will support **Raylib** to enable rendering of 2D/3D graphics directly from MoonlightScript programs, making it possible to:\n- Create windowed or fullscreen applications with dynamic content.\n- Develop interactive 3D games or simulations.\n- Bind MoonlightScript functions to Raylib’s rendering pipeline.\n\n---\n\n## 🚀 System Architecture\n\n### **MoonlightScript Workflow**\nThe development pipeline for LunaVM applications looks like this:\n\n1. **Write MoonlightScript Code**  \n   Example `example.mls`:\n   ```moonlightscript\n   fun main() (Void) {\n     var message: String = \"Hello, Lunar World!\";\n     print(message);\n   }\n   ```\n\n2. **Compile with MoonlightScript Compiler (MLSC)**  \n   - Generates `.lvmb` (binary) and `.lvs` (source-debug) files:\n     - `.lvmb`: Binary file of opcodes for LunarVM.\n     - `.lvs`: Optional source file for debugging and introspection.\n\n3. **Run on LunaVM**  \n   - Load the `.lvmb` file into LunaVM’s memory and execute:\n     ```bash\n     lunarvm example.lvmb\n     ```\n\n---\n\n## 🌟 Virtual Machine Highlights\n\n1. **Opcodes**\n   LunaVM currently supports the following opcodes:\n   - `MOV`: Move data into registers.\n   - `ADD`: Perform arithmetic.\n   - `PRINT`: Display strings or numbers.\n   - `HLT`: Halt execution.\n\n   Example LunarVM program in assembly-like pseudocode:\n   ```\n   0x01 0x01 0x10 // MOV R1, 0x10\n   0x02 0x01 0x01 // ADD R1, R1\n   0x03           // PRINT R1\n   0xFF           // HLT\n   ```\n\n2. **Memory Management**\n   - **Starlock** provides efficient allocation with ownership models and arena-based allocation.\n   - LunarVM’s memory can be extended dynamically via Starlock, enabling applications to manage memory flexibly.\n\n3. **Planned Multitasking**\n   - LunaVM will eventually support multiple loaded programs in separate memory spaces, enabling multitasking.\n\n---\n\n## 🌌 The Vision\n\nThe long-term goal of LunaVM is to evolve into a **general-purpose virtual operating system** capable of running multitasking applications, integrating features like:\n- A basic task scheduler to manage multiple processes.\n- Networking capabilities for communication between applications.\n- A file management system for `.lvmb` binaries and data.\n\n---\n\n## 🔭 Example Use Case\n\n1. **MoonlightScript Application Development**  \n   Write applications like games, utilities, or simulations using MoonlightScript.\n\n2. **Virtualized Operating System**  \n   Build a lightweight OS using MoonlightScript to run multiple `.lvmb` programs concurrently on LunarVM.\n\n3. **Graphics and Game Development**  \n   Integrate Raylib to build interactive games or dynamic simulations in MoonlightScript.\n\n---\n\n## ❌ Contribution Policy\n\nThis project is a personal learning and exploration journey, so contributions are not currently accepted. However, feel free to fork and explore the code!\n\n---\n\n## ❤️ Special Thanks\nThanks for checking out **LunaVM** and supporting this exciting journey into virtual machines, memory management, and custom programming languages. 🌟\n\n--- \n\nLet me know if you’d like to tweak anything further!\n\n![image](https://github.com/user-attachments/assets/d8768ff0-185a-4096-8b5a-ab6ba9b6b36c)\n![image](https://github.com/user-attachments/assets/bb2312e3-d0da-4910-a2e8-e77e6431b4e7)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoffeeeatnight%2Flunavm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoffeeeatnight%2Flunavm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoffeeeatnight%2Flunavm/lists"}