Bytecode: rename several classes and class members, for consistency and clarity
parent
22709f8225
commit
f55019c41e
|
@ -39,7 +39,7 @@ Writer::Writer(const filesystem::path& filename)
|
|||
|
||||
template<>
|
||||
Writer&
|
||||
operator<<(Writer& code_file, const FCALL_& instr)
|
||||
operator<<(Writer& code_file, const FCALL& instr)
|
||||
{
|
||||
code_file.instructions_positions.push_back(code_file.tellp());
|
||||
|
||||
|
@ -47,7 +47,7 @@ operator<<(Writer& code_file, const FCALL_& instr)
|
|||
code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
|
||||
};
|
||||
|
||||
write_member(instr.op_code);
|
||||
write_member(instr.tag);
|
||||
write_member(instr.nb_output_arguments);
|
||||
write_member(instr.nb_input_arguments);
|
||||
write_member(instr.indx);
|
||||
|
@ -69,7 +69,7 @@ operator<<(Writer& code_file, const FCALL_& instr)
|
|||
|
||||
template<>
|
||||
Writer&
|
||||
operator<<(Writer& code_file, const FBEGINBLOCK_& instr)
|
||||
operator<<(Writer& code_file, const FBEGINBLOCK& instr)
|
||||
{
|
||||
code_file.instructions_positions.push_back(code_file.tellp());
|
||||
|
||||
|
@ -77,7 +77,7 @@ operator<<(Writer& code_file, const FBEGINBLOCK_& instr)
|
|||
code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
|
||||
};
|
||||
|
||||
write_member(instr.op_code);
|
||||
write_member(instr.tag);
|
||||
write_member(instr.size);
|
||||
write_member(instr.type);
|
||||
for (int i = 0; i < instr.size; i++)
|
||||
|
|
261
src/Bytecode.hh
261
src/Bytecode.hh
|
@ -35,7 +35,7 @@ namespace Bytecode
|
|||
{
|
||||
|
||||
// The different tags encoding a bytecode instruction
|
||||
enum class Tags
|
||||
enum class Tag
|
||||
{
|
||||
FLDZ, // Loads a zero onto the stack
|
||||
FLDC, // Loads a constant term onto the stack
|
||||
|
@ -131,8 +131,8 @@ class Writer;
|
|||
|
||||
struct Instruction
|
||||
{
|
||||
const Tags op_code;
|
||||
explicit Instruction(Tags op_code_arg) : op_code {op_code_arg}
|
||||
const Tag tag;
|
||||
explicit Instruction(Tag tag_arg) : tag {tag_arg}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -146,41 +146,41 @@ protected:
|
|||
};
|
||||
|
||||
template<typename T1>
|
||||
class TagWithOneArgument : public Instruction
|
||||
class InstructionWithOneArgument : public Instruction
|
||||
{
|
||||
protected:
|
||||
T1 arg1;
|
||||
|
||||
public:
|
||||
TagWithOneArgument(Tags op_code_arg, T1 arg_arg1) : Instruction {op_code_arg}, arg1 {arg_arg1}
|
||||
InstructionWithOneArgument(Tag tag_arg, T1 arg_arg1) : Instruction {tag_arg}, arg1 {arg_arg1}
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
// See Instruction destructor for the rationale
|
||||
~TagWithOneArgument() = default;
|
||||
~InstructionWithOneArgument() = default;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2>
|
||||
class TagWithTwoArguments : public Instruction
|
||||
class InstructionWithTwoArguments : public Instruction
|
||||
{
|
||||
protected:
|
||||
T1 arg1;
|
||||
T2 arg2;
|
||||
|
||||
public:
|
||||
TagWithTwoArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2) :
|
||||
Instruction {op_code_arg}, arg1 {arg_arg1}, arg2 {arg_arg2}
|
||||
InstructionWithTwoArguments(Tag tag_arg, T1 arg_arg1, T2 arg_arg2) :
|
||||
Instruction {tag_arg}, arg1 {arg_arg1}, arg2 {arg_arg2}
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
// See Instruction destructor for the rationale
|
||||
~TagWithTwoArguments() = default;
|
||||
~InstructionWithTwoArguments() = default;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
class TagWithThreeArguments : public Instruction
|
||||
class InstructionWithThreeArguments : public Instruction
|
||||
{
|
||||
protected:
|
||||
T1 arg1;
|
||||
|
@ -188,18 +188,18 @@ protected:
|
|||
T3 arg3;
|
||||
|
||||
public:
|
||||
TagWithThreeArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) :
|
||||
Instruction {op_code_arg}, arg1 {arg_arg1}, arg2 {arg_arg2}, arg3 {arg_arg3}
|
||||
InstructionWithThreeArguments(Tag tag_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) :
|
||||
Instruction {tag_arg}, arg1 {arg_arg1}, arg2 {arg_arg2}, arg3 {arg_arg3}
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
// See Instruction destructor for the rationale
|
||||
~TagWithThreeArguments() = default;
|
||||
~InstructionWithThreeArguments() = default;
|
||||
};
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
class TagWithFourArguments : public Instruction
|
||||
class InstructionWithFourArguments : public Instruction
|
||||
{
|
||||
protected:
|
||||
T1 arg1;
|
||||
|
@ -208,8 +208,8 @@ protected:
|
|||
T4 arg4;
|
||||
|
||||
public:
|
||||
TagWithFourArguments(Tags op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) :
|
||||
Instruction {op_code_arg},
|
||||
InstructionWithFourArguments(Tag tag_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) :
|
||||
Instruction {tag_arg},
|
||||
arg1 {arg_arg1},
|
||||
arg2 {arg_arg2},
|
||||
arg3 {move(arg_arg3)},
|
||||
|
@ -219,45 +219,45 @@ public:
|
|||
|
||||
protected:
|
||||
// See Instruction destructor for the rationale
|
||||
~TagWithFourArguments() = default;
|
||||
~InstructionWithFourArguments() = default;
|
||||
};
|
||||
|
||||
class FLDZ_ final : public Instruction
|
||||
class FLDZ final : public Instruction
|
||||
{
|
||||
public:
|
||||
FLDZ_() : Instruction {Tags::FLDZ}
|
||||
FLDZ() : Instruction {Tag::FLDZ}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class FEND_ final : public Instruction
|
||||
class FEND final : public Instruction
|
||||
{
|
||||
public:
|
||||
FEND_() : Instruction {Tags::FEND}
|
||||
FEND() : Instruction {Tag::FEND}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class FENDBLOCK_ final : public Instruction
|
||||
class FENDBLOCK final : public Instruction
|
||||
{
|
||||
public:
|
||||
FENDBLOCK_() : Instruction {Tags::FENDBLOCK}
|
||||
FENDBLOCK() : Instruction {Tag::FENDBLOCK}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class FENDEQU_ final : public Instruction
|
||||
class FENDEQU final : public Instruction
|
||||
{
|
||||
public:
|
||||
FENDEQU_() : Instruction {Tags::FENDEQU}
|
||||
FENDEQU() : Instruction {Tag::FENDEQU}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class FDIMT_ final : public TagWithOneArgument<int>
|
||||
class FDIMT final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FDIMT_(int size_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FDIMT, size_arg}
|
||||
explicit FDIMT(int size_arg) : InstructionWithOneArgument {Tag::FDIMT, size_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -267,10 +267,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FDIMST_ final : public TagWithOneArgument<int>
|
||||
class FDIMST final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FDIMST_(int size_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FDIMST, size_arg}
|
||||
explicit FDIMST(int size_arg) : InstructionWithOneArgument {Tag::FDIMST, size_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -280,10 +280,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDC_ final : public TagWithOneArgument<double>
|
||||
class FLDC final : public InstructionWithOneArgument<double>
|
||||
{
|
||||
public:
|
||||
explicit FLDC_(double value_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDC, value_arg}
|
||||
explicit FLDC(double value_arg) : InstructionWithOneArgument {Tag::FLDC, value_arg}
|
||||
{
|
||||
}
|
||||
double
|
||||
|
@ -293,10 +293,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDU_ final : public TagWithOneArgument<int>
|
||||
class FLDU final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDU_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDU, pos_arg}
|
||||
explicit FLDU(int pos_arg) : InstructionWithOneArgument {Tag::FLDU, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -306,10 +306,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDSU_ final : public TagWithOneArgument<int>
|
||||
class FLDSU final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDSU_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDSU, pos_arg}
|
||||
explicit FLDSU(int pos_arg) : InstructionWithOneArgument {Tag::FLDSU, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -319,10 +319,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDR_ final : public TagWithOneArgument<int>
|
||||
class FLDR final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDR_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDR, pos_arg}
|
||||
explicit FLDR(int pos_arg) : InstructionWithOneArgument {Tag::FLDR, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -332,10 +332,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDT_ final : public TagWithOneArgument<int>
|
||||
class FLDT final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDT_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDT, pos_arg}
|
||||
explicit FLDT(int pos_arg) : InstructionWithOneArgument {Tag::FLDT, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -345,10 +345,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDST_ final : public TagWithOneArgument<int>
|
||||
class FLDST final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDST_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FLDST, pos_arg}
|
||||
explicit FLDST(int pos_arg) : InstructionWithOneArgument {Tag::FLDST, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -358,10 +358,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPT_ final : public TagWithOneArgument<int>
|
||||
class FSTPT final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPT_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPT, pos_arg}
|
||||
explicit FSTPT(int pos_arg) : InstructionWithOneArgument {Tag::FSTPT, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -371,10 +371,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPST_ final : public TagWithOneArgument<int>
|
||||
class FSTPST final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPST_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPST, pos_arg}
|
||||
explicit FSTPST(int pos_arg) : InstructionWithOneArgument {Tag::FSTPST, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -384,10 +384,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPR_ final : public TagWithOneArgument<int>
|
||||
class FSTPR final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPR_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPR, pos_arg}
|
||||
explicit FSTPR(int pos_arg) : InstructionWithOneArgument {Tag::FSTPR, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -397,10 +397,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPU_ final : public TagWithOneArgument<int>
|
||||
class FSTPU final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPU_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPU, pos_arg}
|
||||
explicit FSTPU(int pos_arg) : InstructionWithOneArgument {Tag::FSTPU, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -410,10 +410,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPSU_ final : public TagWithOneArgument<int>
|
||||
class FSTPSU final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPSU_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPSU, pos_arg}
|
||||
explicit FSTPSU(int pos_arg) : InstructionWithOneArgument {Tag::FSTPSU, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -423,10 +423,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPG_ final : public TagWithOneArgument<int>
|
||||
class FSTPG final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPG_(int pos_arg) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPG, pos_arg}
|
||||
explicit FSTPG(int pos_arg) : InstructionWithOneArgument {Tag::FSTPG, pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -436,11 +436,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPG2_ final : public TagWithTwoArguments<int, int>
|
||||
class FSTPG2 final : public InstructionWithTwoArguments<int, int>
|
||||
{
|
||||
public:
|
||||
FSTPG2_(int row_arg, int col_arg) :
|
||||
TagWithTwoArguments::TagWithTwoArguments {Tags::FSTPG2, row_arg, col_arg}
|
||||
FSTPG2(int row_arg, int col_arg) : InstructionWithTwoArguments {Tag::FSTPG2, row_arg, col_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -455,12 +454,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPG3_ final : public TagWithFourArguments<int, int, int, int>
|
||||
class FSTPG3 final : public InstructionWithFourArguments<int, int, int, int>
|
||||
{
|
||||
public:
|
||||
FSTPG3_(int row_arg, int col_arg, int lag_arg, int col_pos_arg) :
|
||||
TagWithFourArguments::TagWithFourArguments {Tags::FSTPG3, row_arg, col_arg, lag_arg,
|
||||
col_pos_arg}
|
||||
FSTPG3(int row_arg, int col_arg, int lag_arg, int col_pos_arg) :
|
||||
InstructionWithFourArguments {Tag::FSTPG3, row_arg, col_arg, lag_arg, col_pos_arg}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -485,11 +483,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FUNARY_ final : public TagWithOneArgument<UnaryOpcode>
|
||||
class FUNARY final : public InstructionWithOneArgument<UnaryOpcode>
|
||||
{
|
||||
public:
|
||||
explicit FUNARY_(UnaryOpcode op_type_arg) :
|
||||
TagWithOneArgument::TagWithOneArgument {Tags::FUNARY, op_type_arg}
|
||||
explicit FUNARY(UnaryOpcode op_type_arg) : InstructionWithOneArgument {Tag::FUNARY, op_type_arg}
|
||||
{
|
||||
}
|
||||
UnaryOpcode
|
||||
|
@ -499,11 +496,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FBINARY_ final : public TagWithOneArgument<BinaryOpcode>
|
||||
class FBINARY final : public InstructionWithOneArgument<BinaryOpcode>
|
||||
{
|
||||
public:
|
||||
explicit FBINARY_(BinaryOpcode op_type_arg) :
|
||||
TagWithOneArgument::TagWithOneArgument {Tags::FBINARY, op_type_arg}
|
||||
explicit FBINARY(BinaryOpcode op_type_arg) :
|
||||
InstructionWithOneArgument {Tag::FBINARY, op_type_arg}
|
||||
{
|
||||
}
|
||||
BinaryOpcode
|
||||
|
@ -513,11 +510,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FTRINARY_ final : public TagWithOneArgument<TrinaryOpcode>
|
||||
class FTRINARY final : public InstructionWithOneArgument<TrinaryOpcode>
|
||||
{
|
||||
public:
|
||||
explicit FTRINARY_(TrinaryOpcode op_type_arg) :
|
||||
TagWithOneArgument::TagWithOneArgument {Tags::FTRINARY, op_type_arg}
|
||||
explicit FTRINARY(TrinaryOpcode op_type_arg) :
|
||||
InstructionWithOneArgument {Tag::FTRINARY, op_type_arg}
|
||||
{
|
||||
}
|
||||
TrinaryOpcode
|
||||
|
@ -527,11 +524,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FJMPIFEVAL_ final : public TagWithOneArgument<int>
|
||||
class FJMPIFEVAL final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FJMPIFEVAL_(int arg_pos) :
|
||||
TagWithOneArgument::TagWithOneArgument {Tags::FJMPIFEVAL, arg_pos}
|
||||
explicit FJMPIFEVAL(int arg_pos) : InstructionWithOneArgument {Tag::FJMPIFEVAL, arg_pos}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -541,10 +537,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FJMP_ final : public TagWithOneArgument<int>
|
||||
class FJMP final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FJMP_(int arg_pos) : TagWithOneArgument::TagWithOneArgument {Tags::FJMP, arg_pos}
|
||||
explicit FJMP(int arg_pos) : InstructionWithOneArgument {Tag::FJMP, arg_pos}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -554,10 +550,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FLDTEF_ final : public TagWithOneArgument<int>
|
||||
class FLDTEF final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FLDTEF_(int number) : TagWithOneArgument::TagWithOneArgument {Tags::FLDTEF, number}
|
||||
explicit FLDTEF(int number) : InstructionWithOneArgument {Tag::FLDTEF, number}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -567,10 +563,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FSTPTEF_ final : public TagWithOneArgument<int>
|
||||
class FSTPTEF final : public InstructionWithOneArgument<int>
|
||||
{
|
||||
public:
|
||||
explicit FSTPTEF_(int number) : TagWithOneArgument::TagWithOneArgument {Tags::FSTPTEF, number}
|
||||
explicit FSTPTEF(int number) : InstructionWithOneArgument {Tag::FSTPTEF, number}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -580,10 +576,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FLDTEFD_ final : public TagWithTwoArguments<int, int>
|
||||
class FLDTEFD final : public InstructionWithTwoArguments<int, int>
|
||||
{
|
||||
public:
|
||||
FLDTEFD_(int indx, int row) : TagWithTwoArguments::TagWithTwoArguments {Tags::FLDTEFD, indx, row}
|
||||
FLDTEFD(int indx, int row) : InstructionWithTwoArguments {Tag::FLDTEFD, indx, row}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -598,11 +594,10 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPTEFD_ final : public TagWithTwoArguments<int, int>
|
||||
class FSTPTEFD final : public InstructionWithTwoArguments<int, int>
|
||||
{
|
||||
public:
|
||||
FSTPTEFD_(int indx, int row) :
|
||||
TagWithTwoArguments::TagWithTwoArguments {Tags::FSTPTEFD, indx, row}
|
||||
FSTPTEFD(int indx, int row) : InstructionWithTwoArguments {Tag::FSTPTEFD, indx, row}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -617,11 +612,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDTEFDD_ final : public TagWithThreeArguments<int, int, int>
|
||||
class FLDTEFDD final : public InstructionWithThreeArguments<int, int, int>
|
||||
{
|
||||
public:
|
||||
FLDTEFDD_(int indx, int row, int col) :
|
||||
TagWithThreeArguments::TagWithThreeArguments {Tags::FLDTEFDD, indx, row, col}
|
||||
FLDTEFDD(int indx, int row, int col) :
|
||||
InstructionWithThreeArguments {Tag::FLDTEFDD, indx, row, col}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -641,11 +636,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPTEFDD_ final : public TagWithThreeArguments<int, int, int>
|
||||
class FSTPTEFDD final : public InstructionWithThreeArguments<int, int, int>
|
||||
{
|
||||
public:
|
||||
FSTPTEFDD_(int indx, int row, int col) :
|
||||
TagWithThreeArguments::TagWithThreeArguments {Tags::FSTPTEF, indx, row, col}
|
||||
FSTPTEFDD(int indx, int row, int col) :
|
||||
InstructionWithThreeArguments {Tag::FSTPTEF, indx, row, col}
|
||||
{
|
||||
}
|
||||
int
|
||||
|
@ -665,11 +660,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDVS_ final : public TagWithTwoArguments<SymbolType, int>
|
||||
class FLDVS final : public InstructionWithTwoArguments<SymbolType, int>
|
||||
{
|
||||
public:
|
||||
FLDVS_(SymbolType type_arg, int pos_arg) :
|
||||
TagWithTwoArguments::TagWithTwoArguments {Tags::FLDVS, type_arg, pos_arg}
|
||||
FLDVS(SymbolType type_arg, int pos_arg) :
|
||||
InstructionWithTwoArguments {Tag::FLDVS, type_arg, pos_arg}
|
||||
{
|
||||
}
|
||||
SymbolType
|
||||
|
@ -684,11 +679,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDSV_ final : public TagWithTwoArguments<SymbolType, int>
|
||||
class FLDSV final : public InstructionWithTwoArguments<SymbolType, int>
|
||||
{
|
||||
public:
|
||||
FLDSV_(SymbolType type_arg, int pos_arg) :
|
||||
TagWithTwoArguments::TagWithTwoArguments {Tags::FLDSV, type_arg, pos_arg}
|
||||
FLDSV(SymbolType type_arg, int pos_arg) :
|
||||
InstructionWithTwoArguments {Tag::FLDSV, type_arg, pos_arg}
|
||||
{
|
||||
}
|
||||
SymbolType
|
||||
|
@ -703,11 +698,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPSV_ final : public TagWithTwoArguments<SymbolType, int>
|
||||
class FSTPSV final : public InstructionWithTwoArguments<SymbolType, int>
|
||||
{
|
||||
public:
|
||||
FSTPSV_(SymbolType type_arg, int pos_arg) :
|
||||
TagWithTwoArguments::TagWithTwoArguments {Tags::FSTPSV, type_arg, pos_arg}
|
||||
FSTPSV(SymbolType type_arg, int pos_arg) :
|
||||
InstructionWithTwoArguments {Tag::FSTPSV, type_arg, pos_arg}
|
||||
{
|
||||
}
|
||||
SymbolType
|
||||
|
@ -722,11 +717,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FLDV_ final : public TagWithThreeArguments<SymbolType, int, int>
|
||||
class FLDV final : public InstructionWithThreeArguments<SymbolType, int, int>
|
||||
{
|
||||
public:
|
||||
FLDV_(SymbolType type_arg, int pos_arg, int lead_lag_arg) :
|
||||
TagWithThreeArguments::TagWithThreeArguments {Tags::FLDV, type_arg, pos_arg, lead_lag_arg}
|
||||
FLDV(SymbolType type_arg, int pos_arg, int lead_lag_arg) :
|
||||
InstructionWithThreeArguments {Tag::FLDV, type_arg, pos_arg, lead_lag_arg}
|
||||
{
|
||||
}
|
||||
SymbolType
|
||||
|
@ -746,11 +741,11 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FSTPV_ final : public TagWithThreeArguments<SymbolType, int, int>
|
||||
class FSTPV final : public InstructionWithThreeArguments<SymbolType, int, int>
|
||||
{
|
||||
public:
|
||||
FSTPV_(SymbolType type_arg, int pos_arg, int lead_lag_arg) :
|
||||
TagWithThreeArguments::TagWithThreeArguments {Tags::FSTPV, type_arg, pos_arg, lead_lag_arg}
|
||||
FSTPV(SymbolType type_arg, int pos_arg, int lead_lag_arg) :
|
||||
InstructionWithThreeArguments {Tag::FSTPV, type_arg, pos_arg, lead_lag_arg}
|
||||
{
|
||||
}
|
||||
SymbolType
|
||||
|
@ -770,7 +765,7 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FCALL_ final : public Instruction
|
||||
class FCALL final : public Instruction
|
||||
{
|
||||
template<typename B>
|
||||
friend Writer& operator<<(Writer& code_file, const B& instr);
|
||||
|
@ -783,9 +778,9 @@ private:
|
|||
ExternalFunctionCallType call_type;
|
||||
|
||||
public:
|
||||
FCALL_(int nb_output_arguments_arg, int nb_input_arguments_arg, string func_name_arg,
|
||||
int indx_arg, ExternalFunctionCallType call_type_arg) :
|
||||
Instruction {Tags::FCALL},
|
||||
FCALL(int nb_output_arguments_arg, int nb_input_arguments_arg, string func_name_arg, int indx_arg,
|
||||
ExternalFunctionCallType call_type_arg) :
|
||||
Instruction {Tag::FCALL},
|
||||
nb_output_arguments {nb_output_arguments_arg},
|
||||
nb_input_arguments {nb_input_arguments_arg},
|
||||
indx {indx_arg},
|
||||
|
@ -795,9 +790,9 @@ public:
|
|||
}
|
||||
/* Deserializing constructor.
|
||||
Updates the code pointer to point beyond the bytes read. */
|
||||
FCALL_(char*& code) : Instruction {Tags::FCALL}
|
||||
FCALL(char*& code) : Instruction {Tag::FCALL}
|
||||
{
|
||||
code += sizeof(op_code);
|
||||
code += sizeof(tag);
|
||||
|
||||
auto read_member = [&code](auto& member) {
|
||||
member = *reinterpret_cast<add_pointer_t<decltype(member)>>(code);
|
||||
|
@ -890,7 +885,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FNUMEXPR_ final : public Instruction
|
||||
class FNUMEXPR final : public Instruction
|
||||
{
|
||||
private:
|
||||
ExpressionType expression_type;
|
||||
|
@ -899,25 +894,25 @@ private:
|
|||
int dvariable1; // For derivatives, type-specific ID of the derivation variable
|
||||
int lag1; // For derivatives, lead/lag of the derivation variable
|
||||
public:
|
||||
FNUMEXPR_(const ExpressionType expression_type_arg, int equation_arg) :
|
||||
Instruction {Tags::FNUMEXPR},
|
||||
FNUMEXPR(const ExpressionType expression_type_arg, int equation_arg) :
|
||||
Instruction {Tag::FNUMEXPR},
|
||||
expression_type {expression_type_arg},
|
||||
equation {equation_arg},
|
||||
dvariable1 {0},
|
||||
lag1 {0}
|
||||
{
|
||||
}
|
||||
FNUMEXPR_(const ExpressionType expression_type_arg, int equation_arg, int dvariable1_arg) :
|
||||
Instruction {Tags::FNUMEXPR},
|
||||
FNUMEXPR(const ExpressionType expression_type_arg, int equation_arg, int dvariable1_arg) :
|
||||
Instruction {Tag::FNUMEXPR},
|
||||
expression_type {expression_type_arg},
|
||||
equation {equation_arg},
|
||||
dvariable1 {dvariable1_arg},
|
||||
lag1 {0}
|
||||
{
|
||||
}
|
||||
FNUMEXPR_(const ExpressionType expression_type_arg, int equation_arg, int dvariable1_arg,
|
||||
int lag1_arg) :
|
||||
Instruction {Tags::FNUMEXPR},
|
||||
FNUMEXPR(const ExpressionType expression_type_arg, int equation_arg, int dvariable1_arg,
|
||||
int lag1_arg) :
|
||||
Instruction {Tag::FNUMEXPR},
|
||||
expression_type {expression_type_arg},
|
||||
equation {equation_arg},
|
||||
dvariable1 {dvariable1_arg},
|
||||
|
@ -946,7 +941,7 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
class FBEGINBLOCK_ final : public Instruction
|
||||
class FBEGINBLOCK final : public Instruction
|
||||
{
|
||||
template<typename B>
|
||||
friend Writer& operator<<(Writer& code_file, const B& instr);
|
||||
|
@ -968,11 +963,11 @@ public:
|
|||
/* Constructor when derivatives w.r.t. exogenous are present (only makes
|
||||
sense when there is no block-decomposition, since there is no provision for
|
||||
derivatives w.r.t. endogenous not belonging to the block) */
|
||||
FBEGINBLOCK_(int size_arg, BlockSimulationType type_arg, int first_element, int block_size,
|
||||
const vector<int>& variable_arg, const vector<int>& equation_arg, bool is_linear_arg,
|
||||
int u_count_int_arg, int nb_col_jacob_arg, int det_exo_size_arg, int exo_size_arg,
|
||||
vector<int> det_exogenous_arg, vector<int> exogenous_arg) :
|
||||
Instruction {Tags::FBEGINBLOCK},
|
||||
FBEGINBLOCK(int size_arg, BlockSimulationType type_arg, int first_element, int block_size,
|
||||
const vector<int>& variable_arg, const vector<int>& equation_arg, bool is_linear_arg,
|
||||
int u_count_int_arg, int nb_col_jacob_arg, int det_exo_size_arg, int exo_size_arg,
|
||||
vector<int> det_exogenous_arg, vector<int> exogenous_arg) :
|
||||
Instruction {Tag::FBEGINBLOCK},
|
||||
size {size_arg},
|
||||
type {type_arg},
|
||||
variable {variable_arg.begin() + first_element,
|
||||
|
@ -989,10 +984,10 @@ public:
|
|||
{
|
||||
}
|
||||
// Constructor when derivatives w.r.t. exogenous are absent
|
||||
FBEGINBLOCK_(int size_arg, BlockSimulationType type_arg, int first_element, int block_size,
|
||||
const vector<int>& variable_arg, const vector<int>& equation_arg, bool is_linear_arg,
|
||||
int u_count_int_arg, int nb_col_jacob_arg) :
|
||||
Instruction {Tags::FBEGINBLOCK},
|
||||
FBEGINBLOCK(int size_arg, BlockSimulationType type_arg, int first_element, int block_size,
|
||||
const vector<int>& variable_arg, const vector<int>& equation_arg, bool is_linear_arg,
|
||||
int u_count_int_arg, int nb_col_jacob_arg) :
|
||||
Instruction {Tag::FBEGINBLOCK},
|
||||
size {size_arg},
|
||||
type {type_arg},
|
||||
variable {variable_arg.begin() + first_element,
|
||||
|
@ -1008,9 +1003,9 @@ public:
|
|||
}
|
||||
/* Deserializing constructor.
|
||||
Updates the code pointer to point beyond the bytes read. */
|
||||
FBEGINBLOCK_(char*& code) : Instruction {Tags::FBEGINBLOCK}
|
||||
FBEGINBLOCK(char*& code) : Instruction {Tag::FBEGINBLOCK}
|
||||
{
|
||||
code += sizeof(op_code);
|
||||
code += sizeof(tag);
|
||||
|
||||
auto read_member = [&code](auto& member) {
|
||||
member = *reinterpret_cast<add_pointer_t<decltype(member)>>(code);
|
||||
|
@ -1148,10 +1143,10 @@ operator<<(Writer& code_file, const B& instr)
|
|||
}
|
||||
|
||||
template<>
|
||||
Writer& operator<<(Writer& code_file, const FCALL_& instr);
|
||||
Writer& operator<<(Writer& code_file, const FCALL& instr);
|
||||
|
||||
template<>
|
||||
Writer& operator<<(Writer& code_file, const FBEGINBLOCK_& instr);
|
||||
Writer& operator<<(Writer& code_file, const FBEGINBLOCK& instr);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ DynamicModel::writeDynamicBytecode(const string& basename) const
|
|||
Bytecode::Writer code_file {basename + "/model/bytecode/dynamic.cod"};
|
||||
|
||||
// Declare temporary terms
|
||||
code_file << Bytecode::FDIMT_ {static_cast<int>(temporary_terms_derivatives[0].size()
|
||||
+ temporary_terms_derivatives[1].size())};
|
||||
code_file << Bytecode::FDIMT {static_cast<int>(temporary_terms_derivatives[0].size()
|
||||
+ temporary_terms_derivatives[1].size())};
|
||||
|
||||
// Declare the (single) block
|
||||
vector<int> exo(symbol_table.exo_nbr()), exo_det(symbol_table.exo_det_nbr());
|
||||
|
@ -183,19 +183,19 @@ DynamicModel::writeDynamicBytecode(const string& basename) const
|
|||
vector<int> endo_idx(symbol_table.endo_nbr());
|
||||
iota(endo_idx.begin(), endo_idx.end(), 0);
|
||||
|
||||
code_file << Bytecode::FBEGINBLOCK_ {symbol_table.endo_nbr(),
|
||||
simulation_type,
|
||||
0,
|
||||
symbol_table.endo_nbr(),
|
||||
endo_idx,
|
||||
eq_idx,
|
||||
false,
|
||||
u_count_int,
|
||||
jacobian_ncols_endo,
|
||||
symbol_table.exo_det_nbr(),
|
||||
symbol_table.exo_nbr(),
|
||||
exo_det,
|
||||
exo};
|
||||
code_file << Bytecode::FBEGINBLOCK {symbol_table.endo_nbr(),
|
||||
simulation_type,
|
||||
0,
|
||||
symbol_table.endo_nbr(),
|
||||
endo_idx,
|
||||
eq_idx,
|
||||
false,
|
||||
u_count_int,
|
||||
jacobian_ncols_endo,
|
||||
symbol_table.exo_det_nbr(),
|
||||
symbol_table.exo_nbr(),
|
||||
exo_det,
|
||||
exo};
|
||||
|
||||
writeBytecodeHelper<true>(code_file);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ DynamicModel::writeDynamicBlockBytecode(const string& basename) const
|
|||
}
|
||||
|
||||
// Temporary variables declaration
|
||||
code_file << Bytecode::FDIMT_ {static_cast<int>(blocks_temporary_terms_idxs.size())};
|
||||
code_file << Bytecode::FDIMT {static_cast<int>(blocks_temporary_terms_idxs.size())};
|
||||
|
||||
temporary_terms_t temporary_terms_written;
|
||||
|
||||
|
@ -231,19 +231,19 @@ DynamicModel::writeDynamicBlockBytecode(const string& basename) const
|
|||
? writeBlockBytecodeBinFile(bin_file, block)
|
||||
: 0};
|
||||
|
||||
code_file << Bytecode::FBEGINBLOCK_ {blocks[block].mfs_size,
|
||||
simulation_type,
|
||||
blocks[block].first_equation,
|
||||
blocks[block].size,
|
||||
endo_idx_block2orig,
|
||||
eq_idx_block2orig,
|
||||
blocks[block].linear,
|
||||
u_count,
|
||||
static_cast<int>(blocks_jacob_cols_endo[block].size())};
|
||||
code_file << Bytecode::FBEGINBLOCK {blocks[block].mfs_size,
|
||||
simulation_type,
|
||||
blocks[block].first_equation,
|
||||
blocks[block].size,
|
||||
endo_idx_block2orig,
|
||||
eq_idx_block2orig,
|
||||
blocks[block].linear,
|
||||
u_count,
|
||||
static_cast<int>(blocks_jacob_cols_endo[block].size())};
|
||||
|
||||
writeBlockBytecodeHelper<true>(code_file, block, temporary_terms_written);
|
||||
}
|
||||
code_file << Bytecode::FEND_ {};
|
||||
code_file << Bytecode::FEND {};
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -163,10 +163,10 @@ ExprNode::checkIfTemporaryTermThenWriteBytecode(
|
|||
was initially not called with steady_dynamic=true). */
|
||||
return false;
|
||||
case ExprNodeBytecodeOutputType::dynamicModel:
|
||||
code_file << Bytecode::FLDT_ {it2->second};
|
||||
code_file << Bytecode::FLDT {it2->second};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::staticModel:
|
||||
code_file << Bytecode::FLDST_ {it2->second};
|
||||
code_file << Bytecode::FLDST {it2->second};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::dynamicAssignmentLHS:
|
||||
case ExprNodeBytecodeOutputType::staticAssignmentLHS:
|
||||
|
@ -565,7 +565,7 @@ NumConstNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
assert(!isAssignmentLHSBytecodeOutput(output_type));
|
||||
if (!checkIfTemporaryTermThenWriteBytecode(code_file, output_type, temporary_terms,
|
||||
temporary_terms_idxs))
|
||||
code_file << Bytecode::FLDC_ {datatree.num_constants.getDouble(id)};
|
||||
code_file << Bytecode::FLDC {datatree.num_constants.getDouble(id)};
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1452,19 +1452,19 @@ VariableNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
switch (output_type)
|
||||
{
|
||||
case ExprNodeBytecodeOutputType::dynamicModel:
|
||||
code_file << Bytecode::FLDV_ {type, tsid, lag};
|
||||
code_file << Bytecode::FLDV {type, tsid, lag};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::staticModel:
|
||||
code_file << Bytecode::FLDSV_ {type, tsid};
|
||||
code_file << Bytecode::FLDSV {type, tsid};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::dynamicSteadyStateOperator:
|
||||
code_file << Bytecode::FLDVS_ {type, tsid};
|
||||
code_file << Bytecode::FLDVS {type, tsid};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::dynamicAssignmentLHS:
|
||||
code_file << Bytecode::FSTPV_ {type, tsid, lag};
|
||||
code_file << Bytecode::FSTPV {type, tsid, lag};
|
||||
break;
|
||||
case ExprNodeBytecodeOutputType::staticAssignmentLHS:
|
||||
code_file << Bytecode::FSTPSV_ {type, tsid};
|
||||
code_file << Bytecode::FSTPSV {type, tsid};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3286,7 +3286,7 @@ UnaryOpNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
{
|
||||
arg->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
code_file << Bytecode::FUNARY_ {op_code};
|
||||
code_file << Bytecode::FUNARY {op_code};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4562,12 +4562,12 @@ BinaryOpNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
return;
|
||||
|
||||
if (op_code == BinaryOpcode::powerDeriv)
|
||||
code_file << Bytecode::FLDC_ {static_cast<double>(powerDerivOrder)};
|
||||
code_file << Bytecode::FLDC {static_cast<double>(powerDerivOrder)};
|
||||
arg1->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
arg2->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
code_file << Bytecode::FBINARY_ {op_code};
|
||||
code_file << Bytecode::FBINARY {op_code};
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -6309,7 +6309,7 @@ TrinaryOpNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
tef_terms);
|
||||
arg3->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
code_file << Bytecode::FTRINARY_ {op_code};
|
||||
code_file << Bytecode::FTRINARY {op_code};
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -7460,9 +7460,9 @@ ExternalFunctionNode::writeBytecodeOutput(Bytecode::Writer& code_file,
|
|||
return;
|
||||
|
||||
if (!isAssignmentLHSBytecodeOutput(output_type))
|
||||
code_file << Bytecode::FLDTEF_ {getIndxInTefTerms(symb_id, tef_terms)};
|
||||
code_file << Bytecode::FLDTEF {getIndxInTefTerms(symb_id, tef_terms)};
|
||||
else
|
||||
code_file << Bytecode::FSTPTEF_ {getIndxInTefTerms(symb_id, tef_terms)};
|
||||
code_file << Bytecode::FSTPTEF {getIndxInTefTerms(symb_id, tef_terms)};
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7506,9 +7506,9 @@ ExternalFunctionNode::writeBytecodeExternalFunctionOutput(
|
|||
call_type = Bytecode::ExternalFunctionCallType::levelWithoutDerivative;
|
||||
}
|
||||
|
||||
code_file << Bytecode::FCALL_ {nb_output_arguments, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(symb_id), indx, call_type}
|
||||
<< Bytecode::FSTPTEF_ {indx};
|
||||
code_file << Bytecode::FCALL {nb_output_arguments, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(symb_id), indx, call_type}
|
||||
<< Bytecode::FSTPTEF {indx};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7839,9 +7839,9 @@ FirstDerivExternalFunctionNode::writeBytecodeOutput(
|
|||
assert(first_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
|
||||
|
||||
if (!isAssignmentLHSBytecodeOutput(output_type))
|
||||
code_file << Bytecode::FLDTEFD_ {getIndxInTefTerms(symb_id, tef_terms), inputIndex};
|
||||
code_file << Bytecode::FLDTEFD {getIndxInTefTerms(symb_id, tef_terms), inputIndex};
|
||||
else
|
||||
code_file << Bytecode::FSTPTEFD_ {getIndxInTefTerms(symb_id, tef_terms), inputIndex};
|
||||
code_file << Bytecode::FSTPTEFD {getIndxInTefTerms(symb_id, tef_terms), inputIndex};
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -8004,12 +8004,12 @@ FirstDerivExternalFunctionNode::writeBytecodeExternalFunctionOutput(
|
|||
{
|
||||
int nb_input_arguments {0};
|
||||
int nb_output_arguments {1};
|
||||
Bytecode::FCALL_ fcall {nb_output_arguments, nb_input_arguments, "jacob_element", indx,
|
||||
Bytecode::ExternalFunctionCallType::numericalFirstDerivative};
|
||||
Bytecode::FCALL fcall {nb_output_arguments, nb_input_arguments, "jacob_element", indx,
|
||||
Bytecode::ExternalFunctionCallType::numericalFirstDerivative};
|
||||
fcall.set_arg_func_name(datatree.symbol_table.getName(symb_id));
|
||||
fcall.set_row(inputIndex);
|
||||
fcall.set_nb_add_input_arguments(static_cast<int>(arguments.size()));
|
||||
code_file << fcall << Bytecode::FSTPTEFD_ {indx, inputIndex};
|
||||
code_file << fcall << Bytecode::FSTPTEFD {indx, inputIndex};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8019,11 +8019,11 @@ FirstDerivExternalFunctionNode::writeBytecodeExternalFunctionOutput(
|
|||
|
||||
int nb_output_arguments {1};
|
||||
|
||||
code_file << Bytecode::
|
||||
FCALL_ {nb_output_arguments, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(first_deriv_symb_id), indx,
|
||||
Bytecode::ExternalFunctionCallType::separatelyProvidedFirstDerivative}
|
||||
<< Bytecode::FSTPTEFD_ {indx, inputIndex};
|
||||
code_file
|
||||
<< Bytecode::FCALL {nb_output_arguments, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(first_deriv_symb_id), indx,
|
||||
Bytecode::ExternalFunctionCallType::separatelyProvidedFirstDerivative}
|
||||
<< Bytecode::FSTPTEFD {indx, inputIndex};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8344,11 +8344,11 @@ SecondDerivExternalFunctionNode::writeBytecodeOutput(
|
|||
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
|
||||
|
||||
if (!isAssignmentLHSBytecodeOutput(output_type))
|
||||
code_file << Bytecode::FLDTEFDD_ {getIndxInTefTerms(symb_id, tef_terms), inputIndex1,
|
||||
inputIndex2};
|
||||
code_file << Bytecode::FLDTEFDD {getIndxInTefTerms(symb_id, tef_terms), inputIndex1,
|
||||
inputIndex2};
|
||||
else
|
||||
code_file << Bytecode::FSTPTEFDD_ {getIndxInTefTerms(symb_id, tef_terms), inputIndex1,
|
||||
inputIndex2};
|
||||
code_file << Bytecode::FSTPTEFDD {getIndxInTefTerms(symb_id, tef_terms), inputIndex1,
|
||||
inputIndex2};
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -8379,23 +8379,23 @@ SecondDerivExternalFunctionNode::writeBytecodeExternalFunctionOutput(
|
|||
if (int indx = getIndxInTefTerms(symb_id, tef_terms);
|
||||
second_deriv_symb_id == ExternalFunctionsTable::IDNotSet)
|
||||
{
|
||||
Bytecode::FCALL_ fcall {1, 0, "hess_element", indx,
|
||||
Bytecode::ExternalFunctionCallType::numericalSecondDerivative};
|
||||
Bytecode::FCALL fcall {1, 0, "hess_element", indx,
|
||||
Bytecode::ExternalFunctionCallType::numericalSecondDerivative};
|
||||
fcall.set_arg_func_name(datatree.symbol_table.getName(symb_id));
|
||||
fcall.set_row(inputIndex1);
|
||||
fcall.set_col(inputIndex2);
|
||||
fcall.set_nb_add_input_arguments(static_cast<int>(arguments.size()));
|
||||
code_file << fcall << Bytecode::FSTPTEFDD_ {indx, inputIndex1, inputIndex2};
|
||||
code_file << fcall << Bytecode::FSTPTEFDD {indx, inputIndex1, inputIndex2};
|
||||
}
|
||||
else
|
||||
{
|
||||
tef_terms[{second_deriv_symb_id, arguments}] = static_cast<int>(tef_terms.size());
|
||||
|
||||
code_file << Bytecode::
|
||||
FCALL_ {1, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(second_deriv_symb_id), indx,
|
||||
Bytecode::ExternalFunctionCallType::separatelyProvidedSecondDerivative}
|
||||
<< Bytecode::FSTPTEFDD_ {indx, inputIndex1, inputIndex2};
|
||||
FCALL {1, static_cast<int>(arguments.size()),
|
||||
datatree.symbol_table.getName(second_deriv_symb_id), indx,
|
||||
Bytecode::ExternalFunctionCallType::separatelyProvidedSecondDerivative}
|
||||
<< Bytecode::FSTPTEFDD {indx, inputIndex1, inputIndex2};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
145
src/ModelTree.hh
145
src/ModelTree.hh
|
@ -1529,16 +1529,16 @@ ModelTree::writeBytecodeTemporaryTerms(const temporary_terms_t& tt,
|
|||
temporary_terms_idxs, tef_terms);
|
||||
|
||||
int idx {temporary_terms_idxs.at(it)};
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::TemporaryTerm, idx};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::TemporaryTerm, idx};
|
||||
it->writeBytecodeOutput(code_file, output_type, temporary_terms_union, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
|
||||
static_assert(output_type == ExprNodeBytecodeOutputType::dynamicModel
|
||||
|| output_type == ExprNodeBytecodeOutputType::staticModel);
|
||||
if constexpr (output_type == ExprNodeBytecodeOutputType::dynamicModel)
|
||||
code_file << Bytecode::FSTPT_ {idx};
|
||||
code_file << Bytecode::FSTPT {idx};
|
||||
else
|
||||
code_file << Bytecode::FSTPST_ {idx};
|
||||
code_file << Bytecode::FSTPST {idx};
|
||||
|
||||
temporary_terms_union.insert(it);
|
||||
}
|
||||
|
@ -1554,7 +1554,7 @@ ModelTree::writeBytecodeModelEquations(Bytecode::Writer& code_file,
|
|||
{
|
||||
BinaryOpNode* eq_node {equations[eq]};
|
||||
expr_t lhs {eq_node->arg1}, rhs {eq_node->arg2};
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::ModelEquation, eq};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::ModelEquation, eq};
|
||||
// Test if the right hand side of the equation is empty.
|
||||
double vrhs {1.0};
|
||||
try
|
||||
|
@ -1572,13 +1572,13 @@ ModelTree::writeBytecodeModelEquations(Bytecode::Writer& code_file,
|
|||
rhs->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::minus} << Bytecode::FSTPR_ {eq};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::minus} << Bytecode::FSTPR {eq};
|
||||
}
|
||||
else // The right hand side of the equation is empty ⇒ residual=lhs
|
||||
{
|
||||
lhs->writeBytecodeOutput(code_file, output_type, temporary_terms, temporary_terms_idxs,
|
||||
tef_terms);
|
||||
code_file << Bytecode::FSTPR_ {eq};
|
||||
code_file << Bytecode::FSTPR {eq};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1597,7 +1597,7 @@ ModelTree::writeBytecodeHelper(Bytecode::Writer& code_file) const
|
|||
code_file, tef_terms);
|
||||
writeBytecodeModelEquations<output_type>(code_file, temporary_terms_union, tef_terms);
|
||||
|
||||
code_file << Bytecode::FENDEQU_ {};
|
||||
code_file << Bytecode::FENDEQU {};
|
||||
|
||||
// Temporary terms for the Jacobian
|
||||
writeBytecodeTemporaryTerms<output_type>(temporary_terms_derivatives[1], temporary_terms_union,
|
||||
|
@ -1605,7 +1605,7 @@ ModelTree::writeBytecodeHelper(Bytecode::Writer& code_file) const
|
|||
|
||||
// Get the current code_file position and jump if “evaluate” mode
|
||||
int pos_jmpifeval {code_file.getInstructionCounter()};
|
||||
code_file << Bytecode::FJMPIFEVAL_ {0}; // Use 0 as jump offset for the time being
|
||||
code_file << Bytecode::FJMPIFEVAL {0}; // Use 0 as jump offset for the time being
|
||||
|
||||
// The Jacobian in “simulate” mode
|
||||
vector<vector<tuple<int, int, int>>> my_derivatives(symbol_table.endo_nbr());
|
||||
|
@ -1619,53 +1619,53 @@ ModelTree::writeBytecodeHelper(Bytecode::Writer& code_file) const
|
|||
int tsid {getTypeSpecificIDByDerivID(deriv_id)};
|
||||
int lag {getLagByDerivID(deriv_id)};
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative, eq,
|
||||
tsid, lag};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative, eq,
|
||||
tsid, lag};
|
||||
else
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative, eq,
|
||||
tsid};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative, eq,
|
||||
tsid};
|
||||
if (!my_derivatives[eq].size())
|
||||
my_derivatives[eq].clear();
|
||||
my_derivatives[eq].emplace_back(tsid, lag, count_u);
|
||||
d1->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
temporary_terms_idxs, tef_terms);
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPU_ {count_u};
|
||||
code_file << Bytecode::FSTPU {count_u};
|
||||
else
|
||||
code_file << Bytecode::FSTPSU_ {count_u};
|
||||
code_file << Bytecode::FSTPSU {count_u};
|
||||
count_u++;
|
||||
}
|
||||
}
|
||||
for (int i {0}; i < symbol_table.endo_nbr(); i++)
|
||||
{
|
||||
code_file << Bytecode::FLDR_ {i};
|
||||
code_file << Bytecode::FLDR {i};
|
||||
if (my_derivatives[i].size())
|
||||
{
|
||||
for (bool first_term {true}; const auto& [tsid, lag, uidx] : my_derivatives[i])
|
||||
{
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FLDU_ {uidx}
|
||||
<< Bytecode::FLDV_ {SymbolType::endogenous, tsid, lag};
|
||||
code_file << Bytecode::FLDU {uidx}
|
||||
<< Bytecode::FLDV {SymbolType::endogenous, tsid, lag};
|
||||
else
|
||||
code_file << Bytecode::FLDSU_ {uidx}
|
||||
<< Bytecode::FLDSV_ {SymbolType::endogenous, tsid};
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::times};
|
||||
code_file << Bytecode::FLDSU {uidx}
|
||||
<< Bytecode::FLDSV {SymbolType::endogenous, tsid};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::times};
|
||||
if (!exchange(first_term, false))
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::plus};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::plus};
|
||||
}
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::minus};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::minus};
|
||||
}
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPU_ {i};
|
||||
code_file << Bytecode::FSTPU {i};
|
||||
else
|
||||
code_file << Bytecode::FSTPSU_ {i};
|
||||
code_file << Bytecode::FSTPSU {i};
|
||||
}
|
||||
|
||||
// Jump unconditionally after the block
|
||||
int pos_jmp {code_file.getInstructionCounter()};
|
||||
code_file << Bytecode::FJMP_ {0}; // Use 0 as jump offset for the time being
|
||||
code_file << Bytecode::FJMP {0}; // Use 0 as jump offset for the time being
|
||||
// Update jump offset for previous JMPIFEVAL
|
||||
code_file.overwriteInstruction(pos_jmpifeval, Bytecode::FJMPIFEVAL_ {pos_jmp - pos_jmpifeval});
|
||||
code_file.overwriteInstruction(pos_jmpifeval, Bytecode::FJMPIFEVAL {pos_jmp - pos_jmpifeval});
|
||||
|
||||
// The Jacobian in “evaluate” mode
|
||||
for (const auto& [indices, d1] : derivatives[1])
|
||||
|
@ -1693,13 +1693,12 @@ ModelTree::writeBytecodeHelper(Bytecode::Writer& code_file) const
|
|||
assert(false);
|
||||
break;
|
||||
}
|
||||
code_file << Bytecode::FNUMEXPR_ {expr_type, eq, tsid, lag};
|
||||
code_file << Bytecode::FNUMEXPR {expr_type, eq, tsid, lag};
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(type == SymbolType::endogenous);
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative, eq,
|
||||
tsid};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative, eq, tsid};
|
||||
}
|
||||
|
||||
d1->writeBytecodeOutput(code_file, output_type, temporary_terms_union, temporary_terms_idxs,
|
||||
|
@ -1708,17 +1707,17 @@ ModelTree::writeBytecodeHelper(Bytecode::Writer& code_file) const
|
|||
{
|
||||
// Bytecode MEX uses a separate matrix for exogenous and exodet Jacobians
|
||||
int jacob_col {type == SymbolType::endogenous ? getJacobianCol(deriv_id, false) : tsid};
|
||||
code_file << Bytecode::FSTPG3_ {eq, tsid, lag, jacob_col};
|
||||
code_file << Bytecode::FSTPG3 {eq, tsid, lag, jacob_col};
|
||||
}
|
||||
else
|
||||
code_file << Bytecode::FSTPG2_ {eq, tsid};
|
||||
code_file << Bytecode::FSTPG2 {eq, tsid};
|
||||
}
|
||||
|
||||
// Update jump offset for previous JMP
|
||||
int pos_end_block {code_file.getInstructionCounter()};
|
||||
code_file.overwriteInstruction(pos_jmp, Bytecode::FJMP_ {pos_end_block - pos_jmp - 1});
|
||||
code_file.overwriteInstruction(pos_jmp, Bytecode::FJMP {pos_end_block - pos_jmp - 1});
|
||||
|
||||
code_file << Bytecode::FENDBLOCK_ {} << Bytecode::FEND_ {};
|
||||
code_file << Bytecode::FENDBLOCK {} << Bytecode::FEND {};
|
||||
}
|
||||
|
||||
template<bool dynamic>
|
||||
|
@ -1746,14 +1745,14 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
it->writeBytecodeExternalFunctionOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::TemporaryTerm,
|
||||
blocks_temporary_terms_idxs.at(it)};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::TemporaryTerm,
|
||||
blocks_temporary_terms_idxs.at(it)};
|
||||
it->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPT_ {blocks_temporary_terms_idxs.at(it)};
|
||||
code_file << Bytecode::FSTPT {blocks_temporary_terms_idxs.at(it)};
|
||||
else
|
||||
code_file << Bytecode::FSTPST_ {blocks_temporary_terms_idxs.at(it)};
|
||||
code_file << Bytecode::FSTPST {blocks_temporary_terms_idxs.at(it)};
|
||||
temporary_terms_union.insert(it);
|
||||
}
|
||||
};
|
||||
|
@ -1779,8 +1778,8 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
}
|
||||
else
|
||||
assert(equ_type == EquationType::evaluate);
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::ModelEquation,
|
||||
getBlockEquationID(block, i)};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::ModelEquation,
|
||||
getBlockEquationID(block, i)};
|
||||
rhs->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
lhs->writeBytecodeOutput(code_file, assignment_lhs_output_type, temporary_terms_union,
|
||||
|
@ -1795,14 +1794,14 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
[[fallthrough]];
|
||||
case BlockSimulationType::solveBackwardSimple:
|
||||
case BlockSimulationType::solveForwardSimple:
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::ModelEquation,
|
||||
getBlockEquationID(block, i)};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::ModelEquation,
|
||||
getBlockEquationID(block, i)};
|
||||
lhs->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
rhs->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::minus}
|
||||
<< Bytecode::FSTPR_ {i - block_recursive};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::minus}
|
||||
<< Bytecode::FSTPR {i - block_recursive};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1817,11 +1816,11 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
be needed in subsequent blocks. */
|
||||
write_eq_tt(blocks[block].size);
|
||||
|
||||
code_file << Bytecode::FENDEQU_ {};
|
||||
code_file << Bytecode::FENDEQU {};
|
||||
|
||||
// Get the current code_file position and jump if evaluating
|
||||
int pos_jmpifeval {code_file.getInstructionCounter()};
|
||||
code_file << Bytecode::FJMPIFEVAL_ {0}; // Use 0 as jump offset for the time being
|
||||
code_file << Bytecode::FJMPIFEVAL {0}; // Use 0 as jump offset for the time being
|
||||
|
||||
/* Write the derivatives for the “simulate” mode (not needed if the block
|
||||
is of type “evaluate backward/forward”) */
|
||||
|
@ -1835,16 +1834,16 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
{
|
||||
int eqr {getBlockEquationID(block, 0)};
|
||||
int varr {getBlockVariableID(block, 0)};
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative, eqr,
|
||||
varr, 0};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative, eqr,
|
||||
varr, 0};
|
||||
// Get contemporaneous derivative of the single variable in the block
|
||||
if (auto it {blocks_derivatives[block].find({0, 0, 0})};
|
||||
it != blocks_derivatives[block].end())
|
||||
it->second->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
else
|
||||
code_file << Bytecode::FLDZ_ {};
|
||||
code_file << Bytecode::FSTPG_ {0};
|
||||
code_file << Bytecode::FLDZ {};
|
||||
code_file << Bytecode::FSTPG {0};
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1869,14 +1868,14 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
&& (simulation_type == BlockSimulationType::solveForwardComplete
|
||||
|| simulation_type == BlockSimulationType::solveBackwardComplete))
|
||||
continue;
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative,
|
||||
eqr, varr, lag};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative,
|
||||
eqr, varr, lag};
|
||||
d1->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPU_ {count_u};
|
||||
code_file << Bytecode::FSTPU {count_u};
|
||||
else
|
||||
code_file << Bytecode::FSTPSU_ {count_u};
|
||||
code_file << Bytecode::FSTPSU {count_u};
|
||||
Uf[eqr].emplace_back(count_u, varr, lag);
|
||||
count_u++;
|
||||
}
|
||||
|
@ -1884,25 +1883,25 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
for (int i {0}; i < block_size; i++)
|
||||
if (i >= block_recursive)
|
||||
{
|
||||
code_file << Bytecode::FLDR_ {i - block_recursive} << Bytecode::FLDZ_ {};
|
||||
code_file << Bytecode::FLDR {i - block_recursive} << Bytecode::FLDZ {};
|
||||
|
||||
int eqr {getBlockEquationID(block, i)};
|
||||
for (const auto& [index_u, var, lag] : Uf[eqr])
|
||||
{
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FLDU_ {index_u}
|
||||
<< Bytecode::FLDV_ {SymbolType::endogenous, var, lag};
|
||||
code_file << Bytecode::FLDU {index_u}
|
||||
<< Bytecode::FLDV {SymbolType::endogenous, var, lag};
|
||||
else
|
||||
code_file << Bytecode::FLDSU_ {index_u}
|
||||
<< Bytecode::FLDSV_ {SymbolType::endogenous, var};
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::times}
|
||||
<< Bytecode::FBINARY_ {BinaryOpcode::plus};
|
||||
code_file << Bytecode::FLDSU {index_u}
|
||||
<< Bytecode::FLDSV {SymbolType::endogenous, var};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::times}
|
||||
<< Bytecode::FBINARY {BinaryOpcode::plus};
|
||||
}
|
||||
code_file << Bytecode::FBINARY_ {BinaryOpcode::minus};
|
||||
code_file << Bytecode::FBINARY {BinaryOpcode::minus};
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPU_ {i - block_recursive};
|
||||
code_file << Bytecode::FSTPU {i - block_recursive};
|
||||
else
|
||||
code_file << Bytecode::FSTPSU_ {i - block_recursive};
|
||||
code_file << Bytecode::FSTPSU {i - block_recursive};
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1913,9 +1912,9 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
|
||||
// Jump unconditionally after the block
|
||||
int pos_jmp {code_file.getInstructionCounter()};
|
||||
code_file << Bytecode::FJMP_ {0}; // Use 0 as jump offset for the time being
|
||||
code_file << Bytecode::FJMP {0}; // Use 0 as jump offset for the time being
|
||||
// Update jump offset for previous JMPIFEVAL
|
||||
code_file.overwriteInstruction(pos_jmpifeval, Bytecode::FJMPIFEVAL_ {pos_jmp - pos_jmpifeval});
|
||||
code_file.overwriteInstruction(pos_jmpifeval, Bytecode::FJMPIFEVAL {pos_jmp - pos_jmpifeval});
|
||||
|
||||
// Write the derivatives for the “evaluate” mode
|
||||
for (const auto& [indices, d] : blocks_derivatives[block])
|
||||
|
@ -1923,24 +1922,24 @@ ModelTree::writeBlockBytecodeHelper(Bytecode::Writer& code_file, int block,
|
|||
const auto& [eq, var, lag] {indices};
|
||||
int eqr {getBlockEquationID(block, eq)};
|
||||
int varr {getBlockVariableID(block, var)};
|
||||
code_file << Bytecode::FNUMEXPR_ {Bytecode::ExpressionType::FirstEndoDerivative, eqr, varr,
|
||||
lag};
|
||||
code_file << Bytecode::FNUMEXPR {Bytecode::ExpressionType::FirstEndoDerivative, eqr, varr,
|
||||
lag};
|
||||
d->writeBytecodeOutput(code_file, output_type, temporary_terms_union,
|
||||
blocks_temporary_terms_idxs, tef_terms);
|
||||
assert(eq >= block_recursive);
|
||||
if constexpr (dynamic)
|
||||
code_file << Bytecode::FSTPG3_ {eq - block_recursive, var, lag,
|
||||
getBlockJacobianEndoCol(block, var, lag)};
|
||||
code_file << Bytecode::FSTPG3 {eq - block_recursive, var, lag,
|
||||
getBlockJacobianEndoCol(block, var, lag)};
|
||||
else
|
||||
code_file << Bytecode::FSTPG2_ {eq - block_recursive,
|
||||
getBlockJacobianEndoCol(block, var, lag)};
|
||||
code_file << Bytecode::FSTPG2 {eq - block_recursive,
|
||||
getBlockJacobianEndoCol(block, var, lag)};
|
||||
}
|
||||
|
||||
// Update jump offset for previous JMP
|
||||
int pos_end_block {code_file.getInstructionCounter()};
|
||||
code_file.overwriteInstruction(pos_jmp, Bytecode::FJMP_ {pos_end_block - pos_jmp - 1});
|
||||
code_file.overwriteInstruction(pos_jmp, Bytecode::FJMP {pos_end_block - pos_jmp - 1});
|
||||
|
||||
code_file << Bytecode::FENDBLOCK_ {};
|
||||
code_file << Bytecode::FENDBLOCK {};
|
||||
}
|
||||
|
||||
template<bool dynamic>
|
||||
|
|
|
@ -138,17 +138,17 @@ StaticModel::writeStaticBytecode(const string& basename) const
|
|||
iota(endo_idx.begin(), endo_idx.end(), 0);
|
||||
|
||||
// Declare temporary terms and the (single) block
|
||||
code_file << Bytecode::FDIMST_ {static_cast<int>(temporary_terms_derivatives[0].size()
|
||||
+ temporary_terms_derivatives[1].size())}
|
||||
<< Bytecode::FBEGINBLOCK_ {symbol_table.endo_nbr(),
|
||||
BlockSimulationType::solveForwardComplete,
|
||||
0,
|
||||
symbol_table.endo_nbr(),
|
||||
endo_idx,
|
||||
eq_idx,
|
||||
false,
|
||||
u_count_int,
|
||||
symbol_table.endo_nbr()};
|
||||
code_file << Bytecode::FDIMST {static_cast<int>(temporary_terms_derivatives[0].size()
|
||||
+ temporary_terms_derivatives[1].size())}
|
||||
<< Bytecode::FBEGINBLOCK {symbol_table.endo_nbr(),
|
||||
BlockSimulationType::solveForwardComplete,
|
||||
0,
|
||||
symbol_table.endo_nbr(),
|
||||
endo_idx,
|
||||
eq_idx,
|
||||
false,
|
||||
u_count_int,
|
||||
symbol_table.endo_nbr()};
|
||||
|
||||
writeBytecodeHelper<false>(code_file);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ StaticModel::writeStaticBlockBytecode(const string& basename) const
|
|||
}
|
||||
|
||||
// Temporary variables declaration
|
||||
code_file << Bytecode::FDIMST_ {static_cast<int>(blocks_temporary_terms_idxs.size())};
|
||||
code_file << Bytecode::FDIMST {static_cast<int>(blocks_temporary_terms_idxs.size())};
|
||||
|
||||
temporary_terms_t temporary_terms_written;
|
||||
|
||||
|
@ -181,19 +181,19 @@ StaticModel::writeStaticBlockBytecode(const string& basename) const
|
|||
? writeBlockBytecodeBinFile(bin_file, block)
|
||||
: 0};
|
||||
|
||||
code_file << Bytecode::FBEGINBLOCK_ {blocks[block].mfs_size,
|
||||
simulation_type,
|
||||
blocks[block].first_equation,
|
||||
block_size,
|
||||
endo_idx_block2orig,
|
||||
eq_idx_block2orig,
|
||||
blocks[block].linear,
|
||||
u_count,
|
||||
block_size};
|
||||
code_file << Bytecode::FBEGINBLOCK {blocks[block].mfs_size,
|
||||
simulation_type,
|
||||
blocks[block].first_equation,
|
||||
block_size,
|
||||
endo_idx_block2orig,
|
||||
eq_idx_block2orig,
|
||||
blocks[block].linear,
|
||||
u_count,
|
||||
block_size};
|
||||
|
||||
writeBlockBytecodeHelper<false>(code_file, block, temporary_terms_written);
|
||||
}
|
||||
code_file << Bytecode::FEND_ {};
|
||||
code_file << Bytecode::FEND {};
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue