New grow and skid sounds from remaxim
[supertux.git] / src / squirrel / squirrel / sqfuncstate.h
1 /*      see copyright notice in squirrel.h */
2 #ifndef _SQFUNCSTATE_H_
3 #define _SQFUNCSTATE_H_
4 ///////////////////////////////////
5 #include "squtils.h"
6
7 struct SQFuncState
8 {
9         SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
10         ~SQFuncState();
11 #ifdef _DEBUG_DUMP
12         void Dump(SQFunctionProto *func);
13 #endif
14         void Error(const SQChar *err);
15         SQFuncState *PushChildState(SQSharedState *ss);
16         void PopChildState();
17         void AddInstruction(SQOpcode _op,SQInteger arg0=0,SQInteger arg1=0,SQInteger arg2=0,SQInteger arg3=0){SQInstruction i(_op,arg0,arg1,arg2,arg3);AddInstruction(i);}
18         void AddInstruction(SQInstruction &i);
19         void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
20         void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);
21         SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
22         void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
23         void SetStackSize(SQInteger n);
24         void SnoozeOpt(){_optimization=false;}
25         void AddDefaultParam(SQInteger trg) { _defaultparams.push_back(trg); }
26         SQInteger GetDefaultParamCount() { return _defaultparams.size(); }
27         SQInteger GetCurrentPos(){return _instructions.size()-1;}
28         SQInteger GetNumericConstant(const SQInteger cons);
29         SQInteger GetNumericConstant(const SQFloat cons);
30         SQInteger PushLocalVariable(const SQObject &name);
31         void AddParameter(const SQObject &name);
32         void AddOuterValue(const SQObject &name);
33         SQInteger GetLocalVariable(const SQObject &name);
34         SQInteger GetOuterVariable(const SQObject &name);
35         SQInteger GenerateCode();
36         SQInteger GetStackSize();
37         SQInteger CalcStackFrameSize();
38         void AddLineInfos(SQInteger line,bool lineop,bool force=false);
39         SQFunctionProto *BuildProto();
40         SQInteger AllocStackPos();
41         SQInteger PushTarget(SQInteger n=-1);
42         SQInteger PopTarget();
43         SQInteger TopTarget();
44         SQInteger GetUpTarget(SQInteger n);
45         bool IsLocal(SQUnsignedInteger stkpos);
46         SQObject CreateString(const SQChar *s,SQInteger len = -1);
47         SQObject CreateTable();
48         bool IsConstant(const SQObject &name,SQObject &e);
49         SQInteger _returnexp;
50         SQLocalVarInfoVec _vlocals;
51         SQIntVec _targetstack;
52         SQInteger _stacksize;
53         bool _varparams;
54         bool _bgenerator;
55         SQIntVec _unresolvedbreaks;
56         SQIntVec _unresolvedcontinues;
57         SQObjectPtrVec _functions;
58         SQObjectPtrVec _parameters;
59         SQOuterVarVec _outervalues;
60         SQInstructionVec _instructions;
61         SQLocalVarInfoVec _localvarinfos;
62         SQObjectPtr _literals;
63         SQObjectPtr _strings;
64         SQObjectPtr _name;
65         SQObjectPtr _sourcename;
66         SQInteger _nliterals;
67         SQLineInfoVec _lineinfos;
68         SQFuncState *_parent;
69         SQIntVec _breaktargets;
70         SQIntVec _continuetargets;
71         SQIntVec _defaultparams;
72         SQInteger _lastline;
73         SQInteger _traps; //contains number of nested exception traps
74         bool _optimization;
75         SQSharedState *_sharedstate;
76         sqvector<SQFuncState*> _childstates;
77         SQInteger GetConstant(const SQObject &cons);
78 private:
79         CompilerErrorFunc _errfunc;
80         void *_errtarget;
81 };
82
83
84 #endif //_SQFUNCSTATE_H_
85