Make Type an enum class (C++11 ftw)
This commit is contained in:
@@ -9,17 +9,17 @@
|
||||
|
||||
class FunctionDefinition : public ASTElement {
|
||||
public:
|
||||
FunctionDefinition(Type *type, std::string name, ParameterList* params, StatementList* sl);
|
||||
FunctionDefinition(Type type, std::string name, ParameterList* params, StatementList* sl);
|
||||
virtual ~FunctionDefinition();
|
||||
|
||||
virtual void accept(ASTVisitor* visitor);
|
||||
|
||||
Type* getType();
|
||||
Type getType();
|
||||
std::string getName();
|
||||
ParameterList* getParams();
|
||||
StatementList* getSl();
|
||||
private:
|
||||
Type* type_;
|
||||
Type type_;
|
||||
std::string name_;
|
||||
ParameterList* params_;
|
||||
StatementList* sl_;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "AST/Type.h"
|
||||
#include <vector>
|
||||
|
||||
typedef std::pair<Type*, std::string> Parameter;
|
||||
typedef std::pair<Type, std::string> Parameter;
|
||||
|
||||
class ParameterList : public ASTElement {
|
||||
public:
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
|
||||
virtual void accept(ASTVisitor* visitor);
|
||||
|
||||
void addParameter(Type* type, std::string name);
|
||||
void addParameter(Type type, std::string name);
|
||||
std::vector<Parameter> getParameters();
|
||||
private:
|
||||
std::vector<Parameter> params_;
|
||||
|
||||
@@ -5,4 +5,6 @@
|
||||
|
||||
enum class Type { BOOL, INT, STRING, VOID };
|
||||
|
||||
std::string typeToString(Type type);
|
||||
|
||||
#endif // TYPE_H
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
class VariableDefinition : public Statement
|
||||
{
|
||||
public:
|
||||
VariableDefinition(Type *type, std::string name);
|
||||
VariableDefinition(Type type, std::string name);
|
||||
virtual ~VariableDefinition();
|
||||
|
||||
virtual void accept(ASTVisitor* visitor);
|
||||
|
||||
Type* getType();
|
||||
Type getType();
|
||||
std::string getName();
|
||||
private:
|
||||
Type* type_;
|
||||
Type type_;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user