From 58a71e57e3824a3a0c5385af91421674395990dc Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 22 Dec 2011 19:53:52 -0700 Subject: The basic structure of the game is coming together. That is the data structures for storing the game objects are coming together. --- src/astnode.h | 3 +++ src/environment.cpp | 10 ++++++++++ src/environment.h | 28 ++++++++++++++++++++++++++++ src/situation.cpp | 10 ++++++++++ src/situation.h | 13 +++++++++++++ src/variable.cpp | 12 ++++++++++++ src/variable.h | 1 + 7 files changed, 77 insertions(+) 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: enum Type { tValue = 0x01000000, + tVarName = 0x01000001, + tLiteral = 0x01000002, + tFuncName = 0x01000003, tBranch = 0x02000000, tScope = 0x02000001, 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 @@ +#include "environment.h" + +Environment::Environment() +{ +} + +Environment::~Environment() +{ +} + 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 @@ +#ifndef ENVIRONMENT_H +#define ENVIRONMENT_H + +#include +#include +#include "function.h" +#include "situation.h" +#include "scope.h" + +class Environment +{ +public: + Environment(); + virtual ~Environment(); + +private: + typedef Bu::Hash FunctionHash; + typedef Bu::Hash SituationHash; + typedef Bu::Hash ScopeHash; + FunctionHash hFunction; + SituationHash hSituation; + ScopeHash hSituationScope; + Scope sGlobal; + Scope sPlayer; + Bu::String sCurSituation; +}; + +#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 @@ +#include "situation.h" + +Situation::Situation() +{ +} + +Situation::~Situation() +{ +} + 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 @@ +#ifndef SITUATION_H +#define SITUATION_H + +class Situation +{ +public: + Situation(); + virtual ~Situation(); + +private: +}; + +#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 ) break; case tString: + case tSituation: (*sValue) = *rhs.sValue; break; @@ -248,6 +249,10 @@ Variable &Variable::operator+=( const Variable &rhs ) case tString: (*sValue).append( *(rhs.to( tString ).sValue) ); break; + + case tSituation: + throw VariableException("You cannot add situations."); + break; } return *this; @@ -294,6 +299,9 @@ Variable Variable::operator+( const Variable &rhs ) const case tDictionary: throw VariableException("You cannot add dictionaries."); break; + + case tSituation: + throw VariableException("You cannot add situations."); } } } @@ -324,6 +332,7 @@ bool Variable::operator==( const Variable &rhs ) const return fValue == rhs.fValue; case tString: + case tSituation: return (*sValue) == (*rhs.sValue); case tList: @@ -351,6 +360,7 @@ void Variable::initType() switch( eType ) { case tString: + case tSituation: sValue = new Bu::String(); break; @@ -369,6 +379,7 @@ void Variable::deinitType() switch( eType ) { case tString: + case tSituation: delete sValue; break; @@ -398,6 +409,7 @@ template<> uint32_t Bu::__calcHashCode( const Variable &k ) return k.fValue; case Variable::tString: + case Variable::tSituation: return Bu::__calcHashCode( *k.sValue ); 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: tInt, tFloat, tString, + tSituation, tList, tDictionary }; -- cgit v1.2.3