The Squirrel interpreter. See http://www.squirrel-lang.org/
squirrel/sqfuncstate.h@3:7268a3ceaffc, 2014-12-16 (annotated)
- Committer:
- jhnwkmn
- Date:
- Tue Dec 16 11:39:42 2014 +0000
- Revision:
- 3:7268a3ceaffc
- Parent:
- 0:97a4f8cc534c
Accepts \r as line terminator as well.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhnwkmn | 0:97a4f8cc534c | 1 | /* see copyright notice in squirrel.h */ |
jhnwkmn | 0:97a4f8cc534c | 2 | #ifndef _SQFUNCSTATE_H_ |
jhnwkmn | 0:97a4f8cc534c | 3 | #define _SQFUNCSTATE_H_ |
jhnwkmn | 0:97a4f8cc534c | 4 | /////////////////////////////////// |
jhnwkmn | 0:97a4f8cc534c | 5 | #include "squtils.h" |
jhnwkmn | 0:97a4f8cc534c | 6 | |
jhnwkmn | 0:97a4f8cc534c | 7 | struct SQFuncState |
jhnwkmn | 0:97a4f8cc534c | 8 | { |
jhnwkmn | 0:97a4f8cc534c | 9 | SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed); |
jhnwkmn | 0:97a4f8cc534c | 10 | ~SQFuncState(); |
jhnwkmn | 0:97a4f8cc534c | 11 | #ifdef _DEBUG_DUMP |
jhnwkmn | 0:97a4f8cc534c | 12 | void Dump(SQFunctionProto *func); |
jhnwkmn | 0:97a4f8cc534c | 13 | #endif |
jhnwkmn | 0:97a4f8cc534c | 14 | void Error(const SQChar *err); |
jhnwkmn | 0:97a4f8cc534c | 15 | SQFuncState *PushChildState(SQSharedState *ss); |
jhnwkmn | 0:97a4f8cc534c | 16 | void PopChildState(); |
jhnwkmn | 0:97a4f8cc534c | 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);} |
jhnwkmn | 0:97a4f8cc534c | 18 | void AddInstruction(SQInstruction &i); |
jhnwkmn | 0:97a4f8cc534c | 19 | void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0); |
jhnwkmn | 0:97a4f8cc534c | 20 | void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val); |
jhnwkmn | 0:97a4f8cc534c | 21 | SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];} |
jhnwkmn | 0:97a4f8cc534c | 22 | void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();} |
jhnwkmn | 0:97a4f8cc534c | 23 | void SetStackSize(SQInteger n); |
jhnwkmn | 0:97a4f8cc534c | 24 | SQInteger CountOuters(SQInteger stacksize); |
jhnwkmn | 0:97a4f8cc534c | 25 | void SnoozeOpt(){_optimization=false;} |
jhnwkmn | 0:97a4f8cc534c | 26 | void AddDefaultParam(SQInteger trg) { _defaultparams.push_back(trg); } |
jhnwkmn | 0:97a4f8cc534c | 27 | SQInteger GetDefaultParamCount() { return _defaultparams.size(); } |
jhnwkmn | 0:97a4f8cc534c | 28 | SQInteger GetCurrentPos(){return _instructions.size()-1;} |
jhnwkmn | 0:97a4f8cc534c | 29 | SQInteger GetNumericConstant(const SQInteger cons); |
jhnwkmn | 0:97a4f8cc534c | 30 | SQInteger GetNumericConstant(const SQFloat cons); |
jhnwkmn | 0:97a4f8cc534c | 31 | SQInteger PushLocalVariable(const SQObject &name); |
jhnwkmn | 0:97a4f8cc534c | 32 | void AddParameter(const SQObject &name); |
jhnwkmn | 0:97a4f8cc534c | 33 | //void AddOuterValue(const SQObject &name); |
jhnwkmn | 0:97a4f8cc534c | 34 | SQInteger GetLocalVariable(const SQObject &name); |
jhnwkmn | 0:97a4f8cc534c | 35 | void MarkLocalAsOuter(SQInteger pos); |
jhnwkmn | 0:97a4f8cc534c | 36 | SQInteger GetOuterVariable(const SQObject &name); |
jhnwkmn | 0:97a4f8cc534c | 37 | SQInteger GenerateCode(); |
jhnwkmn | 0:97a4f8cc534c | 38 | SQInteger GetStackSize(); |
jhnwkmn | 0:97a4f8cc534c | 39 | SQInteger CalcStackFrameSize(); |
jhnwkmn | 0:97a4f8cc534c | 40 | void AddLineInfos(SQInteger line,bool lineop,bool force=false); |
jhnwkmn | 0:97a4f8cc534c | 41 | SQFunctionProto *BuildProto(); |
jhnwkmn | 0:97a4f8cc534c | 42 | SQInteger AllocStackPos(); |
jhnwkmn | 0:97a4f8cc534c | 43 | SQInteger PushTarget(SQInteger n=-1); |
jhnwkmn | 0:97a4f8cc534c | 44 | SQInteger PopTarget(); |
jhnwkmn | 0:97a4f8cc534c | 45 | SQInteger TopTarget(); |
jhnwkmn | 0:97a4f8cc534c | 46 | SQInteger GetUpTarget(SQInteger n); |
jhnwkmn | 0:97a4f8cc534c | 47 | void DiscardTarget(); |
jhnwkmn | 0:97a4f8cc534c | 48 | bool IsLocal(SQUnsignedInteger stkpos); |
jhnwkmn | 0:97a4f8cc534c | 49 | SQObject CreateString(const SQChar *s,SQInteger len = -1); |
jhnwkmn | 0:97a4f8cc534c | 50 | SQObject CreateTable(); |
jhnwkmn | 0:97a4f8cc534c | 51 | bool IsConstant(const SQObject &name,SQObject &e); |
jhnwkmn | 0:97a4f8cc534c | 52 | SQInteger _returnexp; |
jhnwkmn | 0:97a4f8cc534c | 53 | SQLocalVarInfoVec _vlocals; |
jhnwkmn | 0:97a4f8cc534c | 54 | SQIntVec _targetstack; |
jhnwkmn | 0:97a4f8cc534c | 55 | SQInteger _stacksize; |
jhnwkmn | 0:97a4f8cc534c | 56 | bool _varparams; |
jhnwkmn | 0:97a4f8cc534c | 57 | bool _bgenerator; |
jhnwkmn | 0:97a4f8cc534c | 58 | SQIntVec _unresolvedbreaks; |
jhnwkmn | 0:97a4f8cc534c | 59 | SQIntVec _unresolvedcontinues; |
jhnwkmn | 0:97a4f8cc534c | 60 | SQObjectPtrVec _functions; |
jhnwkmn | 0:97a4f8cc534c | 61 | SQObjectPtrVec _parameters; |
jhnwkmn | 0:97a4f8cc534c | 62 | SQOuterVarVec _outervalues; |
jhnwkmn | 0:97a4f8cc534c | 63 | SQInstructionVec _instructions; |
jhnwkmn | 0:97a4f8cc534c | 64 | SQLocalVarInfoVec _localvarinfos; |
jhnwkmn | 0:97a4f8cc534c | 65 | SQObjectPtr _literals; |
jhnwkmn | 0:97a4f8cc534c | 66 | SQObjectPtr _strings; |
jhnwkmn | 0:97a4f8cc534c | 67 | SQObjectPtr _name; |
jhnwkmn | 0:97a4f8cc534c | 68 | SQObjectPtr _sourcename; |
jhnwkmn | 0:97a4f8cc534c | 69 | SQInteger _nliterals; |
jhnwkmn | 0:97a4f8cc534c | 70 | SQLineInfoVec _lineinfos; |
jhnwkmn | 0:97a4f8cc534c | 71 | SQFuncState *_parent; |
jhnwkmn | 0:97a4f8cc534c | 72 | SQIntVec _scope_blocks; |
jhnwkmn | 0:97a4f8cc534c | 73 | SQIntVec _breaktargets; |
jhnwkmn | 0:97a4f8cc534c | 74 | SQIntVec _continuetargets; |
jhnwkmn | 0:97a4f8cc534c | 75 | SQIntVec _defaultparams; |
jhnwkmn | 0:97a4f8cc534c | 76 | SQInteger _lastline; |
jhnwkmn | 0:97a4f8cc534c | 77 | SQInteger _traps; //contains number of nested exception traps |
jhnwkmn | 0:97a4f8cc534c | 78 | SQInteger _outers; |
jhnwkmn | 0:97a4f8cc534c | 79 | bool _optimization; |
jhnwkmn | 0:97a4f8cc534c | 80 | SQSharedState *_sharedstate; |
jhnwkmn | 0:97a4f8cc534c | 81 | sqvector<SQFuncState*> _childstates; |
jhnwkmn | 0:97a4f8cc534c | 82 | SQInteger GetConstant(const SQObject &cons); |
jhnwkmn | 0:97a4f8cc534c | 83 | private: |
jhnwkmn | 0:97a4f8cc534c | 84 | CompilerErrorFunc _errfunc; |
jhnwkmn | 0:97a4f8cc534c | 85 | void *_errtarget; |
jhnwkmn | 0:97a4f8cc534c | 86 | SQSharedState *_ss; |
jhnwkmn | 0:97a4f8cc534c | 87 | }; |
jhnwkmn | 0:97a4f8cc534c | 88 | |
jhnwkmn | 0:97a4f8cc534c | 89 | |
jhnwkmn | 0:97a4f8cc534c | 90 | #endif //_SQFUNCSTATE_H_ |
jhnwkmn | 0:97a4f8cc534c | 91 |