~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/include/scripting/squirrel/sqvm.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
        SQInteger _extarget;
22
22
};
23
23
 
24
 
#define _INLINE 
 
24
#define _INLINE
25
25
 
26
26
#define STK(a) _stack._vals[_stackbase+(a)]
27
27
#define TARGET _stack._vals[_stackbase+arg0]
32
32
{
33
33
        struct VarArgs {
34
34
                VarArgs() { size = 0; base = 0; }
 
35
                // C::B patch: Eliminate compiler warnings
 
36
                /*
35
37
                unsigned short size;
36
38
                unsigned short base;
 
39
                */
 
40
                SQInt32 size;
 
41
                SQInt32 base;
37
42
        };
38
43
 
39
44
        struct CallInfo{
40
 
                CallInfo() { _generator._type = OT_NULL;}
 
45
                //CallInfo() { _generator._type = OT_NULL;}
41
46
                SQInstruction *_ip;
42
47
                SQObjectPtr *_literals;
43
 
                SQObject _closure;
44
 
                SQObject _generator;
 
48
                SQObjectPtr _closure;
 
49
                SQGenerator *_generator;
45
50
                SQInt32 _etraps;
46
51
                SQInt32 _prevstkbase;
47
52
                SQInt32 _prevtop;
50
55
                SQBool _root;
51
56
                VarArgs _vargs;
52
57
        };
53
 
        
 
58
 
54
59
typedef sqvector<CallInfo> CallInfoVec;
55
60
public:
56
 
        enum ExecutionType { ET_CALL, ET_RESUME_GENERATOR, ET_RESUME_VM };
 
61
        enum ExecutionType { ET_CALL, ET_RESUME_GENERATOR, ET_RESUME_VM, ET_RESUME_THROW_VM };
57
62
        SQVM(SQSharedState *ss);
58
63
        ~SQVM();
59
64
        bool Init(SQVM *friendvm, SQInteger stacksize);
60
65
        bool Execute(SQObjectPtr &func, SQInteger target, SQInteger nargs, SQInteger stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
61
66
        //starts a native call return when the NATIVE closure returns
62
 
        bool CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger stackbase, bool tailcall, SQObjectPtr &retval,bool &suspend);
 
67
        bool CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger stackbase, SQObjectPtr &retval,bool &suspend);
63
68
        //starts a SQUIRREL call in the same "Execution loop"
64
69
        bool StartCall(SQClosure *closure, SQInteger target, SQInteger nargs, SQInteger stackbase, bool tailcall);
65
70
        bool CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor);
81
86
        void ToString(const SQObjectPtr &o,SQObjectPtr &res);
82
87
        SQString *PrintObjVal(const SQObject &o);
83
88
 
84
 
 
 
89
 
85
90
        void Raise_Error(const SQChar *s, ...);
86
91
        void Raise_Error(SQObjectPtr &desc);
87
92
        void Raise_IdxError(SQObject &o);
102
107
        bool CLASS_OP(SQObjectPtr &target,SQInteger base,SQInteger attrs);
103
108
        bool GETPARENT_OP(SQObjectPtr &o,SQObjectPtr &target);
104
109
        //return true if the loop is finished
105
 
        bool FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr &o3,SQObjectPtr &o4,SQInteger arg_2,bool &finished);
 
110
        bool FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr &o3,SQObjectPtr &o4,SQInteger arg_2,int exitpos,int &jump);
106
111
        bool DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2);
107
112
        _INLINE bool LOCAL_INC(SQInteger op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr);
108
113
        _INLINE bool PLOCAL_INC(SQInteger op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr);
109
114
        _INLINE bool DerefInc(SQInteger op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix);
110
115
        void PopVarArgs(VarArgs &vargs);
 
116
        void ClearStack(SQInteger last_top);
111
117
#ifdef _DEBUG_DUMP
112
118
        void dumpstack(SQInteger stackbase=-1, bool dumpall = false);
113
119
#endif
118
124
        void Finalize();
119
125
        void GrowCallStack() {
120
126
                SQInteger newsize = _alloccallsstacksize*2;
121
 
                _callsstack = (CallInfo*)sq_realloc(_callsstack,_alloccallsstacksize*sizeof(CallInfo),newsize*sizeof(CallInfo));
 
127
                _callstackdata.resize(newsize);
 
128
                _callsstack = &_callstackdata[0];
122
129
                _alloccallsstacksize = newsize;
123
130
        }
124
131
        void Release(){ sq_delete(this,SQVM); } //does nothing
127
134
        void Remove(SQInteger n);
128
135
 
129
136
        bool IsFalse(SQObjectPtr &o);
130
 
        
 
137
 
131
138
        void Pop();
132
139
        void Pop(SQInteger n);
133
140
        void Push(const SQObjectPtr &o);
146
153
        SQObjectPtr _debughook;
147
154
 
148
155
        SQObjectPtr temp_reg;
149
 
        
 
156
 
150
157
 
151
158
        CallInfo* _callsstack;
152
159
        SQInteger _callsstacksize;
153
160
        SQInteger _alloccallsstacksize;
 
161
        sqvector<CallInfo>  _callstackdata;
154
162
 
155
163
        ExceptionsTraps _etraps;
156
164
        CallInfo *ci;
173
181
};
174
182
 
175
183
inline SQObjectPtr &stack_get(HSQUIRRELVM v,SQInteger idx){return ((idx>=0)?(v->GetAt(idx+v->_stackbase-1)):(v->GetUp(idx)));}
176
 
const SQChar *GetTypeName(const SQObjectPtr &obj1);
177
 
const SQChar *IdType2Name(SQObjectType type);
178
184
 
179
185
#define _ss(_vm_) (_vm_)->_sharedstate
180
186
 
195
201
 
196
202
#define POP_CALLINFO(v){ \
197
203
        v->_callsstacksize--; \
 
204
        v->ci->_closure.Null(); \
198
205
        if(v->_callsstacksize)  \
199
206
                v->ci = &v->_callsstack[v->_callsstacksize-1] ; \
200
207
        else    \