From 1db5fb32cdd01530629600250433f4d69d950703 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 12 May 2024 14:02:38 -0400 Subject: [PATCH] Bodged in support for region pragmas Have them as basic directives They're similar to the assert and panic macros but are hardcoded to true #region () #endregion () --- src/check_builtin.cpp | 16 +++++++++++++++- src/check_expr.cpp | 2 ++ src/parser.cpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index c7d27cf38..80a8705ea 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1670,7 +1670,21 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o operand->value = found->Constant.value; } } - } else { + } + + // Bodging in #region & #endregion support + else if (name == "region") { + operand->type = t_untyped_bool; + operand->mode = Addressing_Constant; + operand->value = exact_value_bool(true); + } + else if (name == "endregion") { + operand->type = t_untyped_bool; + operand->mode = Addressing_Constant; + operand->value = exact_value_bool(true); + } + + else { error(call, "Unknown directive call: #%.*s", LIT(name)); } return true; diff --git a/src/check_expr.cpp b/src/check_expr.cpp index f0c33d9d8..3be2b2873 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7372,6 +7372,8 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c name == "location" || name == "assert" || name == "panic" || + name == "region" || + name == "endregion" || name == "defined" || name == "config" || name == "load" || diff --git a/src/parser.cpp b/src/parser.cpp index ee3c56daf..10a87c751 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5147,7 +5147,7 @@ gb_internal Ast *parse_stmt(AstFile *f) { break; } return s; - } else if (tag == "assert" || tag == "panic") { + } else if (tag == "assert" || tag == "panic" || tag == "region" || tag == "endregion") { Ast *t = ast_basic_directive(f, hash_token, name); Ast *stmt = ast_expr_stmt(f, parse_call_expr(f, t)); expect_semicolon(f);