blob: d4ec61f028de99d293c56568c1d35150070d3f2a (
plain)
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
|
#include "functionast.h"
#include "astbranch.h"
#include "astleaf.h"
#include "runner.h"
#include "context.h"
#include <bu/sio.h>
using namespace Bu;
FunctionAst::FunctionAst( const AstBranch *pRoot, class Runner *pRunner ) :
pRoot( pRoot ),
pRunner( pRunner )
{
sName = dynamic_cast<AstLeaf *>(
*(*pRoot->getBranchBegin()).begin()
)->getStrValue();
}
FunctionAst::~FunctionAst()
{
}
Bu::String FunctionAst::getName() const
{
return sName;
}
Variable FunctionAst::call( Variable &input, VarList lParams )
{
pContext->pushScope();
AstBranch::NodeList::const_iterator vName =
(*(pRoot->getBranchBegin()+1)).begin();
VarList::iterator vValue = lParams.begin();
for( ; vName && vValue; vName++, vValue++ )
{
pContext->addVariable(
dynamic_cast<const AstLeaf *>(*vName)->getStrValue(),
*vValue
);
}
pContext->addVariable("INPUT", input );
Variable vRet = pRunner->run( (*(pRoot->getBranchBegin()+2)).begin() );
pContext->popScope();
return vRet;
}
|