summaryrefslogtreecommitdiff
path: root/node/StatementNode.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-30 15:52:36 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-30 15:52:36 +0800
commit30726a1872c92d40424d496fc52043ca452d935f (patch)
tree86ce09251183ee544033ba8bfa9f51199aa58628 /node/StatementNode.cc
parent4c9d2d541c90968db2065260dc94c3be9e8adef9 (diff)
support for array access (partial)
Diffstat (limited to 'node/StatementNode.cc')
-rw-r--r--node/StatementNode.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/node/StatementNode.cc b/node/StatementNode.cc
index 7256ffd..b6e1189 100644
--- a/node/StatementNode.cc
+++ b/node/StatementNode.cc
@@ -32,8 +32,16 @@ AssignStatementNode::AssignStatementNode(Context* context,
Value AssignStatementNode::CodeGen() {
Value LeftValue = lhs_->CodeGen();
Value RightValue = rhs_->CodeGen();
+ std::shared_ptr<PointerType> LeftType =
+ std::dynamic_pointer_cast<PointerType>(lhs_->GetType());
+ if (LeftType == nullptr) {
+ Log(LogLevel::PCC_ERROR,
+ "type %s is not a valid pointer type, can't store anything into "
+ "this lvalue",
+ lhs_->GetType()->GetCommonName());
+ }
RightValue = context_->GetTypeManager()->CreateCast(
- lhs_->GetType(), rhs_->GetType(), RightValue, context_);
+ LeftType->GetElementType(), rhs_->GetType(), RightValue, context_);
context_->GetBuilder()->CreateStore(RightValue, LeftValue);
return nullptr;
}