Browse Source

Fix typo in SetIntructionParams

mingodad 7 years ago
parent
commit
065b88a368

+ 1 - 1
SquiLu/include/sqapi.h

@@ -106,7 +106,7 @@ SQUIRREL_API_FUNC(void, setreleasehook, (HSQUIRRELVM v,SQInteger idx,SQRELEASEHO
 SQUIRREL_API_FUNC(SQRELEASEHOOK, getreleasehook, (HSQUIRRELVM v,SQInteger idx))
 SQUIRREL_API_FUNC(SQChar*, getscratchpad, (HSQUIRRELVM v,SQInteger minsize))
 SQUIRREL_API_FUNC(SQRESULT, getfunctioninfo, (HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi))
-SQUIRREL_API_FUNC(SQRESULT, getclosureinfo, (HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars))
+SQUIRREL_API_FUNC(SQRESULT, getclosureinfo, (HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars))
 SQUIRREL_API_FUNC(SQRESULT, getclosurename, (HSQUIRRELVM v,SQInteger idx))
 SQUIRREL_API_FUNC(SQRESULT, setnativeclosurename, (HSQUIRRELVM v,SQInteger idx,const SQChar *name))
 SQUIRREL_API_FUNC(SQRESULT, setinstanceup, (HSQUIRRELVM v, SQInteger idx, SQUserPointer p))

+ 3 - 3
SquiLu/squirrel/sqapi.cpp

@@ -521,14 +521,14 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars)
 	v->Push(SQObjectPtr(nc));
 }
 
-SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
+SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars)
 {
 	SQObjectPtr &o = stack_get(v, idx);
 	if(sq_type(o) == OT_CLOSURE) {
 		SQClosure *c = _closure(o);
 		SQFunctionProto *proto = c->_function;
-		*nparams = (SQUnsignedInteger)proto->_nparameters;
-		*nfreevars = (SQUnsignedInteger)proto->_noutervalues;
+		*nparams = (SQInteger)proto->_nparameters;
+		*nfreevars = (SQInteger)proto->_noutervalues;
 		return SQ_OK;
 	}
 	else if(sq_type(o) == OT_NATIVECLOSURE)

+ 26 - 22
SquiLu/squirrel/sqcompiler.cpp

@@ -136,6 +136,7 @@ struct SQScope
         case TK_UNSIGNED_LONG_INTEGER: \
         case TK_LONG_LONG_INTEGER: \
         case TK_UNSIGNED_LONG_LONG_INTEGER
+
 static SQInteger compilerReadFunc(SQUserPointer fp)
 {
     SQInteger c = fgetc((FILE *)fp);
@@ -412,6 +413,7 @@ public:
             Error(_SC("compile time checked constant fail \"%s\""), _stringval(key));
         }
     }
+
     bool ConstsNewSlot(const SQObjectPtr &key, const SQObjectPtr &val)
     {
         if(_scope.nested) return _table(_scope_consts[_scope.nested-1])->NewSlot(key,val);
@@ -589,6 +591,7 @@ public:
                     lib_path += path_len; //move the pointer to the next path
                 }
             }
+
             if(fp != NULL)
             {
                 //increment nested count
@@ -966,6 +969,7 @@ start_again:
             CheckLocalNameScope(id, _scope.nested);
             //Expect(_SC(';'));
             TypesNewSlot(strongid,SQObjectPtr(type_val));
+
             if(_token == _SC('[')) //fixed size array
             {
                 Lex();
@@ -1216,8 +1220,8 @@ start_again:
             Expression();
             SQInteger second_exp = _fs->PopTarget();
             if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
-            _fs->SetIntructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
-            _fs->SetIntructionParam(jzpos, 1, endfirstexp - jzpos + 1);
+            _fs->SetInstructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
+            _fs->SetInstructionParam(jzpos, 1, endfirstexp - jzpos + 1);
             _fs->SnoozeOpt();
         }
         break;
@@ -1258,7 +1262,7 @@ start_again:
                 SQInteger second_exp = _fs->PopTarget();
                 if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
                 _fs->SnoozeOpt();
-                _fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
+                _fs->SetInstructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
                 _es.etype = EXPR;
                 break;
             }
@@ -1282,7 +1286,7 @@ start_again:
                 SQInteger second_exp = _fs->PopTarget();
                 if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
                 _fs->SnoozeOpt();
-                _fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
+                _fs->SetInstructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
                 _es.etype = EXPR;
                 break;
             }
@@ -1818,7 +1822,7 @@ start_again:
                 _fs->AddInstruction(_OP_APPENDARRAY, array, val, AAT_STACK);
                 key++;
             }
-            _fs->SetIntructionParam(apos, 1, key);
+            _fs->SetInstructionParam(apos, 1, key);
             Lex();
         }
         break;
@@ -2290,7 +2294,7 @@ function_params_decl:
             }
         }
         if(separator == _SC(',')) //hack recognizes a table from the separator
-            _fs->SetIntructionParam(tpos, 1, nkeys);
+            _fs->SetInstructionParam(tpos, 1, nkeys);
         Lex();
     }
     void ExternDeclStatement()
@@ -2402,7 +2406,7 @@ function_params_decl:
             {
                 SQInstruction & inst = _fs->GetInstruction(i);
                 //printf("%d: %s\n", inst.op, SQGetOpName(inst.op));
-                if(inst.op == _OP_CLOSURE) _fs->SetIntructionParam(i, 0, inst._arg0 -1);
+                if(inst.op == _OP_CLOSURE) _fs->SetInstructionParam(i, 0, inst._arg0 -1);
             }
             _fs->PopTarget();
 #else
@@ -2550,9 +2554,9 @@ function_params_decl:
             Statement();
             if(_token != TK_IDENTIFIER) OptionalSemicolon();
             END_SCOPE();
-            _fs->SetIntructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
+            _fs->SetInstructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
         }
-        _fs->SetIntructionParam(jnepos, 1, endifblock - jnepos + (haselse?1:0));
+        _fs->SetInstructionParam(jnepos, 1, endifblock - jnepos + (haselse?1:0));
     }
     void WhileStatement()
     {
@@ -2572,7 +2576,7 @@ function_params_decl:
 
         END_SCOPE();
         _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
-        _fs->SetIntructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
+        _fs->SetInstructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
 
         END_BREAKBLE_BLOCK(jmppos);
     }
@@ -2665,7 +2669,7 @@ lbl_commaexpr:
                 _fs->AddInstruction(exp[i]);
         }
         _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1, 0);
-        if(jzpos>  0) _fs->SetIntructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
+        if(jzpos>  0) _fs->SetInstructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
 
         END_BREAKBLE_BLOCK(continuetrg);
         END_SCOPE();
@@ -2711,8 +2715,8 @@ lbl_commaexpr:
         BEGIN_BREAKBLE_BLOCK()
         Statement();
         _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
-        _fs->SetIntructionParam(foreachpos, 1, _fs->GetCurrentPos() - foreachpos);
-        _fs->SetIntructionParam(foreachpos + 1, 1, _fs->GetCurrentPos() - foreachpos);
+        _fs->SetInstructionParam(foreachpos, 1, _fs->GetCurrentPos() - foreachpos);
+        _fs->SetInstructionParam(foreachpos + 1, 1, _fs->GetCurrentPos() - foreachpos);
         END_BREAKBLE_BLOCK(foreachpos - 1);
         //restore the local variable stack(remove index,val and ref idx)
         _fs->PopTarget();
@@ -2737,7 +2741,7 @@ lbl_commaexpr:
             {
                 _fs->AddInstruction(_OP_JMP, 0, 0);
                 skipcondjmp = _fs->GetCurrentPos();
-                _fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
+                _fs->SetInstructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
             }
             //condition
             Lex();
@@ -2760,7 +2764,7 @@ lbl_commaexpr:
             //end condition
             if(skipcondjmp != -1)
             {
-                _fs->SetIntructionParam(skipcondjmp, 1, (_fs->GetCurrentPos() - skipcondjmp));
+                _fs->SetInstructionParam(skipcondjmp, 1, (_fs->GetCurrentPos() - skipcondjmp));
             }
             tonextcondjmp = _fs->GetCurrentPos();
             BEGIN_SCOPE();
@@ -2769,7 +2773,7 @@ lbl_commaexpr:
             bfirst = false;
         }
         if(tonextcondjmp != -1)
-            _fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
+            _fs->SetInstructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
         if(_token == TK_DEFAULT)
         {
             Lex();
@@ -3019,7 +3023,7 @@ error:
         if(_fs->_continuetargets.size()) _fs->_continuetargets.top()--;
         _fs->AddInstruction(_OP_JMP, 0, 0);
         SQInteger jmppos = _fs->GetCurrentPos();
-        _fs->SetIntructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos));
+        _fs->SetInstructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos));
         Expect(TK_CATCH);
         Expect(_SC('('));
         exid = Expect(TK_IDENTIFIER);
@@ -3032,9 +3036,9 @@ error:
         {
             BEGIN_SCOPE();
             SQInteger ex_target = _fs->PushLocalVariable(exid, _scope.nested);
-            _fs->SetIntructionParam(trappos, 0, ex_target);
+            _fs->SetInstructionParam(trappos, 0, ex_target);
             Statement();
-            _fs->SetIntructionParams(jmppos, 0, (_fs->GetCurrentPos() - jmppos), 0);
+            _fs->SetInstructionParams(jmppos, 0, (_fs->GetCurrentPos() - jmppos), 0);
             END_SCOPE();
         }
     }
@@ -3319,7 +3323,7 @@ error:
             break;
         }
 
-        _fs->SetIntructionParams(goto_info.pos, 0, jump_pos, 0);
+        _fs->SetInstructionParams(goto_info.pos, 0, jump_pos, 0);
     }
     void ResolveGotos()
     {
@@ -3384,7 +3388,7 @@ error:
             SQInteger pos = funcstate->_unresolvedbreaks.back();
             funcstate->_unresolvedbreaks.pop_back();
             //set the jmp instruction
-            funcstate->SetIntructionParams(pos, 0, funcstate->GetCurrentPos() - pos, 0);
+            funcstate->SetInstructionParams(pos, 0, funcstate->GetCurrentPos() - pos, 0);
             ntoresolve--;
         }
     }
@@ -3395,7 +3399,7 @@ error:
             SQInteger pos = funcstate->_unresolvedcontinues.back();
             funcstate->_unresolvedcontinues.pop_back();
             //set the jmp instruction
-            funcstate->SetIntructionParams(pos, 0, targetpos - pos, 0);
+            funcstate->SetInstructionParams(pos, 0, targetpos - pos, 0);
             ntoresolve--;
         }
     }

+ 3 - 2
SquiLu/squirrel/sqfuncstate.cpp

@@ -168,7 +168,7 @@ SQInteger SQFuncState::GetConstant(const SQObject &cons)
 	return _integer(val);
 }
 
-void SQFuncState::SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2,SQInteger arg3)
+void SQFuncState::SetInstructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2,SQInteger arg3)
 {
 	_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&arg0);
 	_instructions[pos]._arg1=(SQInt32)*((SQUnsignedInteger *)&arg1);
@@ -176,7 +176,7 @@ void SQFuncState::SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg
 	_instructions[pos]._arg3=(unsigned char)*((SQUnsignedInteger *)&arg3);
 }
 
-void SQFuncState::SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val)
+void SQFuncState::SetInstructionParam(SQInteger pos,SQInteger arg,SQInteger val)
 {
 	switch(arg){
 		case 0:_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&val);break;
@@ -375,6 +375,7 @@ void SQFuncState::SetReturnTypeName(const SQChar *type_name)
 {
 	if(type_name) _return_type = CreateString(type_name, scstrlen(type_name));
 }
+
 SQInteger SQFuncState::FindGotoTarget(const SQObject &name)
 {
 	for(size_t i=0, len=_gototargets.size(); i < len; ++i){

+ 2 - 2
SquiLu/squirrel/sqfuncstate.h

@@ -16,8 +16,8 @@ struct SQFuncState
 	void PopChildState();
 	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);}
 	void AddInstruction(SQInstruction &i);
-	void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
-	void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);
+	void SetInstructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
+	void SetInstructionParam(SQInteger pos,SQInteger arg,SQInteger val);
 	SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
 	void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
 	void SetStackSize(SQInteger n);