fcml  1.1.3
Classes | Public Member Functions | Static Public Member Functions | List of all members
fcml::StatefulAssembler Class Reference

It's a stateful assembler which can be used to assemble instructions one by one on the fly. More...

#include <fcml_stateful_assembler.hpp>

Classes

class  SAFlush
 Used only to indicate the need of the flush operation. More...
 

Public Member Functions

 StatefulAssembler (Assembler &assembler, AssemblerContext &context, bool enableParser=false)
 Creates a stateful assembler for the given assembler and assembler context. More...
 
virtual ~StatefulAssembler ()
 Destructor. More...
 
StatefulAssembleroperator<< (const IB &ib)
 Adds instruction builder to the stateful assembler. More...
 
StatefulAssembleradd (const IB &ib)
 Adds instruction builder to the stateful assembler. More...
 
StatefulAssembleroperator<< (const fcml_cstring &mnemonic)
 Creates an instruction builder for the given mnemonic. More...
 
StatefulAssemblerinst (const fcml_cstring &mnemonic)
 Creates an instruction builder for the given mnemonic. More...
 
StatefulAssembleroperator<< (const Register &reg)
 Adds the new register operand to the instruction builder associated with the buffer. More...
 
StatefulAssembleroperator<< (const Integer &imm)
 Adds the new immediate operand to the instruction builder associated with the buffer. More...
 
StatefulAssembleroperator<< (const Address &address)
 Adds the new address operand to the instruction builder associated with the buffer. More...
 
StatefulAssembleroperator<< (const FarPointer &pointer)
 Adds the new far pointer operand to the instruction builder associated with the buffer. More...
 
StatefulAssembleroperator<< (const Operand &operand)
 Adds an operand to the instruction builder associated with the buffer. More...
 
StatefulAssemblerop (const Operand &operand)
 Adds an operand to the instruction builder associated with the buffer. More...
 
StatefulAssemblerop (const Register &reg)
 Adds the new register operand to the instruction builder associated with the buffer. More...
 
StatefulAssemblerop (const Integer &imm)
 Adds the new immediate operand to the instruction builder associated with the buffer. More...
 
StatefulAssemblerop (const Address &address)
 Adds the new address operand to the instruction builder associated with the buffer. More...
 
StatefulAssemblerop (const FarPointer &pointer)
 Adds the new far pointer operand to the instruction builder associated with the buffer. More...
 
StatefulAssembleroperator<< (const SAFlush &indic)
 Flushes the instruction builder. More...
 
StatefulAssembleroperator<< (const Instruction &instruction)
 Assembles an instruction in the given instruction builder. More...
 
StatefulAssembleroperator<< (const InstructionPrefix &prefix)
 Adds a prefix to the instruction being built. More...
 
StatefulAssembleroperator<< (const InstructionHint &hint)
 Adds an instruction level hint to the instruction being built. More...
 
StatefulAssembleroperator<< (const OperandHint &hint)
 Adds an operand level hint to the instruction being built. More...
 
StatefulAssemblerset (const InstructionPrefix &prefix)
 Adds a prefix to the instruction being built. More...
 
StatefulAssemblerset (const InstructionHint &hint)
 Adds an instruction level hint to the instruction being built. More...
 
StatefulAssemblerset (const OperandHint &hint)
 Adds an operand level hint to the instruction being built. More...
 
StatefulAssemblerinst (const Instruction &instruction)
 Assembles an instruction in the given instruction builder. More...
 
CodeIterator getCodeIterator ()
 Gets iterator which allows to iterate through the whole machine code byte by byte. More...
 
std::vector< AssembledInstruction > & getAssembledInstructions ()
 Gets all chosen assembled instructions. More...
 
fcml_usize getCodeLength ()
 Gets the code length of all assembled instructions available. More...
 
void flush ()
 Assembles all pending instructions. More...
 
const ParserConfiggetParserConfig () const
 Gets configuration used by parser if parsing is supported. More...
 
ParserConfiggetParserConfig ()
 Gets configuration used by parser if parsing is supported. More...
 
const SymbolTablegetSymbolTable () const
 Gets symbol table used together with the parser. More...
 
SymbolTablegetSymbolTable ()
 Gets symbol table used together with the parser. More...
 
void setSymbolTable (SymbolTable *symbolTable)
 Sets a new symbol table for the parser. More...
 

Static Public Member Functions

static SAFlush FLUSH ()
 Creates flush indicated for "shift" operators. More...
 

Detailed Description

It's a stateful assembler which can be used to assemble instructions one by one on the fly.

By default is works with the general instruction models as well as with instruction builders, but it can be also configured to parse whole statements using internally managed parser. It holds it's own state, so it's not necessary to update instruction pointer etc while it's working. Assembled instructions are placed inside a dedicated vector, but generated machine code is accessing directly by the dedicated CodeIterator.

Since
1.1.0
Remarks
This class isn't thread-safe.

Constructor & Destructor Documentation

fcml::StatefulAssembler::StatefulAssembler ( Assembler assembler,
AssemblerContext context,
bool  enableParser = false 
)
inline

Creates a stateful assembler for the given assembler and assembler context.

Bear in mind that assembler and context are not copied in any way and have to be valid as long as the stateful assembler in in use. Parsing support can be enabled optionally using the third parameter.

Parameters
assemblerThe assembled that will be used to assemble the code.
contextThe assembler context.
enableParserEnables parsing support.
Since
1.1.0
virtual fcml::StatefulAssembler::~StatefulAssembler ( )
inlinevirtual

Destructor.

Since
1.1.0

Member Function Documentation

StatefulAssembler& fcml::StatefulAssembler::add ( const IB ib)
inline

Adds instruction builder to the stateful assembler.

Such a instruction builder will be used then to assemble an instruction it represents. Before any operation is performed, pending instruction is flushed if there is any available.

Parameters
ibThe instruction builder to be flushed.
Returns
The stateful assembler itself.
Exceptions
AssemblingFailedException
Since
1.1.0
void fcml::StatefulAssembler::flush ( )
inline

Assembles all pending instructions.

Since
1.1.0
Exceptions
AssemblingFailedException
static SAFlush fcml::StatefulAssembler::FLUSH ( )
inlinestatic

Creates flush indicated for "shift" operators.

Returns
Flush indicator.
Since
1.1.0
std::vector<AssembledInstruction>& fcml::StatefulAssembler::getAssembledInstructions ( )
inline

Gets all chosen assembled instructions.

Returns
All assembled instructions available in the buffer.
Since
1.1.0
CodeIterator fcml::StatefulAssembler::getCodeIterator ( )
inline

Gets iterator which allows to iterate through the whole machine code byte by byte.

Returns
Iterator instance.
Since
1.1.0
fcml_usize fcml::StatefulAssembler::getCodeLength ( )
inline

Gets the code length of all assembled instructions available.

Returns
The code length.
Since
1.1.0
const ParserConfig& fcml::StatefulAssembler::getParserConfig ( ) const
inline

Gets configuration used by parser if parsing is supported.

Returns
Parser configuration.
ParserConfig& fcml::StatefulAssembler::getParserConfig ( )
inline

Gets configuration used by parser if parsing is supported.

Returns
Parser configuration.
Since
1.1.0
const SymbolTable* fcml::StatefulAssembler::getSymbolTable ( ) const
inline

Gets symbol table used together with the parser.

Returns
The symbol table used by the parser.
Since
1.1.0
SymbolTable* fcml::StatefulAssembler::getSymbolTable ( )
inline

Gets symbol table used together with the parser.

Returns
The symbol table used by the parser.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::inst ( const fcml_cstring mnemonic)
inline

Creates an instruction builder for the given mnemonic.

Parameters
mnemonicThe instruction mnemonic.
Returns
The stateful assembler itself.
Exceptions
AssemblingFailedException,ParsingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::inst ( const Instruction instruction)
inline

Assembles an instruction in the given instruction builder.

Parameters
instructionInstruction to be assembled.
Returns
Stateful assembler.
Exceptions
AssemblingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::op ( const Operand operand)
inline

Adds an operand to the instruction builder associated with the buffer.

Parameters
operandThe operand to be added..
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::op ( const Register reg)
inline

Adds the new register operand to the instruction builder associated with the buffer.

Parameters
regThe register.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::op ( const Integer imm)
inline

Adds the new immediate operand to the instruction builder associated with the buffer.

Parameters
immThe immediate value.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::op ( const Address address)
inline

Adds the new address operand to the instruction builder associated with the buffer.

Parameters
addressThe address.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::op ( const FarPointer pointer)
inline

Adds the new far pointer operand to the instruction builder associated with the buffer.

Parameters
pointerThe far pointer.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const IB ib)
inline

Adds instruction builder to the stateful assembler.

Such a instruction builder will be used then to assemble an instruction it represents. Before any operation is performed, pending instruction is flushed if there is any available.

Parameters
ibThe instruction builder to be flushed.
Returns
The stateful assembler itself.
Exceptions
AssemblingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const fcml_cstring mnemonic)
inline

Creates an instruction builder for the given mnemonic.

Parameters
mnemonicThe instruction mnemonic.
Returns
The stateful assembler itself.
Exceptions
AssemblingFailedException,ParsingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const Register reg)
inline

Adds the new register operand to the instruction builder associated with the buffer.

Parameters
regThe register.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const Integer imm)
inline

Adds the new immediate operand to the instruction builder associated with the buffer.

Parameters
immThe immediate value.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const Address address)
inline

Adds the new address operand to the instruction builder associated with the buffer.

Parameters
addressThe address.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const FarPointer pointer)
inline

Adds the new far pointer operand to the instruction builder associated with the buffer.

Parameters
pointerThe far pointer.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const Operand operand)
inline

Adds an operand to the instruction builder associated with the buffer.

Parameters
operandThe operand to be added.
Returns
The stateful assembler itself.
Exceptions
IllegalStateException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const SAFlush indic)
inline

Flushes the instruction builder.

Parameters
indicFlush indicator.
Returns
The stateful assembler itself.
Exceptions
AssemblingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const Instruction instruction)
inline

Assembles an instruction in the given instruction builder.

Parameters
instructionInstruction to be assembled.
Returns
Stateful assembler.
Exceptions
AssemblingFailedException
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const InstructionPrefix prefix)
inline

Adds a prefix to the instruction being built.

Parameters
prefixThe prefix to be added.
Returns
The instruction builder with the new prefix set for it.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const InstructionHint hint)
inline

Adds an instruction level hint to the instruction being built.

Parameters
hintThe hint to be added.
Returns
The instruction builder with the new hint added to it.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::operator<< ( const OperandHint hint)
inline

Adds an operand level hint to the instruction being built.

Parameters
hintThe hint to be added.
Returns
The instruction builder with the new hint added to it.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::set ( const InstructionPrefix prefix)
inline

Adds a prefix to the instruction being built.

Parameters
prefixThe prefix to be added.
Returns
The instruction builder with the new prefix set for it.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::set ( const InstructionHint hint)
inline

Adds an instruction level hint to the instruction being built.

Parameters
hintThe hint to be added.
Returns
The instruction builder with the new hint added to it.
Since
1.1.0
StatefulAssembler& fcml::StatefulAssembler::set ( const OperandHint hint)
inline

Adds an operand level hint to the instruction being built.

Parameters
hintThe hint to be added.
Returns
The instruction builder with the new hint added to it.
Since
1.1.0
void fcml::StatefulAssembler::setSymbolTable ( SymbolTable symbolTable)
inline

Sets a new symbol table for the parser.

Parameters
symbolTableThe new symbol table.
Since
1.1.0

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