diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-10-04 14:32:55 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-10-04 14:33:52 -0400 |
| commit | 23b07ad8d25809baa3169f64d9c7be980501352d (patch) | |
| tree | c2ccfa4832e4c2ac5517b937487fb378a3265ace /src/analyze.cpp | |
| parent | 31469daca397b7cdb8c348932a7a3c9e27354fa5 (diff) | |
| download | zig-23b07ad8d25809baa3169f64d9c7be980501352d.tar.gz zig-23b07ad8d25809baa3169f64d9c7be980501352d.zip | |
refactor ir.cpp
Analysis functions no longer return `ZigType *`. Instead they
return `IrInstruction *`.
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 4f8b2f8880..42737a22e5 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -5512,10 +5512,19 @@ Error type_resolve(CodeGen *g, ZigType *ty, ResolveStatus status) { } bool ir_get_var_is_comptime(ZigVar *var) { - if (!var->is_comptime) + // The is_comptime field can be left null, which means not comptime. + if (var->is_comptime == nullptr) return false; - if (var->is_comptime->other) - return var->is_comptime->other->value.data.x_bool; + // When the is_comptime field references an instruction that has to get analyzed, this + // is the value. + if (var->is_comptime->child != nullptr) { + assert(var->is_comptime->child->value.type->id == ZigTypeIdBool); + return var->is_comptime->child->value.data.x_bool; + } + // As an optimization, is_comptime values which are constant are allowed + // to be omitted from analysis. In this case, there is no child instruction + // and we simply look at the unanalyzed const parent instruction. + assert(var->is_comptime->value.type->id == ZigTypeIdBool); return var->is_comptime->value.data.x_bool; } |
