Codegen initial alloca and store
This commit is contained in:
parent
db60335507
commit
cf94296877
@ -23,7 +23,18 @@ namespace AST {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitializationStatement::codegen(codegen::Builder& builder) {
|
void InitializationStatement::codegen(codegen::Builder& builder) {
|
||||||
return;
|
if (!builder.block)
|
||||||
|
return;
|
||||||
|
|
||||||
|
builder.builder->SetInsertPoint(builder.block.get());
|
||||||
|
|
||||||
|
auto ty = this->m_type->codegen(builder);
|
||||||
|
auto ptr = builder.builder->CreateAlloca(ty);
|
||||||
|
if (this->m_expr.has_value()) {
|
||||||
|
auto value = this->m_expr->get()->codegen(builder);
|
||||||
|
builder.builder->CreateStore(value, ptr, false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Function::codegen(codegen::Builder& builder) {
|
void Function::codegen(codegen::Builder& builder) {
|
||||||
|
|||||||
@ -56,7 +56,6 @@ namespace parsing {
|
|||||||
|
|
||||||
std::optional<std::unique_ptr<AST::Expression>> expr = {};
|
std::optional<std::unique_ptr<AST::Expression>> expr = {};
|
||||||
if (inner.peek().type == token::Type::Symbol && inner.peek().content == "=") {
|
if (inner.peek().type == token::Type::Symbol && inner.peek().content == "=") {
|
||||||
std::cout << "hello" << std::endl;
|
|
||||||
inner.expect(token::Type::Symbol, "=");
|
inner.expect(token::Type::Symbol, "=");
|
||||||
expr = parse_expression(inner).unwrap();
|
expr = parse_expression(inner).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user