Minor changes

This commit is contained in:
Ginger Bill
2016-12-16 20:18:23 +00:00
parent 9634b28b07
commit d4457e9fa4
5 changed files with 17 additions and 70 deletions

View File

@@ -1,60 +1,6 @@
#import win32 "sys/windows.odin";
#import "fmt.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() {
lib, lib_ok := load_library("example.dll");
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();
fmt.println("Hellope");
}

View File

@@ -35,11 +35,6 @@ semaphore_wait :: proc(s: ^Semaphore) {
win32.WaitForSingleObject(s.handle, win32.INFINITE);
}
mutex_make :: proc() -> Mutex {
m: Mutex
mutex_init(^m)
return m
}
mutex_init :: proc(m: ^Mutex) {
atomic.store32(^m.counter, 0);

View File

@@ -193,9 +193,9 @@ gb_global ImplicitValueInfo implicit_value_infos[ImplicitValue_Count] = {0};
typedef struct CheckerContext {
Scope * scope;
DeclInfo *decl;
u32 stmt_state_flags;
Scope * scope;
DeclInfo * decl;
u32 stmt_state_flags;
} CheckerContext;
#define MAP_TYPE TypeAndValue

View File

@@ -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);
while (f->curr_token.kind == Token_Ident ||
@@ -2090,6 +2090,11 @@ AstNodeArray parse_parameter_list(AstFile *f) {
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");
AstNode *type = NULL;
@@ -2405,7 +2410,7 @@ Token parse_proc_signature(AstFile *f,
AstNodeArray *results) {
Token proc_token = expect_token(f, Token_proc);
expect_token(f, Token_OpenParen);
*params = parse_parameter_list(f);
*params = parse_parameter_list(f, true);
expect_token_after(f, Token_CloseParen, "parameter list");
*results = parse_results(f);
return proc_token;

View File

@@ -4,11 +4,11 @@
TOKEN_KIND(Token_Comment, "Comment"), \
\
TOKEN_KIND(Token__LiteralBegin, "_LiteralBegin"), \
TOKEN_KIND(Token_Ident, "Identifier"), \
TOKEN_KIND(Token_Integer, "Integer"), \
TOKEN_KIND(Token_Float, "Float"), \
TOKEN_KIND(Token_Rune, "Rune"), \
TOKEN_KIND(Token_String, "String"), \
TOKEN_KIND(Token_Ident, "identifier"), \
TOKEN_KIND(Token_Integer, "integer"), \
TOKEN_KIND(Token_Float, "float"), \
TOKEN_KIND(Token_Rune, "rune"), \
TOKEN_KIND(Token_String, "string"), \
TOKEN_KIND(Token__LiteralEnd, "_LiteralEnd"), \
\
TOKEN_KIND(Token__OperatorBegin, "_OperatorBegin"), \
@@ -87,6 +87,7 @@ TOKEN_KIND(Token__KeywordBegin, "_KeywordBegin"), \
/* TOKEN_KIND(Token_import, "import"), */\
/* TOKEN_KIND(Token_include, "include"), */\
TOKEN_KIND(Token_proc, "proc"), \
TOKEN_KIND(Token_macro, "macro"), \
TOKEN_KIND(Token_match, "match"), \
TOKEN_KIND(Token_break, "break"), \
TOKEN_KIND(Token_continue, "continue"), \