-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionCall.cpp
48 lines (38 loc) · 1.01 KB
/
FunctionCall.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "FunctionCall.h"
// Local includes
#include "Expression.h"
#include "PainterContext.h"
#include "NameMangling.h"
FunctionCall::FunctionCall(const QString &functionName, Scope* context)
: Expression(context), m_functionName(functionName)
{
}
FunctionCall::~FunctionCall()
{
qDeleteAll(m_parameters);
}
QVariant::Type FunctionCall::type() const
{
Scope* scopeToUse;
QString functionName = context()->findIdentifierAndScope(m_functionName, scopeToUse);
return (QVariant::Type)scopeToUse->functionReturnType(functionName);
}
void FunctionCall::addParameter(Expression* expression)
{
m_parameters.append(expression);
}
QVariant FunctionCall::evaluate()
{
Scope* scopeToUse;
QString functionName = context()->findIdentifierAndScope(m_functionName, scopeToUse);
QVariant returnValue;
if(scopeToUse->isValidFunction(functionName))
{
returnValue = scopeToUse->execute(functionName, m_parameters);
}
else
{
showErrorMessage(QString("%1 is not a valid function name").arg(functionName));
}
return returnValue;
}