Browse Source

Minor changes

Ginger Bill 8 years ago
parent
commit
d4457e9fa4
5 changed files with 17 additions and 70 deletions
  1. 1 55
      code/demo.odin
  2. 0 5
      core/sync.odin
  3. 3 3
      src/checker/checker.c
  4. 7 2
      src/parser.c
  5. 6 5
      src/tokenizer.c

+ 1 - 55
code/demo.odin

@@ -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");
-	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");
 }
 }

+ 0 - 5
core/sync.odin

@@ -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);

+ 3 - 3
src/checker/checker.c

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

+ 7 - 2
src/parser.c

@@ -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
src/tokenizer.c

@@ -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_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__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"), \