-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionVar.cpp
More file actions
48 lines (43 loc) · 810 Bytes
/
FunctionVar.cpp
File metadata and controls
48 lines (43 loc) · 810 Bytes
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 "FunctionVar.h"
FunctionVar::FunctionVar(void)
{
}
FunctionVar::~FunctionVar(void)
{
}
Variable * FunctionVar::clone(void) const
{
return new FunctionVar(*this);
}
#include "VectorVar.h"
std::shared_ptr<Variable> FunctionVar::operate(const std::string& op, std::shared_ptr<Variable> rhs, bool allocate)
{
if (op.compare("()")==0)
{
std::vector<std::shared_ptr<Variable>> vec;
if (rhs!=0)
{
std::shared_ptr<VectorVar> vv = std::dynamic_pointer_cast<VectorVar>(rhs);
if (vv!=0)
{
vec.insert(vec.end(), vv->v.begin(), vv->v.end());
}
else
{
vec.insert(vec.end(), rhs);
}
}
if (script_func!=0)
{
return script_func->run(vec);
}
if (func_ptr)
{
return func_ptr(vec);
}
}
if (allocate)
return Variable::operate(op, rhs);
else
return 0;
}