Update to Squirrel 3.0.6
[supertux.git] / external / squirrel / squirrel / sqfuncproto.h
old mode 100755 (executable)
new mode 100644 (file)
index 50c6fd7..cd48aa6
@@ -6,8 +6,7 @@
 \r
 enum SQOuterType {\r
        otLOCAL = 0,\r
-       otSYMBOL = 1,\r
-       otOUTER = 2\r
+       otOUTER = 1\r
 };\r
 \r
 struct SQOuterVar\r
@@ -33,7 +32,7 @@ struct SQOuterVar
 \r
 struct SQLocalVarInfo\r
 {\r
-       SQLocalVarInfo():_start_op(0),_end_op(0){}\r
+       SQLocalVarInfo():_start_op(0),_end_op(0),_pos(0){}\r
        SQLocalVarInfo(const SQLocalVarInfo &lvi)\r
        {\r
                _name=lvi._name;\r
@@ -59,25 +58,15 @@ typedef sqvector<SQLineInfo> SQLineInfoVec;
                +(nouters*sizeof(SQOuterVar))+(nlineinf*sizeof(SQLineInfo)) \\r
                +(localinf*sizeof(SQLocalVarInfo))+(defparams*sizeof(SQInteger)))\r
 \r
-#define _CONSTRUCT_VECTOR(type,size,ptr) { \\r
-       for(SQInteger n = 0; n < size; n++) { \\r
-                       new (&ptr[n]) type(); \\r
-               } \\r
-}\r
-\r
-#define _DESTRUCT_VECTOR(type,size,ptr) { \\r
-       for(SQInteger nl = 0; nl < size; nl++) { \\r
-                       ptr[nl].~type(); \\r
-       } \\r
-}\r
-struct SQFunctionProto : public SQRefCounted\r
+\r
+struct SQFunctionProto : public CHAINABLE_OBJ\r
 {\r
 private:\r
-       SQFunctionProto(){\r
-       _stacksize=0;\r
-       _bgenerator=false;}\r
+       SQFunctionProto(SQSharedState *ss);\r
+       ~SQFunctionProto();\r
+       \r
 public:\r
-       static SQFunctionProto *Create(SQInteger ninstructions,\r
+       static SQFunctionProto *Create(SQSharedState *ss,SQInteger ninstructions,\r
                SQInteger nliterals,SQInteger nparameters,\r
                SQInteger nfunctions,SQInteger noutervalues,\r
                SQInteger nlineinfos,SQInteger nlocalvarinfos,SQInteger ndefaultparams)\r
@@ -85,7 +74,7 @@ public:
                SQFunctionProto *f;\r
                //I compact the whole class and members in a single memory allocation\r
                f = (SQFunctionProto *)sq_vm_malloc(_FUNC_SIZE(ninstructions,nliterals,nparameters,nfunctions,noutervalues,nlineinfos,nlocalvarinfos,ndefaultparams));\r
-               new (f) SQFunctionProto;\r
+               new (f) SQFunctionProto(ss);\r
                f->_ninstructions = ninstructions;\r
                f->_literals = (SQObjectPtr*)&f->_instructions[ninstructions];\r
                f->_nliterals = nliterals;\r
@@ -121,16 +110,21 @@ public:
                this->~SQFunctionProto();\r
                sq_vm_free(this,size);\r
        }\r
+       \r
        const SQChar* GetLocal(SQVM *v,SQUnsignedInteger stackbase,SQUnsignedInteger nseq,SQUnsignedInteger nop);\r
        SQInteger GetLine(SQInstruction *curr);\r
        bool Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);\r
        static bool Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);\r
-\r
+#ifndef NO_GARBAGE_COLLECTOR\r
+       void Mark(SQCollectable **chain);\r
+       void Finalize(){ _NULL_SQOBJECT_VECTOR(_literals,_nliterals); }\r
+       SQObjectType GetType() {return OT_FUNCPROTO;}\r
+#endif\r
        SQObjectPtr _sourcename;\r
        SQObjectPtr _name;\r
     SQInteger _stacksize;\r
        bool _bgenerator;\r
-       bool _varparams;\r
+       SQInteger _varparams;\r
 \r
        SQInteger _nlocalvarinfos;\r
        SQLocalVarInfo *_localvarinfos;\r