[DEV] add AutoDec
This commit is contained in:
parent
2fb1234972
commit
d92da4207d
@ -32,6 +32,7 @@ def configure(target, my_module):
|
|||||||
'rabbit/sqapi.cpp',
|
'rabbit/sqapi.cpp',
|
||||||
'rabbit/sqlexer.cpp',
|
'rabbit/sqlexer.cpp',
|
||||||
'rabbit/sqclass.cpp',
|
'rabbit/sqclass.cpp',
|
||||||
|
'rabbit/AutoDec.cpp',
|
||||||
'rabbit/VirtualMachine.cpp',
|
'rabbit/VirtualMachine.cpp',
|
||||||
'rabbit/sqtable.cpp',
|
'rabbit/sqtable.cpp',
|
||||||
'rabbit/sqstate.cpp',
|
'rabbit/sqstate.cpp',
|
||||||
@ -51,6 +52,7 @@ def configure(target, my_module):
|
|||||||
])
|
])
|
||||||
my_module.add_header_file([
|
my_module.add_header_file([
|
||||||
'rabbit/sqclass.hpp',
|
'rabbit/sqclass.hpp',
|
||||||
|
'rabbit/AutoDec.hpp',
|
||||||
'rabbit/VirtualMachine.hpp',
|
'rabbit/VirtualMachine.hpp',
|
||||||
'rabbit/sqstate.hpp',
|
'rabbit/sqstate.hpp',
|
||||||
'rabbit/rabbit.hpp',
|
'rabbit/rabbit.hpp',
|
||||||
|
18
rabbit/AutoDec.cpp
Normal file
18
rabbit/AutoDec.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* @author Alberto DEMICHELIS
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @copyright 2003-2017, Alberto DEMICHELIS, all right reserved
|
||||||
|
* @license MPL-2 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rabbit/AutoDec.hpp>
|
||||||
|
|
||||||
|
rabbit::AutoDec::AutoDec(int64_t* _count) {
|
||||||
|
m_countPointer = _count;
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbit::AutoDec::~AutoDec() {
|
||||||
|
(*m_countPointer)--;
|
||||||
|
}
|
||||||
|
|
22
rabbit/AutoDec.hpp
Normal file
22
rabbit/AutoDec.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* @author Alberto DEMICHELIS
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @copyright 2003-2017, Alberto DEMICHELIS, all right reserved
|
||||||
|
* @license MPL-2 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <rabbit/rabbit.hpp>
|
||||||
|
|
||||||
|
namespace rabbit {
|
||||||
|
class AutoDec {
|
||||||
|
public:
|
||||||
|
AutoDec(int64_t* _count);
|
||||||
|
~AutoDec();
|
||||||
|
private:
|
||||||
|
int64_t* m_countPointer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <rabbit/sqopcodes.hpp>
|
#include <rabbit/sqopcodes.hpp>
|
||||||
#include <rabbit/sqobject.hpp>
|
#include <rabbit/sqobject.hpp>
|
||||||
|
#include <rabbit/AutoDec.hpp>
|
||||||
|
|
||||||
#define MAX_NATIVE_CALLS 100
|
#define MAX_NATIVE_CALLS 100
|
||||||
#define MIN_STACK_OVERHEAD 15
|
#define MIN_STACK_OVERHEAD 15
|
||||||
@ -20,10 +21,11 @@
|
|||||||
|
|
||||||
#define GET_FLAG_RAW 0x00000001
|
#define GET_FLAG_RAW 0x00000001
|
||||||
#define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002
|
#define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002
|
||||||
|
|
||||||
//base lib
|
//base lib
|
||||||
void sq_base_register(rabbit::VirtualMachine* v);
|
void sq_base_register(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
struct SQExceptionTrap{
|
struct SQExceptionTrap {
|
||||||
SQExceptionTrap() {}
|
SQExceptionTrap() {}
|
||||||
SQExceptionTrap(int64_t ss, int64_t stackbase,SQInstruction *ip, int64_t ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;}
|
SQExceptionTrap(int64_t ss, int64_t stackbase,SQInstruction *ip, int64_t ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;}
|
||||||
SQExceptionTrap(const SQExceptionTrap &et) { (*this) = et; }
|
SQExceptionTrap(const SQExceptionTrap &et) { (*this) = et; }
|
||||||
@ -40,7 +42,6 @@ namespace rabbit {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct callInfo{
|
struct callInfo{
|
||||||
//callInfo() { _generator = NULL;}
|
|
||||||
SQInstruction *_ip;
|
SQInstruction *_ip;
|
||||||
SQObjectPtr *_literals;
|
SQObjectPtr *_literals;
|
||||||
SQObjectPtr _closure;
|
SQObjectPtr _closure;
|
||||||
@ -187,15 +188,6 @@ namespace rabbit {
|
|||||||
int64_t _suspended_traps;
|
int64_t _suspended_traps;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AutoDec{
|
|
||||||
AutoDec(int64_t *n) {
|
|
||||||
_n = n;
|
|
||||||
}
|
|
||||||
~AutoDec() {
|
|
||||||
(*_n)--;
|
|
||||||
}
|
|
||||||
int64_t *_n;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline SQObjectPtr &stack_get(rabbit::VirtualMachine* _vm,int64_t _idx) {
|
inline SQObjectPtr &stack_get(rabbit::VirtualMachine* _vm,int64_t _idx) {
|
||||||
if (_idx>=0) {
|
if (_idx>=0) {
|
||||||
@ -204,6 +196,7 @@ namespace rabbit {
|
|||||||
return _vm->getUp(_idx);
|
return _vm->getUp(_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ss(_vm_) (_vm_)->_sharedstate
|
#define _ss(_vm_) (_vm_)->_sharedstate
|
||||||
|
|
||||||
#define PUSH_CALLINFO(v,nci){ \
|
#define PUSH_CALLINFO(v,nci){ \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user