Fixes and changes for function declarations, using shared_ptr instead of raw pointers
This commit is contained in:
@@ -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
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../BoundExpressions/BoundExpression.hpp"
|
||||
#include "../BoundVariables/BoundVariableKey.hpp"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum class BoundStatementKind{
|
||||
@@ -115,32 +116,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class BoundFunctionDeclarationStatement : public BoundStatement{
|
||||
BoundVariableKey* _key;
|
||||
BoundBlockStatement* _block;
|
||||
FunctionScriptType* _type;
|
||||
public:
|
||||
BoundFunctionDeclarationStatement(FunctionScriptType* type, BoundVariableKey* key, BoundBlockStatement* block){
|
||||
_key = key;
|
||||
_block = block;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
BoundStatementKind GetKind() final{
|
||||
return BoundStatementKind ::FunctionDeclaration;
|
||||
}
|
||||
|
||||
BoundVariableKey* GetKey(){
|
||||
return _key;
|
||||
}
|
||||
|
||||
BoundBlockStatement* GetBlock(){
|
||||
return _block;
|
||||
}
|
||||
|
||||
FunctionScriptType* GetType(){
|
||||
return _type;
|
||||
}
|
||||
};
|
||||
#include "BoundFunctionDeclarationStatement.hpp"
|
||||
|
||||
#endif //PORYGONLANG_BOUNDSTATEMENT_HPP
|
||||
|
||||
Reference in New Issue
Block a user