Fixes and changes for function declarations, using shared_ptr instead of raw pointers

This commit is contained in:
2019-06-01 13:43:25 +02:00
parent 6936b26cae
commit 1231a77761
8 changed files with 91 additions and 68 deletions

View File

@@ -0,0 +1,43 @@
#ifndef PORYGONLANG_BOUNDFUNCTIONDECLARATIONSTATEMENT_HPP
#define PORYGONLANG_BOUNDFUNCTIONDECLARATIONSTATEMENT_HPP
#include <memory>
#include "BoundStatement.hpp"
class BoundFunctionDeclarationStatement : public BoundStatement{
BoundVariableKey* _key;
std::shared_ptr<BoundBlockStatement> _block;
FunctionScriptType* _type;
public:
BoundFunctionDeclarationStatement(FunctionScriptType* type, BoundVariableKey* key, BoundBlockStatement* block){
_key = key;
_block = shared_ptr<BoundBlockStatement>(block);
_type = type;
}
~BoundFunctionDeclarationStatement() final{
delete _key;
delete _type;
}
BoundStatementKind GetKind() final{
return BoundStatementKind ::FunctionDeclaration;
}
BoundVariableKey* GetKey(){
return _key;
}
std::shared_ptr<BoundBlockStatement> GetBlock(){
return _block;
}
FunctionScriptType* GetType(){
return _type;
}
};
#include "BoundStatement.hpp"
#endif //PORYGONLANG_BOUNDFUNCTIONDECLARATIONSTATEMENT_HPP