![]() |
V-Gears 0
Free Final Fantasy VII engine.
|
Structure for representing an instruction. More...
#include <Instruction.h>
Public Member Functions | |
virtual std::ostream & | Print (std::ostream &output) const |
Print the instruction to a stream. More... | |
virtual bool | IsJump () const |
Checks if the instruction is a jump of some sort. More... | |
virtual bool | IsCondJump () const |
Checks if the instruction is a conditional jump. More... | |
virtual bool | IsUncondJump () const |
Checks if the instruction is an unconditional jump. More... | |
virtual bool | IsStackOp () const |
Checks if the instruction is a stack operation. More... | |
virtual bool | IsFuncCall () const |
Checks if the instruction is a call to a script function. More... | |
virtual bool | IsReturn () const |
Checks if the instruction is a return statement. More... | |
virtual bool | IsKernelCall () const |
Checks if the instruction is a call to a kernel function. More... | |
virtual bool | IsLoad () const |
Checks if the instruction is a load operation. More... | |
virtual bool | IsStore () const |
Checks if the instruction is a store operation. More... | |
virtual uint32 | GetDestAddress () const |
Returns the destination address of a jump instruction. More... | |
virtual void | ProcessInst (Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen)=0 |
Process an instruction for code generation. More... | |
uint32 | GetOpcode () const |
Retrieves the instruction opcode. More... | |
void | SetOpcode (uint32 opcode) |
Sets the instruction opcode. More... | |
uint32 | GetAddress () const |
Retrieves the instruction address. More... | |
void | SetAddress (uint32 address) |
Sets the instruction address. More... | |
std::string | GetName () const |
Retrieves the instruction name (the opcode name). More... | |
void | SetName (std::string name) |
int16 | GetStackChange () const |
Checks how much the instruction changes the stack pointer. More... | |
void | SetStackChange (int16 stack_change) |
Defines how much the instruction changes the stack pointer. More... | |
std::vector< ValuePtr > | GetParams () const |
Retrieves the list of instruction parameters. More... | |
ValuePtr | GetParam (uint32 index) const |
Retrieves a instruction parameter. More... | |
void | SetParams (std::vector< ValuePtr > params) |
Sets the instructions parameters. More... | |
void | AddParam (ValuePtr value) |
Adds a parameter to the instructions. More... | |
std::string | GetCodeGenData () const |
Retrieves metadata for code generation. More... | |
void | SetCodeGenData (std::string code_gen_data) |
Sets metadata for code generation. More... | |
bool | LabelRequired () const |
Checks if the instruction requires a label. More... | |
void | SetLabelRequired (bool required) |
Indicates if the instruction needs a label. More... | |
Static Public Attributes | |
static int | INST_TYPE_BINARY_OP |
Binary operation (e.g. More... | |
static int | INST_TYPE_BOOL_NEGATE |
Boolean negation. More... | |
static int | INST_TYPE_CALL |
Regular function call. More... | |
static int | INST_TYPE_COND_JUMP |
Conditional jump. More... | |
static int | INST_TYPE_DUP |
Instruction duplicates the most recent stack entry. More... | |
static int | INST_TYPE_JUMP |
Unconditional jump. More... | |
static int | INST_TYPE_KERNEL_CALL |
Kernel functions. More... | |
static int | INST_TYPE_LOAD |
Load value from memory. More... | |
static int | INST_TYPE_RETURN |
Return from regular function call. More... | |
static int | INST_TYPE_STACK |
Stack allocation or deallocation (altering stack pointer). More... | |
static int | INST_TYPE_STORE |
Store value in memory. More... | |
static int | INST_TYPE_UNARY_OP_PRE |
Unary operation (e.g. More... | |
static int | INST_TYPE_UNARY_OP_POST |
Unary operation with operator placed after the operator. More... | |
Protected Attributes | |
uint32 | opcode_ |
The instruction opcode. More... | |
uint32 | address_ |
The instruction address. More... | |
std::string | name_ |
The instruction name (opcode name). More... | |
int16 | stack_change_ |
How much this instruction changes the stack pointer by. More... | |
std::vector< ValuePtr > | params_ |
Array of parameters used for the instruction. More... | |
std::string | code_gen_data_ |
String containing metadata for code generation. More... | |
bool | label_required_ = false |
Indicates if a label is required. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &output, const Instruction *inst) |
Operator overload to output an Instruction to a stream. More... | |
Additional Inherited Members | |
![]() | |
RefCounted () | |
virtual | ~RefCounted () |
Structure for representing an instruction.
void Instruction::AddParam | ( | ValuePtr | value | ) |
Adds a parameter to the instructions.
[in] | value | The parameter to add. |
uint32 Instruction::GetAddress | ( | ) | const |
Retrieves the instruction address.
std::string Instruction::GetCodeGenData | ( | ) | const |
Retrieves metadata for code generation.
See the extended documentation for details.
|
virtual |
Returns the destination address of a jump instruction.
WrongTypeException | if instruction is not a jump. |
Reimplemented in FieldUncondJumpInstruction, WorldCondJumpInstruction, WorldUncondJumpInstruction, and FieldCondJumpInstruction.
std::string Instruction::GetName | ( | ) | const |
Retrieves the instruction name (the opcode name).
uint32 Instruction::GetOpcode | ( | ) | const |
Retrieves the instruction opcode.
Retrieves a instruction parameter.
[in] | index | Index of the parameter to retrieve. |
std::vector< ValuePtr > Instruction::GetParams | ( | ) | const |
Retrieves the list of instruction parameters.
int16 Instruction::GetStackChange | ( | ) | const |
Checks how much the instruction changes the stack pointer.
|
virtual |
Checks if the instruction is a conditional jump.
Reimplemented in CondJumpInstruction.
|
virtual |
Checks if the instruction is a call to a script function.
Reimplemented in FieldUncondJumpInstruction, CallInstruction, and WorldUncondJumpInstruction.
|
virtual |
Checks if the instruction is a jump of some sort.
|
virtual |
Checks if the instruction is a call to a kernel function.
Reimplemented in KernelCallInstruction.
|
virtual |
Checks if the instruction is a load operation.
Reimplemented in LoadInstruction.
|
virtual |
Checks if the instruction is a return statement.
Reimplemented in ReturnInstruction.
|
virtual |
Checks if the instruction is a stack operation.
Reimplemented in StackInstruction.
|
virtual |
Checks if the instruction is a store operation.
Reimplemented in StoreInstruction.
|
virtual |
Checks if the instruction is an unconditional jump.
Reimplemented in FieldUncondJumpInstruction, WorldUncondJumpInstruction, and UncondJumpInstruction.
bool Instruction::LabelRequired | ( | ) | const |
Checks if the instruction requires a label.
|
virtual |
Print the instruction to a stream.
[out] | output | The stream to write to. |
Reimplemented in FieldCondJumpInstruction, FieldUncondJumpInstruction, WorldCondJumpInstruction, and WorldUncondJumpInstruction.
|
pure virtual |
Process an instruction for code generation.
[in] | function | The function the instruction is in. |
[in] | stack | The current stack. |
[in] | engine | The Engine used for code generation. |
[in] | code_gen | The CodeGenerator used for code generation. |
Implemented in PasCFakeInstruction, SubOpcodeFakeInstruction, FieldBackgroundInstruction, FieldCameraInstruction, FieldControlFlowInstruction, FieldMathInstruction, FieldMediaInstruction, FieldModelInstruction, FieldModuleInstruction, FieldNoOperationInstruction, FieldPartyInstruction, FieldUncategorizedInstruction, FieldUncondJumpInstruction, FieldWalkmeshInstruction, FieldWindowInstruction, FieldCondJumpInstruction, BinaryOpStackInstruction, BoolNegateStackInstruction, DupStackInstruction, KernelCallStackInstruction, ReturnInstruction, UnaryOpPostfixStackInstruction, UnaryOpPrefixStackInstruction, UncondJumpInstruction, WorldBinaryEqualStackInstruction, WorldCondJumpInstruction, WorldKernelCallInstruction, WorldLoadBankInstruction, WorldLoadInstruction, WorldNoOutputInstruction, WorldStackInstruction, WorldStoreInstruction, WorldSubStackInstruction, and WorldUncondJumpInstruction.
void Instruction::SetAddress | ( | uint32 | address | ) |
Sets the instruction address.
[in] | address | The address. |
void Instruction::SetCodeGenData | ( | std::string | code_gen_data | ) |
Sets metadata for code generation.
See the extended documentation for details.
[in] | code_gen_data | Code generator metadata. |
void Instruction::SetLabelRequired | ( | bool | required | ) |
Indicates if the instruction needs a label.
void Instruction::SetName | ( | std::string | name | ) |
void Instruction::SetOpcode | ( | uint32 | opcode | ) |
Sets the instruction opcode.
[in] | opcode | The opcode. |
void Instruction::SetParams | ( | std::vector< ValuePtr > | params | ) |
Sets the instructions parameters.
[in] | params | The list of instruction parameters. |
void Instruction::SetStackChange | ( | int16 | stack_change | ) |
Defines how much the instruction changes the stack pointer.
[in] | stack_change | Bytes the instruction changes the stack pointer by. |
|
friend |
Operator overload to output an Instruction to a stream.
[out] | output | The stream to output to. |
[in] | inst | The Instruction to output. |
|
protected |
The instruction address.
|
protected |
String containing metadata for code generation.
See the extended documentation for details.
|
static |
Binary operation (e.g.
+, &&, etc.), including comparisons.
|
static |
Boolean negation.
|
static |
Regular function call.
|
static |
Conditional jump.
|
static |
Instruction duplicates the most recent stack entry.
|
static |
Unconditional jump.
|
static |
Kernel functions.
|
static |
Load value from memory.
|
static |
Return from regular function call.
|
static |
Stack allocation or deallocation (altering stack pointer).
|
static |
Store value in memory.
|
static |
Unary operation with operator placed after the operator.
|
static |
Unary operation (e.g.
!) with operator placed before the operator.
|
protected |
Indicates if a label is required.
|
protected |
The instruction name (opcode name).
|
protected |
The instruction opcode.
|
protected |
Array of parameters used for the instruction.
|
protected |
How much this instruction changes the stack pointer by.