1 /* see copyright notice in squirrel.h */
2 #ifndef _SQFUNCSTATE_H_
3 #define _SQFUNCSTATE_H_
4 ///////////////////////////////////
9 SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
12 void Dump(SQFunctionProto *func);
14 void Error(const SQChar *err);
15 SQFuncState *PushChildState(SQSharedState *ss);
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 SQInteger GetCurrentPos(){return _instructions.size()-1;}
26 SQInteger GetNumericConstant(const SQInteger cons);
27 SQInteger GetNumericConstant(const SQFloat cons);
28 SQInteger PushLocalVariable(const SQObject &name);
29 void AddParameter(const SQObject &name);
30 void AddOuterValue(const SQObject &name);
31 SQInteger GetLocalVariable(const SQObject &name);
32 SQInteger GetOuterVariable(const SQObject &name);
33 SQInteger GenerateCode();
34 SQInteger GetStackSize();
35 SQInteger CalcStackFrameSize();
36 void AddLineInfos(SQInteger line,bool lineop,bool force=false);
37 SQFunctionProto *BuildProto();
38 SQInteger AllocStackPos();
39 SQInteger PushTarget(SQInteger n=-1);
40 SQInteger PopTarget();
41 SQInteger TopTarget();
42 SQInteger GetUpTarget(SQInteger n);
43 bool IsLocal(SQUnsignedInteger stkpos);
44 SQObject CreateString(const SQChar *s,SQInteger len = -1);
46 SQLocalVarInfoVec _vlocals;
47 SQIntVec _targetstack;
51 SQIntVec _unresolvedbreaks;
52 SQIntVec _unresolvedcontinues;
53 SQObjectPtrVec _functions;
54 SQObjectPtrVec _parameters;
55 SQOuterVarVec _outervalues;
56 SQInstructionVec _instructions;
57 SQLocalVarInfoVec _localvarinfos;
58 SQObjectPtr _literals;
61 SQObjectPtr _sourcename;
63 SQLineInfoVec _lineinfos;
65 SQIntVec _breaktargets;
66 SQIntVec _continuetargets;
68 SQInteger _traps; //contains number of nested exception traps
70 SQSharedState *_sharedstate;
71 sqvector<SQFuncState*> _childstates;
72 SQInteger GetConstant(const SQObject &cons);
74 CompilerErrorFunc _errfunc;
79 #endif //_SQFUNCSTATE_H_