Merge tag '14.0-beta1' into jgrpp
# Conflicts: # src/3rdparty/squirrel/squirrel/sqcompiler.cpp # src/aircraft.h # src/animated_tile.h # src/base_consist.h # src/cargotype.h # src/company_gui.cpp # src/console_cmds.cpp # src/core/overflowsafe_type.hpp # src/engine_gui.cpp # src/industry_gui.cpp # src/lang/english.txt # src/music/extmidi.cpp # src/network/core/network_game_info.cpp # src/network/network_server.cpp # src/newgrf.cpp # src/newgrf_industries.cpp # src/order_base.h # src/order_cmd.cpp # src/order_gui.cpp # src/order_type.h # src/os/macosx/misc_osx.cpp # src/os/windows/crashlog_win.cpp # src/rail_gui.cpp # src/rail_gui.h # src/roadveh.h # src/roadveh_cmd.cpp # src/saveload/afterload.cpp # src/saveload/company_sl.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/saveload/saveload_error.hpp # src/script/api/script_town.cpp # src/settingsgen/settingsgen.cpp # src/ship.h # src/ship_cmd.cpp # src/smallmap_gui.cpp # src/spritecache.cpp # src/stdafx.h # src/strgen/strgen.cpp # src/strgen/strgen.h # src/table/settings/script_settings.ini # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/town.h # src/town_cmd.cpp # src/town_cmd.h # src/town_gui.cpp # src/train.h # src/train_cmd.cpp # src/tree_cmd.cpp # src/vehicle.cpp # src/vehicle_base.h # src/vehicle_cmd.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/waypoint_base.h # src/widget.cpp
This commit is contained in:
32
src/3rdparty/squirrel/squirrel/sqcompiler.cpp
vendored
32
src/3rdparty/squirrel/squirrel/sqcompiler.cpp
vendored
@@ -56,24 +56,26 @@ typedef sqvector<ExpState> ExpStateVec;
|
||||
class SQCompiler
|
||||
{
|
||||
public:
|
||||
SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) : _token(0), _fs(nullptr), _lex(_ss(v), rg, up, ThrowError, this), _debugline(0), _debugop(0)
|
||||
SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) : _token(0), _fs(nullptr), _lex(_ss(v), rg, up), _debugline(0), _debugop(0)
|
||||
{
|
||||
_vm=v;
|
||||
_sourcename = SQString::Create(_ss(v), sourcename);
|
||||
_lineinfo = lineinfo;_raiseerror = raiseerror;
|
||||
}
|
||||
NORETURN static void ThrowError(void *ud, const SQChar *s) {
|
||||
SQCompiler *c = (SQCompiler *)ud;
|
||||
c->Error("%s", s);
|
||||
}
|
||||
NORETURN void Error(const SQChar *s, ...) WARN_FORMAT(2, 3)
|
||||
|
||||
[[noreturn]] void Error(const SQChar *s, ...) WARN_FORMAT(2, 3)
|
||||
{
|
||||
static SQChar temp[256];
|
||||
va_list vl;
|
||||
va_start(vl, s);
|
||||
vseprintf(temp, lastof(temp), s, vl);
|
||||
va_end(vl);
|
||||
throw temp;
|
||||
throw CompileException(temp);
|
||||
}
|
||||
|
||||
[[noreturn]] void Error(const std::string &msg)
|
||||
{
|
||||
throw CompileException(msg);
|
||||
}
|
||||
void Lex(){ _token = _lex.Lex();}
|
||||
void PushExpState(){ _expstates.push_back(ExpState()); }
|
||||
@@ -163,7 +165,7 @@ public:
|
||||
_debugline = 1;
|
||||
_debugop = 0;
|
||||
|
||||
SQFuncState funcstate(_ss(_vm), nullptr,ThrowError,this);
|
||||
SQFuncState funcstate(_ss(_vm), nullptr);
|
||||
funcstate._name = SQString::Create(_ss(_vm), "main");
|
||||
_fs = &funcstate;
|
||||
_fs->AddParameter(_fs->CreateString("this"));
|
||||
@@ -185,20 +187,12 @@ public:
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
catch (SQChar *compilererror) {
|
||||
catch (const CompileException &compilererror) {
|
||||
if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
|
||||
_ss(_vm)->_compilererrorhandler(_vm, compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):"unknown",
|
||||
_ss(_vm)->_compilererrorhandler(_vm, compilererror.what(), type(_sourcename) == OT_STRING ? _stringval(_sourcename) : "unknown",
|
||||
_lex._currentline, _lex._currentcolumn);
|
||||
}
|
||||
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror, -1);
|
||||
return false;
|
||||
}
|
||||
catch (const std::string &compilererror) {
|
||||
if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
|
||||
_ss(_vm)->_compilererrorhandler(_vm, compilererror.c_str(), type(_sourcename) == OT_STRING ? _stringval(_sourcename) : "unknown",
|
||||
_lex._currentline, _lex._currentcolumn);
|
||||
}
|
||||
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror);
|
||||
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
7
src/3rdparty/squirrel/squirrel/sqcompiler.h
vendored
7
src/3rdparty/squirrel/squirrel/sqcompiler.h
vendored
@@ -71,12 +71,7 @@ struct SQVM;
|
||||
#define TK_ENUM 323
|
||||
#define TK_CONST 324
|
||||
|
||||
/* MSVC doesn't like NORETURN for function prototypes, but we kinda need it for GCC. */
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
typedef void(*CompilerErrorFunc)(void *ud, const SQChar *s);
|
||||
#else
|
||||
typedef NORETURN void(*CompilerErrorFunc)(void *ud, const SQChar *s);
|
||||
#endif
|
||||
using CompileException = std::runtime_error;
|
||||
|
||||
bool Compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo);
|
||||
#endif //_SQCOMPILER_H_
|
||||
|
@@ -92,7 +92,7 @@ void DumpLiteral(SQObjectPtr &o)
|
||||
}
|
||||
#endif
|
||||
|
||||
SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed)
|
||||
SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent)
|
||||
{
|
||||
_nliterals = 0;
|
||||
_literals = SQTable::Create(ss,0);
|
||||
@@ -105,15 +105,13 @@ SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc
|
||||
_traps = 0;
|
||||
_returnexp = 0;
|
||||
_varparams = false;
|
||||
_errfunc = efunc;
|
||||
_errtarget = ed;
|
||||
_bgenerator = false;
|
||||
|
||||
}
|
||||
|
||||
void SQFuncState::Error(const SQChar *err)
|
||||
{
|
||||
_errfunc(_errtarget,err);
|
||||
throw CompileException(err);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_DUMP
|
||||
@@ -549,7 +547,7 @@ SQFunctionProto *SQFuncState::BuildProto()
|
||||
SQFuncState *SQFuncState::PushChildState(SQSharedState *ss)
|
||||
{
|
||||
SQFuncState *child = (SQFuncState *)sq_malloc(sizeof(SQFuncState));
|
||||
new (child) SQFuncState(ss,this,_errfunc,_errtarget);
|
||||
new (child) SQFuncState(ss,this);
|
||||
_childstates.push_back(child);
|
||||
return child;
|
||||
}
|
||||
|
7
src/3rdparty/squirrel/squirrel/sqfuncstate.h
vendored
7
src/3rdparty/squirrel/squirrel/sqfuncstate.h
vendored
@@ -6,12 +6,12 @@
|
||||
|
||||
struct SQFuncState
|
||||
{
|
||||
SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
|
||||
SQFuncState(SQSharedState *ss,SQFuncState *parent);
|
||||
~SQFuncState();
|
||||
#ifdef _DEBUG_DUMP
|
||||
void Dump(SQFunctionProto *func);
|
||||
#endif
|
||||
void Error(const SQChar *err);
|
||||
[[noreturn]] void Error(const SQChar *err);
|
||||
SQFuncState *PushChildState(SQSharedState *ss);
|
||||
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);}
|
||||
@@ -75,9 +75,6 @@ struct SQFuncState
|
||||
SQSharedState *_sharedstate;
|
||||
sqvector<SQFuncState*> _childstates;
|
||||
SQInteger GetConstant(const SQObject &cons);
|
||||
private:
|
||||
CompilerErrorFunc _errfunc;
|
||||
void *_errtarget;
|
||||
};
|
||||
|
||||
|
||||
|
8
src/3rdparty/squirrel/squirrel/sqlexer.cpp
vendored
8
src/3rdparty/squirrel/squirrel/sqlexer.cpp
vendored
@@ -35,10 +35,8 @@ void SQLexer::APPEND_CHAR(char32_t c)
|
||||
}
|
||||
}
|
||||
|
||||
SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerErrorFunc efunc,void *ed)
|
||||
SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up)
|
||||
{
|
||||
_errfunc = efunc;
|
||||
_errtarget = ed;
|
||||
_sharedstate = ss;
|
||||
_keywords = SQTable::Create(ss, 26);
|
||||
ADD_KEYWORD(while, TK_WHILE);
|
||||
@@ -94,9 +92,9 @@ SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerE
|
||||
Next();
|
||||
}
|
||||
|
||||
NORETURN void SQLexer::Error(const SQChar *err)
|
||||
[[noreturn]] void SQLexer::Error(const SQChar *err)
|
||||
{
|
||||
_errfunc(_errtarget,err);
|
||||
throw CompileException(err);
|
||||
}
|
||||
|
||||
void SQLexer::Next()
|
||||
|
6
src/3rdparty/squirrel/squirrel/sqlexer.h
vendored
6
src/3rdparty/squirrel/squirrel/sqlexer.h
vendored
@@ -5,8 +5,8 @@
|
||||
struct SQLexer
|
||||
{
|
||||
~SQLexer();
|
||||
SQLexer(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up,CompilerErrorFunc efunc,void *ed);
|
||||
NORETURN void Error(const SQChar *err);
|
||||
SQLexer(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up);
|
||||
[[noreturn]] void Error(const SQChar *err);
|
||||
SQInteger Lex();
|
||||
const SQChar *Tok2Str(SQInteger tok);
|
||||
private:
|
||||
@@ -35,8 +35,6 @@ public:
|
||||
char32_t _currdata;
|
||||
SQSharedState *_sharedstate;
|
||||
sqvector<SQChar> _longstr;
|
||||
CompilerErrorFunc _errfunc;
|
||||
void *_errtarget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
10
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
10
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
@@ -216,7 +216,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
|
||||
_RET_SUCCEED(_integer(res))
|
||||
}
|
||||
}
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
default:
|
||||
_RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 );
|
||||
}
|
||||
@@ -288,7 +288,7 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
||||
//else keeps going to the default
|
||||
}
|
||||
}
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
default:
|
||||
seprintf(buf, lastof(buf),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o));
|
||||
}
|
||||
@@ -540,7 +540,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
||||
_generator(o1)->Resume(this, arg_2+1);
|
||||
_FINISH(0);
|
||||
}
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
default:
|
||||
Raise_Error("cannot iterate %s", GetTypeName(o1));
|
||||
}
|
||||
@@ -775,7 +775,7 @@ exception_restore:
|
||||
ct_stackbase = _stackbase;
|
||||
goto common_call;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
case _OP_CALL: {
|
||||
ct_tailcall = false;
|
||||
ct_target = arg0;
|
||||
@@ -1337,7 +1337,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
|
||||
return true;
|
||||
}
|
||||
}
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
case OT_USERDATA:
|
||||
if(_delegable(self)->_delegate) {
|
||||
SQObjectPtr t;
|
||||
|
Reference in New Issue
Block a user