Fix parsing for procedure literals expression statements; improve assert performance; other minor fixes

This commit is contained in:
gingerBill
2019-07-28 22:58:56 +01:00
parent 162c87b1b8
commit 2c5c8192f8
7 changed files with 13 additions and 9 deletions

View File

@@ -955,6 +955,7 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
switch p.curr_tok.kind {
// Operands
case token.Context, // Also allows for 'context = '
token.Proc,
token.Inline, token.No_Inline,
token.Ident,
token.Integer, token.Float, token.Imag,

View File

@@ -666,11 +666,13 @@ card :: proc(s: $S/bit_set[$E; $U]) -> int {
@builtin
assert :: proc(condition: bool, message := "", loc := #caller_location) -> bool {
if !condition {
p := context.assertion_failure_proc;
if p == nil {
p = default_assertion_failure_proc;
}
p("Runtime assertion", message, loc);
proc(message: string, loc: Source_Code_Location) {
p := context.assertion_failure_proc;
if p == nil {
p = default_assertion_failure_proc;
}
p("Runtime assertion", message, loc);
}(message, loc);
}
return condition;
}

View File

@@ -23,7 +23,7 @@ foreign kernel32 {
@(link_name="GetModuleFileNameA") get_module_file_name_a :: proc(module: Hmodule, filename: cstring, size: u32) -> u32 ---;
@(link_name="GetModuleFileNameW") get_module_file_name_w :: proc(module: Hmodule, filename: Wstring, size: u32) -> u32 ---;
@(link_name="Sleep") sleep :: proc(ms: i32) -> i32 ---;
@(link_name="Sleep") sleep :: proc(ms: u32) ---;
@(link_name="QueryPerformanceFrequency") query_performance_frequency :: proc(result: ^i64) -> i32 ---;
@(link_name="QueryPerformanceCounter") query_performance_counter :: proc(result: ^i64) -> i32 ---;
@(link_name="OutputDebugStringA") output_debug_string_a :: proc(c_str: cstring) ---;

View File

@@ -182,7 +182,7 @@ foreign user32 {
@(link_name="DestroyIcon") destroy_icon :: proc(icon: Hicon) -> Bool ---;
@(link_name="LoadCursorA") load_cursor_a :: proc(instance: Hinstance, cursor_name: cstring) -> Hcursor ---;
@(link_name="LoadCursorW") load_cursor_w :: proc(instance: Hinstance, cursor_name: cstring) -> Hcursor ---;
@(link_name="LoadCursorW") load_cursor_w :: proc(instance: Hinstance, cursor_name: Wstring) -> Hcursor ---;
@(link_name="GetCursor") get_cursor :: proc() -> Hcursor ---;
@(link_name="SetCursor") set_cursor :: proc(cursor: Hcursor) -> Hcursor ---;

View File

@@ -20,5 +20,5 @@ now :: proc() -> Time {
sleep :: proc(d: Duration) {
win32.sleep(i32(d/Millisecond));
win32.sleep(u32(d/Millisecond));
}

View File

@@ -3053,7 +3053,7 @@ irValue *ir_emit_call(irProcedure *p, irValue *value, Array<irValue *> args, Pro
if (value->kind == irValue_Proc) {
irProcedure *the_proc = &value->Proc;
Entity *e = the_proc->entity;
if (entity_has_deferred_procedure(e)) {
if (e != nullptr && entity_has_deferred_procedure(e)) {
DeferredProcedureKind kind = e->Procedure.deferred_procedure.kind;
Entity *deferred_entity = e->Procedure.deferred_procedure.entity;
irValue **deferred_found = map_get(&p->module->values, hash_entity(deferred_entity));

View File

@@ -3759,6 +3759,7 @@ Ast *parse_stmt(AstFile *f) {
switch (token.kind) {
// Operands
case Token_context: // Also allows for `context =`
case Token_proc:
case Token_inline:
case Token_no_inline:
case Token_Ident: