From 7aa6a6b0b34706802aed8924414de5646d7fd9b7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 21 Mar 2017 11:46:33 +0200 Subject: [PATCH] Restored explicit assignment operators for VMValue Unfortunately strings require special handling and so all operators must be available This partly solves https://mantis.zdoom.org/view.php?id=453 (and https://mantis.zdoom.org/view.php?id=459 too) --- src/scripting/vm/vm.h | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index e545aebd3..cd4c07351 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -481,6 +481,75 @@ struct VMValue atag = tag; Type = REGT_POINTER; } + VMValue &operator=(const VMValue &o) + { + if (o.Type == REGT_STRING) + { + if (Type == REGT_STRING) + { + s() = o.s(); + } + else + { + new(&s()) FString(o.s()); + Type = REGT_STRING; + } + } + else + { + Kill(); + biggest = o.biggest; + } + return *this; + } + VMValue &operator=(int v) + { + Kill(); + i = v; + Type = REGT_INT; + return *this; + } + VMValue &operator=(double v) + { + Kill(); + f = v; + Type = REGT_FLOAT; + return *this; + } + VMValue &operator=(const FString &v) + { + if (Type == REGT_STRING) + { + s() = v; + } + else + { + ::new(&s()) FString(v); + Type = REGT_STRING; + } + return *this; + } + VMValue &operator=(const char *v) + { + if (Type == REGT_STRING) + { + s() = v; + } + else + { + ::new(&s()) FString(v); + Type = REGT_STRING; + } + return *this; + } + VMValue &operator=(DObject *v) + { + Kill(); + a = v; + atag = ATAG_OBJECT; + Type = REGT_POINTER; + return *this; + } int ToInt() { if (Type == REGT_INT)