mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-25 23:14:59 -07:00
Declaration grouping uses () rather than {}; Fix some problem with compilation on *nix
This commit is contained in:
@@ -88,7 +88,7 @@ String odin_root_dir(void) {
|
||||
|
||||
String odin_root_dir(void) {
|
||||
String path = global_module_path;
|
||||
Array(char) path_buf;
|
||||
Array<char> path_buf;
|
||||
isize len, i;
|
||||
gbTempArenaMemory tmp;
|
||||
wchar_t *text;
|
||||
|
||||
+1
-1
@@ -5162,7 +5162,7 @@ Type *check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNod
|
||||
Entity *proc = procs[valids[i].index];
|
||||
TokenPos pos = proc->token.pos;
|
||||
gbString pt = type_to_string(proc->type);
|
||||
gb_printf_err("\t%.*s :: %s at %.*s(%td:%td) with score %lld\n", LIT(name), pt, LIT(pos.file), pos.line, pos.column, valids[i].score);
|
||||
gb_printf_err("\t%.*s of type %s at %.*s(%td:%td) with score %lld\n", LIT(name), pt, LIT(pos.file), pos.line, pos.column, cast(long long)valids[i].score);
|
||||
gb_string_free(pt);
|
||||
}
|
||||
proc_type = t_invalid;
|
||||
|
||||
+1
-1
@@ -1593,7 +1593,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
|
||||
found = current_scope_lookup_entity(c->context.scope, str);
|
||||
}
|
||||
if (found == NULL) {
|
||||
entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, (gd->flags&VarDeclFlag_immutable) != 0);
|
||||
entity = make_entity_variable(c->allocator, c->context.scope, token, NULL, gd->token.kind == Token_let);
|
||||
entity->identifier = name;
|
||||
|
||||
AstNode *fl = c->context.curr_foreign_library;
|
||||
|
||||
+2
-2
@@ -1585,7 +1585,7 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
|
||||
error_node(name, "A declaration's name must be an identifier, got %.*s", LIT(ast_node_strings[name->kind]));
|
||||
continue;
|
||||
}
|
||||
Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, (gd->flags&VarDeclFlag_immutable) != 0);
|
||||
Entity *e = make_entity_variable(c->allocator, c->context.scope, name->Ident, NULL, gd->token.kind == Token_let);
|
||||
e->Variable.is_thread_local = (gd->flags & VarDeclFlag_thread_local) != 0;
|
||||
e->identifier = name;
|
||||
|
||||
@@ -2005,7 +2005,7 @@ void check_import_entities(Checker *c, Map<Scope *> *file_scopes) {
|
||||
continue;
|
||||
}
|
||||
if (operand.value.kind == ExactValue_Bool &&
|
||||
!operand.value.value_bool) {
|
||||
operand.value.value_bool == false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2144,9 +2144,9 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue *
|
||||
bool is_unsigned = is_type_unsigned(type);
|
||||
char *name = NULL;
|
||||
if (op == Token_Quo) {
|
||||
name = is_unsigned ? "__udivti3" : "__divti3";
|
||||
name = cast(char *)(is_unsigned ? "__udivti3" : "__divti3");
|
||||
} else if (op == Token_Mod) {
|
||||
name = is_unsigned ? "__umodti3" : "__modti3";
|
||||
name = cast(char *)(is_unsigned ? "__umodti3" : "__modti3");
|
||||
}
|
||||
if (name != NULL) {
|
||||
irValue **args = gb_alloc_array(proc->module->allocator, irValue *, 2);
|
||||
@@ -3698,7 +3698,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
|
||||
|
||||
case BuiltinProc_new: {
|
||||
ir_emit_comment(proc, str_lit("new"));
|
||||
// new :: proc(Type) -> ^Type
|
||||
// proc new(Type) -> ^Type
|
||||
gbAllocator a = proc->module->allocator;
|
||||
|
||||
Type *type = type_of_expr(proc->module->info, ce->args[0]);
|
||||
@@ -3720,7 +3720,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
|
||||
irValue **args = gb_alloc_array(a, irValue *, 2);
|
||||
args[0] = ir_const_int(a, size);
|
||||
args[1] = ir_const_int(a, align);
|
||||
irValue *call = ir_emit_global_call(proc, "alloc_align", args, 2);
|
||||
irValue *call = ir_emit_global_call(proc, "alloc", args, 2);
|
||||
irValue *v = ir_emit_conv(proc, call, ptr_type);
|
||||
if (type != allocation_type) {
|
||||
Type *u = base_type(allocation_type);
|
||||
@@ -3758,7 +3758,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
|
||||
irValue **args = gb_alloc_array(a, irValue *, 2);
|
||||
args[0] = slice_size;
|
||||
args[1] = elem_align;
|
||||
irValue *call = ir_emit_global_call(proc, "alloc_align", args, 2);
|
||||
irValue *call = ir_emit_global_call(proc, "alloc", args, 2);
|
||||
|
||||
irValue *ptr = ir_emit_conv(proc, call, elem_ptr_type);
|
||||
irValue *slice = ir_add_local_generated(proc, type);
|
||||
@@ -4128,7 +4128,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
|
||||
|
||||
case BuiltinProc_copy: {
|
||||
ir_emit_comment(proc, str_lit("copy"));
|
||||
// copy :: proc(dst, src: []Type) -> int
|
||||
// proc copy(dst, src: []Type) -> int
|
||||
AstNode *dst_node = ce->args[0];
|
||||
AstNode *src_node = ce->args[1];
|
||||
irValue *dst_slice = ir_build_expr(proc, dst_node);
|
||||
@@ -7321,7 +7321,7 @@ void ir_gen_tree(irGen *s) {
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
if (build_context.is_dll && !has_dll_main) {
|
||||
// DllMain :: proc(inst: rawptr, reason: u32, reserved: rawptr) -> i32
|
||||
// proc DllMain(inst: rawptr, reason: u32, reserved: rawptr) -> i32
|
||||
String name = str_lit("DllMain");
|
||||
Type *proc_params = make_type_tuple(a);
|
||||
Type *proc_results = make_type_tuple(a);
|
||||
@@ -7389,7 +7389,7 @@ void ir_gen_tree(irGen *s) {
|
||||
#endif
|
||||
#if 0 && defined(GB_SYSTEM_WINDOWS)
|
||||
if (!m->build_context->is_dll && !has_win_main) {
|
||||
// WinMain :: proc(inst, prev: rawptr, cmd_line: ^byte, cmd_show: i32) -> i32
|
||||
// proc WinMain(inst, prev: rawptr, cmd_line: ^byte, cmd_show: i32) -> i32
|
||||
String name = str_lit("WinMain");
|
||||
Type *proc_params = make_type_tuple(a);
|
||||
Type *proc_results = make_type_tuple(a);
|
||||
|
||||
+17
-15
@@ -89,8 +89,7 @@ enum ProcCallingConvention {
|
||||
|
||||
enum VarDeclFlag {
|
||||
VarDeclFlag_using = 1<<0,
|
||||
VarDeclFlag_immutable = 1<<1,
|
||||
VarDeclFlag_thread_local = 1<<2,
|
||||
VarDeclFlag_thread_local = 1<<1,
|
||||
};
|
||||
|
||||
enum StmtStateFlag {
|
||||
@@ -2590,17 +2589,24 @@ AstNode *parse_gen_decl(AstFile *f, Token token, ParseSpecFunc *func) {
|
||||
Token open = {};
|
||||
Token close = {};
|
||||
|
||||
if (f->curr_token.kind == Token_OpenBrace) {
|
||||
if (f->curr_token.kind == Token_OpenParen) {
|
||||
specs = make_ast_node_array(f);
|
||||
open = expect_token(f, Token_OpenBrace);
|
||||
while (f->curr_token.kind != Token_CloseBrace &&
|
||||
open = expect_token(f, Token_OpenParen);
|
||||
bool require_semicolon_after_paren = false;
|
||||
while (f->curr_token.kind != Token_CloseParen &&
|
||||
f->curr_token.kind != Token_EOF) {
|
||||
AstNode *spec = func(f, token);
|
||||
array_add(&specs, spec);
|
||||
expect_semicolon(f, spec);
|
||||
if (f->curr_token.kind == Token_CloseParen &&
|
||||
f->curr_token.pos.line == f->prev_token.pos.line) {
|
||||
require_semicolon_after_paren = true;
|
||||
} else {
|
||||
expect_semicolon(f, spec);
|
||||
}
|
||||
}
|
||||
close = expect_token(f, Token_CloseBrace);
|
||||
if (f->curr_token.pos.line == close.pos.line ||
|
||||
close = expect_token(f, Token_CloseParen);
|
||||
if (require_semicolon_after_paren ||
|
||||
f->curr_token.pos.line == close.pos.line ||
|
||||
open.pos.line == close.pos.line) {
|
||||
expect_semicolon(f, NULL);
|
||||
}
|
||||
@@ -2614,11 +2620,7 @@ AstNode *parse_gen_decl(AstFile *f, Token token, ParseSpecFunc *func) {
|
||||
syntax_error(token, "Empty %.*s declaration list", LIT(token_strings[token.kind]));
|
||||
}
|
||||
|
||||
AstNode *decl = ast_gen_decl(f, token, open, close, specs);
|
||||
if (token.kind == Token_let) {
|
||||
decl->GenDecl.flags |= VarDeclFlag_immutable;
|
||||
}
|
||||
return decl;
|
||||
return ast_gen_decl(f, token, open, close, specs);
|
||||
}
|
||||
|
||||
PARSE_SPEC_FUNC(parse_value_spec) {
|
||||
@@ -3247,7 +3249,7 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
|
||||
}
|
||||
if (allow_token(f, Token_Eq)) {
|
||||
// TODO(bill): Should this be true==lhs or false==rhs?
|
||||
default_value = parse_expr(f, true);
|
||||
default_value = parse_expr(f, false);
|
||||
if (!is_procedure) {
|
||||
syntax_error(f->curr_token, "Default parameters are only allowed for procedures");
|
||||
}
|
||||
@@ -3281,7 +3283,7 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
|
||||
}
|
||||
if (allow_token(f, Token_Eq)) {
|
||||
// TODO(bill): Should this be true==lhs or false==rhs?
|
||||
default_value = parse_expr(f, true);
|
||||
default_value = parse_expr(f, false);
|
||||
if (!is_procedure) {
|
||||
syntax_error(f->curr_token, "Default parameters are only allowed for procedures");
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@ struct ssaProc;
|
||||
struct ssaEdge;
|
||||
struct ssaRegister;
|
||||
struct ssaTargetList;
|
||||
enum ssaBlockKind;
|
||||
enum ssaBranchPrediction;
|
||||
enum ssaDeferExitKind;
|
||||
|
||||
|
||||
String ssa_mangle_name(ssaModule *m, String path, Entity *e);
|
||||
|
||||
+1
-1
@@ -2445,7 +2445,7 @@ gbString write_type_to_string(gbString str, Type *type) {
|
||||
break;
|
||||
|
||||
case Type_BitFieldValue:
|
||||
str = gb_string_appendc(str, gb_bprintf("(bit field value with %lld bits)", cast(int)type->BitFieldValue.bits));
|
||||
str = gb_string_appendc(str, gb_bprintf("(bit field value with %d bits)", cast(int)type->BitFieldValue.bits));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user