- added per-channel access for color variables. However, since they are locally stored in registers, it required a minor bit of fudging for this case.
- make sure that a PFunction's implementation is always initialized before starting the code generator.
This commit is contained in:
parent
393bcf9e91
commit
de2eb18727
6 changed files with 48 additions and 1 deletions
|
|
@ -5652,6 +5652,10 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
|
|||
|
||||
SAFE_RESOLVE(Object, ctx);
|
||||
|
||||
// allow accessing the color chanels by mapping the type to a matching struct which defines them.
|
||||
if (Object->ValueType == TypeColor)
|
||||
Object->ValueType = TypeColorStruct;
|
||||
|
||||
if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
||||
{
|
||||
auto ptype = static_cast<PPointer *>(Object->ValueType)->PointedType;
|
||||
|
|
@ -6305,6 +6309,26 @@ FxExpression *FxStructMember::Resolve(FCompileContext &ctx)
|
|||
delete this;
|
||||
return locvar;
|
||||
}
|
||||
else if (classx->ExprType == EFX_LocalVariable && classx->ValueType == TypeColorStruct)
|
||||
{
|
||||
// This needs special treatment because it'd require accessing the register via address.
|
||||
// Fortunately this is the only place where this kind of access is ever needed so an explicit handling is acceptable.
|
||||
int bits;
|
||||
switch (membervar->SymbolName.GetIndex())
|
||||
{
|
||||
case NAME_a: bits = 24; break;
|
||||
case NAME_r: bits = 16; break;
|
||||
case NAME_g: bits = 8; break;
|
||||
case NAME_b: default: bits = 0; break;
|
||||
}
|
||||
classx->ValueType = TypeColor; // need to set it back.
|
||||
FxExpression *x = classx;
|
||||
if (bits > 0) x = new FxShift(TK_URShift, x, new FxConstant(bits, ScriptPosition));
|
||||
x = new FxBitOp('&', x, new FxConstant(255, ScriptPosition));
|
||||
classx = nullptr;
|
||||
delete this;
|
||||
return x->Resolve(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(classx->RequestAddress(ctx, &AddressWritable)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue