Skip to content

Commit

Permalink
change version, improve errors for array/map/struct copy
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Oct 7, 2023
1 parent 7955c8c commit 38e880e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/common/scripting/backend/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)

if (btype->isDynArray())
{
if(ctx.Version >= MakeVersion(4, 11, 0))
if(ctx.Version >= MakeVersion(4, 11, 1))
{
FArgumentList args;
args.Push(Right);
Expand All @@ -2502,20 +2502,22 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)
{
if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer())
{
ScriptPosition.Message(MSG_WARNING, "Dynamic Array assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead\n"
TEXTCOLOR_RED "!! Assigning an out array pointer to another out array pointer does not alter either of the underlying arrays' values below ZScript version 4.11 !!");
ScriptPosition.Message(MSG_WARNING, "Dynamic Array assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead\n"
TEXTCOLOR_RED " Assigning an out array pointer to another out array pointer\n"
" does not alter either of the underlying arrays' values\n"
" it only swaps the pointers below ZScript version 4.11.1!!");
}
else
{
ScriptPosition.Message(MSG_ERROR, "Dynamic Array assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead");
ScriptPosition.Message(MSG_ERROR, "Dynamic Array assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead");
delete this;
return nullptr;
}
}
}
else if (btype->isMap())
{
if(ctx.Version >= MakeVersion(4, 11, 0))
if(ctx.Version >= MakeVersion(4, 11, 1))
{
FArgumentList args;
args.Push(Right);
Expand All @@ -2528,12 +2530,14 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)
{
if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer())
{ // don't break existing code, but warn that it's a no-op
ScriptPosition.Message(MSG_WARNING, "Map assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead\n"
TEXTCOLOR_RED "!! Assigning an out map pointer to another out map pointer does not alter either of the underlying maps' values below ZScript version 4.11 !!");
ScriptPosition.Message(MSG_WARNING, "Map assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead\n"
TEXTCOLOR_RED " Assigning an out map pointer to another out map pointer\n"
" does not alter either of the underlying maps' values\n"
" it only swaps the pointers below ZScript version 4.11.1!!");
}
else
{
ScriptPosition.Message(MSG_ERROR, "Map assignments not allowed in ZScript versions below 4.11, use the Copy() or Move() functions instead");
ScriptPosition.Message(MSG_ERROR, "Map assignments not allowed in ZScript versions below 4.11.1, use the Copy() or Move() functions instead");
delete this;
return nullptr;
}
Expand All @@ -2550,7 +2554,9 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)
if(Base->ValueType->isRealPointer() && Right->ValueType->isRealPointer())
{ // don't break existing code, but warn that it's a no-op
ScriptPosition.Message(MSG_WARNING, "Struct assignment not implemented yet\n"
TEXTCOLOR_RED "!! Assigning an out struct pointer to another out struct pointer does not alter either of the underlying structs' values !!");
TEXTCOLOR_RED " Assigning an out struct pointer to another out struct pointer\n"
" does not alter either of the underlying structs' values\n"
" it only swaps the pointers!!");
}
else
{
Expand Down

0 comments on commit 38e880e

Please sign in to comment.