mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-24 00:17:54 +00:00
Deprecate inline for in favour of #unroll for
This commit is contained in:
+5
-5
@@ -731,11 +731,11 @@ void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
||||
if (val0 == nullptr) {
|
||||
gbString s = expr_to_string(operand.expr);
|
||||
gbString t = type_to_string(operand.type);
|
||||
error(operand.expr, "Cannot iterate over '%s' of type '%s' in an 'inline for' statement", s, t);
|
||||
error(operand.expr, "Cannot iterate over '%s' of type '%s' in an '#unroll for' statement", s, t);
|
||||
gb_string_free(t);
|
||||
gb_string_free(s);
|
||||
} else if (operand.mode != Addressing_Constant) {
|
||||
error(operand.expr, "An 'inline for' expression must be known at compile time");
|
||||
error(operand.expr, "An '#unroll for' expression must be known at compile time");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
||||
}
|
||||
|
||||
|
||||
// NOTE(bill): Minimize the amount of nesting of an 'inline for'
|
||||
// NOTE(bill): Minimize the amount of nesting of an '#unroll for'
|
||||
i64 prev_inline_for_depth = ctx->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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-23
@@ -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<Ast *>(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;
|
||||
|
||||
Reference in New Issue
Block a user