| 233 // |
233 // |
| 234 // Verifies a single value. Helper function for Expression::Verify. |
234 // Verifies a single value. Helper function for Expression::Verify. |
| 235 // |
235 // |
| 236 void Expression::TryVerifyValue (bool* verified, SymbolList::Iterator it) |
236 void Expression::TryVerifyValue (bool* verified, SymbolList::Iterator it) |
| 237 { |
237 { |
| |
238 // If it's an unary operator we skip to its value. The actual operator will |
| |
239 // be verified separately. |
| |
240 if ((*it)->GetType() == eOperatorSymbol && |
| |
241 gOperators[static_cast<ExpressionOperator*> (*it)->GetID()].numoperands == 1) |
| |
242 { |
| |
243 ++it; |
| |
244 } |
| |
245 |
| 238 int i = it - mSymbols.begin(); |
246 int i = it - mSymbols.begin(); |
| 239 |
247 |
| 240 // Ensure it's an actual value |
248 // Ensure it's an actual value |
| 241 if ((*it)->GetType() != eValueSymbol) |
249 if ((*it)->GetType() != eValueSymbol) |
| 242 Error ("malformed expression (symbol #%1 is not a value)", i); |
250 Error ("malformed expression (symbol #%1 is not a value)", i); |
| 412 val->ConvertToBuffer(); |
420 val->ConvertToBuffer(); |
| 413 |
421 |
| 414 ExpressionValue* newval = new ExpressionValue (mType); |
422 ExpressionValue* newval = new ExpressionValue (mType); |
| 415 |
423 |
| 416 if (isconstexpr == false) |
424 if (isconstexpr == false) |
| |
425 { |
| |
426 // This is not a constant expression so we'll have to use databuffers |
| |
427 // to convey the expression to bytecode. Actual value cannot be evaluated |
| |
428 // until Zandronum processes it at run-time. |
| 417 newval->SetBuffer (new DataBuffer); |
429 newval->SetBuffer (new DataBuffer); |
| 418 |
430 |
| 419 if (isconstexpr == false) |
|
| 420 { |
|
| 421 if (op->GetID() == opTernary) |
431 if (op->GetID() == opTernary) |
| 422 { |
432 { |
| 423 // There isn't a dataheader for ternary operator. Instead, we use dhIfNotGoto |
433 // There isn't a dataheader for ternary operator. Instead, we use dhIfNotGoto |
| 424 // to create an "if-block" inside an expression. |
434 // to create an "if-block" inside an expression. |
| 425 // Behold, big block of writing madness! :P |
435 // Behold, big block of writing madness! :P |