Skip to content

Commit

Permalink
Handle global constants in initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
makxenov authored and nkaskov committed Nov 3, 2023
1 parent c4b43a3 commit 7dd5753
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions include/nil/blueprint/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename BlueprintFieldType::value_type> marshalled_field_val = marshal_field_val<BlueprintFieldType>(constant);
Expand Down

0 comments on commit 7dd5753

Please sign in to comment.