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