2008-02-03 11:28:36 +01:00
/*
2023-01-05 16:40:04 +01:00
* Copyright © 2007 - 2023 Dynare Team
2008-02-03 11:28:36 +01:00
*
* This file is part of Dynare .
*
* Dynare is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* Dynare is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2021-06-09 16:52:20 +02:00
* along with Dynare . If not , see < https : //www.gnu.org/licenses/>.
2008-02-03 11:28:36 +01:00
*/
2022-06-16 17:52:14 +02:00
# ifndef _BYTECODE_HH
# define _BYTECODE_HH
2014-12-17 09:37:43 +01:00
2009-10-16 18:34:27 +02:00
# include <fstream>
2009-10-23 13:26:29 +02:00
# include <vector>
2022-06-17 15:33:54 +02:00
# include <utility>
2022-06-23 14:28:13 +02:00
# include <ios>
2023-01-05 16:40:04 +01:00
# include <filesystem>
2022-06-23 14:28:13 +02:00
# include "CommonEnums.hh"
2022-06-16 17:52:14 +02:00
# ifdef BYTECODE_MEX
2021-02-01 14:46:08 +01:00
# include <dynmex.h>
2022-06-16 17:52:14 +02:00
# include <cstring>
2009-10-16 18:34:27 +02:00
# endif
using namespace std ;
2022-06-16 17:52:14 +02:00
// The different opcodes of bytecode
2021-02-01 11:10:59 +01:00
enum class Tags
2009-10-16 18:34:27 +02:00
{
2022-06-17 12:17:57 +02:00
FLDZ , // Loads a zero onto the stack
FLDC , // Loads a constant term onto the stack
FDIMT , // Defines the number of temporary terms - dynamic context (the period has to be indicated)
FDIMST , // Defines the number of temporary terms - static context (the period hasn’ t to be indicated)
FLDT , // Loads a temporary term onto the stack - dynamic context (the period has to be indicated)
FLDST , // Loads a temporary term onto the stack - static context (the period hasn’ t to be indicated)
FSTPT , // Stores a temporary term from the stack - dynamic context (the period has to be indicated)
FSTPST , // Stores a temporary term from the stack - static context (the period hasn’ t to be indicated)
FLDU , // Loads an element of the vector U onto the stack - dynamic context (the period has to be indicated)
FLDSU , // Loads an element of the vector U onto the stack - static context (the period hasn’ t to be indicated)
FSTPU , // Stores an element of the vector U from the stack - dynamic context (the period has to be indicated)
FSTPSU , // Stores an element of the vector U from the stack - static context (the period hasn’ t to be indicated)
FLDV , // Loads a variable (described in SymbolType) onto the stack - dynamic context (the period has to be indicated)
FLDSV , // Loads a variable (described in SymbolType) onto the stack - static context (the period hasn’ t to be indicated)
FLDVS , // Loads a variable (described in SymbolType) onto the stack - dynamic context but inside the STEADY_STATE operator (the period hasn’ t to be indicated)
FSTPV , // Stores a variable (described in SymbolType) from the stack - dynamic context (the period has to be indicated)
FSTPSV , // Stores a variable (described in SymbolType) from the stack - static context (the period hasn’ t to be indicated)
FLDR , // Loads a residual onto the stack
FSTPR , // Stores a residual from the stack
FSTPG , // Stores a derivative from the stack
FSTPG2 , // Stores a derivative matrix for a static model from the stack
FSTPG3 , // Stores a derivative matrix for a dynamic model from the stack
FUNARY , // A unary operator
FBINARY , // A binary operator
FTRINARY , // A trinary operator
FJMPIFEVAL , // Jump if evaluate = true
FJMP , // Jump
FBEGINBLOCK , // Marks the beginning of a model block
FENDBLOCK , // Marks the end of a model block
FENDEQU , // Marks the last equation of the block; for a block that has to be solved, the derivatives appear just after this flag
FEND , // Marks the end of the model code
FNUMEXPR , // Stores the expression type and references
FCALL , // Call an external function
FLDTEF , // Loads the result of an external function onto the stack
FSTPTEF , // Stores the result of an external function from the stack
FLDTEFD , // Loads the result of the 1st derivative of an external function onto the stack
FSTPTEFD , // Stores the result of the 1st derivative of an external function from the stack
FLDTEFDD , // Loads the result of the 2nd derivative of an external function onto the stack
FSTPTEFDD // Stores the result of the 2nd derivative of an external function from the stack
2009-12-16 18:13:23 +01:00
} ;
2008-02-03 11:28:36 +01:00
2021-02-01 11:10:59 +01:00
enum class ExpressionType
2010-01-22 17:42:08 +01:00
{
2019-12-20 16:59:30 +01:00
TemporaryTerm ,
ModelEquation ,
FirstEndoDerivative ,
FirstOtherEndoDerivative ,
FirstExoDerivative ,
FirstExodetDerivative ,
2010-01-22 17:42:08 +01:00
} ;
2022-07-08 16:00:02 +02:00
enum class ExternalFunctionCallType
{
levelWithoutDerivative ,
levelWithFirstDerivative ,
levelWithFirstAndSecondDerivative ,
separatelyProvidedFirstDerivative ,
numericalFirstDerivative ,
separatelyProvidedSecondDerivative ,
numericalSecondDerivative
} ;
2009-12-16 18:13:23 +01:00
struct Block_contain_type
{
int Equation , Variable , Own_Derivative ;
} ;
2009-10-16 18:34:27 +02:00
2022-06-23 14:28:13 +02:00
class BytecodeWriter ;
2022-07-26 18:26:18 +02:00
struct BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
2022-07-26 18:26:18 +02:00
const Tags op_code ;
2009-10-16 18:34:27 +02:00
} ;
2018-10-04 18:00:30 +02:00
template < typename T1 >
2022-06-17 15:33:54 +02:00
class TagWithOneArgument : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
protected :
T1 arg1 ;
public :
2022-06-17 15:33:54 +02:00
TagWithOneArgument ( Tags op_code_arg , T1 arg_arg1 ) : BytecodeInstruction { op_code_arg } ,
2021-02-01 11:10:59 +01:00
arg1 { arg_arg1 }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2018-10-04 18:00:30 +02:00
template < typename T1 , typename T2 >
2022-06-17 15:33:54 +02:00
class TagWithTwoArguments : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
protected :
T1 arg1 ;
T2 arg2 ;
public :
2021-02-01 11:10:59 +01:00
TagWithTwoArguments ( Tags op_code_arg , T1 arg_arg1 , T2 arg_arg2 ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { op_code_arg } , arg1 { arg_arg1 } , arg2 { arg_arg2 }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2018-10-04 18:00:30 +02:00
template < typename T1 , typename T2 , typename T3 >
2022-06-17 15:33:54 +02:00
class TagWithThreeArguments : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
protected :
T1 arg1 ;
T2 arg2 ;
T3 arg3 ;
public :
2021-02-01 11:10:59 +01:00
TagWithThreeArguments ( Tags op_code_arg , T1 arg_arg1 , T2 arg_arg2 , T3 arg_arg3 ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { op_code_arg } , arg1 { arg_arg1 } , arg2 { arg_arg2 } , arg3 { arg_arg3 }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2018-10-04 18:00:30 +02:00
template < typename T1 , typename T2 , typename T3 , typename T4 >
2022-06-17 15:33:54 +02:00
class TagWithFourArguments : public BytecodeInstruction
2010-07-23 11:20:24 +02:00
{
protected :
T1 arg1 ;
T2 arg2 ;
T3 arg3 ;
T4 arg4 ;
public :
2021-02-01 11:10:59 +01:00
TagWithFourArguments ( Tags op_code_arg , T1 arg_arg1 , T2 arg_arg2 , T3 arg_arg3 , T4 arg_arg4 ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { op_code_arg } , arg1 { arg_arg1 } , arg2 { arg_arg2 } ,
2021-02-01 11:10:59 +01:00
arg3 { move ( arg_arg3 ) } , arg4 { arg_arg4 }
2010-07-23 11:20:24 +02:00
{
} ;
} ;
2022-06-17 15:33:54 +02:00
class FLDZ_ : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
public :
2022-06-17 15:33:54 +02:00
FLDZ_ ( ) : BytecodeInstruction { Tags : : FLDZ }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-17 15:33:54 +02:00
class FEND_ : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
public :
2022-06-17 15:33:54 +02:00
FEND_ ( ) : BytecodeInstruction { Tags : : FEND }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-17 15:33:54 +02:00
class FENDBLOCK_ : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
public :
2022-06-17 15:33:54 +02:00
FENDBLOCK_ ( ) : BytecodeInstruction { Tags : : FENDBLOCK }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-17 15:33:54 +02:00
class FENDEQU_ : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
public :
2022-06-17 15:33:54 +02:00
FENDEQU_ ( ) : BytecodeInstruction { Tags : : FENDEQU }
2009-12-16 18:13:23 +01:00
{
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FDIMT_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FDIMT_ ( int size_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FDIMT , size_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_size ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FDIMST_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FDIMST_ ( int size_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FDIMST , size_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_size ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
class FLDC_ : public TagWithOneArgument < double >
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDC_ ( double value_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDC , value_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-17 14:29:12 +02:00
double
2009-12-16 18:13:23 +01:00
get_value ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDU_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDU_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDU , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDSU_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDSU_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDSU , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDR_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDR_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDR , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDT_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDT_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDT , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDST_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDST_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDST , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPT_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPT_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPT , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPST_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPST_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPST , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPR_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPR_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPR , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPU_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPU_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPU , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPSU_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPSU_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPSU , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPG_ : public TagWithOneArgument < int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPG_ ( int pos_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPG , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPG2_ : public TagWithTwoArguments < int , int >
2010-01-22 11:03:29 +01:00
{
public :
2022-06-20 17:49:09 +02:00
FSTPG2_ ( int row_arg , int col_arg ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FSTPG2 , row_arg , col_arg }
2010-01-22 11:03:29 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-01-22 11:03:29 +01:00
get_row ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-01-22 11:03:29 +01:00
get_col ( )
{
return arg2 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FSTPG3_ : public TagWithFourArguments < int , int , int , int >
2010-07-23 11:20:24 +02:00
{
public :
2022-06-20 17:49:09 +02:00
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 }
2010-07-23 11:20:24 +02:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_row ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_col ( )
{
return arg2 ;
} ;
2022-06-17 14:29:12 +02:00
int
2010-07-23 11:20:24 +02:00
get_lag ( )
{
return arg2 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_col_pos ( )
{
return arg4 ;
} ;
} ;
2010-01-22 11:03:29 +01:00
2022-06-20 14:44:55 +02:00
class FUNARY_ : public TagWithOneArgument < UnaryOpcode >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 14:44:55 +02:00
explicit FUNARY_ ( UnaryOpcode op_type_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FUNARY , op_type_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
UnaryOpcode
2009-12-16 18:13:23 +01:00
get_op_type ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 14:44:55 +02:00
class FBINARY_ : public TagWithOneArgument < BinaryOpcode >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 14:44:55 +02:00
explicit FBINARY_ ( BinaryOpcode op_type_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FBINARY , op_type_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
BinaryOpcode
2009-12-16 18:13:23 +01:00
get_op_type ( )
{
return arg1 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 14:44:55 +02:00
class FTRINARY_ : public TagWithOneArgument < TrinaryOpcode >
2010-04-16 16:54:55 +02:00
{
public :
2022-06-20 14:44:55 +02:00
explicit FTRINARY_ ( TrinaryOpcode op_type_arg ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FTRINARY , op_type_arg }
2010-04-16 16:54:55 +02:00
{
} ;
2022-06-20 14:44:55 +02:00
TrinaryOpcode
2010-04-16 16:54:55 +02:00
get_op_type ( )
{
return arg1 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FJMPIFEVAL_ : public TagWithOneArgument < int >
2010-07-23 11:20:24 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FJMPIFEVAL_ ( int arg_pos ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FJMPIFEVAL , arg_pos }
2010-07-23 11:20:24 +02:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_pos ( )
{
return arg1 ;
}
} ;
2022-06-20 17:49:09 +02:00
class FJMP_ : public TagWithOneArgument < int >
2010-07-23 11:20:24 +02:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FJMP_ ( int arg_pos ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FJMP , arg_pos }
2010-07-23 11:20:24 +02:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_pos ( )
{
return arg1 ;
}
} ;
2022-06-20 17:49:09 +02:00
class FLDTEF_ : public TagWithOneArgument < int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FLDTEF_ ( int number ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FLDTEF , number }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_number ( )
{
return arg1 ;
}
} ;
2022-06-20 17:49:09 +02:00
class FSTPTEF_ : public TagWithOneArgument < int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
explicit FSTPTEF_ ( int number ) : TagWithOneArgument : : TagWithOneArgument { Tags : : FSTPTEF , number }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_number ( )
{
return arg1 ;
}
} ;
2022-06-20 17:49:09 +02:00
class FLDTEFD_ : public TagWithTwoArguments < int , int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
FLDTEFD_ ( int indx , int row ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FLDTEFD , indx , row }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_indx ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_row ( )
{
return arg2 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FSTPTEFD_ : public TagWithTwoArguments < int , int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
FSTPTEFD_ ( int indx , int row ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FSTPTEFD , indx , row }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_indx ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_row ( )
{
return arg2 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FLDTEFDD_ : public TagWithThreeArguments < int , int , int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
FLDTEFDD_ ( int indx , int row , int col ) : TagWithThreeArguments : : TagWithThreeArguments { Tags : : FLDTEFDD , indx , row , col }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_indx ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_row ( )
{
return arg2 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_col ( )
{
return arg3 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FSTPTEFDD_ : public TagWithThreeArguments < int , int , int >
2010-12-10 11:50:27 +01:00
{
public :
2022-06-20 17:49:09 +02:00
FSTPTEFDD_ ( int indx , int row , int col ) : TagWithThreeArguments : : TagWithThreeArguments { Tags : : FSTPTEF , indx , row , col }
2010-12-10 11:50:27 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_indx ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_row ( )
{
return arg2 ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_col ( )
{
return arg3 ;
} ;
} ;
2022-06-20 17:49:09 +02:00
class FLDVS_ : public TagWithTwoArguments < SymbolType , int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
FLDVS_ ( SymbolType type_arg , int pos_arg ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FLDVS , type_arg , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
SymbolType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg2 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDSV_ : public TagWithTwoArguments < SymbolType , int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
FLDSV_ ( SymbolType type_arg , int pos_arg ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FLDSV , type_arg , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
SymbolType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg2 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPSV_ : public TagWithTwoArguments < SymbolType , int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
FSTPSV_ ( SymbolType type_arg , int pos_arg ) : TagWithTwoArguments : : TagWithTwoArguments { Tags : : FSTPSV , type_arg , pos_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
SymbolType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg2 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FLDV_ : public TagWithThreeArguments < SymbolType , int , int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
FLDV_ ( SymbolType type_arg , int pos_arg , int lead_lag_arg ) :
2022-06-20 14:44:55 +02:00
TagWithThreeArguments : : TagWithThreeArguments { Tags : : FLDV , type_arg , pos_arg , lead_lag_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
SymbolType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg2 ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_lead_lag ( )
{
return arg3 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-20 17:49:09 +02:00
class FSTPV_ : public TagWithThreeArguments < SymbolType , int , int >
2009-10-16 18:34:27 +02:00
{
public :
2022-06-20 17:49:09 +02:00
FSTPV_ ( SymbolType type_arg , int pos_arg , int lead_lag_arg ) :
2022-06-20 14:44:55 +02:00
TagWithThreeArguments : : TagWithThreeArguments { Tags : : FSTPV , type_arg , pos_arg , lead_lag_arg }
2009-12-16 18:13:23 +01:00
{
} ;
2022-06-20 14:44:55 +02:00
SymbolType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return arg1 ;
} ;
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_pos ( )
{
return arg2 ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_lead_lag ( )
{
return arg3 ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-17 15:33:54 +02:00
class FCALL_ : public BytecodeInstruction
2010-12-10 11:50:27 +01:00
{
2022-06-23 14:28:13 +02:00
template < typename B >
friend BytecodeWriter & operator < < ( BytecodeWriter & code_file , const B & instr ) ;
private :
2022-06-20 17:49:09 +02:00
int nb_output_arguments , nb_input_arguments , indx ;
2010-12-10 11:50:27 +01:00
string func_name ;
string arg_func_name ;
2022-06-20 17:49:09 +02:00
int add_input_arguments { 0 } , row { 0 } , col { 0 } ;
2022-07-08 16:00:02 +02:00
ExternalFunctionCallType call_type ;
2010-12-10 11:50:27 +01:00
public :
2022-06-17 15:33:54 +02:00
FCALL_ ( ) : BytecodeInstruction { Tags : : FCALL }
2010-12-10 11:50:27 +01:00
{
} ;
2022-07-08 16:00:02 +02:00
FCALL_ ( int nb_output_arguments_arg , int nb_input_arguments_arg , string func_name_arg , int indx_arg , ExternalFunctionCallType call_type_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FCALL } ,
nb_output_arguments { nb_output_arguments_arg } ,
nb_input_arguments { nb_input_arguments_arg } ,
indx { indx_arg } ,
2022-07-08 16:00:02 +02:00
func_name { move ( func_name_arg ) } ,
call_type { call_type_arg }
2019-12-16 19:42:59 +01:00
{
2010-12-10 11:50:27 +01:00
} ;
2022-06-17 14:29:12 +02:00
string
2010-12-10 11:50:27 +01:00
get_function_name ( )
{
//printf("get_function_name => func_name=%s\n",func_name.c_str());fflush(stdout);
return func_name ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_nb_output_arguments ( )
{
2022-06-17 15:33:54 +02:00
return nb_output_arguments ;
2010-12-10 11:50:27 +01:00
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_nb_input_arguments ( )
{
2022-06-17 15:33:54 +02:00
return nb_input_arguments ;
2010-12-10 11:50:27 +01:00
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_indx ( )
{
2022-06-17 15:33:54 +02:00
return indx ;
2010-12-10 11:50:27 +01:00
} ;
2022-06-17 14:29:12 +02:00
void
2010-12-10 11:50:27 +01:00
set_arg_func_name ( string arg_arg_func_name )
{
arg_func_name = arg_arg_func_name ;
} ;
2022-06-17 14:29:12 +02:00
string
2010-12-10 11:50:27 +01:00
get_arg_func_name ( )
{
return arg_func_name ;
} ;
2022-06-17 14:29:12 +02:00
void
2022-06-20 17:49:09 +02:00
set_nb_add_input_arguments ( int arg_add_input_arguments )
2010-12-10 11:50:27 +01:00
{
add_input_arguments = arg_add_input_arguments ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_nb_add_input_arguments ( )
{
return add_input_arguments ;
} ;
2022-06-17 14:29:12 +02:00
void
2022-06-20 17:49:09 +02:00
set_row ( int arg_row )
2010-12-10 11:50:27 +01:00
{
row = arg_row ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_row ( )
{
return row ;
}
2022-06-17 14:29:12 +02:00
void
2022-06-20 17:49:09 +02:00
set_col ( int arg_col )
2010-12-10 11:50:27 +01:00
{
col = arg_col ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-12-10 11:50:27 +01:00
get_col ( )
{
return col ;
} ;
2022-07-08 16:00:02 +02:00
ExternalFunctionCallType
get_call_type ( )
2011-02-04 16:25:38 +01:00
{
2022-07-08 16:00:02 +02:00
return call_type ;
2011-02-04 16:25:38 +01:00
}
2022-06-16 17:52:14 +02:00
# ifdef BYTECODE_MEX
2010-12-10 11:50:27 +01:00
2022-06-20 17:49:09 +02:00
char *
load ( char * code )
2010-12-10 11:50:27 +01:00
{
2022-07-26 18:26:18 +02:00
code + = sizeof ( op_code ) ;
2022-06-17 15:33:54 +02:00
memcpy ( & nb_output_arguments , code , sizeof ( nb_output_arguments ) ) ; code + = sizeof ( nb_output_arguments ) ;
memcpy ( & nb_input_arguments , code , sizeof ( nb_input_arguments ) ) ; code + = sizeof ( nb_input_arguments ) ;
memcpy ( & indx , code , sizeof ( indx ) ) ; code + = sizeof ( indx ) ;
2010-12-10 11:50:27 +01:00
memcpy ( & add_input_arguments , code , sizeof ( add_input_arguments ) ) ; code + = sizeof ( add_input_arguments ) ;
memcpy ( & row , code , sizeof ( row ) ) ; code + = sizeof ( row ) ;
memcpy ( & col , code , sizeof ( col ) ) ; code + = sizeof ( col ) ;
2022-07-08 16:00:02 +02:00
memcpy ( & call_type , code , sizeof ( call_type ) ) ; code + = sizeof ( call_type ) ;
2010-12-10 11:50:27 +01:00
int size ;
memcpy ( & size , code , sizeof ( size ) ) ; code + = sizeof ( size ) ;
2019-04-23 11:07:32 +02:00
char * name = static_cast < char * > ( mxMalloc ( ( size + 1 ) * sizeof ( char ) ) ) ;
2010-12-10 11:50:27 +01:00
memcpy ( name , code , size ) ; code + = size ;
2011-02-07 12:38:04 +01:00
name [ size ] = 0 ;
2010-12-10 11:50:27 +01:00
func_name = name ;
mxFree ( name ) ;
memcpy ( & size , code , sizeof ( size ) ) ; code + = sizeof ( size ) ;
2019-04-23 11:07:32 +02:00
name = static_cast < char * > ( mxMalloc ( ( size + 1 ) * sizeof ( char ) ) ) ;
2010-12-10 11:50:27 +01:00
memcpy ( name , code , size ) ; code + = size ;
2011-02-07 12:38:04 +01:00
name [ size ] = 0 ;
2010-12-10 11:50:27 +01:00
arg_func_name = name ;
mxFree ( name ) ;
return code ;
}
# endif
} ;
2022-06-17 15:33:54 +02:00
class FNUMEXPR_ : public BytecodeInstruction
2010-01-22 17:42:08 +01:00
{
private :
2022-06-17 15:33:54 +02:00
ExpressionType expression_type ;
2022-07-26 14:51:48 +02:00
int equation ; // Equation number (non-block-specific) (or temporary term number for ExpressionType::TemporaryTerm)
int dvariable1 ; // For derivatives, type-specific ID of the derivation variable
int lag1 ; // For derivatives, lead/lag of the derivation variable
2010-01-22 17:42:08 +01:00
public :
2022-06-20 17:49:09 +02:00
FNUMEXPR_ ( const ExpressionType expression_type_arg , int equation_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FNUMEXPR } ,
expression_type { expression_type_arg } ,
2018-10-04 17:18:27 +02:00
equation { equation_arg } ,
2022-06-17 16:31:29 +02:00
dvariable1 { 0 } ,
lag1 { 0 }
2010-01-22 17:42:08 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
FNUMEXPR_ ( const ExpressionType expression_type_arg , int equation_arg , int dvariable1_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FNUMEXPR } ,
expression_type { expression_type_arg } ,
2018-10-04 17:18:27 +02:00
equation { equation_arg } ,
2022-06-20 17:49:09 +02:00
dvariable1 { dvariable1_arg } ,
2022-06-17 16:31:29 +02:00
lag1 { 0 }
2010-01-22 17:42:08 +01:00
{
} ;
2022-06-20 17:49:09 +02:00
FNUMEXPR_ ( const ExpressionType expression_type_arg , int equation_arg , int dvariable1_arg , int lag1_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FNUMEXPR } ,
expression_type { expression_type_arg } ,
2018-10-04 17:18:27 +02:00
equation { equation_arg } ,
2022-06-20 17:49:09 +02:00
dvariable1 { dvariable1_arg } ,
2022-06-20 10:44:21 +02:00
lag1 { lag1_arg }
2010-01-22 17:42:08 +01:00
{
} ;
2022-06-17 14:29:12 +02:00
ExpressionType
2010-01-22 17:42:08 +01:00
get_expression_type ( )
{
2022-06-17 15:33:54 +02:00
return expression_type ;
2010-01-22 17:42:08 +01:00
}
2022-06-20 17:49:09 +02:00
int
2010-01-22 17:42:08 +01:00
get_equation ( )
{
return equation ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-01-22 17:42:08 +01:00
get_dvariable1 ( )
{
return dvariable1 ;
} ;
2022-06-17 14:29:12 +02:00
int
2010-01-22 17:42:08 +01:00
get_lag1 ( )
{
return lag1 ;
} ;
} ;
2022-06-17 15:33:54 +02:00
class FBEGINBLOCK_ : public BytecodeInstruction
2009-10-16 18:34:27 +02:00
{
2022-06-23 14:28:13 +02:00
template < typename B >
friend BytecodeWriter & operator < < ( BytecodeWriter & code_file , const B & instr ) ;
2009-10-16 18:34:27 +02:00
private :
2021-02-01 12:44:24 +01:00
int size { 0 } ;
2022-06-20 14:44:55 +02:00
BlockSimulationType type ;
2009-12-16 14:21:31 +01:00
vector < int > variable ;
vector < int > equation ;
2020-05-06 14:02:58 +02:00
vector < int > other_endogenous ;
vector < int > exogenous ;
vector < int > det_exogenous ;
2021-02-01 12:44:24 +01:00
bool is_linear { false } ;
2009-10-23 13:26:29 +02:00
vector < Block_contain_type > Block_Contain_ ;
2021-02-01 12:44:24 +01:00
int endo_nbr { 0 } ;
int Max_Lag { 0 } ;
int Max_Lead { 0 } ;
int u_count_int { 0 } ;
int nb_col_jacob { 0 } ;
2022-06-20 17:49:09 +02:00
int det_exo_size , exo_size , other_endo_size ;
int nb_col_det_exo_jacob , nb_col_exo_jacob , nb_col_other_endo_jacob ;
2009-10-16 18:34:27 +02:00
public :
2022-06-17 15:33:54 +02:00
FBEGINBLOCK_ ( ) : BytecodeInstruction { Tags : : FBEGINBLOCK } ,
2022-06-20 14:44:55 +02:00
type { BlockSimulationType : : unknown }
2009-12-16 18:13:23 +01:00
{
2018-10-04 17:18:27 +02:00
}
2022-06-20 17:49:09 +02:00
FBEGINBLOCK_ ( int size_arg , BlockSimulationType type_arg , int first_element , int block_size ,
2011-02-04 16:25:38 +01:00
const vector < int > & variable_arg , const vector < int > & equation_arg ,
2022-07-19 18:24:36 +02:00
bool is_linear_arg , int endo_nbr_arg , int Max_Lag_arg , int Max_Lead_arg , int u_count_int_arg , int nb_col_jacob_arg ,
2022-06-20 17:49:09 +02:00
int det_exo_size_arg , int nb_col_det_exo_jacob_arg , int exo_size_arg , int nb_col_exo_jacob_arg , int other_endo_size_arg , int nb_col_other_endo_jacob_arg ,
2020-05-06 14:02:58 +02:00
vector < int > det_exogenous_arg , vector < int > exogenous_arg , vector < int > other_endogenous_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FBEGINBLOCK } ,
2022-06-20 17:49:09 +02:00
size { size_arg } ,
2022-06-20 14:44:55 +02:00
type { type_arg } ,
2018-10-04 17:18:27 +02:00
variable { variable_arg . begin ( ) + first_element , variable_arg . begin ( ) + ( first_element + block_size ) } ,
equation { equation_arg . begin ( ) + first_element , equation_arg . begin ( ) + ( first_element + block_size ) } ,
2020-05-06 14:02:58 +02:00
other_endogenous { move ( other_endogenous_arg ) } ,
exogenous { move ( exogenous_arg ) } ,
det_exogenous { move ( det_exogenous_arg ) } ,
2018-10-04 17:18:27 +02:00
is_linear { is_linear_arg } ,
endo_nbr { endo_nbr_arg } ,
Max_Lag { Max_Lag_arg } ,
Max_Lead { Max_Lead_arg } ,
u_count_int { u_count_int_arg } ,
nb_col_jacob { nb_col_jacob_arg } ,
det_exo_size { det_exo_size_arg } ,
exo_size { exo_size_arg } ,
other_endo_size { other_endo_size_arg } ,
nb_col_det_exo_jacob { nb_col_det_exo_jacob_arg } ,
nb_col_exo_jacob { nb_col_exo_jacob_arg } ,
nb_col_other_endo_jacob { nb_col_other_endo_jacob_arg }
2009-12-16 18:13:23 +01:00
{
2018-10-04 17:18:27 +02:00
}
2022-06-20 17:49:09 +02:00
FBEGINBLOCK_ ( int size_arg , BlockSimulationType type_arg , int first_element , int block_size ,
2011-02-04 16:25:38 +01:00
const vector < int > & variable_arg , const vector < int > & equation_arg ,
2022-07-19 18:24:36 +02:00
bool is_linear_arg , int endo_nbr_arg , int Max_Lag_arg , int Max_Lead_arg , int u_count_int_arg , int nb_col_jacob_arg ) :
2022-06-17 15:33:54 +02:00
BytecodeInstruction { Tags : : FBEGINBLOCK } ,
2022-06-20 17:49:09 +02:00
size { size_arg } ,
2022-06-20 14:44:55 +02:00
type { type_arg } ,
2018-10-04 17:18:27 +02:00
variable { variable_arg . begin ( ) + first_element , variable_arg . begin ( ) + ( first_element + block_size ) } ,
equation { equation_arg . begin ( ) + first_element , equation_arg . begin ( ) + ( first_element + block_size ) } ,
is_linear { is_linear_arg } ,
endo_nbr { endo_nbr_arg } ,
Max_Lag { Max_Lag_arg } ,
Max_Lead { Max_Lead_arg } ,
u_count_int { u_count_int_arg } ,
nb_col_jacob { nb_col_jacob_arg } ,
det_exo_size { 0 } ,
exo_size { 0 } ,
other_endo_size { 0 } ,
nb_col_det_exo_jacob { 0 } ,
nb_col_exo_jacob { 0 } ,
nb_col_other_endo_jacob { 0 }
{
2010-07-23 11:20:24 +02:00
}
2022-06-20 17:49:09 +02:00
int
2009-12-16 18:13:23 +01:00
get_size ( )
{
return size ;
} ;
2022-06-20 14:44:55 +02:00
BlockSimulationType
2009-12-16 18:13:23 +01:00
get_type ( )
{
return type ;
} ;
2022-06-17 14:29:12 +02:00
bool
2009-12-16 18:13:23 +01:00
get_is_linear ( )
{
return is_linear ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_endo_nbr ( )
{
return endo_nbr ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_Max_Lag ( )
{
return Max_Lag ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_Max_Lead ( )
{
return Max_Lead ;
} ;
2022-06-17 14:29:12 +02:00
int
2009-12-16 18:13:23 +01:00
get_u_count_int ( )
{
return u_count_int ;
} ;
2022-06-17 14:29:12 +02:00
vector < Block_contain_type >
2009-12-16 18:13:23 +01:00
get_Block_Contain ( )
{
return Block_Contain_ ;
} ;
2022-06-17 14:29:12 +02:00
int
2010-07-23 11:20:24 +02:00
get_nb_col_jacob ( )
{
return nb_col_jacob ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_exo_size ( )
{
return exo_size ;
} ;
2022-06-20 17:49:09 +02:00
int
2014-12-17 09:37:43 +01:00
get_nb_col_exo_jacob ( )
{
return nb_col_exo_jacob ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_det_exo_size ( )
{
return det_exo_size ;
} ;
2022-06-20 17:49:09 +02:00
int
2014-12-17 09:37:43 +01:00
get_nb_col_det_exo_jacob ( )
{
return nb_col_det_exo_jacob ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_other_endo_size ( )
{
return other_endo_size ;
} ;
2022-06-20 17:49:09 +02:00
int
2010-07-23 11:20:24 +02:00
get_nb_col_other_endo_jacob ( )
{
return nb_col_other_endo_jacob ;
} ;
2022-06-17 14:29:12 +02:00
vector < int >
2015-09-22 12:45:27 +02:00
get_endogenous ( )
{
return variable ;
}
2022-06-17 14:29:12 +02:00
vector < int >
2015-09-22 12:45:27 +02:00
get_exogenous ( )
{
return exogenous ;
}
2022-06-16 17:52:14 +02:00
# ifdef BYTECODE_MEX
2009-10-16 18:34:27 +02:00
2022-06-20 17:49:09 +02:00
char *
load ( char * code )
2009-12-16 18:13:23 +01:00
{
2022-07-26 18:26:18 +02:00
code + = sizeof ( op_code ) ;
2009-12-16 18:13:23 +01:00
memcpy ( & size , code , sizeof ( size ) ) ; code + = sizeof ( size ) ;
memcpy ( & type , code , sizeof ( type ) ) ; code + = sizeof ( type ) ;
for ( int i = 0 ; i < size ; i + + )
{
Block_contain_type bc ;
memcpy ( & bc . Variable , code , sizeof ( bc . Variable ) ) ; code + = sizeof ( bc . Variable ) ;
memcpy ( & bc . Equation , code , sizeof ( bc . Equation ) ) ; code + = sizeof ( bc . Equation ) ;
Block_Contain_ . push_back ( bc ) ;
}
2022-06-20 14:44:55 +02:00
if ( type = = BlockSimulationType : : solveTwoBoundariesSimple
| | type = = BlockSimulationType : : solveTwoBoundariesComplete
| | type = = BlockSimulationType : : solveBackwardComplete
| | type = = BlockSimulationType : : solveForwardComplete )
2009-12-16 18:13:23 +01:00
{
memcpy ( & is_linear , code , sizeof ( is_linear ) ) ; code + = sizeof ( is_linear ) ;
memcpy ( & endo_nbr , code , sizeof ( endo_nbr ) ) ; code + = sizeof ( endo_nbr ) ;
memcpy ( & Max_Lag , code , sizeof ( Max_Lag ) ) ; code + = sizeof ( Max_Lag ) ;
memcpy ( & Max_Lead , code , sizeof ( Max_Lead ) ) ; code + = sizeof ( Max_Lead ) ;
memcpy ( & u_count_int , code , sizeof ( u_count_int ) ) ; code + = sizeof ( u_count_int ) ;
}
2010-07-23 11:20:24 +02:00
memcpy ( & nb_col_jacob , code , sizeof ( nb_col_jacob ) ) ; code + = sizeof ( nb_col_jacob ) ;
memcpy ( & det_exo_size , code , sizeof ( det_exo_size ) ) ; code + = sizeof ( det_exo_size ) ;
2014-12-17 09:37:43 +01:00
memcpy ( & nb_col_det_exo_jacob , code , sizeof ( nb_col_det_exo_jacob ) ) ; code + = sizeof ( nb_col_det_exo_jacob ) ;
2010-07-23 11:20:24 +02:00
memcpy ( & exo_size , code , sizeof ( exo_size ) ) ; code + = sizeof ( exo_size ) ;
2014-12-17 09:37:43 +01:00
memcpy ( & nb_col_exo_jacob , code , sizeof ( nb_col_exo_jacob ) ) ; code + = sizeof ( nb_col_exo_jacob ) ;
2010-07-23 11:20:24 +02:00
memcpy ( & other_endo_size , code , sizeof ( other_endo_size ) ) ; code + = sizeof ( other_endo_size ) ;
memcpy ( & nb_col_other_endo_jacob , code , sizeof ( nb_col_other_endo_jacob ) ) ; code + = sizeof ( nb_col_other_endo_jacob ) ;
2022-06-20 17:49:09 +02:00
for ( int i { 0 } ; i < det_exo_size ; i + + )
2010-07-23 11:20:24 +02:00
{
2020-05-06 14:02:58 +02:00
int tmp_i ;
2010-07-23 11:20:24 +02:00
memcpy ( & tmp_i , code , sizeof ( tmp_i ) ) ; code + = sizeof ( tmp_i ) ;
det_exogenous . push_back ( tmp_i ) ;
}
2022-06-20 17:49:09 +02:00
for ( int i { 0 } ; i < exo_size ; i + + )
2010-07-23 11:20:24 +02:00
{
2020-05-06 14:02:58 +02:00
int tmp_i ;
2010-07-23 11:20:24 +02:00
memcpy ( & tmp_i , code , sizeof ( tmp_i ) ) ; code + = sizeof ( tmp_i ) ;
exogenous . push_back ( tmp_i ) ;
}
2022-06-20 17:49:09 +02:00
for ( int i { 0 } ; i < other_endo_size ; i + + )
2010-07-23 11:20:24 +02:00
{
2020-05-06 14:02:58 +02:00
int tmp_i ;
2010-07-23 11:20:24 +02:00
memcpy ( & tmp_i , code , sizeof ( tmp_i ) ) ; code + = sizeof ( tmp_i ) ;
other_endogenous . push_back ( tmp_i ) ;
}
2009-12-16 18:13:23 +01:00
return code ;
} ;
2009-10-16 18:34:27 +02:00
# endif
} ;
2022-06-23 14:28:13 +02:00
// Superclass of std::ofstream for writing a sequence of bytecode instructions
class BytecodeWriter : private ofstream
{
template < typename B >
friend BytecodeWriter & operator < < ( BytecodeWriter & code_file , const B & instr ) ;
private :
// Stores the positions of all instructions in the byte stream
vector < pos_type > instructions_positions ;
public :
2023-01-05 16:40:04 +01:00
BytecodeWriter ( const filesystem : : path & filename ) ;
2022-06-23 14:28:13 +02:00
// Returns the number of the next instruction to be written
int
getInstructionCounter ( ) const
{
return static_cast < int > ( instructions_positions . size ( ) ) ;
}
/* Overwrites an existing instruction, given its number.
It is the responsibility of the caller to ensure that the new instruction
occupies exactly as many bytes as the former one . */
template < typename B >
void
overwriteInstruction ( int instruction_number , const B & new_instruction )
{
seekp ( instructions_positions . at ( instruction_number ) ) ;
* this < < new_instruction ;
instructions_positions . pop_back ( ) ;
seekp ( 0 , ios_base : : end ) ;
}
} ;
// Overloads of operator<< for writing bytecode instructions
template < typename B >
BytecodeWriter &
operator < < ( BytecodeWriter & code_file , const B & instr )
{
code_file . instructions_positions . push_back ( code_file . tellp ( ) ) ;
code_file . write ( reinterpret_cast < const char * > ( & instr ) , sizeof ( B ) ) ;
return code_file ;
}
template < >
BytecodeWriter & operator < < ( BytecodeWriter & code_file , const FCALL_ & instr ) ;
template < >
BytecodeWriter & operator < < ( BytecodeWriter & code_file , const FBEGINBLOCK_ & instr ) ;
2022-06-16 17:52:14 +02:00
# ifdef BYTECODE_MEX
2022-07-26 18:26:18 +02:00
using instructions_list_t = vector < BytecodeInstruction * > ;
2009-10-16 18:34:27 +02:00
class CodeLoad
{
private :
2022-06-20 17:49:09 +02:00
char * code ;
int nb_blocks ;
2013-03-22 15:48:47 +01:00
vector < size_t > begin_block ;
2009-10-16 18:34:27 +02:00
public :
2022-06-20 17:49:09 +02:00
int
2021-02-03 18:09:11 +01:00
get_block_number ( ) const
2010-01-22 17:42:08 +01:00
{
return nb_blocks ;
} ;
2010-10-11 19:21:32 +02:00
2022-06-17 14:29:12 +02:00
size_t
2021-02-03 18:09:11 +01:00
get_begin_block ( int block ) const
2010-10-11 19:21:32 +02:00
{
return begin_block [ block ] ;
}
2022-06-17 14:29:12 +02:00
void *
2021-02-03 18:09:11 +01:00
get_current_code ( ) const
2009-12-16 18:13:23 +01:00
{
return code ;
} ;
2022-07-26 18:26:18 +02:00
instructions_list_t
2023-01-09 14:09:09 +01:00
get_op_code ( const filesystem : : path & codfile )
2009-12-16 18:13:23 +01:00
{
2022-07-26 18:26:18 +02:00
instructions_list_t tags_liste ;
2009-12-16 18:13:23 +01:00
ifstream CompiledCode ;
streamoff Code_Size ;
2023-01-09 14:09:09 +01:00
CompiledCode . open ( codfile , ios : : in | ios : : binary | ios : : ate ) ;
2009-12-16 18:13:23 +01:00
if ( ! CompiledCode . is_open ( ) )
2021-02-03 18:09:11 +01:00
return tags_liste ;
2009-12-16 18:13:23 +01:00
Code_Size = CompiledCode . tellg ( ) ;
2022-06-16 17:52:14 +02:00
CompiledCode . seekg ( ios : : beg ) ;
2022-06-20 17:49:09 +02:00
code = static_cast < char * > ( mxMalloc ( Code_Size ) ) ;
2009-12-16 18:13:23 +01:00
CompiledCode . seekg ( 0 ) ;
CompiledCode . read ( reinterpret_cast < char * > ( code ) , Code_Size ) ;
CompiledCode . close ( ) ;
2010-01-22 17:42:08 +01:00
nb_blocks = 0 ;
2009-12-16 18:13:23 +01:00
bool done = false ;
2010-07-23 11:20:24 +02:00
int instruction = 0 ;
2009-12-16 18:13:23 +01:00
while ( ! done )
{
2022-07-26 18:26:18 +02:00
BytecodeInstruction * instr { reinterpret_cast < BytecodeInstruction * > ( code ) } ;
2022-06-20 10:42:35 +02:00
switch ( * reinterpret_cast < Tags * > ( code ) )
2009-12-16 18:13:23 +01:00
{
2021-02-01 11:10:59 +01:00
case Tags : : FLDZ :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
2021-02-01 11:10:59 +01:00
mexPrintf ( " FLDZ = %d size = %d \n " , Tags : : FLDZ , sizeof ( FLDZ_ ) ) ;
2009-12-16 18:13:23 +01:00
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDZ_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FEND :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FEND \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FEND_ ) ;
done = true ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FENDBLOCK :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FENDBLOCK \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FENDBLOCK_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FENDEQU :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FENDEQU \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FENDEQU_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FDIMT :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
2021-02-01 11:10:59 +01:00
mexPrintf ( " FDIMT = %d size = %d \n " , Tags : : FDIMT , sizeof ( FDIMT_ ) ) ;
2009-12-16 18:13:23 +01:00
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FDIMT_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FDIMST :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FDIMST \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FDIMST_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FNUMEXPR :
2010-01-22 17:42:08 +01:00
# ifdef DEBUGL
mexPrintf ( " FNUMEXPR \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-01-22 17:42:08 +01:00
code + = sizeof ( FNUMEXPR_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDC :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDC \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDC_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDU :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDU \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDU_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDSU :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDSU \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDSU_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDR :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDR \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDR_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDT :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDT \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDT_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDST :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDST \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDST_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPT :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
2021-02-01 11:10:59 +01:00
mexPrintf ( " FSTPT = %d size = %d \n " , Tags : : FSTPT , sizeof ( FSTPT_ ) ) ;
2009-12-16 18:13:23 +01:00
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPT_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPST :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPST \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPST_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPR :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPR \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPR_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPU :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPU \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPU_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPSU :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPSU \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPSU_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPG :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPG \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPG_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPG2 :
2010-07-23 11:20:24 +02:00
# ifdef DEBUGL
mexPrintf ( " FSTPG2 \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-07-23 11:20:24 +02:00
code + = sizeof ( FSTPG2_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPG3 :
2010-07-23 11:20:24 +02:00
# ifdef DEBUGL
mexPrintf ( " FSTPG3 \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-07-23 11:20:24 +02:00
code + = sizeof ( FSTPG3_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FUNARY :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FUNARY \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FUNARY_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FBINARY :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FBINARY \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FBINARY_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FTRINARY :
2010-04-16 16:54:55 +02:00
# ifdef DEBUGL
mexPrintf ( " FTRINARY \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-04-16 16:54:55 +02:00
code + = sizeof ( FTRINARY_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDVS :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDVS \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDVS_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDSV :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDSV \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDSV_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPSV :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPSV \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPSV_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDV :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDV \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FLDV_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPV :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPV \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2009-12-16 18:13:23 +01:00
code + = sizeof ( FSTPV_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FBEGINBLOCK :
2009-12-16 18:13:23 +01:00
# ifdef DEBUGL
mexPrintf ( " FBEGINBLOCK \n " ) ;
# endif
{
2022-06-17 16:10:17 +02:00
// TODO: remove default FBEGINBLOCK_ constructor when the following is remove
2021-02-01 12:42:59 +01:00
auto * fbegin_block = new FBEGINBLOCK_ ;
2009-12-16 18:13:23 +01:00
code = fbegin_block - > load ( code ) ;
2010-10-11 19:21:32 +02:00
begin_block . push_back ( tags_liste . size ( ) ) ;
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( fbegin_block ) ;
2010-01-22 17:42:08 +01:00
nb_blocks + + ;
2009-12-16 18:13:23 +01:00
}
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FJMPIFEVAL :
2010-07-23 11:20:24 +02:00
# ifdef DEBUGL
mexPrintf ( " FJMPIFEVAL \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-07-23 11:20:24 +02:00
code + = sizeof ( FJMPIFEVAL_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FJMP :
2010-07-23 11:20:24 +02:00
# ifdef DEBUGL
mexPrintf ( " FJMP \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-07-23 11:20:24 +02:00
code + = sizeof ( FJMP_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FCALL :
2010-12-10 11:50:27 +01:00
{
# ifdef DEBUGL
mexPrintf ( " FCALL \n " ) ;
# endif
2022-06-17 16:10:17 +02:00
// TODO: remove default FCALL_ constructor when the following is remove
2021-02-01 12:42:59 +01:00
auto * fcall = new FCALL_ ;
2010-12-10 11:50:27 +01:00
code = fcall - > load ( code ) ;
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( fcall ) ;
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
2011-02-04 16:25:38 +01:00
mexPrintf ( " FCALL finish \n " ) ; mexEvalString ( " drawnow; " ) ;
mexPrintf ( " -- *code=%d \n " , * code ) ; mexEvalString ( " drawnow; " ) ;
2010-12-10 11:50:27 +01:00
# endif
}
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDTEF :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDTEF \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FLDTEF_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPTEF :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPTEF \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FSTPTEF_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDTEFD :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDTEFD \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FLDTEFD_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPTEFD :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPTEFD \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FSTPTEFD_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FLDTEFDD :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FLDTEFDD \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FLDTEFDD_ ) ;
break ;
2021-02-01 11:10:59 +01:00
case Tags : : FSTPTEFDD :
2010-12-10 11:50:27 +01:00
# ifdef DEBUGL
mexPrintf ( " FSTPTEFDD \n " ) ;
# endif
2022-07-26 18:26:18 +02:00
tags_liste . push_back ( instr ) ;
2010-12-10 11:50:27 +01:00
code + = sizeof ( FSTPTEFDD_ ) ;
break ;
2009-12-16 18:13:23 +01:00
default :
mexPrintf ( " Unknown Tag value=%d code=%x \n " , * code , code ) ;
done = true ;
}
2010-07-23 11:20:24 +02:00
instruction + + ;
2009-12-16 18:13:23 +01:00
}
return tags_liste ;
} ;
2009-10-16 18:34:27 +02:00
} ;
2022-06-16 17:52:14 +02:00
# endif // BYTECODE_MEX
# endif // _BYTECODE_HH