Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20655: Initializes EvaluableNode to type ENT_NULL if double value is NaN #156

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/Amalgam/evaluablenode/EvaluableNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,19 @@ class EvaluableNode

constexpr void InitializeType(double number_value)
{
type = ENT_NUMBER;
attributes.allAttributes = 0;
attributes.individualAttribs.isIdempotent = true;
value.numberValueContainer.labelStringID = StringInternPool::NOT_A_STRING_ID;
value.numberValueContainer.numberValue = number_value;
if(FastIsNaN(number_value))
{
type = ENT_NULL;
value.ConstructOrderedChildNodes();
}
else
{
type = ENT_NUMBER;
attributes.individualAttribs.isIdempotent = true;
value.numberValueContainer.labelStringID = StringInternPool::NOT_A_STRING_ID;
value.numberValueContainer.numberValue = number_value;
}
}

//initializes to ENT_UNINITIALIZED
Expand Down Expand Up @@ -802,7 +810,7 @@ class EvaluableNode
{ new (&mappedChildNodes) AssocType; }

inline void DestructMappedChildNodes()
{
{
string_intern_pool.DestroyStringReferences(mappedChildNodes, [](auto n) { return n.first; });
mappedChildNodes.~AssocType();
}
Expand All @@ -818,11 +826,11 @@ class EvaluableNode
{
//string value
StringInternPool::StringID stringID;

//allow up to one label -- only used when not part of an extended value
StringInternPool::StringID labelStringID;
} stringValueContainer;

//when type represents a number, holds the corresponding value
struct EvaluableNodeValueNumber
{
Expand Down Expand Up @@ -931,7 +939,7 @@ enum EvaluableNodeImmediateValueType : uint8_t
ENIVT_NUMBER_INDIRECTION_INDEX //not a real EvaluableNode type, but an index to some data structure that has a number
};

//structure that can hold the most immediate value type of an EvaluableNode
//structure that can hold the most immediate value type of an EvaluableNode
// EvaluableNodeImmediateValueType can be used to communicate which type of data is being held
union EvaluableNodeImmediateValue
{
Expand Down