Logo

dev-resources.site

for different kinds of informations.

Luna Compiler Devlog #1

Published at
8/2/2023
Categories
devlog
luau
compiler
llvm
Author
lopydark
Categories
4 categories in total
devlog
open
luau
open
compiler
open
llvm
open
Author
8 person written this
lopydark
open
Luna Compiler Devlog #1

Hey all!

Introduction

I got curious about how languages like C++ or Rust does work and wanted to make my own. I use Luau (lua but typed) on my daily, but it is an interpreted language, so I wanted to make it work in native (binary).

Overview

I've started this proyect using Rust, LLVM bindings (inkwell) and a Luau parser, I got the most dummy program working:

return 2
Enter fullscreen mode Exit fullscreen mode

When I run the binary, the exit code is 2. I'm really new to compilers and this is my first one. I know this will be a very hard and ambitious project, but at least I want something functional, maybe not for daily usage.

Compilation process

Well, the Rust project only takes the .luau file and emits an object file (.obj/.o) and also I have another Rust project (yes, I'm using cargo's workspaces) that takes that object file and converts it into a binary file using the LLVM toolset (clang).

Featured ones: