From a1693c01847f9018ba4c4d9ec455157e34ebd6b3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 23 Feb 2021 14:45:15 +0000 Subject: [PATCH] Deprecate `inline for` in favour of `#unroll for` --- core/runtime/dynamic_map_internal.odin | 2 +- examples/demo/demo.odin | 16 +++++++-------- examples/demo_insert_semicolon/demo.odin | 16 +++++++-------- src/check_stmt.cpp | 10 ++++----- src/ir.cpp | 2 +- src/llvm_backend.cpp | 2 +- src/parser.cpp | 26 +++--------------------- 7 files changed, 27 insertions(+), 47 deletions(-) diff --git a/core/runtime/dynamic_map_internal.odin b/core/runtime/dynamic_map_internal.odin index e880a043f..d6583a6d3 100644 --- a/core/runtime/dynamic_map_internal.odin +++ b/core/runtime/dynamic_map_internal.odin @@ -80,7 +80,7 @@ default_hash_ptr :: inline proc "contextless" (data: rawptr, size: int) -> uintp _default_hasher_const :: inline proc "contextless" (data: rawptr, seed: uintptr, $N: uint) -> uintptr where N <= 16 { h := u64(seed) + 0xcbf29ce484222325; p := uintptr(data); - inline for _ in 0..inline_for_depth; defer (ctx->inline_for_depth = prev_inline_for_depth); { @@ -806,9 +806,9 @@ void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { if (ctx->inline_for_depth >= MAX_INLINE_FOR_DEPTH && prev_inline_for_depth < MAX_INLINE_FOR_DEPTH) { if (prev_inline_for_depth > 0) { - error(node, "Nested 'inline for' loop cannot be inlined as it exceeds the maximum inline for depth (%lld levels >= %lld maximum levels)", v, MAX_INLINE_FOR_DEPTH); + error(node, "Nested '#unroll for' loop cannot be inlined as it exceeds the maximum '#unroll for' depth (%lld levels >= %lld maximum levels)", v, MAX_INLINE_FOR_DEPTH); } else { - error(node, "'inline for' loop cannot be inlined as it exceeds the maximum inline for depth (%lld levels >= %lld maximum levels)", v, MAX_INLINE_FOR_DEPTH); + error(node, "'#unroll for' loop cannot be inlined as it exceeds the maximum '#unroll for' depth (%lld levels >= %lld maximum levels)", v, MAX_INLINE_FOR_DEPTH); } error_line("\tUse a normal 'for' loop instead by removing the 'inline' prefix\n"); ctx->inline_for_depth = MAX_INLINE_FOR_DEPTH; diff --git a/src/ir.cpp b/src/ir.cpp index 2cd3549a9..bfaa84fd1 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11021,7 +11021,7 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { } break; default: - GB_PANIC("Invalid inline for type"); + GB_PANIC("Invalid '#unroll for' type"); break; } } diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 6d0912d5f..a1c3d9589 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -3764,7 +3764,7 @@ void lb_build_inline_range_stmt(lbProcedure *p, AstInlineRangeStmt *rs) { } break; default: - GB_PANIC("Invalid inline for type"); + GB_PANIC("Invalid '#unroll for' type"); break; } } diff --git a/src/parser.cpp b/src/parser.cpp index c1160f8b1..7277f6128 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2066,29 +2066,6 @@ Ast *parse_operand(AstFile *f, bool lhs) { syntax_error(token, "Expected a least 1 argument in a procedure group"); } - return ast_proc_group(f, token, open, close, args); - } else if (f->curr_token.kind == Token_OpenBracket) { // ProcGroup - Token open = expect_token(f, Token_OpenBracket); - warning(open, "Procedure groups using [] are now deprecated, please use {} instead"); - - auto args = array_make(heap_allocator()); - - while (f->curr_token.kind != Token_CloseBracket && - f->curr_token.kind != Token_EOF) { - Ast *elem = parse_expr(f, false); - array_add(&args, elem); - - if (!allow_token(f, Token_Comma)) { - break; - } - } - - Token close = expect_token(f, Token_CloseBracket); - - if (args.count == 0) { - syntax_error(token, "Expected a least 1 argument in a procedure group"); - } - return ast_proc_group(f, token, open, close, args); } @@ -4297,6 +4274,9 @@ Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, TokenKind clo Ast *parse_unrolled_for_loop(AstFile *f, Token inline_token) { + if (inline_token.kind == Token_inline) { + syntax_warning(inline_token, "'inline for' is deprecated in favour of `#unroll for'"); + } Token for_token = expect_token(f, Token_for); Ast *val0 = nullptr; Ast *val1 = nullptr;