From da250b9833e9561a996d11058130e8b7eca2369e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 21 Dec 2011 02:27:51 -0700 Subject: Game environment is coming together. --- src/astnode.h | 18 ++++++++++++++++++ src/environment.cpp | 0 src/environment.h | 0 src/function.cpp | 10 ++++++++++ src/function.h | 17 +++++++++++++++++ src/scope.cpp | 10 ++++++++++ src/scope.h | 16 ++++++++++++++++ src/situation.cpp | 0 src/situation.h | 0 src/userfunction.cpp | 21 +++++++++++++++++++++ src/userfunction.h | 21 +++++++++++++++++++++ src/variable.h | 4 +++- 12 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/environment.cpp create mode 100644 src/environment.h create mode 100644 src/function.cpp create mode 100644 src/function.h create mode 100644 src/scope.cpp create mode 100644 src/scope.h create mode 100644 src/situation.cpp create mode 100644 src/situation.h create mode 100644 src/userfunction.cpp create mode 100644 src/userfunction.h (limited to 'src') diff --git a/src/astnode.h b/src/astnode.h index 3344ca2..a345a56 100644 --- a/src/astnode.h +++ b/src/astnode.h @@ -9,6 +9,24 @@ public: AstNode(); virtual ~AstNode(); + enum Type + { + tValue = 0x01000000, + tBranch = 0x02000000, + tScope = 0x02000001, + tIf = 0x02000002, + tElse = 0x02000003, + tNot = 0x00000004, + tComp = 0x02000005, + tCompGt = 0x02000006, + tCompLt = 0x02000007, + tCompGtEq = 0x02000008, + tCompLtEq = 0x02000009, + tStore = 0x0200000A, + tAnd = 0x0200000B, + tOr = 0x0200000C, + }; + private: }; diff --git a/src/environment.cpp b/src/environment.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/environment.h b/src/environment.h new file mode 100644 index 0000000..e69de29 diff --git a/src/function.cpp b/src/function.cpp new file mode 100644 index 0000000..e89a06f --- /dev/null +++ b/src/function.cpp @@ -0,0 +1,10 @@ +#include "function.h" + +Function::Function() +{ +} + +Function::~Function() +{ +} + diff --git a/src/function.h b/src/function.h new file mode 100644 index 0000000..1191129 --- /dev/null +++ b/src/function.h @@ -0,0 +1,17 @@ +#ifndef FUNCTION_H +#define FUNCTION_H + +#include +#include "variable.h" + +class Function +{ +public: + Function(); + virtual ~Function(); + + virtual Bu::String getName() const=0; + virtual Variable call( const VariableList &lParams )=0; +}; + +#endif diff --git a/src/scope.cpp b/src/scope.cpp new file mode 100644 index 0000000..45d4484 --- /dev/null +++ b/src/scope.cpp @@ -0,0 +1,10 @@ +#include "scope.h" + +Scope::Scope() +{ +} + +Scope::~Scope() +{ +} + diff --git a/src/scope.h b/src/scope.h new file mode 100644 index 0000000..84797f0 --- /dev/null +++ b/src/scope.h @@ -0,0 +1,16 @@ +#ifndef SCOPE_H +#define SCOPE_H + +#include "variable.h" + +class Scope +{ +public: + Scope(); + virtual ~Scope(); + +private: + VariableHash hVars; +}; + +#endif diff --git a/src/situation.cpp b/src/situation.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/situation.h b/src/situation.h new file mode 100644 index 0000000..e69de29 diff --git a/src/userfunction.cpp b/src/userfunction.cpp new file mode 100644 index 0000000..3bdd973 --- /dev/null +++ b/src/userfunction.cpp @@ -0,0 +1,21 @@ +#include "userfunction.h" + +UserFunction::UserFunction( const Bu::String &sName, const AstNode &anRoot ) : + sName( sName ) +{ +} + +UserFunction::~UserFunction() +{ +} + +Bu::String UserFunction::getName() const +{ + return sName; +} + +Variable UserFunction::call( const VariableList &lParams ) +{ + return Variable( Variable::tNull ); +} + diff --git a/src/userfunction.h b/src/userfunction.h new file mode 100644 index 0000000..67b96cc --- /dev/null +++ b/src/userfunction.h @@ -0,0 +1,21 @@ +#ifndef USER_FUNCTION_H +#define USER_FUNCTION_H + +#include "function.h" + +class AstNode; + +class UserFunction : public Function +{ +public: + UserFunction( const Bu::String &sName, const AstNode &anRoot ); + virtual ~UserFunction(); + + virtual Bu::String getName() const; + virtual Variable call( const VariableList &lParams ); + +private: + Bu::String sName; +}; + +#endif diff --git a/src/variable.h b/src/variable.h index 67f35c8..c728718 100644 --- a/src/variable.h +++ b/src/variable.h @@ -76,7 +76,9 @@ namespace Bu { template<> uint32_t __calcHashCode( const Variable &k ); template<> bool __cmpHashKeys( const Variable &a, const Variable &b ); -} +}; +typedef Bu::List VariableList; +typedef Bu::Hash VariableHash; #endif -- cgit v1.2.3