diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-17 12:01:53 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-17 12:01:53 +0100 |
| commit | 2deb2f8eebc42dd52ef8b78811c59e1b07f54f21 (patch) | |
| tree | 6450f88b93b155bd1db798ee11f8ac03e7cc1f84 /src | |
| parent | 3fa398ec43ddc6fc40562087fd8ab87dc5292499 (diff) | |
Declaration grouping uses () rather than {}; Fix some problem with compilation on *nix
Diffstat (limited to 'src')
| -rw-r--r-- | src/build_settings.cpp | 2 | ||||
| -rw-r--r-- | src/check_expr.cpp | 2 | ||||
| -rw-r--r-- | src/check_stmt.cpp | 2 | ||||
| -rw-r--r-- | src/checker.cpp | 4 | ||||
| -rw-r--r-- | src/ir.cpp | 16 | ||||
| -rw-r--r-- | src/parser.cpp | 32 | ||||
| -rw-r--r-- | src/ssa.cpp | 3 | ||||
| -rw-r--r-- | src/types.cpp | 2 |
8 files changed, 31 insertions, 32 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 68e8ec372..8d397705e 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -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; diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 6a391f00c..8759f9f09 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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; diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index fbf301878..318239b25 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -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; diff --git a/src/checker.cpp b/src/checker.cpp index 0f8c2606a..c76c908d9 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -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; } } diff --git a/src/ir.cpp b/src/ir.cpp index 75f9b8153..c585c99df 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -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); diff --git a/src/parser.cpp b/src/parser.cpp index 8aadba765..44f46150e 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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"); } diff --git a/src/ssa.cpp b/src/ssa.cpp index 06da0afa1..6168b025f 100644 --- a/src/ssa.cpp +++ b/src/ssa.cpp @@ -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); diff --git a/src/types.cpp b/src/types.cpp index 94d4cf7c8..ca74a1b77 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -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; } |