From 81bc05b7c56a6c60f5a5fc540e5ea7985ca38246 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 7 Mar 2018 15:58:06 +0200 Subject: [PATCH] Added support for default values of arguments with uint type --- src/scripting/backend/codegen.cpp | 6 +++--- src/scripting/backend/codegen.h | 2 +- src/scripting/vm/vm.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 273d4e498..256af647a 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -924,11 +924,11 @@ void FxBoolCast::EmitCompare(VMFunctionBuilder *build, bool invert, TArrayScriptPosition) { basex=x; - ValueType = TypeSInt32; + ValueType = isunsigned ? TypeUInt32 : TypeSInt32; NoWarn = nowarn; Explicit = explicitly; } @@ -1632,7 +1632,7 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx) else if (ValueType->isInt()) { // This is only for casting to actual ints. Subtypes representing an int will be handled elsewhere. - FxExpression *x = new FxIntCast(basex, NoWarn, Explicit); + FxExpression *x = new FxIntCast(basex, NoWarn, Explicit, static_cast(ValueType)->Unsigned); x = x->Resolve(ctx); basex = nullptr; delete this; diff --git a/src/scripting/backend/codegen.h b/src/scripting/backend/codegen.h index 8ee32423f..88ea7bcdd 100644 --- a/src/scripting/backend/codegen.h +++ b/src/scripting/backend/codegen.h @@ -604,7 +604,7 @@ class FxIntCast : public FxExpression public: - FxIntCast(FxExpression *x, bool nowarn, bool explicitly = false); + FxIntCast(FxExpression *x, bool nowarn, bool explicitly = false, bool isunsigned = false); ~FxIntCast(); FxExpression *Resolve(FCompileContext&); diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index e5f7d1357..342b44d78 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -411,6 +411,7 @@ bool AssertObject(void * ob); #define PARAM_EXISTS(p) ((p) < numparam) #define PARAM_INT_DEF_AT(p,x) int x; if (PARAM_EXISTS(p)) { ASSERTINT(param[p]); x = param[p].i; } else { ASSERTINT(defaultparam[p]); x = defaultparam[p].i; } +#define PARAM_UINT_DEF_AT(p,x) unsigned x; if (PARAM_EXISTS(p)) { ASSERTINT(param[p]); x = param[p].i; } else { ASSERTINT(defaultparam[p]); x = defaultparam[p].i; } #define PARAM_BOOL_DEF_AT(p,x) bool x; if (PARAM_EXISTS(p)) { ASSERTINT(param[p]); x = !!param[p].i; } else { ASSERTINT(defaultparam[p]); x = !!defaultparam[p].i; } #define PARAM_NAME_DEF_AT(p,x) FName x; if (PARAM_EXISTS(p)) { ASSERTINT(param[p]); x = ENamedName(param[p].i); } else { ASSERTINT(defaultparam[p]); x = ENamedName(defaultparam[p].i); } #define PARAM_SOUND_DEF_AT(p,x) FSoundID x; if (PARAM_EXISTS(p)) { ASSERTINT(param[p]); x = FSoundID(param[p].i); } else { ASSERTINT(defaultparam[p]); x = FSoundID(defaultparam[p].i); } @@ -449,6 +450,7 @@ bool AssertObject(void * ob); #define PARAM_CLASS_NOT_NULL(x,base) ++paramnum; PARAM_CLASS_NOT_NULL_AT(paramnum,x,base) #define PARAM_INT_DEF(x) ++paramnum; PARAM_INT_DEF_AT(paramnum,x) +#define PARAM_UINT_DEF(x) ++paramnum; PARAM_UINT_DEF_AT(paramnum,x) #define PARAM_BOOL_DEF(x) ++paramnum; PARAM_BOOL_DEF_AT(paramnum,x) #define PARAM_NAME_DEF(x) ++paramnum; PARAM_NAME_DEF_AT(paramnum,x) #define PARAM_SOUND_DEF(x) ++paramnum; PARAM_SOUND_DEF_AT(paramnum,x)