Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/squirrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
#if defined(__GNUC__) || defined(__clang__)
# define SQ_UNUSED_ARG(x) x __attribute__((__unused__))
#else
# define SQ_UNUSED_ARG(x) x
# define SQ_UNUSED_ARG(x)
#endif

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion squirrel/sqapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ HSQUIRRELVM sq_open(SQInteger initialstacksize)
sq_vm_destroy_alloc_context(&allocctx);
return NULL;
}
return v;
}

HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize)
Expand Down
6 changes: 3 additions & 3 deletions squirrel/sqbaselib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ static SQInteger string_substitute(HSQUIRRELVM v)
SQObjectPtr &val = stack_get(v, index);
SQObjectPtr valStr;
if (v->ToString(val, valStr)) {
int delta = _string(valStr)->_len - (j + 1 - i);
int delta = (int)_string(valStr)->_len - (j + 1 - i);
s = replace_substring_internal(allocctx, s, buf_len, len, i, j + 1 - i,
_stringval(valStr), _string(valStr)->_len);
i = j + delta;
Expand All @@ -1540,7 +1540,7 @@ static SQInteger string_substitute(HSQUIRRELVM v)
SQObjectPtr valStr;
if (table->GetStr(s + i + 1, j - i - 1, val)) {
if (v->ToString(val, valStr)) {
int delta = _string(valStr)->_len - (j + 1 - i);
int delta = (int)_string(valStr)->_len - (j + 1 - i);
s = replace_substring_internal(allocctx, s, buf_len, len, i, j + 1 - i,
_stringval(valStr), _string(valStr)->_len);
i = j + delta;
Expand Down Expand Up @@ -1755,7 +1755,7 @@ static SQInteger string_split(HSQUIRRELVM v)
const SQChar *sthis=_stringval(str); \
SQChar *snew=(_ss(v)->GetScratchPad(sq_rsl(len))); \
memcpy(snew,sthis,sq_rsl(len));\
for(SQInteger i=sidx;i<eidx;i++) snew[i] = func(sthis[i]); \
for(SQInteger i=sidx;i<eidx;i++) snew[i] = (SQChar)func(sthis[i]); \
v->Push(SQString::Create(_ss(v),snew,len)); \
return 1; \
}
Expand Down
7 changes: 5 additions & 2 deletions squirrel/sqcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,13 +977,14 @@ class SQCompiler
break;
}

SQObject id;
SQObject id = {};
SQObject constant;

switch(_token) {
case TK_IDENTIFIER: id = _fs->CreateString(_lex._svalue); break;
case TK_THIS: id = _fs->CreateString(_SC("this"),4); break;
case TK_CONSTRUCTOR: id = _fs->CreateString(_SC("constructor"),11); break;
default: Error("Unhandled token type %d", _token); break;
}

if (_stringval(id) == _stringval(_fs->_name)) {
Expand Down Expand Up @@ -1147,7 +1148,9 @@ class SQCompiler
if(target < 0) {
target = _fs->PushTarget();
}
if(sizeof(SQFloat) == sizeof(SQInt32)) {
// Fixes warning C4127: conditional expression is constant
static bool floatIs32Bit = (sizeof(SQFloat) == sizeof(SQInt32));
if(floatIs32Bit) {
_fs->AddInstruction(_OP_LOADFLOAT, target,*((SQInt32 *)&value));
}
else {
Expand Down
4 changes: 2 additions & 2 deletions squirrel/sqlexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ SQInteger SQLexer::LexSingleToken()
NEXT();
RETURN_TOKEN(c);
}
RETURN_TOKEN(0);
UNREACHABLE
}
}
}
Expand Down Expand Up @@ -732,7 +732,7 @@ SQInteger SQLexer::ReadNumber()
}
}
else {
APPEND_CHAR((int)firstchar);
APPEND_CHAR((SQChar)firstchar);
while (CUR_CHAR == _SC('.') || scisdigit(CUR_CHAR) || isexponent(CUR_CHAR)) {
if(CUR_CHAR == _SC('.') || isexponent(CUR_CHAR)) type = TFLOAT;
if(isexponent(CUR_CHAR)) {
Expand Down
6 changes: 3 additions & 3 deletions squirrel/sqobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,11 @@ bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr

for(i = 0; i < noutervalues; i++){
SQUnsignedInteger type;
SQObjectPtr name;
SQObjectPtr inner_name;
_CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger)));
_CHECK_IO(ReadObject(v, up, read, o));
_CHECK_IO(ReadObject(v, up, read, name));
f->_outervalues[i] = SQOuterVar(name,o, (SQOuterType)type);
_CHECK_IO(ReadObject(v, up, read, inner_name));
f->_outervalues[i] = SQOuterVar(inner_name,o, (SQOuterType)type);
}
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));

Expand Down
11 changes: 11 additions & 0 deletions squirrel/sqpcheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
#include <crtdbg.h>
#endif

#if defined(_MSC_VER)
#pragma warning(disable: 4706) // assignment within conditional expression
#pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
#endif

#if defined(_MSC_VER)
#define UNREACHABLE
#else
#define UNREACHABLE assert(0);
#endif

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions squirrel/sqtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void SQTable::AllocNodes(SQInteger nSize)
new (&n) _HashNode;
n.next=NULL;
}
_numofnodes_minus_one=nSize-1;
_numofnodes_minus_one=(uint32_t)(nSize-1);
_nodes=nodes;
_firstfree=&_nodes[_numofnodes_minus_one];
}
Expand Down Expand Up @@ -202,7 +202,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val VT_DECL_ARG

SQInteger SQTable::Next(bool getweakrefs,const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval)
{
uint32_t idx = TranslateIndex(refpos);
uint32_t idx = (uint32_t)TranslateIndex(refpos);
while (idx <= _numofnodes_minus_one) {
if(sq_type(_nodes[idx].key) != OT_NULL) {
//first found
Expand Down
32 changes: 15 additions & 17 deletions squirrel/sqvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
default:
_RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 );
}
assert(0);
UNREACHABLE
//if(sq_type(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; }
// _RET_SUCCEED(_integer(res));

Expand All @@ -273,8 +273,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
else { Raise_CompareError(o1,o2); return false; }

}
assert(0);
_RET_SUCCEED(0); //cannot happen
UNREACHABLE
}

bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res)
Expand Down Expand Up @@ -853,11 +852,11 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger nargs, SQInteger stackbase,SQ
case OT_TABLE:
case OT_USERDATA:
case OT_INSTANCE:{
SQObjectPtr closure;
if(_delegable(clo)->_delegate && _delegable(clo)->GetMetaMethod(this,MT_CALL,closure)) {
SQObjectPtr inner_closure;
if(_delegable(clo)->_delegate && _delegable(clo)->GetMetaMethod(this,MT_CALL, inner_closure)) {
Push(clo);
for (SQInteger i = 0; i < arg3; i++) Push(STK(arg2 + i));
if(!CallMetaMethod(closure, MT_CALL, arg3+1, clo)) SQ_THROW();
if(!CallMetaMethod(inner_closure, MT_CALL, arg3+1, clo)) SQ_THROW();
if(tgt0 != -1) {
STK(tgt0) = clo;
}
Expand Down Expand Up @@ -1211,11 +1210,11 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger nargs, SQInteger stackbase,SQ

while( ci ) {
if(ci->_etraps > 0) {
SQExceptionTrap &et = _etraps.top();
ci->_ip = et._ip;
_top = et._stacksize;
_stackbase = et._stackbase;
_stack._vals[_stackbase + et._extarget] = currerror;
SQExceptionTrap &inner_et = _etraps.top();
ci->_ip = inner_et._ip;
_top = inner_et._stacksize;
_stackbase = inner_et._stackbase;
_stack._vals[_stackbase + inner_et._extarget] = currerror;
_etraps.pop_back(); traps--; ci->_etraps--;
while(last_top >= _top) _stack._vals[last_top--].Null();
goto exception_restore;
Expand All @@ -1236,8 +1235,7 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger nargs, SQInteger stackbase,SQ
_lasterror = currerror;
return false;
}
assert(0);
return false;
UNREACHABLE
}

bool SQVM::CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor)
Expand Down Expand Up @@ -1291,10 +1289,10 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline)
_debughook_native(this,type,src,line,fname);
}
else {
SQObjectPtr temp_reg;
SQObjectPtr local_temp_reg;
SQInteger nparams=5;
Push(_roottable); Push(type); Push(func->_sourcename); Push(forcedline?forcedline:func->GetLine(ci->_ip)); Push(func->_name);
Call(_debughook_closure,nparams,_top-nparams,temp_reg,SQFalse);
Call(_debughook_closure,nparams,_top-nparams, local_temp_reg,SQFalse);
Pop(nparams);
}
_debughook = true;
Expand Down Expand Up @@ -1650,7 +1648,7 @@ SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const

bool SQVM::Clone(const SQObjectPtr &self,SQObjectPtr &target)
{
SQObjectPtr temp_reg;
SQObjectPtr local_temp_reg;
SQObjectPtr newobj;
switch(sq_type(self)){
case OT_TABLE:
Expand All @@ -1663,7 +1661,7 @@ bool SQVM::Clone(const SQObjectPtr &self,SQObjectPtr &target)
if(_delegable(newobj)->_delegate && _delegable(newobj)->GetMetaMethod(this,MT_CLONED,closure)) {
Push(newobj);
Push(self);
if(!CallMetaMethod(closure,MT_CLONED,2,temp_reg))
if(!CallMetaMethod(closure,MT_CLONED,2, local_temp_reg))
return false;
}
}
Expand Down