Johan Wikman / SQUIRREL3

Dependents:   Squirrel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sqfuncstate.h Source File

sqfuncstate.h

00001 /*  see copyright notice in squirrel.h */
00002 #ifndef _SQFUNCSTATE_H_
00003 #define _SQFUNCSTATE_H_
00004 ///////////////////////////////////
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     SQInteger CountOuters(SQInteger stacksize);
00025     void SnoozeOpt(){_optimization=false;}
00026     void AddDefaultParam(SQInteger trg) { _defaultparams.push_back(trg); }
00027     SQInteger GetDefaultParamCount() { return _defaultparams.size(); }
00028     SQInteger GetCurrentPos(){return _instructions.size()-1;}
00029     SQInteger GetNumericConstant(const SQInteger cons);
00030     SQInteger GetNumericConstant(const SQFloat cons);
00031     SQInteger PushLocalVariable(const SQObject &name);
00032     void AddParameter(const SQObject &name);
00033     //void AddOuterValue(const SQObject &name);
00034     SQInteger GetLocalVariable(const SQObject &name);
00035     void MarkLocalAsOuter(SQInteger pos);
00036     SQInteger GetOuterVariable(const SQObject &name);
00037     SQInteger GenerateCode();
00038     SQInteger GetStackSize();
00039     SQInteger CalcStackFrameSize();
00040     void AddLineInfos(SQInteger line,bool lineop,bool force=false);
00041     SQFunctionProto *BuildProto();
00042     SQInteger AllocStackPos();
00043     SQInteger PushTarget(SQInteger n=-1);
00044     SQInteger PopTarget();
00045     SQInteger TopTarget();
00046     SQInteger GetUpTarget(SQInteger n);
00047     void DiscardTarget();
00048     bool IsLocal(SQUnsignedInteger stkpos);
00049     SQObject CreateString(const SQChar *s,SQInteger len = -1);
00050     SQObject CreateTable();
00051     bool IsConstant(const SQObject &name,SQObject &e);
00052     SQInteger _returnexp;
00053     SQLocalVarInfoVec _vlocals;
00054     SQIntVec _targetstack;
00055     SQInteger _stacksize;
00056     bool _varparams;
00057     bool _bgenerator;
00058     SQIntVec _unresolvedbreaks;
00059     SQIntVec _unresolvedcontinues;
00060     SQObjectPtrVec _functions;
00061     SQObjectPtrVec _parameters;
00062     SQOuterVarVec _outervalues;
00063     SQInstructionVec _instructions;
00064     SQLocalVarInfoVec _localvarinfos;
00065     SQObjectPtr _literals;
00066     SQObjectPtr _strings;
00067     SQObjectPtr _name;
00068     SQObjectPtr _sourcename;
00069     SQInteger _nliterals;
00070     SQLineInfoVec _lineinfos;
00071     SQFuncState *_parent;
00072     SQIntVec _scope_blocks;
00073     SQIntVec _breaktargets;
00074     SQIntVec _continuetargets;
00075     SQIntVec _defaultparams;
00076     SQInteger _lastline;
00077     SQInteger _traps; //contains number of nested exception traps
00078     SQInteger _outers;
00079     bool _optimization;
00080     SQSharedState *_sharedstate;
00081     sqvector<SQFuncState*> _childstates;
00082     SQInteger GetConstant(const SQObject &cons);
00083 private:
00084     CompilerErrorFunc _errfunc;
00085     void *_errtarget;
00086     SQSharedState *_ss;
00087 };
00088 
00089 
00090 #endif //_SQFUNCSTATE_H_
00091