|
|
|
@ -595,14 +595,25 @@ void IRBuilder::visit(SyntaxTree::VarDef &node) {
|
|
|
|
|
identAlloca = dynamic_pointer_cast<Value>(tmpIdent);
|
|
|
|
|
scope.push(node.name, identAlloca);
|
|
|
|
|
auto varInit = constArrayInit.get();
|
|
|
|
|
std::cout << arraySize << std::endl;
|
|
|
|
|
Ptr<Constant> tmpZero;
|
|
|
|
|
if (varType->is_integer_type()) {
|
|
|
|
|
tmpZero = CONST_INT(0);
|
|
|
|
|
} else {
|
|
|
|
|
tmpZero = CONST_FLOAT(0.0);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0u; i < arraySize; i++) {
|
|
|
|
|
auto index = CONST_INT(i);
|
|
|
|
|
auto ptr = builder->create_gep(identAlloca, {CONST_INT(0), index});
|
|
|
|
|
if ((*varInit)[i] == nullptr) {
|
|
|
|
|
builder->create_store(tmpZero, ptr);
|
|
|
|
|
} else {
|
|
|
|
|
builder->create_store((*varInit)[i], ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FINISH
|
|
|
|
|