aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorryuukk <ryuukk.dev@gmail.com>2023-06-26 03:58:47 +0200
committerryuukk <ryuukk.dev@gmail.com>2023-06-26 03:58:47 +0200
commit7d175c5bdb9d10ec435aea37a5386568284baa70 (patch)
treeb940388e1b925c5e67535b74e2dda338fdd57040 /src
parent2adfe2ad91a2c6af0d208447834e544097b6769c (diff)
Handle '==' and '!=' for 'when' directive
Diffstat (limited to 'src')
-rw-r--r--src/common/ast.odin13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index d32b32f..c8e2da5 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -314,11 +314,20 @@ collect_globals :: proc(
}
if ident != nil && implicit != nil {
- allowed :=
- ident.name == "ODIN_OS" &&
+ allowed := false
+
+ if binary.op.text == "==" {
+ allowed = ident.name == "ODIN_OS" &&
implicit.field.name == fmt.tprint(ODIN_OS) ||
ident.name == "ODIN_ARCH" &&
implicit.field.name == fmt.tprint(ODIN_ARCH)
+ } else if binary.op.text == "!=" {
+ allowed = ident.name == "ODIN_OS" &&
+ implicit.field.name != fmt.tprint(ODIN_OS) ||
+ ident.name == "ODIN_ARCH" &&
+ implicit.field.name != fmt.tprint(ODIN_ARCH)
+ }
+
if allowed {
if block, ok := when_decl.body.derived.(^ast.Block_Stmt);
ok {