- changed VMValue to handle strings by reference.
This makes VMValue a real POD type with no hacky overloads and eliminates a lot of destructor code in all places that call a VM function. Due to the way this had to be handled, none of these destructors could be skipped because any value could have been a string. This required some minor changes in functions that passed a temporary FString into the VM to ensure that the temporary object lives long enough to be handled. The code generator had already been changed to deal with this in a previous commit. This is easily offset by the code savings and reduced maintenance needs elsewhere.
This commit is contained in:
parent
9bffe4ee50
commit
4417afd548
9 changed files with 55 additions and 93 deletions
|
|
@ -50,6 +50,8 @@
|
|||
#include "gdtoa.h"
|
||||
#include "backend/vmbuilder.h"
|
||||
|
||||
FSharedStringArena VMStringConstants;
|
||||
|
||||
static int GetIntConst(FxExpression *ex, FCompileContext &ctx)
|
||||
{
|
||||
ex = new FxIntCast(ex, false);
|
||||
|
|
@ -2555,7 +2557,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
break;
|
||||
|
||||
case REGT_STRING:
|
||||
vmval[0] = cnst->GetValue().GetString();
|
||||
// We need a reference to something permanently stored here.
|
||||
vmval[0] = VMStringConstants.Alloc(cnst->GetValue().GetString());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue