LCOV - code coverage report
Current view: top level - src/runtime - vmachine.hpp (source / functions) Hit Total Coverage
Test: flower-f.info Lines: 1 1 100.0 %
Date: 2022-06-10 00:44:15 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #ifndef VMACHINE_H
       2             : #define VMACHINE_H
       3             : 
       4             : #include <fstream>
       5             : #include <vector>
       6             : #include "common/tables.hpp"
       7             : #include "common/poliz.hpp"
       8             : #include "common/stack.hpp"
       9             : 
      10             : class VirtualMachine {
      11             : protected:
      12             :     char * base;
      13             :     char * cmd;
      14             :     int cmdNum;
      15             : 
      16             :     bool inThread;
      17             : 
      18             :     Stack stackVM;
      19             :     Stack registerVM;
      20             :     Stack sharedVars;
      21             :     Stack offsets;
      22             :     Stack params;
      23             :     std::vector<pid_t> threads;
      24             :     std::vector<int *> pipefd;
      25             :     Gendarme dynamicStrings;
      26             : public:
      27          52 :     VirtualMachine(): base(nullptr), cmd(nullptr), cmdNum(0), inThread(false) {};
      28             : 
      29             :     void loadBIN(const char * filename);
      30             : 
      31             :     virtual void run(void);
      32             : 
      33             :     bool exec(op_t op, int * eip);
      34             : 
      35             :     void updateVars(void);
      36             : 
      37             :     static char * getString(void * x);
      38             : 
      39             :     void numberOp(type_t lval, type_t rval, void* f);
      40             : 
      41             :     template <typename lval_t, typename rval_t, typename res_t>
      42             :     void tempOp(res_t (*f) (lval_t, rval_t), type_t TYPE);
      43             : 
      44             :     template <class lval_t, class rval_t>
      45             :     void assign(void);
      46             : 
      47             :     virtual ~VirtualMachine(void);
      48             : };
      49             : 
      50             : #define ARITH_OPERATION(OP) { \
      51             :     if ((lval == _INT_) && (rval == _INT_)) \
      52             :         tempOp<int, int, int>( [] (int x, int y) { return x OP y; }, _INT_); \
      53             :     if ((lval == _INT_) && (rval == _REAL_)) \
      54             :         tempOp<int, float, float>( [] (int x, float y) { return x OP y; }, _REAL_); \
      55             :     if ((lval == _REAL_) && (rval == _INT_)) \
      56             :         tempOp<float, int, float>( [] (float x, int y) { return x OP y; }, _REAL_); \
      57             :     if ((lval == _REAL_) && (rval == _REAL_)) \
      58             :         tempOp<float, float, float>( [] (float x, float y) { return x OP y; }, _REAL_); \
      59             : }
      60             : 
      61             : #define LOGIC_OPERATION(OP) { \
      62             :     if ((lval == _INT_) && (rval == _INT_)) \
      63             :         tempOp<int, int, bool>( [] (int x, int y) { return x OP y; }, _BOOLEAN_); \
      64             :     if ((lval == _INT_) && (rval == _REAL_)) \
      65             :         tempOp<int, float, bool>( [] (int x, float y) { return x OP y; }, _BOOLEAN_); \
      66             :     if ((lval == _REAL_) && (rval == _INT_)) \
      67             :         tempOp<float, int, bool>( [] (float x, int y) { return x OP y; }, _BOOLEAN_); \
      68             :     if ((lval == _REAL_) && (rval == _REAL_)) \
      69             :         tempOp<float, float, bool>( [] (float x, float y) { return x OP y; }, _BOOLEAN_); \
      70             : }
      71             : 
      72             : #endif

Generated by: LCOV version 1.14