From 7dd5753fc1a018a4d4a686cc5a035bec2d89cd4f Mon Sep 17 00:00:00 2001 From: Mikhail Aksenov Date: Wed, 18 Oct 2023 10:24:57 +0000 Subject: [PATCH] Handle global constants in initializers --- include/nil/blueprint/parser.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/nil/blueprint/parser.hpp b/include/nil/blueprint/parser.hpp index 3b3f4e77..7905d008 100644 --- a/include/nil/blueprint/parser.hpp +++ b/include/nil/blueprint/parser.hpp @@ -270,9 +270,15 @@ namespace nil { component_stack.pop(); llvm::Type *type = constant->getType(); if (type->isPointerTy()) { - ASSERT_MSG(constant->isZeroValue(), "Only zero initializers are supported for pointers"); - stack_memory.store(ptr++, zero_var); - continue; + if (constant->isZeroValue()) { + stack_memory.store(ptr++, zero_var); + continue; + } + if (globals.find(constant) != globals.end()) { + stack_memory.store(ptr++, globals[constant]); + continue; + } + UNREACHABLE("Unsupported pointer initialization!"); } if (!type->isAggregateType() && !type->isVectorTy()) { std::vector marshalled_field_val = marshal_field_val(constant);