22#include <boost/intrusive_ptr.hpp>
161 virtual std::ostream&
Print(std::ostream &output)
const = 0;
205 return value->
Print(output);
290 virtual std::ostream&
Print(std::ostream &output)
const override;
364 virtual std::ostream&
Print(std::ostream &output)
const override;
428 virtual std::ostream&
Print(std::ostream &output)
const override;
480 virtual std::ostream&
Print(std::ostream &output)
const override;
524 virtual std::ostream&
Print(std::ostream &output)
const override;
554 virtual std::ostream&
Print(std::ostream &output)
const override;
568 explicit VarValue(std::string name);
575 virtual std::ostream&
Print(std::ostream &output)
const override;
623 virtual std::ostream&
Print(std::ostream &output)
const override;
670 virtual std::ostream&
Print(std::ostream &output)
const override;
747 virtual std::ostream&
Print(std::ostream &output)
const override;
849 virtual std::ostream&
Print(std::ostream &output)
const override;
const int PRECEDENCE_BIT_AND
Precedence value for bitwise AND (&).
Definition: Value.h:68
const int PRECEDENCE_BIT_OR
Precedence value for bitwise OR (|).
Definition: Value.h:78
Stack< ValuePtr > ValueStack
Type representing a stack.
Definition: Value.h:103
std::deque< ValuePtr > ValueList
Type representing a list of values, e.g.
Definition: Value.h:98
const int PRECEDENCE_LOGIC_OR
Precedence value for logical OR (||).
Definition: Value.h:88
const int PRECEDENCE_UNARY
Precedence value for a unary operation.
Definition: Value.h:38
const int PRECEDENCE_NO
Precedence value for individual values with no operations.
Definition: Value.h:33
const int PRECEDENCE_RELATION
Precedence value for relative comparison (<, <=, >=, >).
Definition: Value.h:58
const int PRECEDENCE_SHIFT
Precedence value for bit shifting (<<, >>).
Definition: Value.h:53
boost::intrusive_ptr< Value > ValuePtr
Pointer to a Value.
Definition: Value.h:93
const int PRECEDENCE_ADD
Precedence value for addition and subtraction (+, -).
Definition: Value.h:48
const int PRECEDENCE_LOGIC_AND
Precedence value for logical AND (&&).
Definition: Value.h:83
const int PRECEDENCE_BIT_XOR
Precedence value for bitwise XOR (^).
Definition: Value.h:73
const int PRECEDENCE_MULT
Precedence value for multiplication, division, modulus (*, /, %).
Definition: Value.h:43
const int PRECEDENCE_EQUALITY
Precedence value for equality comparisons (==, !=).
Definition: Value.h:63
Value containing an absolute address.
Definition: Value.h:308
int32 GetSigned() override
Always throws {.
Definition: Value.cpp:108
AddressValue(const AddressValue &value)=delete
Copy constructor, disabled.
AddressValue & operator=(const AddressValue &value)=delete
Copy constructor, disabled.
bool IsAddress() override
Return whether or not the Value is an address.
Definition: Value.cpp:106
ValuePtr Dup(std::ostream &output) override
Duplicates the value.
Definition: Value.cpp:110
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:112
Value representing array access.
Definition: Value.h:588
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:153
ArrayValue & operator=(const ArrayValue &value)=delete
Copy constructor, disabled.
const ValueList indexes_
Values representing the indexes used (left-to-right).
Definition: Value.h:630
ArrayValue(const ArrayValue &value)=delete
Copy constructor, disabled.
Value representing the result of a binary operation.
Definition: Value.h:636
const ValuePtr left_val_
Value at the left side of the operator.
Definition: Value.h:695
virtual int GetPrecedence() const override
Retrieves the operator precedence for this operation.
Definition: Value.cpp:172
const ValuePtr right_val_
Value at the right side of the operator.
Definition: Value.h:700
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:163
virtual ValuePtr Negate() override
Negates a value.
Definition: Value.cpp:177
BinaryOpValue(const BinaryOpValue &value)=delete
Copy constructor, disabled.
BinaryOpValue & operator=(const BinaryOpValue &value)=delete
Copy constructor, disabled.
const std::string oper_
The operator.
Definition: Value.h:705
Value representing a function call.
Definition: Value.h:817
CallValue(const CallValue &value)=delete
Copy constructor, disabled.
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:202
const ValueList args_
List of values used as function arguments.
Definition: Value.h:861
const std::string function_
The name of the function.
Definition: Value.h:856
CallValue & operator=(const CallValue &value)=delete
Copy constructor, disabled.
Duplicated value.
Definition: Value.h:441
ValuePtr Dup(std::ostream &output) override
Duplicates the value.
Definition: Value.cpp:132
DupValue & operator=(const DupValue &value)=delete
Copy constructor, disabled.
DupValue(const DupValue &value)=delete
Copy constructor, disabled.
const int index_
Index to distinguish multiple duplicated entries.
Definition: Value.h:487
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:134
Value containing an integer.
Definition: Value.h:213
IntValue(const IntValue &value)=delete
Copy constructor, disabled.
bool IsInteger() override
Return whether or not the Value is an integer.
Definition: Value.cpp:88
ValuePtr Dup(std::ostream &output) override
Duplicates the value.
Definition: Value.cpp:96
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:98
int32 GetSigned() override
Retrieves a signed integer representing the value, if possible.
Definition: Value.cpp:92
IntValue & operator=(const IntValue &value)=delete
Copy constructor, disabled.
const int32 val_
The value of the integer.
Definition: Value.h:297
const bool signed_
True if the value is signed, false if it's not.
Definition: Value.h:302
uint32 GetUnsigned() override
Retrieves an unsigned integer representing the value, if possible.
Definition: Value.cpp:94
bool IsSignedValue() override
Returns whether or not the stored integer value is signed.
Definition: Value.cpp:90
Negated value.
Definition: Value.h:781
NegatedValue(const NegatedValue &value)=delete
Copy constructor, disabled.
virtual ValuePtr Negate() override
Negates the value.
Definition: Value.cpp:198
NegatedValue & operator=(const NegatedValue &value)=delete
Copy constructor, disabled.
Provides a base implementation of reference counting.
Definition: RefCounted.h:28
Value containing a signed, relative address.
Definition: Value.h:373
RelAddressValue(const RelAddressValue &value)=delete
Copy constructor, disabled.
uint32 GetUnsigned() override
Retrieves the exact address.
Definition: Value.cpp:121
bool IsAddress() override
Return whether or not the Value is an address.
Definition: Value.cpp:119
const uint32 base_addr_
The base address for the offset.
Definition: Value.h:435
ValuePtr Dup(std::ostream &output) override
Duplicates the value.
Definition: Value.cpp:123
virtual std::ostream & Print(std::ostream &output) const override
Print the relative address to a stream.
Definition: Value.cpp:125
RelAddressValue & operator=(const RelAddressValue &value)=delete
Copy constructor, disabled.
String value.
Definition: Value.h:493
StringValue & operator=(const StringValue &value)=delete
Copy constructor, disabled.
StringValue(const StringValue &value)=delete
Copy constructor, disabled.
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:138
const std::string str_
The string value.
Definition: Value.h:531
Value representing the result of a unary operation.
Definition: Value.h:713
UnaryOpValue & operator=(const UnaryOpValue &value)=delete
Copy constructor, disabled.
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:186
const std::string oper_
The operator for this value.
Definition: Value.h:770
UnaryOpValue(const UnaryOpValue &value)=delete
Copy constructor, disabled.
const bool postfix_
True if the operator is postfixed to the operand, false otherwise.
Definition: Value.h:775
virtual int GetPrecedence() const override
Retrieves the operator precedence for this operation.
Definition: Value.cpp:194
const ValuePtr operand_
The operand of the operation.
Definition: Value.h:765
A string value, unquoted.
Definition: Value.h:537
virtual std::ostream & Print(std::ostream &output) const override
Prints the value to a stream.
Definition: Value.cpp:144
UnquotedStringValue(std::string str)
Constructor.
Definition: Value.cpp:142
Class representing a value (stack entry, parameter, etc.)
Definition: Value.h:108
virtual ~Value()
Destructor.
Definition: Value.cpp:56
friend std::ostream & operator<<(std::ostream &output, Value *value)
Output a value to a stream.
Definition: Value.h:204
virtual std::string GetString() const
Retrieves the string representation of the value.
Definition: Value.cpp:76
virtual int32 GetSigned()
Retrieves a signed integer representing the value, if possible.
Definition: Value.cpp:64
virtual bool IsInteger()
Return whether or not the Value is an integer.
Definition: Value.cpp:58
virtual ValuePtr Negate()
Negates a value.
Definition: Value.cpp:74
virtual bool IsSignedValue()
Returns whether or not any stored integer value is signed.
Definition: Value.cpp:62
virtual std::ostream & Print(std::ostream &output) const =0
Print the value to a stream.
virtual uint32 GetUnsigned()
Retrieves an unsigned integer representing the value, if possible.
Definition: Value.cpp:66
virtual int GetPrecedence() const
Operator precedence for this value.
Definition: Value.cpp:82
virtual bool IsAddress()
Return whether or not the Value is an address.
Definition: Value.cpp:60
virtual ValuePtr Dup(std::ostream &output)
Duplicates a value.
Definition: Value.cpp:68
Value representing a variable.
Definition: Value.h:560
virtual std::ostream & Print(std::ostream &output) const override
Print the value to a stream.
Definition: Value.cpp:148
std::string name_
The variable name.
Definition: Value.h:582
VarValue(std::string name)
Constructor for VarValue.
Definition: Value.cpp:146
unsigned int uint32
Definition: scummsys.h:435
signed int int32
Definition: scummsys.h:436