Fixed logger and module builder
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
void buildStatement(shared_ptr<Statement> statement);
|
||||
void buildFunction(shared_ptr<StatementFunction> statement);
|
||||
void buildRawFunction(shared_ptr<StatementRawFunction> statement);
|
||||
void buildType(shared_ptr<StatementBlob> statement);
|
||||
void buildBlob(shared_ptr<StatementBlob> statement);
|
||||
void buildVarDeclaration(shared_ptr<StatementVariable> statement);
|
||||
void buildAssignment(shared_ptr<StatementAssignment> statement);
|
||||
void buildBlock(shared_ptr<StatementBlock> statement);
|
||||
|
||||
@@ -307,6 +307,8 @@ string Logger::toString(shared_ptr<StatementBlob> statement) {
|
||||
string text;
|
||||
|
||||
text += format("BLOB(\"{}\"):\n", statement->getIdentifier());
|
||||
for (pair<string, shared_ptr<ValueType>> &variable : statement->getVariables())
|
||||
text += format("{}: {}\n", variable.first, toString(variable.second));
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -537,18 +537,6 @@ shared_ptr<Statement> Parser::matchStatementBlob() {
|
||||
break;
|
||||
}
|
||||
|
||||
// consume new line
|
||||
/*if (!tryMatchingTokenKinds({TokenKind::NEW_LINE}, true, true)) {
|
||||
markError(TokenKind::NEW_LINE, {});
|
||||
return nullptr;
|
||||
}*/
|
||||
|
||||
// closing semicolon
|
||||
/*if(!tryMatchingTokenKinds({TokenKind::SEMICOLON}, false, true)) {
|
||||
markError(TokenKind::SEMICOLON, {});
|
||||
return nullptr;
|
||||
}*/
|
||||
|
||||
return make_shared<StatementBlob>(identifier, variables);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user