104 #define TO_STR_sub(s) #s 120 #define NODE_TYPE_NAME(node) { Node::node_t::NODE_##node, TO_STR_sub(node), __LINE__ } 398 #if defined(_DEBUG) || defined(DEBUG) 401 static bool checked =
false;
408 if(g_node_type_name[idx].f_type <= g_node_type_name[idx - 1].f_type)
412 std::cerr <<
"INTERNAL ERROR at offset " << idx
413 <<
" (line #" << g_node_type_name[idx].
f_line 414 <<
", node type " <<
static_cast<uint32_t
>(g_node_type_name[idx].
f_type)
415 <<
" vs. " << static_cast<uint32_t>(g_node_type_name[idx - 1].f_type)
416 <<
"): the g_node_type_name table is not sorted properly. We cannot binary search it." 418 throw exception_internal_error(
"INTERNAL ERROR: node type names not properly sorted, cannot properly search for names using a binary search.");
426 size_t j(g_node_type_name_size);
429 size_t p((j - i) / 2 + i);
430 int r(static_cast<int>(g_node_type_name[p].f_type) - static_cast<int>(static_cast<node_t>(type)));
433 return g_node_type_name[p].
f_name;
457 return f_type_node.lock();
477 return type_to_string(f_type);
509 return f_type == node_t::NODE_INT64 || f_type == node_t::NODE_FLOAT64;
541 if(f_type == node_t::NODE_STRING)
543 return f_str.is_number();
546 return f_type != node_t::NODE_INT64
547 && f_type != node_t::NODE_FLOAT64
548 && f_type != node_t::NODE_TRUE
549 && f_type != node_t::NODE_FALSE
550 && f_type != node_t::NODE_NULL;
574 return f_type == node_t::NODE_INT64;
598 return f_type == node_t::NODE_FLOAT64;
623 return f_type == node_t::NODE_TRUE || f_type == node_t::NODE_FALSE;
647 return f_type == node_t::NODE_TRUE;
671 return f_type == node_t::NODE_FALSE;
695 return f_type == node_t::NODE_STRING;
719 return f_type == node_t::NODE_UNDEFINED;
743 return f_type == node_t::NODE_NULL;
768 return f_type == node_t::NODE_IDENTIFIER || f_type == node_t::NODE_VIDENTIFIER;
804 case node_t::NODE_FALSE:
805 case node_t::NODE_FLOAT64:
806 case node_t::NODE_INT64:
807 case node_t::NODE_NULL:
808 case node_t::NODE_STRING:
809 case node_t::NODE_TRUE:
810 case node_t::NODE_UNDEFINED:
899 case node_t::NODE_ASSIGNMENT:
900 case node_t::NODE_ASSIGNMENT_ADD:
901 case node_t::NODE_ASSIGNMENT_BITWISE_AND:
902 case node_t::NODE_ASSIGNMENT_BITWISE_OR:
903 case node_t::NODE_ASSIGNMENT_BITWISE_XOR:
904 case node_t::NODE_ASSIGNMENT_DIVIDE:
905 case node_t::NODE_ASSIGNMENT_LOGICAL_AND:
906 case node_t::NODE_ASSIGNMENT_LOGICAL_OR:
907 case node_t::NODE_ASSIGNMENT_LOGICAL_XOR:
908 case node_t::NODE_ASSIGNMENT_MAXIMUM:
909 case node_t::NODE_ASSIGNMENT_MINIMUM:
910 case node_t::NODE_ASSIGNMENT_MODULO:
911 case node_t::NODE_ASSIGNMENT_MULTIPLY:
912 case node_t::NODE_ASSIGNMENT_POWER:
913 case node_t::NODE_ASSIGNMENT_ROTATE_LEFT:
914 case node_t::NODE_ASSIGNMENT_ROTATE_RIGHT:
915 case node_t::NODE_ASSIGNMENT_SHIFT_LEFT:
916 case node_t::NODE_ASSIGNMENT_SHIFT_RIGHT:
917 case node_t::NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED:
918 case node_t::NODE_ASSIGNMENT_SUBTRACT:
919 case node_t::NODE_CALL:
920 case node_t::NODE_DECREMENT:
921 case node_t::NODE_DELETE:
922 case node_t::NODE_INCREMENT:
923 case node_t::NODE_NEW:
924 case node_t::NODE_POST_DECREMENT:
925 case node_t::NODE_POST_INCREMENT:
940 for(
size_t idx(0); idx < f_children.size(); ++idx)
942 if(f_children[idx] && f_children[idx]->has_side_effects())
bool has_side_effects() const
Check whether a node has side effects.
pointer_t get_type_node() const
int f_line
The line number of the definition.
bool is_null() const
Check whether a node is the special value null.
bool is_literal() const
Check whether this node represents a literal.
bool is_undefined() const
Check whether a node is the special value undefined.
static char const * type_to_string(node_t type)
Convert the specified type to a string.
bool is_boolean() const
Check whether a node is a Boolean value.
Node::node_t f_type
The node type.
size_t const g_node_type_name_size
Define the size of the node type table.
bool is_float64() const
Check whether a node is a floating point.
void set_type_node(Node::pointer_t node)
bool is_true() const
Check whether a node represents the true Boolean value.
bool is_nan() const
Check whether this node represents a NaN if converted to a number.
bool is_false() const
Check whether a node represents the false Boolean value.
std::shared_ptr< Node > pointer_t
bool is_identifier() const
Check whether a node is an identifier.
bool is_number() const
Return true if Node represents a number.
bool is_string() const
Check whether a node is a string.
#define NODE_TYPE_NAME(node)
Macro used to add a named type to the table of node types.
type_name_t const g_node_type_name[]
List of node types with their name.
The AlexScript to JavaScript namespace.
bool is_int64() const
Check whether a node is an integer.
char const * f_name
The name of the node type.
node_t get_type() const
Retrieve the type of the node.
Structure used to define the name of each node type.
char const * get_type_name() const
Retrieve the type of this node.