aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-11 00:27:10 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-11 00:27:10 -0400
commit7411a88d5f8109ced238cf14205ae36575f02f21 (patch)
treec61dd9c7a046e113509dc96c8a1bd42d57ce21dc /src/analyze.cpp
parent33371ab55c01d896b91df13eafe6e5c601400a07 (diff)
downloadzig-7411a88d5f8109ced238cf14205ae36575f02f21.tar.gz
zig-7411a88d5f8109ced238cf14205ae36575f02f21.zip
fix comptime function calls
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 0168dad6ea..beaa9f1486 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -7293,3 +7293,31 @@ void src_assert(bool ok, AstNode *source_node) {
const char *msg = "assertion failed. This is a bug in the Zig compiler.";
stage2_panic(msg, strlen(msg));
}
+
+bool scope_is_elided(Scope *scope) {
+ for (;;) {
+ switch (scope->id) {
+ case ScopeIdElide:
+ if (reinterpret_cast<ScopeElide *>(scope)->activated)
+ return true;
+ // fallthrough
+ case ScopeIdBlock:
+ case ScopeIdDefer:
+ case ScopeIdDeferExpr:
+ case ScopeIdVarDecl:
+ case ScopeIdLoop:
+ case ScopeIdSuspend:
+ case ScopeIdCoroPrelude:
+ case ScopeIdRuntime:
+ scope = scope->parent;
+ continue;
+ case ScopeIdFnDef:
+ case ScopeIdCompTime:
+ case ScopeIdDecls:
+ case ScopeIdCImport:
+ return false;
+ }
+ zig_unreachable();
+ }
+}
+