aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-09 22:23:38 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-09 22:23:38 -0400
commit01f066de379caf545ec65c572f75cc1ed1312799 (patch)
tree0e96968a4ce4acf3eaa25a8edf43218ed25dd637 /src/analyze.cpp
parent99f077baf96c0f19026ea3d7f9475aa41b720cb9 (diff)
downloadzig-01f066de379caf545ec65c572f75cc1ed1312799.tar.gz
zig-01f066de379caf545ec65c572f75cc1ed1312799.zip
ability to slice ptr to hard coded integer at comptime
closes #369
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index f397f441c8..8642389a23 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3638,6 +3638,23 @@ ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bo
return const_val;
}
+void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *pointee_type,
+ size_t addr, bool is_const)
+{
+ const_val->special = ConstValSpecialStatic;
+ const_val->type = get_pointer_to_type(g, pointee_type, is_const);
+ const_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
+ const_val->data.x_ptr.data.hard_coded_addr.addr = addr;
+}
+
+ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, TypeTableEntry *pointee_type,
+ size_t addr, bool is_const)
+{
+ ConstExprValue *const_val = allocate<ConstExprValue>(1);
+ init_const_ptr_hard_coded_addr(g, const_val, pointee_type, addr, is_const);
+ return const_val;
+}
+
void init_const_arg_tuple(CodeGen *g, ConstExprValue *const_val, size_t arg_index_start, size_t arg_index_end) {
const_val->special = ConstValSpecialStatic;
const_val->type = g->builtin_types.entry_arg_tuple;