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
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);
50
SQLocalVarInfoVec _vlocals;
51
SQIntVec _targetstack;
55
SQIntVec _unresolvedbreaks;
56
SQIntVec _unresolvedcontinues;
57
SQObjectPtrVec _functions;
58
SQObjectPtrVec _parameters;
59
SQOuterVarVec _outervalues;
60
SQInstructionVec _instructions;
61
SQLocalVarInfoVec _localvarinfos;
62
SQObjectPtr _literals;
65
SQObjectPtr _sourcename;
67
SQLineInfoVec _lineinfos;
69
SQIntVec _breaktargets;
70
SQIntVec _continuetargets;
71
SQIntVec _defaultparams;
73
SQInteger _traps; //contains number of nested exception traps
75
SQSharedState *_sharedstate;
76
sqvector<SQFuncState*> _childstates;
77
SQInteger GetConstant(const SQObject &cons);
79
CompilerErrorFunc _errfunc;
84
#endif //_SQFUNCSTATE_H_