59 #pragma GCC diagnostic push 60 #pragma GCC diagnostic ignored "-Weffc++" 61 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 64 :
public std::enable_shared_from_this<Node>
273 NODE_CATCH_FLAG_TYPED,
276 NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES,
279 NODE_ENUM_FLAG_CLASS,
280 NODE_ENUM_FLAG_INUSE,
284 NODE_FOR_FLAG_FOREACH,
288 NODE_FUNCTION_FLAG_GETTER,
289 NODE_FUNCTION_FLAG_SETTER,
290 NODE_FUNCTION_FLAG_OUT,
291 NODE_FUNCTION_FLAG_VOID,
292 NODE_FUNCTION_FLAG_NEVER,
293 NODE_FUNCTION_FLAG_NOPARAMS,
294 NODE_FUNCTION_FLAG_OPERATOR,
297 NODE_IDENTIFIER_FLAG_WITH,
298 NODE_IDENTIFIER_FLAG_TYPED,
301 NODE_IMPORT_FLAG_IMPLEMENTS,
304 NODE_PACKAGE_FLAG_FOUND_LABELS,
305 NODE_PACKAGE_FLAG_REFERENCED,
308 NODE_PARAM_FLAG_CONST,
311 NODE_PARAM_FLAG_NAMED,
312 NODE_PARAM_FLAG_REST,
313 NODE_PARAM_FLAG_UNCHECKED,
314 NODE_PARAM_FLAG_UNPROTOTYPED,
315 NODE_PARAM_FLAG_REFERENCED,
316 NODE_PARAM_FLAG_PARAMREF,
317 NODE_PARAM_FLAG_CATCH,
320 NODE_PARAM_MATCH_FLAG_UNPROTOTYPED,
323 NODE_SWITCH_FLAG_DEFAULT,
326 NODE_TYPE_FLAG_MODULO,
329 NODE_VARIABLE_FLAG_CONST,
330 NODE_VARIABLE_FLAG_FINAL,
331 NODE_VARIABLE_FLAG_LOCAL,
332 NODE_VARIABLE_FLAG_MEMBER,
333 NODE_VARIABLE_FLAG_ATTRIBUTES,
334 NODE_VARIABLE_FLAG_ENUM,
335 NODE_VARIABLE_FLAG_COMPILED,
336 NODE_VARIABLE_FLAG_INUSE,
337 NODE_VARIABLE_FLAG_ATTRS,
338 NODE_VARIABLE_FLAG_DEFINED,
339 NODE_VARIABLE_FLAG_DEFINING,
340 NODE_VARIABLE_FLAG_TOADD,
370 NODE_ATTR_REQUIRE_ELSE,
371 NODE_ATTR_ENSURE_THEN,
380 NODE_ATTR_DEPRECATED,
389 NODE_ATTR_CONSTRUCTOR,
395 NODE_ATTR_ENUMERABLE,
441 virtual ~Node() noexcept(
false);
561 void set_child(
int index, pointer_t child);
577 void display(std::ostream& out,
int indent,
char c)
const;
631 #pragma GCC diagnostic pop
bool has_side_effects() const
Check whether a node has side effects.
void set_goto_enter(pointer_t node)
Define the "Goto Enter" pointer.
void to_videntifier()
Transform an identifier into a NODE_VIDENTIFIER.
pointer_t get_type_node() const
pointer_t get_attribute_node() const
void add_label(pointer_t label)
Add a label to a function.
bool to_string()
Transform a node to a string.
static node_t string_to_operator(String const &str)
Transform a string in an operator.
weak_pointer_t f_goto_enter
void set_param_depth(size_t j, depth_t depth)
Set the depth of a parameter.
bool is_null() const
Check whether a node is the special value null.
bool is_literal() const
Check whether this node represents a literal.
void set_flag(flag_t f, bool v)
Set a flag.
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.
param_index_t f_param_index
std::vector< weak_pointer_t > vector_of_weak_pointers_t
bool to_identifier()
Convert this node to a NODE_IDENTIFIER.
void append_child(pointer_t child)
Append a child to 'this' node.
depth_t get_param_depth(size_t j) const
Get the depth at the specified index.
param_depth_t f_param_depth
weak_pointer_t f_type_node
pointer_t get_goto_enter() const
Save a link in this node.
bool is_boolean() const
Check whether a node is a Boolean value.
size_t get_param_index(size_t idx) const
Get the index of the parameter.
pointer_t get_variable(int index) const
Retrieve the variable at the specified index.
weak_pointer_t f_goto_exit
bool to_call()
Convert a getter or setter to a function call.
pointer_t get_child(int index) const
Retrieve a child.
weak_pointer_t f_instance
bool to_float64()
Convert this node to a NODE_FLOAT64.
node_t get_switch_operator() const
Retrieve the switch operator.
pointer_t get_goto_exit() const
Retrieve the "Goto Exit" pointer.
String const & get_string() const
Get the string of this node.
void set_boolean(bool value)
Set the Boolean value of this node.
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.
std::vector< Node::pointer_t > node_pointer_vector_t
Float64 get_float64() const
Get the Float64 of this node.
bool to_boolean()
Convert this node to a Boolean node.
std::vector< pointer_t > vector_of_pointers_t
bool is_nan() const
Check whether this node represents a NaN if converted to a number.
bool to_number()
Convert this node to a number.
void set_attribute_node(pointer_t node)
bool to_as()
Transform a call in a NODE_AS node.
void display_data(std::ostream &out) const
Display a node.
void lock()
Lock this node.
void set_int64(Int64 value)
Set the Int64 of this node.
bool is_false() const
Check whether a node represents the false Boolean value.
void replace_with(pointer_t node)
Replace this node with the node parameter.
size_t get_param_size() const
Return the size of the parameter index and depth vectors.
void set_attribute_tree(attribute_t const a, bool const v)
Set an attribute in a whole tree.
virtual ~Node() noexcept(false)
Verify that a node is clean when deleting it.
void verify_attribute(attribute_t const f) const
Verify that a corresponds to the Node type.
void set_parent(pointer_t parent=pointer_t(), int index=-1)
This function sets the parent of a node.
void modifying() const
Test whether the node can be modified.
bool to_int64()
Convert this node to a NODE_INT64.
static char const * attribute_to_string(attribute_t const attr)
Convert an attribute to a string.
Position const & get_position() const
The position of the node.
vector_of_pointers_t f_children
void display(std::ostream &out, int indent, char c) const
Display a node tree.
static compare_t compare(Node::pointer_t const lhs, Node::pointer_t const rhs, compare_mode_t const mode)
Compare two nodes together.
void set_float64(Float64 value)
Set the Float64 of this node.
bool verify_exclusive_attributes(attribute_t f) const
Verify that we can indeed set an attribute.
node_t to_boolean_type_only() const
Check whether a node can be converted to Boolean.
std::shared_ptr< Node > pointer_t
void set_param_size(size_t size)
Define the size of the parameter index and depth vectors.
size_t get_children_size() const
Return the number of children available in this node.
bool is_identifier() const
Check whether a node is an identifier.
Node & operator=(Node const &)=delete
Do not allow direct copies of nodes.
bool to_label()
Convert this node to a label.
void delete_child(int index)
Delete the specified child from the parent.
bool get_boolean() const
Get the Boolean value of this node.
attribute_set_t f_attributes
void set_attribute(attribute_t const a, bool const v)
Set an attribute.
void verify_flag(flag_t f) const
Verify that f corresponds to the node type.
std::bitset< static_cast< int >attribute_t::NODE_ATTR_max)> attribute_set_t
Node(node_t type)
Initialize a node.
std::ostream & operator<<(std::ostream &out, Node const &node)
Send a node to the specified output stream.
void set_param_index(size_t idx, size_t j)
Set the parameter index.
pointer_t get_parent() const
Get a pointer to the parent of this node.
bool is_number() const
Return true if Node represents a number.
void unlock()
Unlock a node that was previously locked.
std::bitset< static_cast< size_t >flag_t::NODE_FLAG_max)> flag_set_t
vector_of_weak_pointers_t f_variables
static depth_t const MATCH_LOWEST_DEPTH
map_of_weak_pointers_t f_labels
Int64 get_int64() const
Get the Int64 of this node.
pointer_t clone_basic_node() const
Create a clone of a basic node.
bool is_string() const
Check whether a node is a string.
std::map< String, weak_pointer_t > map_of_weak_pointers_t
bool compare_all_flags(flag_set_t const &s) const
Compare a set of flags with the current flags of this node.
void set_position(Position const &position)
Change the position of the node.
void insert_child(int index, pointer_t child)
Insert the specified child at the specified location.
pointer_t get_instance() const
The AlexScript to JavaScript namespace.
bool is_int64() const
Check whether a node is an integer.
void set_switch_operator(node_t op)
Set the switch statement operator.
void to_var_attributes()
Transform a variable into a variable of attributes.
void set_instance(pointer_t node)
pointer_t f_attribute_node
void set_child(int index, pointer_t child)
Replace the current child at position index with child.
bool get_attribute(attribute_t const a) const
Get the current status of an attribute.
size_t get_variable_size() const
Retrieve the number of variables defined in this node.
std::vector< int32_t > param_depth_t
void add_variable(pointer_t variable)
Add a variable to this node.
node_t get_type() const
Retrieve the type of the node.
std::weak_ptr< Node > weak_pointer_t
static char const * operator_to_string(node_t op)
Transform an operator to a string.
static depth_t const MATCH_HIGHEST_DEPTH
size_t get_offset() const
Find the offset of this node in its parent array of children.
void to_unknown()
Transform any node to NODE_UNKNOWN.
pointer_t find_label(String const &name) const
Find a label previously added with the add_label() function.
bool is_locked() const
Check whether a node is locked.
pointer_t find_first_child(node_t type) const
Find the first child of a given type.
bool compare_all_attributes(attribute_set_t const &s) const
Compare a set of attributes with the current attributes of this node.
pointer_t create_replacement(node_t type) const
Create a new node with the given type.
bool get_flag(flag_t f) const
Get the current status of a flag.
static depth_t const MATCH_NOT_FOUND
std::vector< uint32_t > param_index_t
pointer_t find_next_child(pointer_t start, node_t type) const
Find the next child with the specified type.
void set_goto_exit(pointer_t node)
Define the "Goto Exit" pointer.
void clean_tree()
Remove all the unknown nodes.
void set_string(String const &value)
Set the string of this node.
char const * get_type_name() const
Retrieve the type of this node.