Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends

Operation Class Reference

#include <operators.h>

Inheritance diagram for Operation:
ExprTree ExprTree

List of all members.

Public Types

enum  OpKind {
  __NO_OP__, __FIRST_OP__, __COMPARISON_START__ = __FIRST_OP__, LESS_THAN_OP = __COMPARISON_START__,
  LESS_OR_EQUAL_OP, NOT_EQUAL_OP, EQUAL_OP, GREATER_OR_EQUAL_OP,
  GREATER_THAN_OP, META_EQUAL_OP, IS_OP = META_EQUAL_OP, META_NOT_EQUAL_OP,
  ISNT_OP = META_NOT_EQUAL_OP, __COMPARISON_END__ = ISNT_OP, __ARITHMETIC_START__, UNARY_PLUS_OP = __ARITHMETIC_START__,
  UNARY_MINUS_OP, ADDITION_OP, SUBTRACTION_OP, MULTIPLICATION_OP,
  DIVISION_OP, MODULUS_OP, __ARITHMETIC_END__ = MODULUS_OP, __LOGIC_START__,
  LOGICAL_NOT_OP = __LOGIC_START__, LOGICAL_OR_OP, LOGICAL_AND_OP, __LOGIC_END__ = LOGICAL_AND_OP,
  __BITWISE_START__, BITWISE_NOT_OP = __BITWISE_START__, BITWISE_OR_OP, BITWISE_XOR_OP,
  BITWISE_AND_OP, LEFT_SHIFT_OP, RIGHT_SHIFT_OP, URIGHT_SHIFT_OP,
  __BITWISE_END__ = URIGHT_SHIFT_OP, __MISC_START__, PARENTHESES_OP = __MISC_START__, SUBSCRIPT_OP,
  TERNARY_OP, __MISC_END__ = TERNARY_OP, __LAST_OP__ = __MISC_END__, __NO_OP__,
  __FIRST_OP__, __COMPARISON_START__ = __FIRST_OP__, LESS_THAN_OP = __COMPARISON_START__, LESS_OR_EQUAL_OP,
  NOT_EQUAL_OP, EQUAL_OP, GREATER_OR_EQUAL_OP, GREATER_THAN_OP,
  META_EQUAL_OP, IS_OP = META_EQUAL_OP, META_NOT_EQUAL_OP, ISNT_OP = META_NOT_EQUAL_OP,
  __COMPARISON_END__ = ISNT_OP, __ARITHMETIC_START__, UNARY_PLUS_OP = __ARITHMETIC_START__, UNARY_MINUS_OP,
  ADDITION_OP, SUBTRACTION_OP, MULTIPLICATION_OP, DIVISION_OP,
  MODULUS_OP, __ARITHMETIC_END__ = MODULUS_OP, __LOGIC_START__, LOGICAL_NOT_OP = __LOGIC_START__,
  LOGICAL_OR_OP, LOGICAL_AND_OP, __LOGIC_END__ = LOGICAL_AND_OP, __BITWISE_START__,
  BITWISE_NOT_OP = __BITWISE_START__, BITWISE_OR_OP, BITWISE_XOR_OP, BITWISE_AND_OP,
  LEFT_SHIFT_OP, RIGHT_SHIFT_OP, URIGHT_SHIFT_OP, __BITWISE_END__ = URIGHT_SHIFT_OP,
  __MISC_START__, PARENTHESES_OP = __MISC_START__, SUBSCRIPT_OP, TERNARY_OP,
  __MISC_END__ = TERNARY_OP, __LAST_OP__ = __MISC_END__
}
 

List of supported operators.

More...
enum  OpKind {
  __NO_OP__, __FIRST_OP__, __COMPARISON_START__ = __FIRST_OP__, LESS_THAN_OP = __COMPARISON_START__,
  LESS_OR_EQUAL_OP, NOT_EQUAL_OP, EQUAL_OP, GREATER_OR_EQUAL_OP,
  GREATER_THAN_OP, META_EQUAL_OP, IS_OP = META_EQUAL_OP, META_NOT_EQUAL_OP,
  ISNT_OP = META_NOT_EQUAL_OP, __COMPARISON_END__ = ISNT_OP, __ARITHMETIC_START__, UNARY_PLUS_OP = __ARITHMETIC_START__,
  UNARY_MINUS_OP, ADDITION_OP, SUBTRACTION_OP, MULTIPLICATION_OP,
  DIVISION_OP, MODULUS_OP, __ARITHMETIC_END__ = MODULUS_OP, __LOGIC_START__,
  LOGICAL_NOT_OP = __LOGIC_START__, LOGICAL_OR_OP, LOGICAL_AND_OP, __LOGIC_END__ = LOGICAL_AND_OP,
  __BITWISE_START__, BITWISE_NOT_OP = __BITWISE_START__, BITWISE_OR_OP, BITWISE_XOR_OP,
  BITWISE_AND_OP, LEFT_SHIFT_OP, RIGHT_SHIFT_OP, URIGHT_SHIFT_OP,
  __BITWISE_END__ = URIGHT_SHIFT_OP, __MISC_START__, PARENTHESES_OP = __MISC_START__, SUBSCRIPT_OP,
  TERNARY_OP, __MISC_END__ = TERNARY_OP, __LAST_OP__ = __MISC_END__, __NO_OP__,
  __FIRST_OP__, __COMPARISON_START__ = __FIRST_OP__, LESS_THAN_OP = __COMPARISON_START__, LESS_OR_EQUAL_OP,
  NOT_EQUAL_OP, EQUAL_OP, GREATER_OR_EQUAL_OP, GREATER_THAN_OP,
  META_EQUAL_OP, IS_OP = META_EQUAL_OP, META_NOT_EQUAL_OP, ISNT_OP = META_NOT_EQUAL_OP,
  __COMPARISON_END__ = ISNT_OP, __ARITHMETIC_START__, UNARY_PLUS_OP = __ARITHMETIC_START__, UNARY_MINUS_OP,
  ADDITION_OP, SUBTRACTION_OP, MULTIPLICATION_OP, DIVISION_OP,
  MODULUS_OP, __ARITHMETIC_END__ = MODULUS_OP, __LOGIC_START__, LOGICAL_NOT_OP = __LOGIC_START__,
  LOGICAL_OR_OP, LOGICAL_AND_OP, __LOGIC_END__ = LOGICAL_AND_OP, __BITWISE_START__,
  BITWISE_NOT_OP = __BITWISE_START__, BITWISE_OR_OP, BITWISE_XOR_OP, BITWISE_AND_OP,
  LEFT_SHIFT_OP, RIGHT_SHIFT_OP, URIGHT_SHIFT_OP, __BITWISE_END__ = URIGHT_SHIFT_OP,
  __MISC_START__, PARENTHESES_OP = __MISC_START__, SUBSCRIPT_OP, TERNARY_OP,
  __MISC_END__ = TERNARY_OP, __LAST_OP__ = __MISC_END__
}
 

List of supported operators.

More...
Strict comparison operators

Non-strict comparison operators

Arithmetic operators

Logical operators

Bitwise operators

Miscellaneous operators

Public Member Functions

 Operation (const Operation &op)
 Copy Constructor.
virtual ~Operation ()
 Destructor.
Operationoperator= (const Operation &op)
 Assignment operator.
void GetComponents (OpKind &, ExprTree *&, ExprTree *&, ExprTree *&) const
virtual ExprTreeCopy () const
 Make a deep copy of the expression.
bool CopyFrom (const Operation &op)
virtual bool SameAs (const ExprTree *tree) const
 Operation (const Operation &op)
 Copy Constructor.
virtual ~Operation ()
 Destructor.
Operationoperator= (const Operation &op)
 Assignment operator.
void GetComponents (OpKind &, ExprTree *&, ExprTree *&, ExprTree *&) const
virtual ExprTreeCopy () const
 Make a deep copy of the expression.
bool CopyFrom (const Operation &op)
virtual bool SameAs (const ExprTree *tree) const

Static Public Member Functions

static OperationMakeOperation (OpKind kind, ExprTree *e1=NULL, ExprTree *e2=NULL, ExprTree *e3=NULL)
static void Operate (OpKind op, Value &op1, Value &op2, Value &result)
static void Operate (OpKind op, Value &op1, Value &op2, Value &op3, Value &result)
static bool IsStrictOperator (OpKind)
static int PrecedenceLevel (OpKind)
static OperationMakeOperation (OpKind kind, ExprTree *e1=NULL, ExprTree *e2=NULL, ExprTree *e3=NULL)
static void Operate (OpKind op, Value &op1, Value &op2, Value &result)
static void Operate (OpKind op, Value &op1, Value &op2, Value &op3, Value &result)
static bool IsStrictOperator (OpKind)
static int PrecedenceLevel (OpKind)

Protected Member Functions

 Operation ()
 Constructor.
 Operation ()
 Constructor.

Friends

bool operator== (const Operation &op1, const Operation &op2)
bool operator== (const Operation &op1, const Operation &op2)

Detailed Description

Represents a node of the expression tree which is an operation applied to expression operands, like 3 + 2


Member Enumeration Documentation

List of supported operators.

Enumerator:
__NO_OP__ 

No op

LESS_THAN_OP 

Less than operator

LESS_OR_EQUAL_OP 

Less or equal

NOT_EQUAL_OP 

Not equal

EQUAL_OP 

Equal

GREATER_OR_EQUAL_OP 

Greater or equal

GREATER_THAN_OP 

Greater than

META_EQUAL_OP 

Meta-equal (same as IS)

IS_OP 

Is

META_NOT_EQUAL_OP 

Meta-not-equal (same as ISNT)

ISNT_OP 

Isnt

UNARY_PLUS_OP 

Unary plus

UNARY_MINUS_OP 

Unary minus

ADDITION_OP 

Addition

SUBTRACTION_OP 

Subtraction

MULTIPLICATION_OP 

Multiplication

DIVISION_OP 

Division

MODULUS_OP 

Modulus

LOGICAL_NOT_OP 

Logical not

LOGICAL_OR_OP 

Logical or

LOGICAL_AND_OP 

Logical and

BITWISE_NOT_OP 

Bitwise not

BITWISE_OR_OP 

Bitwise or

BITWISE_XOR_OP 

Bitwise xor

BITWISE_AND_OP 

Bitwise and

LEFT_SHIFT_OP 

Left shift

RIGHT_SHIFT_OP 

Right shift

URIGHT_SHIFT_OP 

Unsigned right shift

PARENTHESES_OP 

Parentheses

SUBSCRIPT_OP 

Subscript

TERNARY_OP 

Conditional op

__NO_OP__ 

No op

LESS_THAN_OP 

Less than operator

LESS_OR_EQUAL_OP 

Less or equal

NOT_EQUAL_OP 

Not equal

EQUAL_OP 

Equal

GREATER_OR_EQUAL_OP 

Greater or equal

GREATER_THAN_OP 

Greater than

META_EQUAL_OP 

Meta-equal (same as IS)

IS_OP 

Is

META_NOT_EQUAL_OP 

Meta-not-equal (same as ISNT)

ISNT_OP 

Isnt

UNARY_PLUS_OP 

Unary plus

UNARY_MINUS_OP 

Unary minus

ADDITION_OP 

Addition

SUBTRACTION_OP 

Subtraction

MULTIPLICATION_OP 

Multiplication

DIVISION_OP 

Division

MODULUS_OP 

Modulus

LOGICAL_NOT_OP 

Logical not

LOGICAL_OR_OP 

Logical or

LOGICAL_AND_OP 

Logical and

BITWISE_NOT_OP 

Bitwise not

BITWISE_OR_OP 

Bitwise or

BITWISE_XOR_OP 

Bitwise xor

BITWISE_AND_OP 

Bitwise and

LEFT_SHIFT_OP 

Left shift

RIGHT_SHIFT_OP 

Right shift

URIGHT_SHIFT_OP 

Unsigned right shift

PARENTHESES_OP 

Parentheses

SUBSCRIPT_OP 

Subscript

TERNARY_OP 

Conditional op

List of supported operators.

Enumerator:
__NO_OP__ 

No op

LESS_THAN_OP 

Less than operator

LESS_OR_EQUAL_OP 

Less or equal

NOT_EQUAL_OP 

Not equal

EQUAL_OP 

Equal

GREATER_OR_EQUAL_OP 

Greater or equal

GREATER_THAN_OP 

Greater than

META_EQUAL_OP 

Meta-equal (same as IS)

IS_OP 

Is

META_NOT_EQUAL_OP 

Meta-not-equal (same as ISNT)

ISNT_OP 

Isnt

UNARY_PLUS_OP 

Unary plus

UNARY_MINUS_OP 

Unary minus

ADDITION_OP 

Addition

SUBTRACTION_OP 

Subtraction

MULTIPLICATION_OP 

Multiplication

DIVISION_OP 

Division

MODULUS_OP 

Modulus

LOGICAL_NOT_OP 

Logical not

LOGICAL_OR_OP 

Logical or

LOGICAL_AND_OP 

Logical and

BITWISE_NOT_OP 

Bitwise not

BITWISE_OR_OP 

Bitwise or

BITWISE_XOR_OP 

Bitwise xor

BITWISE_AND_OP 

Bitwise and

LEFT_SHIFT_OP 

Left shift

RIGHT_SHIFT_OP 

Right shift

URIGHT_SHIFT_OP 

Unsigned right shift

PARENTHESES_OP 

Parentheses

SUBSCRIPT_OP 

Subscript

TERNARY_OP 

Conditional op

__NO_OP__ 

No op

LESS_THAN_OP 

Less than operator

LESS_OR_EQUAL_OP 

Less or equal

NOT_EQUAL_OP 

Not equal

EQUAL_OP 

Equal

GREATER_OR_EQUAL_OP 

Greater or equal

GREATER_THAN_OP 

Greater than

META_EQUAL_OP 

Meta-equal (same as IS)

IS_OP 

Is

META_NOT_EQUAL_OP 

Meta-not-equal (same as ISNT)

ISNT_OP 

Isnt

UNARY_PLUS_OP 

Unary plus

UNARY_MINUS_OP 

Unary minus

ADDITION_OP 

Addition

SUBTRACTION_OP 

Subtraction

MULTIPLICATION_OP 

Multiplication

DIVISION_OP 

Division

MODULUS_OP 

Modulus

LOGICAL_NOT_OP 

Logical not

LOGICAL_OR_OP 

Logical or

LOGICAL_AND_OP 

Logical and

BITWISE_NOT_OP 

Bitwise not

BITWISE_OR_OP 

Bitwise or

BITWISE_XOR_OP 

Bitwise xor

BITWISE_AND_OP 

Bitwise and

LEFT_SHIFT_OP 

Left shift

RIGHT_SHIFT_OP 

Right shift

URIGHT_SHIFT_OP 

Unsigned right shift

PARENTHESES_OP 

Parentheses

SUBSCRIPT_OP 

Subscript

TERNARY_OP 

Conditional op


Member Function Documentation

void Operation::GetComponents ( OpKind op,
ExprTree *&  e1,
ExprTree *&  e2,
ExprTree *&  e3 
) const

Deconstructor to obtain the components of an operation node

Parameters:
kind The kind of operation.
e1 The first sub-expression child of the node.
e2 The second sub-expression child of the node (if any).
e3 The third sub-expression child of the node (if any).
void Operation::GetComponents ( OpKind ,
ExprTree *&  ,
ExprTree *&  ,
ExprTree *&   
) const

Deconstructor to obtain the components of an operation node

Parameters:
kind The kind of operation.
e1 The first sub-expression child of the node.
e2 The second sub-expression child of the node (if any).
e3 The third sub-expression child of the node (if any).
static bool Operation::IsStrictOperator ( OpKind   )  [static]

Predicate which tests if an operator is strict.

Parameters:
op The operator to be tested.
Returns:
true if the operator is strict, false otherwise.
bool Operation::IsStrictOperator ( OpKind  op  )  [static]

Predicate which tests if an operator is strict.

Parameters:
op The operator to be tested.
Returns:
true if the operator is strict, false otherwise.
static Operation* Operation::MakeOperation ( OpKind  kind,
ExprTree e1 = NULL,
ExprTree e2 = NULL,
ExprTree e3 = NULL 
) [static]

Factory method to create an operation expression node

Parameters:
kind The kind of operation.
e1 The first sub-expression child of the node.
e2 The second sub-expression child of the node (if any).
e3 The third sub-expression child of the node (if any).
Returns:
The constructed operation
Operation * Operation::MakeOperation ( OpKind  kind,
ExprTree e1 = NULL,
ExprTree e2 = NULL,
ExprTree e3 = NULL 
) [static]

Factory method to create an operation expression node

Parameters:
kind The kind of operation.
e1 The first sub-expression child of the node.
e2 The second sub-expression child of the node (if any).
e3 The third sub-expression child of the node (if any).
Returns:
The constructed operation
static void Operation::Operate ( OpKind  op,
Value op1,
Value op2,
Value op3,
Value result 
) [static]

Convenience method which operates on ternary operators.

Parameters:
op The kind of operation.
op1 The first operand.
op2 The second operand.
op3 The third operand.
result The result of the operation.
See also:
OpKind, Value
void Operation::Operate ( OpKind  op,
Value op1,
Value op2,
Value result 
) [static]

Convenience method which operates on binary operators.

Parameters:
op The kind of operation.
op1 The first operand.
op2 The second operand.
result The result of the operation.
See also:
OpKind, Value
void Operation::Operate ( OpKind  op,
Value op1,
Value op2,
Value op3,
Value result 
) [static]

Convenience method which operates on ternary operators.

Parameters:
op The kind of operation.
op1 The first operand.
op2 The second operand.
op3 The third operand.
result The result of the operation.
See also:
OpKind, Value
static void Operation::Operate ( OpKind  op,
Value op1,
Value op2,
Value result 
) [static]

Convenience method which operates on binary operators.

Parameters:
op The kind of operation.
op1 The first operand.
op2 The second operand.
result The result of the operation.
See also:
OpKind, Value
int Operation::PrecedenceLevel ( OpKind  op  )  [static]

Gets the precedence level of an operator. Higher precedences get higher values. (See K&R, p.53)

Parameters:
op The operator to get the precedence of
Returns:
The precedence level of the operator.
static int Operation::PrecedenceLevel ( OpKind   )  [static]

Gets the precedence level of an operator. Higher precedences get higher values. (See K&R, p.53)

Parameters:
op The operator to get the precedence of
Returns:
The precedence level of the operator.
virtual bool Operation::SameAs ( const ExprTree tree  )  const [virtual]

Is this ExprTree the same as the tree?

Returns:
true if it is the same, false otherwise

Implements ExprTree.

bool Operation::SameAs ( const ExprTree tree  )  const [virtual]

Is this ExprTree the same as the tree?

Returns:
true if it is the same, false otherwise

Implements ExprTree.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends