Finish high dim array

main
Odeinjul 12 months ago
parent a29f560cc6
commit dab3153471
No known key found for this signature in database
GPG Key ID: E384228B2B38FFBB

@ -595,14 +595,25 @@ void IRBuilder::visit(SyntaxTree::VarDef &node) {
identAlloca = dynamic_pointer_cast<Value>(tmpIdent); identAlloca = dynamic_pointer_cast<Value>(tmpIdent);
scope.push(node.name, identAlloca); scope.push(node.name, identAlloca);
auto varInit = constArrayInit.get(); 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++) { for (int i = 0u; i < arraySize; i++) {
auto index = CONST_INT(i); auto index = CONST_INT(i);
auto ptr = builder->create_gep(identAlloca, {CONST_INT(0), index}); 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); builder->create_store((*varInit)[i], ptr);
} }
} }
} }
} }
}
} }
// FINISH // FINISH

Loading…
Cancel
Save