RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
Apple::OMFFormat::Segment::Expression Class Reference

Classes

struct  precedence
 

Public Types

enum  operation_type {
  End = 0x00 , Addition = 0x01 , Subtraction = 0x02 , Multiplication = 0x03 ,
  Division = 0x04 , IntegerRemainder = 0x05 , Negation = 0x06 , BitShift = 0x07 ,
  And = 0x08 , Or = 0x09 , EOr = 0x0A , Not = 0x0B ,
  LessOrEqualTo = 0x0C , GreaterOrEqualTo = 0x0D , NotEqual = 0x0E , LessThan = 0x0F ,
  GreaterThan = 0x10 , EqualTo = 0x11 , BitAnd = 0x12 , BitOr = 0x13 ,
  BitEOr = 0x14 , BitNot = 0x15 , LocationCounterOperand = 0x80 , ConstantOperand = 0x81 ,
  WeakLabelReferenceOperand = 0x82 , LabelReferenceOperand = 0x83 , LengthOfLabelReferenceOperand = 0x84 , TypeOfLabelReferenceOperand = 0x85 ,
  CountOfLabelReferenceOperand = 0x86 , RelativeOffsetOperand = 0x87 , StackUnderflow = -1
}
 Represents an operation inside an expression in the object file. More...
 

Public Member Functions

 Expression (int operation)
 
 Expression (int operation, std::unique_ptr< Expression > &operand)
 
 Expression (int operation, std::unique_ptr< Expression > &operand1, std::unique_ptr< Expression > &operand2)
 
 Expression (int operation, offset_t value)
 
 Expression (int operation, std::string value)
 
offset_t GetLength (const Segment &segment) const
 
void ReadFile (Segment &segment, Linker::Reader &rd)
 
void WriteFile (const Segment &segment, Linker::Writer &wr) const
 
std::string GetStandardNotation () const
 Converts expression into a C-like syntax.
 

Public Attributes

operation_type operation = End
 The type of operation, End means that the result is the last operand.
 
std::vector< std::unique_ptr< Expression > > operands
 The operands the operation takes.
 
std::optional< std::variant< offset_t, std::string > > value
 A value corresponding to an operation, such as an integer constant or a label name.
 

Protected Types

typedef precedence::precedence_type precedence_type
 

Protected Member Functions

void PopElementsInto (size_t count, std::vector< std::unique_ptr< Expression > > &target)
 Removes elements from the top of the operands stack and copies them into target. On stack underflow, the missing elements are replaced with StackUnderflow expressions.
 
uint8_t ReadSingleOperation (Segment &segment, Linker::Reader &rd)
 Reads a single byte of operation (plus optional number and label) and modifies the current list of operands as an operation acting on a stack.
 
void GetStandardNotation (std::ostream &out, precedence_type precedence) const
 

Member Enumeration Documentation

◆ operation_type

Represents an operation inside an expression in the object file.

The numerical values are identical to the opcode bytes in the binary file

Enumerator
StackUnderflow 

A symbolic value to represent a stack underflow condition, it should not be printed back into a binary.


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