Bla
This commit is contained in:
@@ -3,14 +3,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Type {
|
enum class Type { BOOL, INT, STRING, VOID };
|
||||||
public:
|
|
||||||
Type(std::string name);
|
|
||||||
~Type();
|
|
||||||
|
|
||||||
std::string getName();
|
|
||||||
private:
|
|
||||||
std::string name_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TYPE_H
|
#endif // TYPE_H
|
||||||
|
|||||||
@@ -59,6 +59,32 @@ void CodeGenVisitor::visit(ForStatement* e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenVisitor::visit(FunctionCallExpression* e) {
|
void CodeGenVisitor::visit(FunctionCallExpression* e) {
|
||||||
|
llvm::Function* cf = module_->getFunction(e->getId());
|
||||||
|
if (!cf) {
|
||||||
|
// TODO error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto values = e->getValues()->getValues();
|
||||||
|
if (cf->arg_size() != values.size()) {
|
||||||
|
// TODO error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<llvm::Value*> args;
|
||||||
|
auto iter = values.begin();
|
||||||
|
auto end = values.end();
|
||||||
|
for (; iter != end; ++iter) {
|
||||||
|
Expression *expr = (*iter);
|
||||||
|
expr->accept(this);
|
||||||
|
if (!value_) {
|
||||||
|
// TODO error
|
||||||
|
}
|
||||||
|
args.push_back(value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
value_ = builder_->CreateCall(cf, args, "calltmp");
|
||||||
|
value_->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenVisitor::visit(FunctionDefinition* e) {
|
void CodeGenVisitor::visit(FunctionDefinition* e) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void PrintVisitor::visit(FunctionDefinition* e) {
|
|||||||
println(ss.str());
|
println(ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss.clear();
|
ss.clear();
|
||||||
ss << "Type: " << e->getType()->getName();
|
ss << "Type: " << e->getType();
|
||||||
println(ss.str());
|
println(ss.str());
|
||||||
ParameterList* params = e->getParams();
|
ParameterList* params = e->getParams();
|
||||||
if (params) {
|
if (params) {
|
||||||
|
|||||||
@@ -1,9 +1 @@
|
|||||||
#include "AST/Type.h"
|
#include "AST/Type.h"
|
||||||
|
|
||||||
Type::Type(std::string name) : name_(name) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Type::getName() {
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user