src/Expression.cc

changeset 105
6dbac3305614
parent 103
48472c0678cc
child 106
9174be9ac686
equal deleted inserted replaced
104:62da929f7814 105:6dbac3305614
1 #include "Expression.h" 1 #include "Expression.h"
2 #include "DataBuffer.h" 2 #include "DataBuffer.h"
3 #include "Lexer.h" 3 #include "Lexer.h"
4 #include "Variables.h"
5 4
6 struct OperatorInfo 5 struct OperatorInfo
7 { 6 {
8 EToken token; 7 EToken token;
9 int priority; 8 int priority;
105 104
106 op->SetBuffer (mParser->ParseCommand (comm)); 105 op->SetBuffer (mParser->ParseCommand (comm));
107 return op; 106 return op;
108 } 107 }
109 108
110 // Check global variable 109 // Check for variables
111 // TODO: handle locals too when they're implemented
112 if (mLexer->GetTokenType() == tkDollarSign) 110 if (mLexer->GetTokenType() == tkDollarSign)
113 { 111 {
114 mLexer->MustGetNext (tkSymbol); 112 mLexer->MustGetNext (tkSymbol);
115 ScriptVariable* globalvar = FindGlobalVariable (GetTokenString()); 113 Variable* globalvar = mParser->FindVariable (GetTokenString());
116 114
117 if (globalvar == null) 115 if (globalvar == null)
118 Error ("unknown variable %1", GetTokenString()); 116 Error ("unknown variable %1", GetTokenString());
119 117
120 if (globalvar->writelevel == ScriptVariable::WRITE_Constexpr) 118 if (globalvar->writelevel == Variable::WRITE_Constexpr)
121 op->SetValue (globalvar->value); 119 op->SetValue (globalvar->value);
122 else 120 else
123 { 121 {
124 DataBuffer* buf = new DataBuffer (8); 122 DataBuffer* buf = new DataBuffer (8);
125 buf->WriteDWord (dhPushGlobalVar); 123 buf->WriteDWord (dhPushGlobalVar);

mercurial