sqfuncstate.h

00001 /*  see copyright notice in squirrel.h */
00002 #ifndef _SQFUNCSTATE_H_
00003 #define _SQFUNCSTATE_H_
00005 #include "squtils.h"
00006 
00007 struct SQFuncState
00008 {
00009   SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
00010   ~SQFuncState();
00011 #ifdef _DEBUG_DUMP
00012   void Dump(SQFunctionProto *func);
00013 #endif
00014   void Error(const SQChar *err);
00015   SQFuncState *PushChildState(SQSharedState *ss);
00016   void PopChildState();
00017   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);}
00018   void AddInstruction(SQInstruction &i);
00019   void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
00020   void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);
00021   SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
00022   void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
00023   void SetStackSize(SQInteger n);
00024   void SnoozeOpt(){_optimization=false;}
00025   void AddDefaultParam(SQInteger trg) { _defaultparams.push_back(trg); }
00026   SQInteger GetDefaultParamCount() { return _defaultparams.size(); }
00027   SQInteger GetCurrentPos(){return _instructions.size()-1;}
00028   SQInteger GetNumericConstant(const SQInteger cons);
00029   SQInteger GetNumericConstant(const SQFloat cons);
00030   SQInteger PushLocalVariable(const SQObject &name);
00031   void AddParameter(const SQObject &name);
00032   void AddOuterValue(const SQObject &name);
00033   SQInteger GetLocalVariable(const SQObject &name);
00034   SQInteger GetOuterVariable(const SQObject &name);
00035   SQInteger GenerateCode();
00036   SQInteger GetStackSize();
00037   SQInteger CalcStackFrameSize();
00038   void AddLineInfos(SQInteger line,bool lineop,bool force=false);
00039   SQFunctionProto *BuildProto();
00040   SQInteger AllocStackPos();
00041   SQInteger PushTarget(SQInteger n=-1);
00042   SQInteger PopTarget();
00043   SQInteger TopTarget();
00044   SQInteger GetUpTarget(SQInteger n);
00045   bool IsLocal(SQUnsignedInteger stkpos);
00046   SQObject CreateString(const SQChar *s,SQInteger len = -1);
00047   SQObject CreateTable();
00048   bool IsConstant(const SQObject &name,SQObject &e);
00049   SQInteger _returnexp;
00050   SQLocalVarInfoVec _vlocals;
00051   SQIntVec _targetstack;
00052   SQInteger _stacksize;
00053   bool _varparams;
00054   bool _bgenerator;
00055   SQIntVec _unresolvedbreaks;
00056   SQIntVec _unresolvedcontinues;
00057   SQObjectPtrVec _functions;
00058   SQObjectPtrVec _parameters;
00059   SQOuterVarVec _outervalues;
00060   SQInstructionVec _instructions;
00061   SQLocalVarInfoVec _localvarinfos;
00062   SQObjectPtr _literals;
00063   SQObjectPtr _strings;
00064   SQObjectPtr _name;
00065   SQObjectPtr _sourcename;
00066   SQInteger _nliterals;
00067   SQLineInfoVec _lineinfos;
00068   SQFuncState *_parent;
00069   SQIntVec _breaktargets;
00070   SQIntVec _continuetargets;
00071   SQIntVec _defaultparams;
00072   SQInteger _lastline;
00073   SQInteger _traps; //contains number of nested exception traps
00074   bool _optimization;
00075   SQSharedState *_sharedstate;
00076   sqvector<SQFuncState*> _childstates;
00077   SQInteger GetConstant(const SQObject &cons);
00078 private:
00079   CompilerErrorFunc _errfunc;
00080   void *_errtarget;
00081 };
00082 
00083 
00084 #endif //_SQFUNCSTATE_H_
00085 

Generated on Thu Oct 1 11:03:11 2009 for OpenTTD by  doxygen 1.5.6