Modify VarDef

main
Odeinjul 12 months ago
parent 7653fecd16
commit 0e256196e6
No known key found for this signature in database
GPG Key ID: E384228B2B38FFBB

@ -1,3 +1,4 @@
#include <cassert>
#include "IRBuilder.h"
namespace SysYF
@ -81,17 +82,17 @@ void IRBuilder::visit(SyntaxTree::FuncParam &node) {
if (!node.array_index.empty()) {
// TODO high dim array
funcFParam.push_back(INT32PTR_T);
}
else
} else {
funcFParam.push_back(INT32_T);
}
break;
case SyntaxTree::Type::FLOAT:
if (!node.array_index.empty()) {
// TODO high dim array (not now)
funcFParam.push_back(FLOATPTR_T);
}
else
} else {
funcFParam.push_back(FLOAT_T);
}
break;
default:
funcFParam.push_back(INT32_T);
@ -100,7 +101,66 @@ void IRBuilder::visit(SyntaxTree::FuncParam &node) {
}
void IRBuilder::visit(SyntaxTree::VarDef &node) {
;
// TODO high dim array (not now)
Ptr<Value> arrayLength;
Ptr<Value> initVal;
if (node.is_constant) {
assert(node.is_inited);
switch (node.btype) {
case (SyntaxTree::Type::INT):
if (!node.array_length.empty()) {
} else {
}
break;
case (SyntaxTree::Type::FLOAT):
if (!node.array_length.empty()) {
} else {
}
break;
default:
break;
}
} else {
switch (node.btype) {
case (SyntaxTree::Type::INT):
if (!node.array_length.empty()) {
} else {
auto alloca = builder->create_alloca(INT32_T);
if (node.is_inited) {
builder->create_store(initVal, alloca);
} else {
builder->create_store(CONST_INT(0), alloca);
scope.push(node.name, alloca);
}
}
break;
case (SyntaxTree::Type::FLOAT):
if (!node.array_length.empty()) {
} else {
auto alloca = builder->create_alloca(FLOAT_T);
if (node.is_inited) {
builder->create_store(initVal, alloca);
} else {
builder->create_store(CONST_FLOAT(0), alloca);
scope.push(node.name, alloca);
}
}
break;
default:
break;
}
}
}
void IRBuilder::visit(SyntaxTree::LVal &node) {

Loading…
Cancel
Save