Initial commit

This commit is contained in:
Quinten Kock 2020-07-16 18:14:46 +02:00
commit f5def18c26
4 changed files with 67 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/lbce
/obj/

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
src := $(wildcard src/*.c)
obj := $(src:src/%.c=obj/%.o)
headers := $(wildcard include/*.h)
CC = gcc
CFLAGS = -g -O2
.PHONY: clean
lbce: obj $(obj) $(headers)
$(CC) -o lbce $(LDFLAGS) $(obj) $(LOADLIBES) $(LDLIBS)
obj/%.o: src/%.c $(headers)
$(CC) -c -o $@ $(CFLAGS) $<
obj:
mkdir -p obj
clean:
rm -r obj
rm lbce

38
include/types.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef __TYPES_H
#define __TYPES_H
#include <stdint.h>
typedef Integer int;
typedef byte uint8_t;
struct String {
size_t size;
char* data;
}
struct Header {
uint32_t signature;
uint8_t lua_version;
uint8_t format_version;
uint8_t endianness;
uint8_t int_size;
uint8_t size_size;
uint8_t instr_size;
uint8_t number_size;
uint8_t integral;
}
struct Function {
String source_name;
Integer line_def;
Integer line_end;
byte upval_num;
byte param_num;
byte is_vararg;
byte max_stack;
}
#endif

6
src/main.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("hello");
return 0;
}