Each statement class in separate file
This commit is contained in:
49
src/Parser/Statement/StatementFunction.cpp
Normal file
49
src/Parser/Statement/StatementFunction.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "StatementFunction.h"
|
||||
|
||||
#include "Parser/Statement/StatementBlock.h"
|
||||
|
||||
static string valueTypeToString(ValueType valueType) {
|
||||
switch (valueType) {
|
||||
case ValueType::NONE:
|
||||
return "NONE";
|
||||
case ValueType::BOOL:
|
||||
return "BOOL";
|
||||
case ValueType::SINT32:
|
||||
return "SINT32";
|
||||
case ValueType::REAL32:
|
||||
return "REAL32";
|
||||
}
|
||||
}
|
||||
|
||||
StatementFunction::StatementFunction(string name, vector<pair<string, ValueType>> arguments, ValueType returnValueType, shared_ptr<StatementBlock> statementBlock):
|
||||
Statement(StatementKind::FUNCTION_DECLARATION), name(name), arguments(arguments), returnValueType(returnValueType), statementBlock(statementBlock) { }
|
||||
|
||||
string StatementFunction::getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
vector<pair<string, ValueType>> StatementFunction::getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
ValueType StatementFunction::getReturnValueType() {
|
||||
return returnValueType;
|
||||
}
|
||||
|
||||
shared_ptr<StatementBlock> StatementFunction::getStatementBlock() {
|
||||
return statementBlock;
|
||||
}
|
||||
|
||||
string StatementFunction::toString(int indent) {
|
||||
string value = "";
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "FUNCTION(";
|
||||
value += valueTypeToString(returnValueType);
|
||||
value += ", " + name + "):\n";
|
||||
value += statementBlock->toString(indent+1);
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += ";";
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user