summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/astnode.h3
-rw-r--r--src/environment.cpp10
-rw-r--r--src/environment.h28
-rw-r--r--src/situation.cpp10
-rw-r--r--src/situation.h13
-rw-r--r--src/variable.cpp12
-rw-r--r--src/variable.h1
7 files changed, 77 insertions, 0 deletions
diff --git a/src/astnode.h b/src/astnode.h
index a345a56..780e07e 100644
--- a/src/astnode.h
+++ b/src/astnode.h
@@ -12,6 +12,9 @@ public:
12 enum Type 12 enum Type
13 { 13 {
14 tValue = 0x01000000, 14 tValue = 0x01000000,
15 tVarName = 0x01000001,
16 tLiteral = 0x01000002,
17 tFuncName = 0x01000003,
15 tBranch = 0x02000000, 18 tBranch = 0x02000000,
16 tScope = 0x02000001, 19 tScope = 0x02000001,
17 tIf = 0x02000002, 20 tIf = 0x02000002,
diff --git a/src/environment.cpp b/src/environment.cpp
index e69de29..513649f 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -0,0 +1,10 @@
1#include "environment.h"
2
3Environment::Environment()
4{
5}
6
7Environment::~Environment()
8{
9}
10
diff --git a/src/environment.h b/src/environment.h
index e69de29..e728c50 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -0,0 +1,28 @@
1#ifndef ENVIRONMENT_H
2#define ENVIRONMENT_H
3
4#include <bu/string.h>
5#include <bu/hash.h>
6#include "function.h"
7#include "situation.h"
8#include "scope.h"
9
10class Environment
11{
12public:
13 Environment();
14 virtual ~Environment();
15
16private:
17 typedef Bu::Hash<Bu::String, Function *> FunctionHash;
18 typedef Bu::Hash<Bu::String, Situation *> SituationHash;
19 typedef Bu::Hash<Bu::String, Scope *> ScopeHash;
20 FunctionHash hFunction;
21 SituationHash hSituation;
22 ScopeHash hSituationScope;
23 Scope sGlobal;
24 Scope sPlayer;
25 Bu::String sCurSituation;
26};
27
28#endif
diff --git a/src/situation.cpp b/src/situation.cpp
index e69de29..0d24aa4 100644
--- a/src/situation.cpp
+++ b/src/situation.cpp
@@ -0,0 +1,10 @@
1#include "situation.h"
2
3Situation::Situation()
4{
5}
6
7Situation::~Situation()
8{
9}
10
diff --git a/src/situation.h b/src/situation.h
index e69de29..aed6397 100644
--- a/src/situation.h
+++ b/src/situation.h
@@ -0,0 +1,13 @@
1#ifndef SITUATION_H
2#define SITUATION_H
3
4class Situation
5{
6public:
7 Situation();
8 virtual ~Situation();
9
10private:
11};
12
13#endif
diff --git a/src/variable.cpp b/src/variable.cpp
index 6487474..ef6760d 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -186,6 +186,7 @@ Variable &Variable::operator=( const Variable &rhs )
186 break; 186 break;
187 187
188 case tString: 188 case tString:
189 case tSituation:
189 (*sValue) = *rhs.sValue; 190 (*sValue) = *rhs.sValue;
190 break; 191 break;
191 192
@@ -248,6 +249,10 @@ Variable &Variable::operator+=( const Variable &rhs )
248 case tString: 249 case tString:
249 (*sValue).append( *(rhs.to( tString ).sValue) ); 250 (*sValue).append( *(rhs.to( tString ).sValue) );
250 break; 251 break;
252
253 case tSituation:
254 throw VariableException("You cannot add situations.");
255 break;
251 } 256 }
252 257
253 return *this; 258 return *this;
@@ -294,6 +299,9 @@ Variable Variable::operator+( const Variable &rhs ) const
294 case tDictionary: 299 case tDictionary:
295 throw VariableException("You cannot add dictionaries."); 300 throw VariableException("You cannot add dictionaries.");
296 break; 301 break;
302
303 case tSituation:
304 throw VariableException("You cannot add situations.");
297 } 305 }
298 } 306 }
299} 307}
@@ -324,6 +332,7 @@ bool Variable::operator==( const Variable &rhs ) const
324 return fValue == rhs.fValue; 332 return fValue == rhs.fValue;
325 333
326 case tString: 334 case tString:
335 case tSituation:
327 return (*sValue) == (*rhs.sValue); 336 return (*sValue) == (*rhs.sValue);
328 337
329 case tList: 338 case tList:
@@ -351,6 +360,7 @@ void Variable::initType()
351 switch( eType ) 360 switch( eType )
352 { 361 {
353 case tString: 362 case tString:
363 case tSituation:
354 sValue = new Bu::String(); 364 sValue = new Bu::String();
355 break; 365 break;
356 366
@@ -369,6 +379,7 @@ void Variable::deinitType()
369 switch( eType ) 379 switch( eType )
370 { 380 {
371 case tString: 381 case tString:
382 case tSituation:
372 delete sValue; 383 delete sValue;
373 break; 384 break;
374 385
@@ -398,6 +409,7 @@ template<> uint32_t Bu::__calcHashCode<Variable>( const Variable &k )
398 return k.fValue; 409 return k.fValue;
399 410
400 case Variable::tString: 411 case Variable::tString:
412 case Variable::tSituation:
401 return Bu::__calcHashCode( *k.sValue ); 413 return Bu::__calcHashCode( *k.sValue );
402 414
403 case Variable::tList: 415 case Variable::tList:
diff --git a/src/variable.h b/src/variable.h
index c728718..8bc12a6 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -17,6 +17,7 @@ public:
17 tInt, 17 tInt,
18 tFloat, 18 tFloat,
19 tString, 19 tString,
20 tSituation,
20 tList, 21 tList,
21 tDictionary 22 tDictionary
22 }; 23 };