Game Development Reference
In-Depth Information
class
Integer
inherits
Expression
// Stores the integral value
int
value
// Constructor
...
function
Execute()
// Push value onto calculator's stack
...
end
end
class
Addition
inherits
Expression
// LHS/RHS operands
Expression
lhs
,
rhs
// Constructor
...
function
Execute()
// Post-order means execute left child, then
right child,
// then myself.
lhs
.Execute()
rhs
.Execute()
// Add top two values on calculator's stack,
push result back on
...
end
end
// Subtraction node identical to Addition, except
it subtracts
...