Add Switch On Enum node

This commit is contained in:
Wojciech Figat
2020-12-14 12:39:55 +01:00
parent 058ccf24b7
commit 1b818499b7
2 changed files with 164 additions and 0 deletions

View File

@@ -860,6 +860,28 @@ void VisjectExecutor::ProcessGroupComparisons(Box* box, Node* node, Value& value
else
value = tryGetValue(node->GetBox(1), 0, Value::Zero);
break;
}
// Switch On Enum
case 8:
{
const Value v = tryGetValue(node->GetBox(0), Value::Null);
if (v.Type.Type == VariantType::Enum && node->Values.Count() == 1 && node->Values[0].Type.Type == VariantType::Blob)
{
int32* dataValues = (int32*)node->Values[0].AsBlob.Data;
int32 dataValuesCount = node->Values[0].AsBlob.Length / 4;
int32 vAsInt = (int32)v;
for (int32 i = 0; i < dataValuesCount; i++)
{
if (dataValues[i] == vAsInt)
{
value = tryGetValue(node->GetBox(i + 2), Value::Null);
break;
}
}
}
else
value = Value::Null;
break;
}
}
}