27 #ifndef FCML_STATEFUL_ASSEMBLER_HPP_ 28 #define FCML_STATEFUL_ASSEMBLER_HPP_ 67 _assembler(assembler),
111 _instructionBuilder.setNotNull(
true);
112 _instructionBuilder.setValue(ib);
125 return inst( mnemonic );
140 _parserContext.setIp( _context.getEntryPoint().getIP() );
143 _parser->parse( _parserContext, mnemonic, _parserResult );
144 *
this << _parserResult.getInstruction();
148 _instructionBuilder.setNotNull(
true);
149 _instructionBuilder.setValue(
IB(mnemonic));
211 return op( operand );
223 if( !_instructionBuilder.isNotNull() ) {
226 IB &ib = _instructionBuilder.getValue();
300 return inst( instruction );
340 if( !_instructionBuilder.isNotNull() ) {
343 _instructionBuilder.getValue() << prefix;
354 if( !_instructionBuilder.isNotNull() ) {
357 _instructionBuilder.getValue() << hint;
368 if( !_instructionBuilder.isNotNull() ) {
371 _instructionBuilder.getValue() << hint;
394 _assembler.assemble( _context, instruction, _result );
398 if( assembledInstruction ) {
399 _assembledInstructions.push_back( *assembledInstruction );
427 return _assembledInstructions;
447 if( _instructionBuilder.isNotNull() ) {
449 Instruction instruction = _instructionBuilder.getValue().build();
451 _instructionBuilder.setNotNull(
false);
453 *
this << instruction;
470 return _parserContext.getConfig();
478 return _parserContext.getConfig();
505 _parserContext.setSymbolTable( symbolTable );
525 std::vector<AssembledInstruction> _assembledInstructions;
527 fcml_usize _codeLength;
An instruction builder.
Definition: fcml_common.hpp:6624
C++ wrapper for FCML assembler.
fcml_usize getCodeLength() const
Gets number of bytes in the buffer.
Definition: fcml_assembler.hpp:124
Parser wrapper.
Definition: fcml_parser.hpp:383
static SAFlush FLUSH()
Creates flush indicated for "shift" operators.
Definition: fcml_stateful_assembler.hpp:462
void setThrowExceptionOnError(bool throwExceptionOnError)
Sets the way how the error handling is done.
Definition: fcml_assembler.hpp:475
fcml_usize getCodeLength()
Gets the code length of all assembled instructions available.
Definition: fcml_stateful_assembler.hpp:436
Assembler result.
Definition: fcml_assembler.hpp:177
Illegal state exception.
Definition: fcml_common.hpp:228
StatefulAssembler & op(const Address &address)
Adds the new address operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:263
Assembling failed.
Definition: fcml_assembler.hpp:45
std::vector< AssembledInstruction > & getAssembledInstructions()
Gets all chosen assembled instructions.
Definition: fcml_stateful_assembler.hpp:425
std::basic_string< fcml_char > fcml_cstring
By using this type definition here, it will be definitely much easier to support UNICODE in future re...
Definition: fcml_common.hpp:53
Address operand.
Definition: fcml_common.hpp:3847
x86 - 64 register representation.
Definition: fcml_common.hpp:1574
Wraps operand hint and exposes factory methods for instruction hints.
Definition: fcml_common.hpp:436
void flush()
Assembles all pending instructions.
Definition: fcml_stateful_assembler.hpp:446
Assembler context.
Definition: fcml_assembler.hpp:498
Wrapper for nullable value types.
Definition: fcml_common.hpp:120
ParserConfig & getParserConfig()
Gets configuration used by parser if parsing is supported.
Definition: fcml_stateful_assembler.hpp:477
#define FCML_TEXT(x)
Used to code literal strings.
Definition: fcml_types.h:61
StatefulAssembler & op(const Operand &operand)
Adds an operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:222
void setSymbolTable(SymbolTable *symbolTable)
Sets a new symbol table for the parser.
Definition: fcml_stateful_assembler.hpp:504
Describes far pointer.
Definition: fcml_common.hpp:3148
Definition: fcml_assembler.hpp:39
Wraps instruction hint and exposes factory methods for instruction hints.
Definition: fcml_common.hpp:377
virtual ~StatefulAssembler()
Destructor.
Definition: fcml_stateful_assembler.hpp:77
Parser configuration.
Definition: fcml_parser.hpp:53
Parser result.
Definition: fcml_parser.hpp:271
Instruction operand.
Definition: fcml_common.hpp:4247
Represents integer value.
Definition: fcml_common.hpp:675
void setIncrementIp(bool incrementIp)
Definition: fcml_assembler.hpp:427
An assembler wrapper.
Definition: fcml_assembler.hpp:696
void op(const Operand &operand)
Sets a next operand for the instruction.
Definition: fcml_common.hpp:6716
Describes an assembled instruction.
Definition: fcml_assembler.hpp:55
StatefulAssembler & inst(const Instruction &instruction)
Assembles an instruction in the given instruction builder.
Definition: fcml_stateful_assembler.hpp:383
StatefulAssembler(Assembler &assembler, AssemblerContext &context, bool enableParser=false)
Creates a stateful assembler for the given assembler and assembler context.
Definition: fcml_stateful_assembler.hpp:65
SymbolTable * getSymbolTable()
Gets symbol table used together with the parser.
Definition: fcml_stateful_assembler.hpp:495
fcml_st_symbol_table & getSymbolTable()
Gets native FCML symbol table.
Definition: fcml_symbols.hpp:177
StatefulAssembler & op(const Register ®)
Adds the new register operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:239
StatefulAssembler & op(const FarPointer &pointer)
Adds the new far pointer operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:275
StatefulAssembler & operator<<(const IB &ib)
Adds instruction builder to the stateful assembler.
Definition: fcml_stateful_assembler.hpp:94
StatefulAssembler & inst(const fcml_cstring &mnemonic)
Creates an instruction builder for the given mnemonic.
Definition: fcml_stateful_assembler.hpp:136
CodeIterator getCodeIterator()
Gets iterator which allows to iterate through the whole machine code byte by byte.
Definition: fcml_stateful_assembler.hpp:414
void setThrowExceptionOnError(bool throwExceptionOnError)
Sets exception on error flag.
Definition: fcml_parser.hpp:133
Describes an instruction.
Definition: fcml_common.hpp:6207
Wraps instruction prefix and prepares factory methods for the hints.
Definition: fcml_common.hpp:287
const ParserConfig & getParserConfig() const
Gets configuration used by parser if parsing is supported.
Definition: fcml_stateful_assembler.hpp:469
Assembler configuration.
Definition: fcml_assembler.hpp:311
Parser context.
Definition: fcml_parser.hpp:149
Definition: fcml_symbols.hpp:142
StatefulAssembler & op(const Integer &imm)
Adds the new immediate operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:251
Dialect & getDialect() const
Gets dialect associated with the assembler.
Definition: fcml_assembler.hpp:821
const SymbolTable * getSymbolTable() const
Gets symbol table used together with the parser.
Definition: fcml_stateful_assembler.hpp:486
Used only to indicate the need of the flush operation.
Definition: fcml_stateful_assembler.hpp:52
Iterates over machine code bytes from assembled instructions.
Definition: fcml_assembler.hpp:838
It's a stateful assembler which can be used to assemble instructions one by one on the fly...
Definition: fcml_stateful_assembler.hpp:48
C++ wrapper for instruction parser.
StatefulAssembler & add(const IB &ib)
Adds instruction builder to the stateful assembler.
Definition: fcml_stateful_assembler.hpp:109