Fixed logger and module builder

This commit is contained in:
Rafał Grodziński
2025-08-07 21:34:14 +09:00
parent 8dcdcc7061
commit 39be17e6a1
4 changed files with 15 additions and 17 deletions

View File

@@ -70,7 +70,7 @@ void ModuleBuilder::buildStatement(shared_ptr<Statement> statement) {
buildRawFunction(dynamic_pointer_cast<StatementRawFunction>(statement));
break;
case StatementKind::BLOB:
buildType(dynamic_pointer_cast<StatementBlob>(statement));
buildBlob(dynamic_pointer_cast<StatementBlob>(statement));
break;
case StatementKind::VARIABLE:
buildVarDeclaration(dynamic_pointer_cast<StatementVariable>(statement));
@@ -164,10 +164,18 @@ void ModuleBuilder::buildRawFunction(shared_ptr<StatementRawFunction> statement)
return;
}
void ModuleBuilder::buildType(shared_ptr<StatementBlob> statement) {
void ModuleBuilder::buildBlob(shared_ptr<StatementBlob> statement) {
llvm::StructType *structType = llvm::StructType::create(*context, statement->getIdentifier());
vector<llvm::Type *> elements;
structType->setBody(elements, false);
// Generate types for body
vector<llvm::Type *> types;
for (pair<string, shared_ptr<ValueType>> &variable: statement->getVariables()) {
llvm::Type *type = typeForValueType(variable.second);
if (type == nullptr)
return;
types.push_back(type);
}
structType->setBody(types, false);
if (!setStruct(statement->getIdentifier(), structType))
return;
}