mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Minor changes
This commit is contained in:
+1
-55
@@ -1,60 +1,6 @@
|
|||||||
#import win32 "sys/windows.odin";
|
|
||||||
#import "fmt.odin";
|
#import "fmt.odin";
|
||||||
#import "sync.odin";
|
#import "sync.odin";
|
||||||
#import "hash.odin";
|
|
||||||
#import "math.odin";
|
|
||||||
#import "mem.odin";
|
|
||||||
#import "opengl.odin";
|
|
||||||
#import "os.odin";
|
|
||||||
#import "utf8.odin";
|
|
||||||
|
|
||||||
Dll :: struct {
|
|
||||||
Handle :: type rawptr;
|
|
||||||
name: string;
|
|
||||||
handle: Handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
load_library :: proc(name: string) -> (Dll, bool) {
|
|
||||||
buf: [4096]byte;
|
|
||||||
copy(buf[:], name as []byte);
|
|
||||||
|
|
||||||
lib := win32.LoadLibraryA(^buf[0]);
|
|
||||||
if lib == nil {
|
|
||||||
return nil, false;
|
|
||||||
}
|
|
||||||
return Dll{name, lib as Dll.Handle}, true;
|
|
||||||
}
|
|
||||||
|
|
||||||
free_library :: proc(dll: Dll) {
|
|
||||||
win32.FreeLibrary(dll.handle as win32.HMODULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
get_proc_address :: proc(dll: Dll, name: string) -> (rawptr, bool) {
|
|
||||||
buf: [4096]byte;
|
|
||||||
copy(buf[:], name as []byte);
|
|
||||||
|
|
||||||
addr := win32.GetProcAddress(dll.handle as win32.HMODULE, ^buf[0]) as rawptr;
|
|
||||||
if addr == nil {
|
|
||||||
return nil, false;
|
|
||||||
}
|
|
||||||
return addr, true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
lib, lib_ok := load_library("example.dll");
|
fmt.println("Hellope");
|
||||||
if !lib_ok {
|
|
||||||
fmt.println("Could not load library");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
defer free_library(lib);
|
|
||||||
|
|
||||||
proc_addr, addr_ok := get_proc_address(lib, "some_thing");
|
|
||||||
if !addr_ok {
|
|
||||||
fmt.println("Could not load 'some_thing'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
some_thing := (proc_addr as proc());
|
|
||||||
some_thing();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ semaphore_wait :: proc(s: ^Semaphore) {
|
|||||||
win32.WaitForSingleObject(s.handle, win32.INFINITE);
|
win32.WaitForSingleObject(s.handle, win32.INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_make :: proc() -> Mutex {
|
|
||||||
m: Mutex
|
|
||||||
mutex_init(^m)
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_init :: proc(m: ^Mutex) {
|
mutex_init :: proc(m: ^Mutex) {
|
||||||
atomic.store32(^m.counter, 0);
|
atomic.store32(^m.counter, 0);
|
||||||
|
|||||||
@@ -193,9 +193,9 @@ gb_global ImplicitValueInfo implicit_value_infos[ImplicitValue_Count] = {0};
|
|||||||
|
|
||||||
|
|
||||||
typedef struct CheckerContext {
|
typedef struct CheckerContext {
|
||||||
Scope * scope;
|
Scope * scope;
|
||||||
DeclInfo *decl;
|
DeclInfo * decl;
|
||||||
u32 stmt_state_flags;
|
u32 stmt_state_flags;
|
||||||
} CheckerContext;
|
} CheckerContext;
|
||||||
|
|
||||||
#define MAP_TYPE TypeAndValue
|
#define MAP_TYPE TypeAndValue
|
||||||
|
|||||||
+7
-2
@@ -2070,7 +2070,7 @@ AstNode *parse_proc_type(AstFile *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AstNodeArray parse_parameter_list(AstFile *f) {
|
AstNodeArray parse_parameter_list(AstFile *f, bool allow_using) {
|
||||||
AstNodeArray params = make_ast_node_array(f);
|
AstNodeArray params = make_ast_node_array(f);
|
||||||
|
|
||||||
while (f->curr_token.kind == Token_Ident ||
|
while (f->curr_token.kind == Token_Ident ||
|
||||||
@@ -2090,6 +2090,11 @@ AstNodeArray parse_parameter_list(AstFile *f) {
|
|||||||
is_using = false;
|
is_using = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!allow_using && is_using) {
|
||||||
|
syntax_error(f->curr_token, "`using` is not allowed within this parameter list");
|
||||||
|
is_using = false;
|
||||||
|
}
|
||||||
|
|
||||||
expect_token_after(f, Token_Colon, "parameter list");
|
expect_token_after(f, Token_Colon, "parameter list");
|
||||||
|
|
||||||
AstNode *type = NULL;
|
AstNode *type = NULL;
|
||||||
@@ -2405,7 +2410,7 @@ Token parse_proc_signature(AstFile *f,
|
|||||||
AstNodeArray *results) {
|
AstNodeArray *results) {
|
||||||
Token proc_token = expect_token(f, Token_proc);
|
Token proc_token = expect_token(f, Token_proc);
|
||||||
expect_token(f, Token_OpenParen);
|
expect_token(f, Token_OpenParen);
|
||||||
*params = parse_parameter_list(f);
|
*params = parse_parameter_list(f, true);
|
||||||
expect_token_after(f, Token_CloseParen, "parameter list");
|
expect_token_after(f, Token_CloseParen, "parameter list");
|
||||||
*results = parse_results(f);
|
*results = parse_results(f);
|
||||||
return proc_token;
|
return proc_token;
|
||||||
|
|||||||
+6
-5
@@ -4,11 +4,11 @@
|
|||||||
TOKEN_KIND(Token_Comment, "Comment"), \
|
TOKEN_KIND(Token_Comment, "Comment"), \
|
||||||
\
|
\
|
||||||
TOKEN_KIND(Token__LiteralBegin, "_LiteralBegin"), \
|
TOKEN_KIND(Token__LiteralBegin, "_LiteralBegin"), \
|
||||||
TOKEN_KIND(Token_Ident, "Identifier"), \
|
TOKEN_KIND(Token_Ident, "identifier"), \
|
||||||
TOKEN_KIND(Token_Integer, "Integer"), \
|
TOKEN_KIND(Token_Integer, "integer"), \
|
||||||
TOKEN_KIND(Token_Float, "Float"), \
|
TOKEN_KIND(Token_Float, "float"), \
|
||||||
TOKEN_KIND(Token_Rune, "Rune"), \
|
TOKEN_KIND(Token_Rune, "rune"), \
|
||||||
TOKEN_KIND(Token_String, "String"), \
|
TOKEN_KIND(Token_String, "string"), \
|
||||||
TOKEN_KIND(Token__LiteralEnd, "_LiteralEnd"), \
|
TOKEN_KIND(Token__LiteralEnd, "_LiteralEnd"), \
|
||||||
\
|
\
|
||||||
TOKEN_KIND(Token__OperatorBegin, "_OperatorBegin"), \
|
TOKEN_KIND(Token__OperatorBegin, "_OperatorBegin"), \
|
||||||
@@ -87,6 +87,7 @@ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \
|
|||||||
/* TOKEN_KIND(Token_import, "import"), */\
|
/* TOKEN_KIND(Token_import, "import"), */\
|
||||||
/* TOKEN_KIND(Token_include, "include"), */\
|
/* TOKEN_KIND(Token_include, "include"), */\
|
||||||
TOKEN_KIND(Token_proc, "proc"), \
|
TOKEN_KIND(Token_proc, "proc"), \
|
||||||
|
TOKEN_KIND(Token_macro, "macro"), \
|
||||||
TOKEN_KIND(Token_match, "match"), \
|
TOKEN_KIND(Token_match, "match"), \
|
||||||
TOKEN_KIND(Token_break, "break"), \
|
TOKEN_KIND(Token_break, "break"), \
|
||||||
TOKEN_KIND(Token_continue, "continue"), \
|
TOKEN_KIND(Token_continue, "continue"), \
|
||||||
|
|||||||
Reference in New Issue
Block a user