diff options
[IPL/T] Values now have a return value which can be parsed easily
3 files changed, 8 insertions, 0 deletions
diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp index 6d38aad..954c8da 100644 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.cpp @@ -5,4 +5,10 @@ std::string BuiltInFunction::Visit(LLVMVisitor& visitor) const { return visitor.Visit(*this); } +Value::T_Primitive BuiltInFunction::RetType() const { + if (args.empty()) + return T_void; + return args.front()->RetType(); +} + BuiltInFunction::BuiltInFunction(std::string name, std::deque<Value*> args) : Function(name, args) {} diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h index 26fba3f..c4ea301 100644 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/BuiltInFunction.h @@ -6,6 +6,7 @@ class BuiltInFunction : public Function { public: std::string Visit(LLVMVisitor& visitor) const override; + T_Primitive RetType() const override; BuiltInFunction(std::string name, std::deque<Value*> args); }; diff --git a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h index 549d15e..34e3ea1 100644 --- a/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h +++ b/Year 2/Implementation of Programming Languages/Transpiler/src/Value/Function/Function.h @@ -6,6 +6,7 @@ #include "../Value.h" class Function : public Value { +protected: std::string name; std::deque<Value*> args; |
