Skip to content

Commit

Permalink
20655: Initializes EvaluableNode to type ENT_NULL if double value is …
Browse files Browse the repository at this point in the history
…NaN (#156)

Note, this merges into branch 20490, not main
  • Loading branch information
cademack authored Jun 24, 2024
1 parent d41f566 commit 9cfb748
Showing 1 changed file with 16 additions and 8 deletions.
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

0 comments on commit 9cfb748

Please sign in to comment.