ScummVM API documentation
sqfuncstate.h
1 /* see copyright notice in squirrel.h */
2 #ifndef _SQFUNCSTATE_H_
3 #define _SQFUNCSTATE_H_
4 #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 SetInstructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
20  void SetInstructionParam(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  SQInteger CountOuters(SQInteger stacksize);
25  void SnoozeOpt(){_optimization=false;}
26  void AddDefaultParam(SQInteger trg) { _defaultparams.push_back(trg); }
27  SQInteger GetDefaultParamCount() { return _defaultparams.size(); }
28  SQInteger GetCurrentPos(){return _instructions.size()-1;}
29  SQInteger GetNumericConstant(const SQInteger cons);
30  SQInteger GetNumericConstant(const SQFloat cons);
31  SQInteger PushLocalVariable(const SQObject &name);
32  void AddParameter(const SQObject &name);
33  //void AddOuterValue(const SQObject &name);
34  SQInteger GetLocalVariable(const SQObject &name);
35  void MarkLocalAsOuter(SQInteger pos);
36  SQInteger GetOuterVariable(const SQObject &name);
37  SQInteger GenerateCode();
38  SQInteger GetStackSize();
39  SQInteger CalcStackFrameSize();
40  void AddLineInfos(SQInteger line,bool lineop,bool force=false);
41  SQFunctionProto *BuildProto();
42  SQInteger AllocStackPos();
43  SQInteger PushTarget(SQInteger n=-1);
44  SQInteger PopTarget();
45  SQInteger TopTarget();
46  SQInteger GetUpTarget(SQInteger n);
47  void DiscardTarget();
48  bool IsLocal(SQUnsignedInteger stkpos);
49  SQObject CreateString(const SQChar *s,SQInteger len = -1);
50  SQObject CreateTable();
51  bool IsConstant(const SQObject &name,SQObject &e);
52  SQInteger _returnexp;
53  SQLocalVarInfoVec _vlocals;
54  SQIntVec _targetstack;
55  SQInteger _stacksize;
56  bool _varparams;
57  bool _bgenerator;
58  SQIntVec _unresolvedbreaks;
59  SQIntVec _unresolvedcontinues;
60  SQObjectPtrVec _functions;
61  SQObjectPtrVec _parameters;
62  SQOuterVarVec _outervalues;
63  SQInstructionVec _instructions;
64  SQLocalVarInfoVec _localvarinfos;
65  SQObjectPtr _literals;
66  SQObjectPtr _strings;
67  SQObjectPtr _name;
68  SQObjectPtr _sourcename;
69  SQInteger _nliterals;
70  SQLineInfoVec _lineinfos;
71  SQFuncState *_parent;
72  SQIntVec _scope_blocks;
73  SQIntVec _breaktargets;
74  SQIntVec _continuetargets;
75  SQIntVec _defaultparams;
76  SQInteger _lastline;
77  SQInteger _traps; //contains number of nested exception traps
78  SQInteger _outers;
79  bool _optimization;
80  SQSharedState *_sharedstate;
81  sqvector<SQFuncState*> _childstates;
82  SQInteger GetConstant(const SQObject &cons);
83 private:
84  CompilerErrorFunc _errfunc;
85  void *_errtarget;
86  SQSharedState *_ss;
87 };
88 
89 
90 #endif //_SQFUNCSTATE_H_
91 
Definition: sqfuncstate.h:7
Definition: sqstate.h:59
Definition: sqopcodes.h:109
Definition: squirrel.h:153
Definition: sqobject.h:205
Definition: sqfuncproto.h:49