Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
Gyoji::mir::OperationCast Class Reference

This subclass of OperationUnary represents a cast operation. More...

#include <operations.hpp>

Inheritance diagram for Gyoji::mir::OperationCast:
Inheritance graph
[legend]
Collaboration diagram for Gyoji::mir::OperationCast:
Collaboration graph
[legend]

Public Member Functions

 OperationCast (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result, size_t _operand, const Type *_cast_type)
 Construct cast operation with a single operand and a type.
 
virtual ~OperationCast ()
 Move along, nothing to see here.
 
const Typeget_cast_type () const
 Get type being cast/converted to.
 
- Public Member Functions inherited from Gyoji::mir::OperationUnary
 OperationUnary (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result, size_t _operand)
 Construct unary operation with a single operand.
 
virtual ~OperationUnary ()
 Move along, nothing to see here.
 
size_t get_a () const
 Returns the operand of the unary operation.
 
- Public Member Functions inherited from Gyoji::mir::Operation
 Operation (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result)
 
 Operation (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result, size_t _operand)
 
 Operation (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result, size_t _operand_a, size_t _operand_b)
 
 Operation (OperationType _type, const Gyoji::context::SourceReference &_src_ref, size_t _result, size_t _operand_a, size_t _operand_b, size_t _operand_c)
 
virtual ~Operation ()
 Move along, nothing to see here.
 
void dump (FILE *out) const
 
OperationType get_type () const
 Opcode of this operation.
 
const std::vector< size_t > & get_operands () const
 Get the operands.
 
size_t get_result () const
 Get the result of this operation.
 
bool is_terminating () const
 Returns true if this is a terminating operation for a block.
 
const Gyoji::context::SourceReferenceget_source_ref () const
 Get the reference to the source which originated this operation.
 

Protected Member Functions

virtual std::string get_description () const
 Produce a description of the operation.
 
- Protected Member Functions inherited from Gyoji::mir::Operation
void add_operand (size_t operand)
 Add an operand.
 

Additional Inherited Members

- Public Types inherited from Gyoji::mir::Operation
enum  OperationType {
  OP_FUNCTION_CALL , OP_SYMBOL , OP_WIDEN_SIGNED , OP_WIDEN_UNSIGNED ,
  OP_WIDEN_FLOAT , OP_ARRAY_INDEX , OP_DOT , OP_LOCAL_DECLARE ,
  OP_LOCAL_UNDECLARE , OP_LOCAL_VARIABLE , OP_LITERAL_CHAR , OP_LITERAL_STRING ,
  OP_LITERAL_INT , OP_LITERAL_FLOAT , OP_LITERAL_BOOL , OP_LITERAL_NULL ,
  OP_ADDRESSOF , OP_DEREFERENCE , OP_NEGATE , OP_BITWISE_NOT ,
  OP_LOGICAL_NOT , OP_SIZEOF_TYPE , OP_ADD , OP_SUBTRACT ,
  OP_MULTIPLY , OP_DIVIDE , OP_MODULO , OP_LOGICAL_AND ,
  OP_LOGICAL_OR , OP_BITWISE_AND , OP_BITWISE_OR , OP_BITWISE_XOR ,
  OP_SHIFT_LEFT , OP_SHIFT_RIGHT , OP_COMPARE_LESS , OP_COMPARE_GREATER ,
  OP_COMPARE_LESS_EQUAL , OP_COMPARE_GREATER_EQUAL , OP_COMPARE_NOT_EQUAL , OP_COMPARE_EQUAL ,
  OP_ASSIGN , OP_JUMP_CONDITIONAL , OP_JUMP , OP_RETURN ,
  OP_RETURN_VOID
}
 Operations of the MIR virtual-machine. More...
 

Detailed Description

This subclass of OperationUnary represents a cast operation.

This class is used to represent opcodes whose first argument is a value and the second argument is a type. It is used for opcodes that in some way manipulate the data to conform to the given type. In some cases, the value itself is not modified and is returned exactly as it was with only new type information (reinterpret casts), and in some cases, the value itself changes such as sign extending integers or conversions from integers to floating-point numbers. Each individual opcode carries the rules for these conversions. This class is merely a container for instances of those operations.

Constructor & Destructor Documentation

◆ OperationCast()

OperationCast::OperationCast ( OperationType  _type,
const Gyoji::context::SourceReference _src_ref,
size_t  _result,
size_t  _operand,
const Type _cast_type 
)

Construct cast operation with a single operand and a type.

This constructor is used for cast expressions which take a single operand and a reference to a type and produce a single result.

◆ ~OperationCast()

OperationCast::~OperationCast ( )
virtual

Move along, nothing to see here.

Move along, nothing to see here.

Member Function Documentation

◆ get_cast_type()

const Type * OperationCast::get_cast_type ( ) const

Get type being cast/converted to.

This method returns the type of variable being cast or converted to.

◆ get_description()

std::string OperationCast::get_description ( ) const
protectedvirtual

Produce a description of the operation.

This method returns a full description of the operation including the return-value, operands, and any other ancilary information about the operation. This is a string that is constructed dynamically when needed and is used almost exclusively by the "dump" method to provide debuginng information.

Reimplemented from Gyoji::mir::Operation.


The documentation for this class was generated from the following files: