-/* see copyright notice in squirrel.h */\r
-#ifndef _SQFUNCSTATE_H_\r
-#define _SQFUNCSTATE_H_\r
-///////////////////////////////////\r
-#include "squtils.h"\r
-\r
-struct SQFuncState\r
-{\r
- SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);\r
- ~SQFuncState();\r
-#ifdef _DEBUG_DUMP\r
- void Dump(SQFunctionProto *func);\r
-#endif\r
- void Error(const SQChar *err);\r
- SQFuncState *PushChildState(SQSharedState *ss);\r
- void PopChildState();\r
- 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);}\r
- void AddInstruction(SQInstruction &i);\r
- void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);\r
- void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);\r
- SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}\r
- void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}\r
- void SetStackSize(SQInteger n);\r
- void SnoozeOpt(){_optimization=false;}\r
- SQInteger GetCurrentPos(){return _instructions.size()-1;}\r
- //SQInteger GetStringConstant(const SQChar *cons);\r
- SQInteger GetNumericConstant(const SQInteger cons);\r
- SQInteger GetNumericConstant(const SQFloat cons);\r
- SQInteger PushLocalVariable(const SQObject &name);\r
- void AddParameter(const SQObject &name);\r
- void AddOuterValue(const SQObject &name);\r
- SQInteger GetLocalVariable(const SQObject &name);\r
- SQInteger GetOuterVariable(const SQObject &name);\r
- SQInteger GenerateCode();\r
- SQInteger GetStackSize();\r
- SQInteger CalcStackFrameSize();\r
- void AddLineInfos(SQInteger line,bool lineop,bool force=false);\r
- SQFunctionProto *BuildProto();\r
- SQInteger AllocStackPos();\r
- SQInteger PushTarget(SQInteger n=-1);\r
- SQInteger PopTarget();\r
- SQInteger TopTarget();\r
- SQInteger GetUpTarget(SQInteger n);\r
- bool IsLocal(SQUnsignedInteger stkpos);\r
- SQObject CreateString(const SQChar *s,SQInteger len = -1);\r
- SQInteger _returnexp;\r
- SQLocalVarInfoVec _vlocals;\r
- SQIntVec _targetstack;\r
- SQInteger _stacksize;\r
- bool _varparams;\r
- bool _bgenerator;\r
- SQIntVec _unresolvedbreaks;\r
- SQIntVec _unresolvedcontinues;\r
- SQObjectPtrVec _functions;\r
- SQObjectPtrVec _parameters;\r
- SQOuterVarVec _outervalues;\r
- SQInstructionVec _instructions;\r
- SQLocalVarInfoVec _localvarinfos;\r
- SQObjectPtr _literals;\r
- SQObjectPtr _strings;\r
- SQObjectPtr _name;\r
- SQObjectPtr _sourcename;\r
- SQInteger _nliterals;\r
- SQLineInfoVec _lineinfos;\r
- SQFuncState *_parent;\r
- SQIntVec _breaktargets; //contains number of nested exception traps\r
- SQIntVec _continuetargets;\r
- SQInteger _lastline;\r
- SQInteger _traps;\r
- bool _optimization;\r
- SQSharedState *_sharedstate;\r
- sqvector<SQFuncState*> _childstates;\r
- SQInteger GetConstant(const SQObject &cons);\r
-private:\r
- CompilerErrorFunc _errfunc;\r
- void *_errtarget;\r
-};\r
-\r
-\r
-#endif //_SQFUNCSTATE_H_\r
-\r
+/* see copyright notice in squirrel.h */
+#ifndef _SQFUNCSTATE_H_
+#define _SQFUNCSTATE_H_
+///////////////////////////////////
+#include "squtils.h"
+
+struct SQFuncState
+{
+ SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
+ ~SQFuncState();
+#ifdef _DEBUG_DUMP
+ void Dump(SQFunctionProto *func);
+#endif
+ void Error(const SQChar *err);
+ SQFuncState *PushChildState(SQSharedState *ss);
+ void PopChildState();
+ 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);}
+ void AddInstruction(SQInstruction &i);
+ void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
+ void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);
+ SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
+ void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
+ void SetStackSize(SQInteger n);
+ void SnoozeOpt(){_optimization=false;}
+ SQInteger GetCurrentPos(){return _instructions.size()-1;}
+ SQInteger GetNumericConstant(const SQInteger cons);
+ SQInteger GetNumericConstant(const SQFloat cons);
+ SQInteger PushLocalVariable(const SQObject &name);
+ void AddParameter(const SQObject &name);
+ void AddOuterValue(const SQObject &name);
+ SQInteger GetLocalVariable(const SQObject &name);
+ SQInteger GetOuterVariable(const SQObject &name);
+ SQInteger GenerateCode();
+ SQInteger GetStackSize();
+ SQInteger CalcStackFrameSize();
+ void AddLineInfos(SQInteger line,bool lineop,bool force=false);
+ SQFunctionProto *BuildProto();
+ SQInteger AllocStackPos();
+ SQInteger PushTarget(SQInteger n=-1);
+ SQInteger PopTarget();
+ SQInteger TopTarget();
+ SQInteger GetUpTarget(SQInteger n);
+ bool IsLocal(SQUnsignedInteger stkpos);
+ SQObject CreateString(const SQChar *s,SQInteger len = -1);
+ SQInteger _returnexp;
+ SQLocalVarInfoVec _vlocals;
+ SQIntVec _targetstack;
+ SQInteger _stacksize;
+ bool _varparams;
+ bool _bgenerator;
+ SQIntVec _unresolvedbreaks;
+ SQIntVec _unresolvedcontinues;
+ SQObjectPtrVec _functions;
+ SQObjectPtrVec _parameters;
+ SQOuterVarVec _outervalues;
+ SQInstructionVec _instructions;
+ SQLocalVarInfoVec _localvarinfos;
+ SQObjectPtr _literals;
+ SQObjectPtr _strings;
+ SQObjectPtr _name;
+ SQObjectPtr _sourcename;
+ SQInteger _nliterals;
+ SQLineInfoVec _lineinfos;
+ SQFuncState *_parent;
+ SQIntVec _breaktargets;
+ SQIntVec _continuetargets;
+ SQInteger _lastline;
+ SQInteger _traps; //contains number of nested exception traps
+ bool _optimization;
+ SQSharedState *_sharedstate;
+ sqvector<SQFuncState*> _childstates;
+ SQInteger GetConstant(const SQObject &cons);
+private:
+ CompilerErrorFunc _errfunc;
+ void *_errtarget;
+};
+
+
+#endif //_SQFUNCSTATE_H_