fixed warnings in squirrel
[supertux.git] / src / squirrel / squirrel / sqfuncproto.h
1 /*      see copyright notice in squirrel.h */
2 #ifndef _SQFUNCTION_H_
3 #define _SQFUNCTION_H_
4
5 #include "sqopcodes.h"
6
7 enum SQOuterType {
8         otLOCAL = 0,
9         otSYMBOL = 1,
10         otOUTER = 2
11 };
12
13 struct SQOuterVar
14 {
15         
16         SQOuterVar(){}
17         SQOuterVar(const SQObjectPtr &name,const SQObjectPtr &src,SQOuterType t)
18         {
19                 _name = name;
20                 _src=src;
21                 _type=t;
22         }
23         SQOuterVar(const SQOuterVar &ov)
24         {
25                 _type=ov._type;
26                 _src=ov._src;
27                 _name=ov._name;
28         }
29         SQOuterType _type;
30         SQObjectPtr _name;
31         SQObjectPtr _src;
32 };
33
34 struct SQLocalVarInfo
35 {
36         SQLocalVarInfo():_start_op(0),_end_op(0){}
37         SQLocalVarInfo(const SQLocalVarInfo &lvi)
38         {
39                 _name=lvi._name;
40                 _start_op=lvi._start_op;
41                 _end_op=lvi._end_op;
42                 _pos=lvi._pos;
43         }
44         SQObjectPtr _name;
45         unsigned int _start_op;
46         unsigned int _end_op;
47         unsigned int _pos;
48 };
49
50 struct SQLineInfo { int _line;int _op; };
51
52 typedef sqvector<SQOuterVar> SQOuterVarVec;
53 typedef sqvector<SQLocalVarInfo> SQLocalVarInfoVec;
54 typedef sqvector<SQLineInfo> SQLineInfoVec;
55
56 struct SQFunctionProto : public SQRefCounted
57 {
58 private:
59         SQFunctionProto(){
60                 _uiRef=0;
61         _stacksize=0;
62         _bgenerator=false;}
63 public:
64         static SQFunctionProto *Create()
65         {
66                 SQFunctionProto *f;
67                 sq_new(f,SQFunctionProto);
68                 return f;
69         }
70         void Release(){ sq_delete(this,SQFunctionProto);}
71         const SQChar* GetLocal(SQVM *v,unsigned int stackbase,unsigned int nseq,unsigned int nop);
72         int GetLine(SQInstruction *curr);
73         bool Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
74         bool Load(SQVM *v,SQUserPointer up,SQREADFUNC read);
75         SQObjectPtrVec _literals;
76         SQObjectPtrVec _functions;
77         SQObjectPtrVec _parameters;
78         SQOuterVarVec _outervalues;
79         SQInstructionVec _instructions;
80         SQObjectPtr _sourcename;
81         SQObjectPtr _name;
82         SQLocalVarInfoVec _localvarinfos;
83         SQLineInfoVec _lineinfos;
84     int _stacksize;
85         bool _bgenerator;
86         bool _varparams;
87 };
88
89 #endif //_SQFUNCTION_H_