- fixed initialization of local variables with other local variables.

- fixed several occurenced where vectors were treated as floats. NOTE: The entire codegen.cpp file needs to be carefully reviewed for bad use of the REGT_ constants, there's probably more places where using them has broken some type checks.
- fixed: committed test version of zscript.txt instead of changed actor.txt by accident.

Initialization and assignment for strings is working with this commit.
This commit is contained in:
Christoph Oelckers 2016-10-29 16:49:21 +02:00
parent 4dc97a6ed0
commit 853c6f6684
3 changed files with 16 additions and 10 deletions

View File

@ -676,7 +676,7 @@ FxExpression *FxBoolCast::Resolve(FCompileContext &ctx)
delete this;
return x;
}
else if (basex->ValueType->GetRegType() == REGT_INT || basex->ValueType->GetRegType() == REGT_FLOAT || basex->ValueType->GetRegType() == REGT_POINTER)
else if ((basex->ValueType->GetRegType() == REGT_INT || basex->ValueType->GetRegType() == REGT_FLOAT || basex->ValueType->GetRegType() == REGT_POINTER) && !basex->IsVector())
{
if (basex->isConstant())
{
@ -797,7 +797,7 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
return x;
}
}
else if (basex->ValueType->GetRegType() == REGT_FLOAT)
else if (basex->ValueType->GetRegType() == REGT_FLOAT && !basex->IsVector())
{
if (basex->isConstant())
{
@ -875,7 +875,7 @@ FxExpression *FxFloatCast::Resolve(FCompileContext &ctx)
CHECKRESOLVED();
SAFE_RESOLVE(basex, ctx);
if (basex->ValueType->GetRegType() == REGT_FLOAT)
if (basex->ValueType->GetRegType() == REGT_FLOAT && !basex->IsVector())
{
FxExpression *x = basex;
basex = NULL;
@ -1095,11 +1095,11 @@ ExpEmit FxStringCast::Emit(VMFunctionBuilder *build)
from.Free(build);
ExpEmit to(build, REGT_STRING);
if (ValueType == TypeName)
if (basex->ValueType == TypeName)
{
build->Emit(OP_CAST, to.RegNum, from.RegNum, CAST_N2S);
}
else if (ValueType == TypeSound)
else if (basex->ValueType == TypeSound)
{
build->Emit(OP_CAST, to.RegNum, from.RegNum, CAST_So2S);
}
@ -1325,7 +1325,7 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx)
{
goto basereturn;
}
else if (ValueType->GetRegType() == REGT_FLOAT)
else if (ValueType->GetRegType() == REGT_FLOAT && !IsVector())
{
FxExpression *x = new FxFloatCast(basex);
x = x->Resolve(ctx);
@ -4867,6 +4867,7 @@ ExpEmit FxLocalVariable::Emit(VMFunctionBuilder *build)
}
//==========================================================================
//
//
@ -7671,11 +7672,17 @@ ExpEmit FxLocalVariableDeclaration::Emit(VMFunctionBuilder *build)
}
emitval.Free(build);
}
else
else if (Init->ExprType != EFX_LocalVariable)
{
// take over the register that got allocated while emitting the Init expression.
RegNum = emitval.RegNum;
}
else
{
ExpEmit out(build, emitval.RegType, emitval.RegCount);
build->Emit(ValueType->GetMoveOp(), out.RegNum, emitval.RegNum);
RegNum = out.RegNum;
}
}
return ExpEmit();
}

View File

@ -177,5 +177,3 @@ zscript/chex/chexweapons.txt
zscript/chex/chexitems.txt
zscript/chex/chexdecorations.txt
zscript/chex/chexplayer.txt
zscript/test2.txt

View File

@ -53,6 +53,7 @@ class Actor : Thinker native
return GetPointer(ptr_select1) == GetPointer(ptr_select2);
}
native void SetOrigin(vector3 newpos, bool moving);
native Actor GetPointer(int aaptr);
native Actor SpawnMissile(Actor dest, class<Actor> type, Actor owner = null);
native void TraceBleed(int damage, Actor missile);
@ -296,7 +297,7 @@ class Actor : Thinker native
deprecated native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0);
deprecated native void A_StopSoundEx(name slot);
native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10);
native state A_Jump(int chance = 256, state label, ...);
native state A_Jump(int chance, state label, ...);
native void A_CustomMissile(class<Actor> missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET);
native void A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET, class<Actor> missile = null, float Spawnheight = 32, float Spawnofs_xy = 0);
native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = 0, color color2 = 0, int flags = 0, int aim = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float spread_xy = 0, float spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = null, float spawnofs_z = 0, int spiraloffset = 270, int limit = 0);