summaryrefslogtreecommitdiff
path: root/src/functionjoin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/functionjoin.cpp')
-rw-r--r--src/functionjoin.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/functionjoin.cpp b/src/functionjoin.cpp
new file mode 100644
index 0000000..71ee879
--- /dev/null
+++ b/src/functionjoin.cpp
@@ -0,0 +1,36 @@
1#include "functionjoin.h"
2
3#include "gamestate.h"
4
5#include <bu/sio.h>
6using namespace Bu;
7
8FunctionJoin::FunctionJoin()
9{
10}
11
12FunctionJoin::~FunctionJoin()
13{
14}
15
16void FunctionJoin::call( class GameState &gState )
17{
18 Variable vSep = gState.popDeref().to( Variable::tString );
19 Variable vLst = gState.popDeref();
20
21 if( vLst.getType() != Variable::tList )
22 throw Bu::ExceptionBase("First parameter of join must be a list.");
23
24 Bu::String sOut;
25 for( Variable::VariableArray::const_iterator i = vLst.getList().begin();
26 i; i++ )
27 {
28 if( i != vLst.getList().begin() )
29 sOut += vSep.getString();
30 sOut += (*i).to( Variable::tString ).getString();
31 }
32
33
34 gState.push( sOut );
35}
36