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 );
143 _parser->
parse( _parserContext, mnemonic, _parserResult );
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;
525 std::vector<AssembledInstruction> _assembledInstructions;
527 fcml_usize _codeLength;
An instruction builder.
Definition: fcml_common.hpp:6624
C++ wrapper for FCML assembler.
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
fcml_ip getIP() const
Gets instruction pointer held by the entry point.
Definition: fcml_common.hpp:616
Assembling failed.
Definition: fcml_assembler.hpp:45
std::vector< AssembledInstruction > & getAssembledInstructions()
Gets all chosen assembled instructions.
Definition: fcml_stateful_assembler.hpp:425
const ParserConfig & getConfig() const
Gets the parser configuration associated with the context.
Definition: fcml_parser.hpp:183
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
StatefulAssembler & set(const InstructionHint &hint)
Adds an instruction level hint to the instruction being built.
Definition: fcml_stateful_assembler.hpp:353
Wrapper for nullable value types.
Definition: fcml_common.hpp:120
StatefulAssembler & set(const InstructionPrefix &prefix)
Adds a prefix to the instruction being built.
Definition: fcml_stateful_assembler.hpp:339
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
const AssembledInstruction * getChosenInstruction() const
Gets instruction chosen by the assembler as the preferred one.
Definition: fcml_assembler.hpp:195
Definition: fcml_assembler.hpp:39
fcml_ceh_error parse(ParserContext &ctx, const fcml_cstring &instruction, ParserResult &parserResult)
Parses instruction given in the parameters.
Definition: fcml_parser.hpp:406
fcml_ceh_error assemble(AssemblerContext &ctx, const Instruction &instruction, AssemblerResult &result)
Assembles given generic instruction model.
Definition: fcml_assembler.hpp:736
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
const SymbolTable * getSymbolTable() const
Gets the symbol table associated with the context.
Definition: fcml_parser.hpp:233
Parser result.
Definition: fcml_parser.hpp:271
Instruction operand.
Definition: fcml_common.hpp:4247
Represents integer value.
Definition: fcml_common.hpp:675
const EntryPoint & getEntryPoint() const
Gets reference to the constant entry point instance associated with the context.
Definition: fcml_assembler.hpp:559
void setIncrementIp(bool incrementIp)
Definition: fcml_assembler.hpp:427
const AssemblerConf & getConfig() const
Gets constant assembler configuration associated with the context.
Definition: fcml_assembler.hpp:527
StatefulAssembler & set(const OperandHint &hint)
Adds an operand level hint to the instruction being built.
Definition: fcml_stateful_assembler.hpp:367
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
void setSymbolTable(SymbolTable *symbolTable)
Sets a symbol table for the instruction.
Definition: fcml_parser.hpp:253
StatefulAssembler & op(const Register ®)
Adds the new register operand to the instruction builder associated with the buffer.
Definition: fcml_stateful_assembler.hpp:239
fcml_usize getCodeLength() const
Gets number of bytes in the buffer.
Definition: fcml_assembler.hpp:124
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
const SymbolTable * getSymbolTable() const
Gets symbol table used together with the parser.
Definition: fcml_stateful_assembler.hpp:486
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
Assembler configuration.
Definition: fcml_assembler.hpp:311
Parser context.
Definition: fcml_parser.hpp:149
const ParserConfig & getParserConfig() const
Gets configuration used by parser if parsing is supported.
Definition: fcml_stateful_assembler.hpp:469
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
Used only to indicate the need of the flush operation.
Definition: fcml_stateful_assembler.hpp:52
Dialect & getDialect() const
Gets dialect associated with the assembler.
Definition: fcml_assembler.hpp:821
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
void setIp(fcml_ip ip)
Gets a new instruction pointer.
Definition: fcml_parser.hpp:213
C++ wrapper for instruction parser.
StatefulAssembler & add(const IB &ib)
Adds instruction builder to the stateful assembler.
Definition: fcml_stateful_assembler.hpp:109
const Instruction & getInstruction() const
Gets the parsed instruction.
Definition: fcml_parser.hpp:297