link directive
This commit is contained in:
13
README.md
13
README.md
@@ -76,9 +76,7 @@ Dot :: (a: Vec3, b: Vec3): F32 ;; return a.x*b.x + a.y*b.y + a.z*b.z
|
|||||||
- [x] Constant evaluation and constant folding - Folding and precomputing every expression that can be calculated at compile time. Which allows to check if a given constant expression is actually something that can be computed at compile time
|
- [x] Constant evaluation and constant folding - Folding and precomputing every expression that can be calculated at compile time. Which allows to check if a given constant expression is actually something that can be computed at compile time
|
||||||
|
|
||||||
- [x] Untyped types - Context dependent type assignment of constant expressions, this is a feature I really loved in Go, it makes constants work very well with a very strict type system and it makes errors like overflow of constants in C due to bad size specifier impossible
|
- [x] Untyped types - Context dependent type assignment of constant expressions, this is a feature I really loved in Go, it makes constants work very well with a very strict type system and it makes errors like overflow of constants in C due to bad size specifier impossible
|
||||||
- [x] Infinite precision integers in constants
|
- [x] Infinite precision integers in constants using big ints! No more overflows or underflows (at least at compile time).
|
||||||
- [x] Resolution of all untyped types in the typechecking stage
|
|
||||||
- [x] Special case of booleans and their type propagation
|
|
||||||
|
|
||||||
- [x] Module system
|
- [x] Module system
|
||||||
- [x] Lazy evaluation of modules (unused code is not compiled or typechecked)
|
- [x] Lazy evaluation of modules (unused code is not compiled or typechecked)
|
||||||
@@ -98,7 +96,11 @@ Dot :: (a: Vec3, b: Vec3): F32 ;; return a.x*b.x + a.y*b.y + a.z*b.z
|
|||||||
- [ ] Casting might need a redesign not sure from '->' to 'cast'
|
- [ ] Casting might need a redesign not sure from '->' to 'cast'
|
||||||
|
|
||||||
- [x] Runtime reflection
|
- [x] Runtime reflection
|
||||||
- [x] Dumping info
|
- [x] Package of type and pointer which enables dynamic typing
|
||||||
|
- [x] Types are values holding type ids, this way we can do if TypeOf(value) == S64 ;; blah
|
||||||
|
- [x] Typesafe variadic arguments using []Any slice (no more var args!)
|
||||||
|
- [x] Any semantics that make it easy to use (automatic unpacking to pointer and type)
|
||||||
|
- [x] Optional type information dump
|
||||||
- [ ] Is the design of this correct? That's a lot of data.
|
- [ ] Is the design of this correct? That's a lot of data.
|
||||||
|
|
||||||
- [ ] Builtin data structures
|
- [ ] Builtin data structures
|
||||||
@@ -123,11 +125,14 @@ Dot :: (a: Vec3, b: Vec3): F32 ;; return a.x*b.x + a.y*b.y + a.z*b.z
|
|||||||
- [x] Platforms
|
- [x] Platforms
|
||||||
- [x] Conditional compilation
|
- [x] Conditional compilation
|
||||||
- [x] Windows
|
- [x] Windows
|
||||||
|
- [x] Fully working
|
||||||
|
- [x] Multimedia library
|
||||||
- [x] Linux (Only tested on ubuntu)
|
- [x] Linux (Only tested on ubuntu)
|
||||||
- [x] Paths
|
- [x] Paths
|
||||||
- [x] Reading files
|
- [x] Reading files
|
||||||
- [x] Listing files
|
- [x] Listing files
|
||||||
- [x] Virtual memory
|
- [x] Virtual memory
|
||||||
|
- [ ] Multimedia library (maybe using SDL)
|
||||||
|
|
||||||
- [ ] Language constructs
|
- [ ] Language constructs
|
||||||
- [x] Standard constructs like if, for loop etc.
|
- [x] Standard constructs like if, for loop etc.
|
||||||
|
|||||||
3
base.cpp
3
base.cpp
@@ -50,12 +50,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
|
#define OS_EXE ".exe"
|
||||||
#define OS_NAME "Win32"_s
|
#define OS_NAME "Win32"_s
|
||||||
#define OS_NAME_LOWER "win32"_s
|
#define OS_NAME_LOWER "win32"_s
|
||||||
#elif OS_LINUX
|
#elif OS_LINUX
|
||||||
|
#define OS_EXE ".out"
|
||||||
#define OS_NAME "Linux"_s
|
#define OS_NAME "Linux"_s
|
||||||
#define OS_NAME_LOWER "linux"_s
|
#define OS_NAME_LOWER "linux"_s
|
||||||
#elif OS_MAC
|
#elif OS_MAC
|
||||||
|
#define OS_EXE ".out"
|
||||||
#define OS_NAME "Mac"_s
|
#define OS_NAME "Mac"_s
|
||||||
#define OS_NAME_LOWER "mac"_s
|
#define OS_NAME_LOWER "mac"_s
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ intern_strict = l->intern("strict"_s);
|
|||||||
intern_void = l->intern("void"_s);
|
intern_void = l->intern("void"_s);
|
||||||
intern_flag = l->intern("flag"_s);
|
intern_flag = l->intern("flag"_s);
|
||||||
intern_it = l->intern("it"_s);
|
intern_it = l->intern("it"_s);
|
||||||
|
intern_load = l->intern("load"_s);
|
||||||
|
intern_import = l->intern("import"_s);
|
||||||
|
intern_link = l->intern("link"_s);
|
||||||
op_info_table[0].op = l->intern("*"_s);
|
op_info_table[0].op = l->intern("*"_s);
|
||||||
op_info_table[1].op = l->intern("/"_s);
|
op_info_table[1].op = l->intern("/"_s);
|
||||||
op_info_table[2].op = l->intern("%"_s);
|
op_info_table[2].op = l->intern("%"_s);
|
||||||
@@ -309,12 +312,13 @@ compile_file(String filename, U32 compile_flags = COMPILE_NULL){
|
|||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
F64 begin = os_time();
|
F64 begin = os_time();
|
||||||
#if OS_WINDOWS
|
String_Builder builder = {scratch};
|
||||||
String compiler_call = string_fmt(scratch, "clang.exe program.c -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a.exe -lgdi32 -luser32 -lwinmm");
|
builder.addf("clang program.c -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a" OS_EXE " ");
|
||||||
#else
|
Iter(&pctx->files_to_link){
|
||||||
String compiler_call = string_fmt(scratch, "clang program.c -std=c99 -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a.out");
|
builder.addf("-l%Q ", it.item[0]->intern_val);
|
||||||
// String compiler_call = string_fmt(scratch, "tcc program.c -Wall -g -o a.out");
|
}
|
||||||
#endif
|
String compiler_call = string_flatten(scratch, &builder);
|
||||||
|
|
||||||
log_trace("%Q", compiler_call);
|
log_trace("%Q", compiler_call);
|
||||||
system((const char *)compiler_call.str);
|
system((const char *)compiler_call.str);
|
||||||
F64 end = os_time();
|
F64 end = os_time();
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ struct Parse_Ctx:Lexer{
|
|||||||
String module_folder;
|
String module_folder;
|
||||||
String exe_folder;
|
String exe_folder;
|
||||||
String working_folder;
|
String working_folder;
|
||||||
|
List<Token *> files_to_link;
|
||||||
|
|
||||||
S64 indent;
|
S64 indent;
|
||||||
String_Builder gen;
|
String_Builder gen;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ Intern_String intern_strict;
|
|||||||
Intern_String intern_void;
|
Intern_String intern_void;
|
||||||
Intern_String intern_flag;
|
Intern_String intern_flag;
|
||||||
Intern_String intern_it;
|
Intern_String intern_it;
|
||||||
|
Intern_String intern_load;
|
||||||
|
Intern_String intern_import;
|
||||||
|
Intern_String intern_link;
|
||||||
/*END*/
|
/*END*/
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -924,13 +924,17 @@ parse_file(Ast_File *file){
|
|||||||
pctx->currently_parsed_file = file;
|
pctx->currently_parsed_file = file;
|
||||||
pctx->currently_parsed_scope = file;
|
pctx->currently_parsed_scope = file;
|
||||||
lex_restream(pctx, file->filecontent, file->absolute_file_path);
|
lex_restream(pctx, file->filecontent, file->absolute_file_path);
|
||||||
while(token_expect(SAME_SCOPE)){
|
while (token_expect(SAME_SCOPE)) {
|
||||||
if(token_match_pound(pctx->intern("load"_s))){
|
if (token_match_pound(intern_load)) {
|
||||||
parse_load(true);
|
parse_load(true);
|
||||||
continue;
|
continue;
|
||||||
} else if(token_match_pound(pctx->intern("import"_s))){
|
} else if (token_match_pound(intern_import)) {
|
||||||
parse_import(true);
|
parse_import(true);
|
||||||
continue;
|
continue;
|
||||||
|
} else if (token_match_pound(intern_link)) {
|
||||||
|
Token *file = token_expect(TK_StringLit);
|
||||||
|
add(pctx->perm, &pctx->files_to_link, file);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!file->pos){
|
if(!file->pos){
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ search_for_single_decl(Ast_Scope *scope, Intern_String name){
|
|||||||
compiler_error(0, "Unidentified name [%s]", name.str);
|
compiler_error(0, "Unidentified name [%s]", name.str);
|
||||||
}
|
}
|
||||||
if(search.results.len > 1){
|
if(search.results.len > 1){
|
||||||
compiler_error(0, "Found multiple definitions of name [%s]", name.str);
|
compiler_error(search.results.data[0]->pos, search.results.data[1]->pos, "Found multiple definitions of name [%s]", name.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return search.results.data[0];
|
return search.results.data[0];
|
||||||
|
|||||||
3
meta.py
3
meta.py
@@ -124,4 +124,7 @@ interns = [
|
|||||||
"void",
|
"void",
|
||||||
"flag",
|
"flag",
|
||||||
"it",
|
"it",
|
||||||
|
"load",
|
||||||
|
"import",
|
||||||
|
"link",
|
||||||
]
|
]
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#import "KERNEL32.core"
|
#import "KERNEL32.core"
|
||||||
|
#link "gdi32.lib"
|
||||||
RBGQUAD :: struct;; rgbBlue: BYTE; rgbGreen: BYTE; rgbRed: BYTE; rgbReserved: BYTE
|
RBGQUAD :: struct;; rgbBlue: BYTE; rgbGreen: BYTE; rgbRed: BYTE; rgbReserved: BYTE
|
||||||
BITMAPINFOHEADER :: struct;; biSize: DWORD; biWidth: LONG; biHeight: LONG; biPlanes: WORD; biBitCount: WORD; biCompression: DWORD; biSizeImage: DWORD; biXPelsPerMeter: LONG; biYPelsPerMeter: LONG; biClrUsed: DWORD; biClrImportant: DWORD
|
BITMAPINFOHEADER :: struct;; biSize: DWORD; biWidth: LONG; biHeight: LONG; biPlanes: WORD; biBitCount: WORD; biCompression: DWORD; biSizeImage: DWORD; biXPelsPerMeter: LONG; biYPelsPerMeter: LONG; biClrUsed: DWORD; biClrImportant: DWORD
|
||||||
BITMAPINFO :: struct;; bmiHeader: BITMAPINFOHEADER; bmiColors: [1]RBGQUAD
|
BITMAPINFO :: struct;; bmiHeader: BITMAPINFOHEADER; bmiColors: [1]RBGQUAD
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#link "kernel32.lib"
|
||||||
|
|
||||||
DWORD :: U32
|
DWORD :: U32
|
||||||
LPCSTR :: *char
|
LPCSTR :: *char
|
||||||
LPSTR :: *char
|
LPSTR :: *char
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#import "KERNEL32.core"
|
#import "KERNEL32.core"
|
||||||
|
#link "user32.lib"
|
||||||
WNDPROC :: (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
WNDPROC :: (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||||
WNDCLASSW :: struct;; style: UINT; lpfnWndProc: WNDPROC; cbClsExtra: int; cbWndExtra: int; hInstance: HINSTANCE; hIcon: HICON; hCursor: HCURSOR; hbrBackground: HBRUSH; lpszMenuName: LPCWSTR; lpszClassName: LPCWSTR
|
WNDCLASSW :: struct;; style: UINT; lpfnWndProc: WNDPROC; cbClsExtra: int; cbWndExtra: int; hInstance: HINSTANCE; hIcon: HICON; hCursor: HCURSOR; hbrBackground: HBRUSH; lpszMenuName: LPCWSTR; lpszClassName: LPCWSTR
|
||||||
MSG :: struct;; hwnd: HWND; message: UINT; wParam: WPARAM; lParam: LPARAM; time: DWORD; pt: POINT; lPrivate: DWORD
|
MSG :: struct;; hwnd: HWND; message: UINT; wParam: WPARAM; lParam: LPARAM; time: DWORD; pt: POINT; lPrivate: DWORD
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#import "KERNEL32.core"
|
#import "KERNEL32.core"
|
||||||
|
#link "winmm.lib"
|
||||||
|
|
||||||
MMRESULT :: UINT
|
MMRESULT :: UINT
|
||||||
TIMERR_NOERROR :: 0
|
TIMERR_NOERROR :: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user