summaryrefslogtreecommitdiff
path: root/src/functioncount.cpp
blob: f8792387f953e478ec570013b3a50bfbc85087d8 (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
#include "functioncount.h"

#include "gamestate.h"

FunctionCount::FunctionCount()
{
}

FunctionCount::~FunctionCount()
{
}

void FunctionCount::call( class GameState &gState )
{
	Variable v = gState.popDeref();
	switch( v.getType() )
	{
		case Variable::tList:
			gState.push( (int64_t)v.getList().getSize() );
			break;

		case Variable::tDictionary:
			gState.push( (int64_t)v.getHash().getSize() );
			break;

		case Variable::tString:
			gState.push( (int64_t)v.getString().getSize() );
			break;

		default:
			gState.push( Variable( Variable::tNull ) );
			break;
	}
}