Snap! Websites
An Open Source CMS System in C++
#include <node.h>
node
parameter. More...index
with child
. More...a
corresponds to the Node type. More...This function initializes a new node. The specified type is assigned to the new node as expected.
If the type
parameter does not represent a valid type of node, then the function throws. This means only valid type of nodes can be created.
Once created, a node representing a literal can have its value defined using one of the set_...() functions. Note that the set_boolean() function is a special case which converts the node to either NODE_TRUE or NODE_FALSE.
It is also expected that you will set the position of the token using the set_position() function.
Definition at line 104 of file node.cpp.
References NODE_ABSTRACT, NODE_ADD, NODE_ARRAY, NODE_ARRAY_LITERAL, NODE_AS, NODE_ASSIGNMENT, NODE_ASSIGNMENT_ADD, NODE_ASSIGNMENT_BITWISE_AND, NODE_ASSIGNMENT_BITWISE_OR, NODE_ASSIGNMENT_BITWISE_XOR, NODE_ASSIGNMENT_DIVIDE, NODE_ASSIGNMENT_LOGICAL_AND, NODE_ASSIGNMENT_LOGICAL_OR, NODE_ASSIGNMENT_LOGICAL_XOR, NODE_ASSIGNMENT_MAXIMUM, NODE_ASSIGNMENT_MINIMUM, NODE_ASSIGNMENT_MODULO, NODE_ASSIGNMENT_MULTIPLY, NODE_ASSIGNMENT_POWER, NODE_ASSIGNMENT_ROTATE_LEFT, NODE_ASSIGNMENT_ROTATE_RIGHT, NODE_ASSIGNMENT_SHIFT_LEFT, NODE_ASSIGNMENT_SHIFT_RIGHT, NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED, NODE_ASSIGNMENT_SUBTRACT, NODE_ATTRIBUTES, NODE_AUTO, NODE_BITWISE_AND, NODE_BITWISE_NOT, NODE_BITWISE_OR, NODE_BITWISE_XOR, NODE_BOOLEAN, NODE_BREAK, NODE_BYTE, NODE_CALL, NODE_CASE, NODE_CATCH, NODE_CHAR, NODE_CLASS, NODE_CLOSE_CURVLY_BRACKET, NODE_CLOSE_PARENTHESIS, NODE_CLOSE_SQUARE_BRACKET, NODE_COLON, NODE_COMMA, NODE_COMPARE, NODE_CONDITIONAL, NODE_CONST, NODE_CONTINUE, NODE_DEBUGGER, NODE_DECREMENT, NODE_DEFAULT, NODE_DELETE, NODE_DIRECTIVE_LIST, NODE_DIVIDE, NODE_DO, NODE_DOUBLE, NODE_ELSE, NODE_EMPTY, NODE_ENSURE, NODE_ENUM, NODE_EOF, NODE_EQUAL, NODE_EXCLUDE, NODE_EXPORT, NODE_EXTENDS, NODE_FALSE, NODE_FINAL, NODE_FINALLY, NODE_FLOAT, NODE_FLOAT64, NODE_FOR, NODE_FUNCTION, NODE_GOTO, NODE_GREATER, NODE_GREATER_EQUAL, NODE_IDENTIFIER, NODE_IF, NODE_IMPLEMENTS, NODE_IMPORT, NODE_IN, NODE_INCLUDE, NODE_INCREMENT, NODE_INLINE, NODE_INSTANCEOF, NODE_INT64, NODE_INTERFACE, NODE_INVARIANT, NODE_IS, NODE_LABEL, NODE_LESS, NODE_LESS_EQUAL, NODE_LIST, NODE_LOGICAL_AND, NODE_LOGICAL_NOT, NODE_LOGICAL_OR, NODE_LOGICAL_XOR, NODE_LONG, NODE_MATCH, NODE_MAXIMUM, NODE_MEMBER, NODE_MINIMUM, NODE_MODULO, NODE_MULTIPLY, NODE_NAME, NODE_NAMESPACE, NODE_NATIVE, NODE_NEW, NODE_NOT_EQUAL, NODE_NOT_MATCH, NODE_NULL, NODE_OBJECT_LITERAL, NODE_OPEN_CURVLY_BRACKET, NODE_OPEN_PARENTHESIS, NODE_OPEN_SQUARE_BRACKET, NODE_PACKAGE, NODE_PARAM, NODE_PARAM_MATCH, NODE_PARAMETERS, NODE_POST_DECREMENT, NODE_POST_INCREMENT, NODE_POWER, NODE_PRIVATE, NODE_PROGRAM, NODE_PROTECTED, NODE_PUBLIC, NODE_RANGE, NODE_REGULAR_EXPRESSION, NODE_REQUIRE, NODE_REST, NODE_RETURN, NODE_ROOT, NODE_ROTATE_LEFT, NODE_ROTATE_RIGHT, NODE_SCOPE, NODE_SEMICOLON, NODE_SET, NODE_SHIFT_LEFT, NODE_SHIFT_RIGHT, NODE_SHIFT_RIGHT_UNSIGNED, NODE_SHORT, NODE_SMART_MATCH, NODE_STATIC, NODE_STRICTLY_EQUAL, NODE_STRICTLY_NOT_EQUAL, NODE_STRING, NODE_SUBTRACT, NODE_SUPER, NODE_SWITCH, NODE_SYNCHRONIZED, NODE_THEN, NODE_THIS, NODE_THROW, NODE_THROWS, NODE_TRANSIENT, NODE_TRUE, NODE_TRY, NODE_TYPE, NODE_TYPEOF, NODE_UNDEFINED, NODE_UNKNOWN, NODE_USE, NODE_VAR, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, NODE_VIDENTIFIER, NODE_VOID, NODE_VOLATILE, NODE_WHILE, NODE_WITH, and NODE_YIELD.
Referenced by clone_basic_node(), and create_replacement().
This function ensures that a node is clean, as in, not locked, when it gets deleted.
If we properly make use of the NodeLock, then a node cannot get deleted until all the locks get canceled with an unlock() call.
Definition at line 325 of file node.cpp.
References as2js::AS_ERR_NOT_ALLOWED, f_lock, and as2js::MESSAGE_LEVEL_FATAL.
It is not safe to just copy a node because a node is part of a tree (parent, child, siblings...) and a copy would not work.
This function adds a label to this function node. Labels are saved using a map so we can quickly find them.
Definition at line 930 of file node.cpp.
References f_labels, f_type, NODE_FUNCTION, and NODE_LABEL.
A node can hold pointers to variable nodes. This is used to handle variable scopes properly. Note that the variable
parameter must be a node of type NODE_VARIABLE.
variable
parameter is not of type NODE_VARIABLE.
Definition at line 827 of file node.cpp.
References f_variables, and NODE_VARIABLE.
This function appends (adds at the end of the vector of children) a child to 'this' node, which means the child is given 'this' node as a parent.
The following two lines of code are identical:
child
pointer is not null. If null, this exception is raised.
Definition at line 524 of file node_tree.cpp.
This function converts an attribute to a string. This is most often used to print out an error about an attribute.
Definition at line 719 of file node_attribute.cpp.
References as2js::anonymous_namespace{node_attribute.cpp}::g_attribute_names, and NODE_ATTR_max.
Referenced by display(), and verify_attribute().
This function goes through the entire tree starting at 'this' node and remove all the children that are marked as NODE_UNKNOWN.
This allows many functions to clear out many nodes without having to have very special handling of their loops while scanning all the children of a node.
Definition at line 804 of file node_tree.cpp.
References delete_child(), f_children, get_type(), and NODE_UNKNOWN.
This function creates a new node which is a copy of this node. The function really only works with basic nodes, namely, literals.
This function cannot be used to create a copy of a node that has children or other pointers.
Definition at line 476 of file node.cpp.
References f_attribute_node, f_attributes, f_flags, f_float, f_goto_enter, f_goto_exit, f_instance, f_int, f_labels, f_position, f_str, f_switch_operator, f_type, f_type_node, f_variables, Node(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_TRUE, and NODE_UNDEFINED.
This function returns the result of comparing two nodes against each others. The result is one of the compare_t values.
At this time, if the function is used to compare nodes that are not literals, then it returns COMPARE_ERROR.
The function may return COMPARE_UNORDERED in strict mode or when comparing a value against a NaN.
As per the ECMAScript refence, strings are compared as is in binary mode. We do not make use of Unicode or take the locale in account.
The nearly equal is only used by the smart match operator. This is an addition by as2js which is somewhat like the ~~ operator defined by perl.
Definition at line 94 of file node_compare.cpp.
References as2js::Float64::compare(), as2js::COMPARE_EQUAL, as2js::COMPARE_ERROR, as2js::COMPARE_GREATER, as2js::COMPARE_LESS, COMPARE_SMART, COMPARE_STRICT, as2js::COMPARE_UNORDERED, as2js::Float64::f_float, as2js::Float64::nearly_equal(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, NODE_UNDEFINED, as2js::Float64::set(), and as2js::Float64::set_NaN().
Referenced by as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_COMPARE(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_EQUAL(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_LESS(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_LESS_EQUAL(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_MAXIMUM(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_MINIMUM(), as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_SMART_MATCH(), and as2js::optimizer_details::anonymous_namespace{optimizer_optimize.cpp}::optimizer_func_STRICTLY_EQUAL().
This function compares the specified set of attributes with the node's attributes. If the sets are equal, then the function returns true. Otherwise the function returns false.
This function compares all the attributes, whether or not they are valid for the current node type.
s
is equal to the node attributes. Definition at line 704 of file node_attribute.cpp.
References f_attributes.
This function compares the specified set of flags with the node's flags. If the sets are equal, then the function returns true. Otherwise the function returns false.
This function compares all the flags, whether or not they are valid for the current node type.
s
is equal to the node flags.Definition at line 309 of file node_flag.cpp.
References f_flags.
This function creates a new node that is expected to be used as a replacement of this node.
Note that the input node does not get modified by this call.
This is similar to creating a node directly and then setting up the position of the new node to the position information of 'this' node. In other words, a short hand for this:
Definition at line 554 of file node.cpp.
References f_position, and Node().
This function removes a child from its parent (i.e. "unparent" a node.)
The following two lines of code are identical:
Note that the vector of children of 'this' node changes, be careful. Whenever possible, to avoid bugs, you may want to consider using the lock() function through the NodeLock object.
Definition at line 495 of file node_tree.cpp.
References f_children.
Referenced by clean_tree(), and set_child().
This function displays this node, its children, its children's children, etc. until all the nodes in the tree were displayed.
Note that the function knows about the node links, variables, and labels which also get displayed.
Because the tree cannot generate loops (the set_parent() function prevents such), we do not have anything that would break the recursivity of the function.
The character used to start the string (c
) changes depending on what we are showing to the user. That way we know whether it is the root (.), a child (-), a variable (=), or a label (:).
Definition at line 425 of file node_display.cpp.
References attribute_to_string(), display_data(), f_attribute_node, f_attributes, f_children, f_goto_enter, f_goto_exit, f_instance, f_labels, f_lock, f_position, f_type_node, f_variables, lock(), NODE_ATTR_ABSTRACT, NODE_ATTR_ARRAY, NODE_ATTR_AUTOBREAK, NODE_ATTR_CONSTRUCTOR, NODE_ATTR_DEFINED, NODE_ATTR_DEPRECATED, NODE_ATTR_DYNAMIC, NODE_ATTR_ENSURE_THEN, NODE_ATTR_ENUMERABLE, NODE_ATTR_FALSE, NODE_ATTR_FINAL, NODE_ATTR_FOREACH, NODE_ATTR_INLINE, NODE_ATTR_INTERNAL, NODE_ATTR_NATIVE, NODE_ATTR_NOBREAK, NODE_ATTR_PRIVATE, NODE_ATTR_PROTECTED, NODE_ATTR_PUBLIC, NODE_ATTR_REQUIRE_ELSE, NODE_ATTR_STATIC, NODE_ATTR_TRANSIENT, NODE_ATTR_TRUE, NODE_ATTR_TYPE, NODE_ATTR_UNSAFE, NODE_ATTR_UNUSED, NODE_ATTR_VIRTUAL, and NODE_ATTR_VOLATILE.
Referenced by as2js::operator<<().
This function prints a node in the out
stream.
The function is smart enough to recognize the different type of nodes and thus know what is saved in them and knows how to display all of that information.
This is only to display a node in a technical way. It does not attempt to display things in JavaScript or any other language.
Definition at line 91 of file node_display.cpp.
References f_flags, f_float, f_int, f_str, f_type, as2js::Int64::get(), as2js::Float64::get(), get_type_name(), NODE_BREAK, NODE_CATCH, NODE_CATCH_FLAG_TYPED, NODE_CLASS, NODE_CONTINUE, NODE_DIRECTIVE_LIST, NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES, NODE_ENUM, NODE_ENUM_FLAG_CLASS, NODE_ENUM_FLAG_INUSE, NODE_FLOAT64, NODE_FOR, NODE_FOR_FLAG_CONST, NODE_FOR_FLAG_FOREACH, NODE_FOR_FLAG_IN, NODE_FUNCTION, NODE_FUNCTION_FLAG_GETTER, NODE_FUNCTION_FLAG_NEVER, NODE_FUNCTION_FLAG_NOPARAMS, NODE_FUNCTION_FLAG_OPERATOR, NODE_FUNCTION_FLAG_OUT, NODE_FUNCTION_FLAG_SETTER, NODE_FUNCTION_FLAG_VOID, NODE_GOTO, NODE_IDENTIFIER, NODE_IDENTIFIER_FLAG_TYPED, NODE_IDENTIFIER_FLAG_WITH, NODE_IMPORT, NODE_IMPORT_FLAG_IMPLEMENTS, NODE_INT64, NODE_INTERFACE, NODE_LABEL, NODE_NAMESPACE, NODE_PACKAGE, NODE_PACKAGE_FLAG_FOUND_LABELS, NODE_PACKAGE_FLAG_REFERENCED, NODE_PARAM, NODE_PARAM_FLAG_CATCH, NODE_PARAM_FLAG_CONST, NODE_PARAM_FLAG_IN, NODE_PARAM_FLAG_NAMED, NODE_PARAM_FLAG_OUT, NODE_PARAM_FLAG_PARAMREF, NODE_PARAM_FLAG_REFERENCED, NODE_PARAM_FLAG_REST, NODE_PARAM_FLAG_UNCHECKED, NODE_PARAM_FLAG_UNPROTOTYPED, NODE_PARAM_MATCH, NODE_PARAM_MATCH_FLAG_UNPROTOTYPED, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_SWITCH, NODE_SWITCH_FLAG_DEFAULT, NODE_TYPE, NODE_TYPE_FLAG_MODULO, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, NODE_VARIABLE_FLAG_ATTRIBUTES, NODE_VARIABLE_FLAG_ATTRS, NODE_VARIABLE_FLAG_COMPILED, NODE_VARIABLE_FLAG_CONST, NODE_VARIABLE_FLAG_DEFINED, NODE_VARIABLE_FLAG_DEFINING, NODE_VARIABLE_FLAG_ENUM, NODE_VARIABLE_FLAG_FINAL, NODE_VARIABLE_FLAG_INUSE, NODE_VARIABLE_FLAG_LOCAL, NODE_VARIABLE_FLAG_MEMBER, NODE_VARIABLE_FLAG_TOADD, and NODE_VIDENTIFIER.
Referenced by display().
This function searches the vector of children for the first child with the specified type
. This can be used to quickly scan a list of children for the first node with a specific type.
Definition at line 735 of file node_tree.cpp.
References find_next_child().
This function checks whether a label was defined in this function. If so, then its smart pointer gets returned.
The name
parameter represents the name of the label exactly. The returned label will have the same name.
Definition at line 964 of file node.cpp.
References f_labels.
This function searches the vector of children for the next child with the specified type
. This can be used to quickly scan a list of children for a specific type of node.
The child
parameter can be set to nullptr in which case the first child of that type is returned (like find_first_child() would do for you.)
Definition at line 766 of file node_tree.cpp.
References f_children, and get_type().
Referenced by find_first_child().
This function returns true or false depending on the current status of the specified attribute.
The function verifies that the specified attribute (a
) corresponds to the type of data you are dealing with. If not, an exception is raised.
If the attribute was never set, this function returns false.
Definition at line 240 of file node_attribute.cpp.
References f_attributes, and verify_attribute().
Definition at line 214 of file node_attribute.cpp.
References f_attribute_node.
This function returns true or false depending on the node type: NODE_TRUE or NODE_FALSE.
Definition at line 229 of file node_value.cpp.
References f_type, NODE_FALSE, and NODE_TRUE.
This function retrieves a child from this parent node.
The index
parameter must be between 0 and get_children_size() - 1. If get_children_size() returns zero, then you cannot call this function.
Definition at line 709 of file node_tree.cpp.
References f_children.
This function returns the number of children we have available in this node.
Definition at line 461 of file node_tree.cpp.
References f_children.
This function returns true or false depending on the current status of the specified flag.
The function verifies that the specified flag (f
) corresponds to the Node type we are dealing with.
If the flag was never set, this function returns false.
compare_all_flags() can be used to compare all the flags at once without having to load each flag one at a time. This is particularly useful in our unit tests.
Definition at line 101 of file node_flag.cpp.
References f_flags, and verify_flag().
This function returns the Float64 of this node.
Note that only one type of nodes can be assigned a Float64:
NODE_FLOAT64
Definition at line 293 of file node_value.cpp.
References f_float, f_type, and NODE_FLOAT64.
This function saves a link pointer in this node. It can later be retrieved using the get_link() function.
If a link was already defined at that offset, the function raises an exception and the existing offset is not modified.
It is possible to clear a link by passing an empty smart pointer down (i.e. pass nullptr.) If you first clear a link in this way, you can then replace it with another pointer.
Links are used to save information about a node such as its type and attributes. \note Links are saved as full smart pointers, not weak pointers. This means a node that references another in this way may generate loops that will not easily break when trying to release the whole tree. \note The Node must not be locked. \exception exception_index_out_of_range The index is out of range. Links make use of a very few predefined indexes such as Node::link_t::LINK_ATTRIBUTES. However, Node::link_t::LINK_max cannot be used as an index. \exception exception_already_defined The link at that index is already defined and the function was called anyway. This is an internal error because you should check whether the value was already defined and if so use that value. \param[in] index The index of the link to save. \param[in] link A smart pointer to the link. \sa get_link()
Retrieve a link previously saved with set_link().
This function returns a pointer to a link that was previously saved in this node using the set_link() function.
Links are used to save information about a node such as its type and attributes.
The function may return a null pointer. You are responsible for checking the validity of the link.
This function returns a pointer to the "Goto Enter" node. The pointer may be null.
Definition at line 748 of file node.cpp.
References f_goto_enter.
This function returns a pointer to the "Goto Exit" node. The pointer may be null.
Definition at line 761 of file node.cpp.
References f_goto_exit.
Definition at line 872 of file node_tree.cpp.
References f_instance.
This function returns the Int64 of this node.
Note that only one type of nodes can be assigned an Int64:
NODE_INT64
Definition at line 262 of file node_value.cpp.
References f_int, f_type, and NODE_INT64.
This function searches for a node in its parent list of children and returns the corresponding index so we can apply functions to that child from the parent.
Definition at line 844 of file node_tree.cpp.
References f_parent.
Referenced by replace_with().
This function returns the depth parameter at the specified index.
This function cannot be called until the set_param_size() gets called with a valid size.
j
parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Definition at line 140 of file node_param.cpp.
References f_param_depth.
When a user writes a function call, he can spell out the parameter names as in:
The parameters, in the function declaration, may not be in the same order:
The parameter index vector holds the indices so we can reorganize the call as in:
The really cool thing is that you could call a function with multiple definitions and still get the parameters in the right order even though both functions define their parameters in a different order.
idx
parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Definition at line 216 of file node_param.cpp.
References f_param_index.
This function returns zero until set_param_size() is successfully called with a valid size.
Definition at line 109 of file node_param.cpp.
References f_param_depth.
This function returns the pointer to the parent of this node. It may be a null pointer.
Note that the parent is kept as a weak pointer internally. However, when returned it gets locked first (as in shared pointer lock) so you do not have to do that yourselves.
Definition at line 446 of file node_tree.cpp.
References f_parent.
This function returns a reference to the position of the node. The position represents the filename, line number, character position, function name, etc. where this specific node was read. It can be used to print out the line to the user and to show him exactly where the error occurred.
This position can be changed with the set_position() function. By default a node has a default position: no file name, no function name, and positions are all set to 1.
Definition at line 609 of file node.cpp.
References f_position.
This function returns the string of this node. The string is a standard String object (full Unicode support.)
Note that only a few types of nodes can be assigned a string:
NODE_BREAK, NODE_CLASS, NODE_CONTINUE, NODE_ENUM, NODE_FUNCTION, NODE_GOTO, NODE_IDENTIFIER, NODE_IMPORT, NODE_INTERFACE, NODE_LABEL, NODE_NAME, NODE_NAMESPACE, NODE_PACKAGE, NODE_PARAM, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_VARIABLE, NODE_VAR_ATTRIBUTES, and NODE_VIDENTIFIER
Definition at line 329 of file node_value.cpp.
References f_str, f_type, get_type_name(), NODE_BREAK, NODE_CLASS, NODE_CONTINUE, NODE_ENUM, NODE_FUNCTION, NODE_GOTO, NODE_IDENTIFIER, NODE_IMPORT, NODE_INTERFACE, NODE_LABEL, NODE_NAME, NODE_NAMESPACE, NODE_PACKAGE, NODE_PARAM, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, and NODE_VIDENTIFIER.
A switch statement can be constrained to use a specific operator using the with() syntax as in:
This operator is saved in the switch node and can later be retrieved with this function.
Definition at line 369 of file node.cpp.
References f_switch_operator, f_type, and NODE_SWITCH.
This function gets the type of the node and returns it. The type is one of the node_t::NODE_... values.
Note the value of the node types are not all sequencial. The lower portion used one to one with characters has many sparse places. However, the Node constructor ensures that only valid types get used.
There are some functions available to convert a certain number of Node types. These are used by the compiler and optimizer to implement their functionality.
Definition at line 367 of file node_type.cpp.
Referenced by clean_tree(), and find_next_child().
This function retrieves the type of this node.
This function is equivalent to:
Definition at line 475 of file node_type.cpp.
Referenced by display_data(), get_string(), set_parent(), and verify_attribute().
Definition at line 455 of file node_type.cpp.
This function retrieves the variable at the specified index. If the index is out of the variable array bounds, then the function raises an error.
The current boundaries are from 0 to get_variable_size() - 1. This set may be empty if no variables were added to this node.
This function will not return a null pointer. An index out of range raises an exception instead.
Definition at line 888 of file node.cpp.
References f_variables.
A node can hold variable pointers. This is used to handle variable scopes properly.
Definition at line 855 of file node.cpp.
References f_variables.
This function checks whether a node, or any of its children, has a side effect.
Having a side effect means that the function of the node is to modify something. For example an assignment modifies its destination which is an obvious side effect. The following node types are viewed as having a side effects:
The test is run against this node and all of its children because if any one node implies a modification, the tree as a whole implies a modification and thus the function must return true.
For optimizations, we will still be able to remove nodes wrapping nodes that have side effects. For example the following optimization is perfectly valid:
The one reason the previous statement may not be optimizable is if 'a' represents an object which has the '+' (addition) operator defined. Anyway, in that case the optimizer sees the following code which cannot be optimized:
Definition at line 864 of file node_type.cpp.
When adding a child to a node, it can be placed before existing children of that node. This function is used for this purpose.
By default the index is set to -1 which means that the child is added at the end of the list (see also the append_child() function.)
This is a helper function since you could as well call the set_parent() function directly:
child
pointer is not null. If null, this exception is raised.
Definition at line 560 of file node_tree.cpp.
Referenced by set_child().
This function checks whether the type of the node is NODE_TRUE or NODE_FALSE.
Definition at line 621 of file node_type.cpp.
This function checks whether the type of the node is NODE_FALSE.
Definition at line 669 of file node_type.cpp.
This function checks whether the type of the node is NODE_FLOAT64.
Definition at line 596 of file node_type.cpp.
This function checks whether the type of the node is NODE_IDENTIFIER or NODE_VIDENTIFIER.
Definition at line 766 of file node_type.cpp.
This function checks whether the type of the node is NODE_INT64.
Definition at line 572 of file node_type.cpp.
Literals are:
If this node represents any one of those types, this function returns true.
Definition at line 800 of file node_type.cpp.
This function returns true if the specified node is currently locked. False otherwise.
Definition at line 114 of file node_lock.cpp.
References f_lock.
Referenced by modifying().
When converting a node to a number (to_number() function) we accept a certain number of parameters as numbers:
Definition at line 539 of file node_type.cpp.
This function checks whether the type of the node is NODE_NULL.
Definition at line 741 of file node_type.cpp.
This function returns true if the node is an integer or a floating point value. This is tested using the Node type which should either be NODE_INT64 or NODE_FLOAT64.
Note that means this function returns false on a string that represents a valid number.
Note that JavaScript also considered Boolean values and null as valid numbers. To test such, use is_nan() instead.
Definition at line 507 of file node_type.cpp.
This function checks whether the type of the node is NODE_STRING.
Definition at line 693 of file node_type.cpp.
This function checks whether the type of the node is NODE_TRUE.
Definition at line 645 of file node_type.cpp.
This function checks whether the type of the node is NODE_UNDEFINED.
Definition at line 717 of file node_type.cpp.
This function locks this node. A node can be locked multiple times. The unlock() function needs to be called the same number of times the lock() function was called.
It is strongly recommended that you use the NodeLock object in order to lock your nodes. That way they automatically get unlocked when you exit your scope, even if an exception occurs.
Definition at line 164 of file node_lock.cpp.
References f_lock.
Referenced by display().
This function verifies whether the node can be modified. Nodes that were locked cannot be modified. It can be very difficult to determine what is happening on the tree when working with a very large tree. This parameter ensures that nodes we are looping over while doing work do not get modify at the wrong time.
To avoid the exception that this function generates, you may instead call the is_locked() function.
Definition at line 91 of file node_lock.cpp.
References is_locked().
Referenced by set_parent(), to_as(), to_boolean(), to_call(), to_float64(), to_identifier(), to_int64(), to_label(), to_number(), to_string(), to_unknown(), to_var_attributes(), and to_videntifier().
It is not safe to just copy a node because a node is part of a tree (parent, child, siblings...) and a copy would not work.
This function transforms the specified operator (op
) to a printable string. It is generaly used to print out an error message.
If the function cannot find the operator, then it returns a null pointer (be careful, we return a standard C null terminated string here, not an std::string or as2js::String.)
Definition at line 220 of file node_operator.cpp.
References as2js::anonymous_namespace{node_operator.cpp}::operator_to_string_t::f_line, as2js::anonymous_namespace{node_operator.cpp}::operator_to_string_t::f_name, as2js::anonymous_namespace{node_operator.cpp}::operator_to_string_t::f_node, and as2js::anonymous_namespace{node_operator.cpp}::g_operator_to_string_size.
Referenced by as2js::Parser::function().
This function replaces this node with the specified node. This is used in the optimizer and in the compiler.
It is useful in a case such as an if() statement that has a resulting Boolean value known at compile time. For example:
can be optimized by just this:
In that case what we do is replace the NODE_IF (this) with the content of the 'blah' node. This can be done with this function.
This function is very similar to the set_child() when you do not know the index position of 'this' node in its parent or do not have the parent node handy. The following code shows what the function does internally (without all the additional checks):
Definition at line 655 of file node_tree.cpp.
References f_parent, and get_offset().
This function sets the specified attribute a
to the specified value v
in this Node object.
The function verifies that the specified attribute (a
) corresponds to the type of data you are dealing with.
Definition at line 263 of file node_attribute.cpp.
References f_attributes, verify_attribute(), and verify_exclusive_attributes().
Definition at line 208 of file node_attribute.cpp.
References f_attribute_node.
This function sets the specified attribute a
to the specified value v
in this Node object and all of its children.
The function verifies that the specified attribute (a
) corresponds to the type of data you are dealing with.
Definition at line 297 of file node_attribute.cpp.
References f_attributes, f_children, verify_attribute(), and verify_exclusive_attributes().
This function saves a Boolean value in this node.
Note that only two types of nodes can be assigned a Boolean value:
NODE_TRUE and NODE_FALSE
This function converst the C++ Boolean value to either NODE_TRUE or NODE_FALSE.
Definition at line 84 of file node_value.cpp.
References f_type, NODE_FALSE, and NODE_TRUE.
This function replaces the child in this node at index
with the new specified child
.
This is a helper function as this functionality is offered by the set_parent() function as in:
child
pointer is not null. If null, this exception is raised.
index
.
Definition at line 594 of file node_tree.cpp.
References delete_child(), and insert_child().
This function sets the specified flag f
to the specified value v
in this Node object.
The function verifies that the specified flag (f
) corresponds to the Node type we are dealing with.
Definition at line 122 of file node_flag.cpp.
References f_flags, and verify_flag().
This function saves a Float64 in this node.
Note that only one type of node can be assigned a Float64:
NODE_FLOAT64
Definition at line 147 of file node_value.cpp.
References f_float, f_type, and NODE_FLOAT64.
This function saves the specified node
pointer as the "Goto Enter" node. The pointer may be null.
Definition at line 774 of file node.cpp.
References f_goto_enter.
This function saves the specified node
pointer as the "Goto Exit" node. The pointer may be null.
Definition at line 787 of file node.cpp.
References f_goto_exit.
Definition at line 866 of file node_tree.cpp.
References f_instance.
This function saves an Int64 in this node.
Note that only one type of node can be assigned an Int64:
NODE_INT64
Definition at line 116 of file node_value.cpp.
References f_int, f_type, and NODE_INT64.
When we search for a match of a function call, we check its parameters. If a parameter has a higher class type definition, then it wins over the others. This depth value represents that information.
j
parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Definition at line 166 of file node_param.cpp.
References f_param_depth.
Save the index of the parameter in the function being called, opposed to the index of the parameter in the function call.
See function get_param_index() for more details about the indexes.
idx
or j
parameters are out of range. They should both be defined between 0 and get_param_size() - 1.
Definition at line 241 of file node_param.cpp.
References f_param_index.
This function defines the size of the depth and index parameter vectors. Until this function is called, trying to set a depth or index parameter will fail.
Also, the function cannot be called more than once and the size parameter cannot be zero.
size
parameter is zero, this exception is raised.
Definition at line 81 of file node_param.cpp.
References f_param_depth, f_param_index, f_type, and NODE_PARAM_MATCH.
This function is the only function that handles the tree of nodes, in other words, the only one that modifies the f_parent and f_children pointers. It is done that way to make 100% sure (assuming it is itself correct) that we do not mess up the tree.
This node loses its current parent, and thus is removed from the list of children of that parent. Then is is assigned the new parent as passed to this function.
If an index
is specified, the child is inserted at that specific location. Otherwise the child is appended.
The function does nothing if the current parent is the same as the new parent and the default index
is used (-1).
Use an index
of 0 to insert the item at the start of the list of children. Use an index
of get_children_size() to force the child at the end of the list even if the parent remains the same.
Helper functions are available to make more sense of the usage of this function but they all are based on the set_parent() function:
parent
Node must not be locked. If the parent is being changed, then the other existing parent must also not be locked either.index
parameter is larger than the number of children currently available in the new parent or is negative, then this exception is raised. Note that if the index is -1, then the correct value is used to append the child.
Definition at line 160 of file node_tree.cpp.
References f_parent, f_type, get_type_name(), modifying(), NODE_ABSTRACT, NODE_ADD, NODE_ARRAY, NODE_ARRAY_LITERAL, NODE_AS, NODE_ASSIGNMENT, NODE_ASSIGNMENT_ADD, NODE_ASSIGNMENT_BITWISE_AND, NODE_ASSIGNMENT_BITWISE_OR, NODE_ASSIGNMENT_BITWISE_XOR, NODE_ASSIGNMENT_DIVIDE, NODE_ASSIGNMENT_LOGICAL_AND, NODE_ASSIGNMENT_LOGICAL_OR, NODE_ASSIGNMENT_LOGICAL_XOR, NODE_ASSIGNMENT_MAXIMUM, NODE_ASSIGNMENT_MINIMUM, NODE_ASSIGNMENT_MODULO, NODE_ASSIGNMENT_MULTIPLY, NODE_ASSIGNMENT_POWER, NODE_ASSIGNMENT_ROTATE_LEFT, NODE_ASSIGNMENT_ROTATE_RIGHT, NODE_ASSIGNMENT_SHIFT_LEFT, NODE_ASSIGNMENT_SHIFT_RIGHT, NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED, NODE_ASSIGNMENT_SUBTRACT, NODE_ATTRIBUTES, NODE_AUTO, NODE_BITWISE_AND, NODE_BITWISE_NOT, NODE_BITWISE_OR, NODE_BITWISE_XOR, NODE_BOOLEAN, NODE_BREAK, NODE_BYTE, NODE_CALL, NODE_CASE, NODE_CATCH, NODE_CHAR, NODE_CLASS, NODE_CLOSE_CURVLY_BRACKET, NODE_CLOSE_PARENTHESIS, NODE_CLOSE_SQUARE_BRACKET, NODE_COLON, NODE_COMMA, NODE_COMPARE, NODE_CONDITIONAL, NODE_CONST, NODE_CONTINUE, NODE_DEBUGGER, NODE_DECREMENT, NODE_DEFAULT, NODE_DELETE, NODE_DIRECTIVE_LIST, NODE_DIVIDE, NODE_DO, NODE_DOUBLE, NODE_ELSE, NODE_EMPTY, NODE_ENSURE, NODE_ENUM, NODE_EOF, NODE_EQUAL, NODE_EXCLUDE, NODE_EXPORT, NODE_EXTENDS, NODE_FALSE, NODE_FINAL, NODE_FINALLY, NODE_FLOAT, NODE_FLOAT64, NODE_FOR, NODE_FUNCTION, NODE_GOTO, NODE_GREATER, NODE_GREATER_EQUAL, NODE_IDENTIFIER, NODE_IF, NODE_IMPLEMENTS, NODE_IMPORT, NODE_IN, NODE_INCLUDE, NODE_INCREMENT, NODE_INLINE, NODE_INSTANCEOF, NODE_INT64, NODE_INTERFACE, NODE_INVARIANT, NODE_IS, NODE_LABEL, NODE_LESS, NODE_LESS_EQUAL, NODE_LIST, NODE_LOGICAL_AND, NODE_LOGICAL_NOT, NODE_LOGICAL_OR, NODE_LOGICAL_XOR, NODE_LONG, NODE_MATCH, NODE_max, NODE_MAXIMUM, NODE_MEMBER, NODE_MINIMUM, NODE_MODULO, NODE_MULTIPLY, NODE_NAME, NODE_NAMESPACE, NODE_NATIVE, NODE_NEW, NODE_NOT_EQUAL, NODE_NOT_MATCH, NODE_NULL, NODE_OBJECT_LITERAL, NODE_OPEN_CURVLY_BRACKET, NODE_OPEN_PARENTHESIS, NODE_OPEN_SQUARE_BRACKET, NODE_other, NODE_PACKAGE, NODE_PARAM, NODE_PARAM_MATCH, NODE_PARAMETERS, NODE_POST_DECREMENT, NODE_POST_INCREMENT, NODE_POWER, NODE_PRIVATE, NODE_PROGRAM, NODE_PROTECTED, NODE_PUBLIC, NODE_RANGE, NODE_REGULAR_EXPRESSION, NODE_REQUIRE, NODE_REST, NODE_RETURN, NODE_ROOT, NODE_ROTATE_LEFT, NODE_ROTATE_RIGHT, NODE_SCOPE, NODE_SEMICOLON, NODE_SET, NODE_SHIFT_LEFT, NODE_SHIFT_RIGHT, NODE_SHIFT_RIGHT_UNSIGNED, NODE_SHORT, NODE_SMART_MATCH, NODE_STATIC, NODE_STRICTLY_EQUAL, NODE_STRICTLY_NOT_EQUAL, NODE_STRING, NODE_SUBTRACT, NODE_SUPER, NODE_SWITCH, NODE_SYNCHRONIZED, NODE_THEN, NODE_THIS, NODE_THROW, NODE_THROWS, NODE_TRANSIENT, NODE_TRUE, NODE_TRY, NODE_TYPE, NODE_TYPEOF, NODE_UNDEFINED, NODE_UNKNOWN, NODE_USE, NODE_VAR, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, NODE_VIDENTIFIER, NODE_VOID, NODE_VOLATILE, NODE_WHILE, NODE_WITH, and NODE_YIELD.
As you are reading a file, a position object gets updated. That position object represents the location where different token are found in the source files. It is saved in a node as it is created to represent the position where the data was found. This helps in indicating to the user where an error occurred.
The position used as input can later change as the node keeps a copy of the parameter passed to it.
The position can later be retrieved with the get_position() function.
When the compiler creates new nodes as required, it generally will make use of the create_replacement() function which creates a new node with a new type, but keeps the position information of the old node.
Definition at line 587 of file node.cpp.
References f_position.
This function saves a string in this node. The string is a standard String object (full Unicode support.)
Note that only a few types of nodes can be assigned a string:
NODE_BREAK, NODE_CLASS, NODE_CONTINUE, NODE_ENUM, NODE_FUNCTION, NODE_GOTO, NODE_IDENTIFIER, NODE_IMPORT, NODE_INTERFACE, NODE_LABEL, NODE_NAME, NODE_NAMESPACE, NODE_PACKAGE, NODE_PARAM, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_VARIABLE, NODE_VAR_ATTRIBUTES, and NODE_VIDENTIFIER
Definition at line 183 of file node_value.cpp.
References f_str, f_type, NODE_BREAK, NODE_CLASS, NODE_CONTINUE, NODE_ENUM, NODE_FUNCTION, NODE_GOTO, NODE_IDENTIFIER, NODE_IMPORT, NODE_INTERFACE, NODE_LABEL, NODE_NAME, NODE_NAMESPACE, NODE_PACKAGE, NODE_PARAM, NODE_REGULAR_EXPRESSION, NODE_STRING, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, and NODE_VIDENTIFIER.
Referenced by to_identifier().
This function saves the operator defined following the switch statement using the with() instruction as in:
The currently supported operators are:
Definition at line 421 of file node.cpp.
References f_switch_operator, f_type, NODE_AS, NODE_DEFAULT, NODE_EQUAL, NODE_GREATER, NODE_GREATER_EQUAL, NODE_IN, NODE_INSTANCEOF, NODE_IS, NODE_LESS, NODE_LESS_EQUAL, NODE_MATCH, NODE_NOT_EQUAL, NODE_STRICTLY_EQUAL, NODE_STRICTLY_NOT_EQUAL, NODE_SWITCH, and NODE_UNKNOWN.
Definition at line 449 of file node_type.cpp.
The user may declare operators in his classes. Because of that the lexer returns identifiers and strings that need to later be converted to an operator. This function is used for this purpose.
If the operator is invalid, then the function returns NODE_UNKNOWN.
Definition at line 302 of file node_operator.cpp.
References as2js::anonymous_namespace{node_operator.cpp}::operator_to_string_t::f_node, and as2js::anonymous_namespace{node_operator.cpp}::g_operator_to_string_size.
Referenced by as2js::Parser::function().
This function transforms a node defined as NODE_CALL into a NODE_AS. The special casting syntax looks exactly like a function call. For this reason the parser returns it as such. The compiler, however, can determine whether the function name is really a function name or if it is a type name. If it is a type, then the tree is changed to represent an AS instruction instead:
Definition at line 123 of file node_convert.cpp.
References f_type, modifying(), NODE_AS, and NODE_CALL.
This function converts 'this' node to a Boolean node:
Other input types do not get converted and the function returns false.
To just test the Boolean value of a node without converting it, call to_boolean_type_only() instead.
Definition at line 226 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, as2js::Int64::get(), as2js::Float64::get(), as2js::Float64::is_NaN(), as2js::String::is_true(), modifying(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, and NODE_UNDEFINED.
This function is constant and can be used to see whether a node represents true or false without actually converting the node.
Note that in this case we completely ignore the content of a string. The strings "false", "0.0", and "0" all represent Boolean 'true'.
Definition at line 164 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, as2js::Int64::get(), as2js::Float64::get(), as2js::Float64::is_NaN(), as2js::String::is_true(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, and NODE_UNDEFINED.
This function is used to convert a getter ot a setter to a function call.
A read from a member variable is a getter if the name of the field was actually defined as a 'get' function.
A write to a member variable is a setter if the name of the field was actually defined as a 'set' function.
The function returns false if 'this' node is not a NODE_MEMBER or a NODE_ASSIGNMENT.
Definition at line 306 of file node_convert.cpp.
References f_type, modifying(), NODE_ASSIGNMENT, NODE_CALL, and NODE_MEMBER.
This function converts the node to a floating point number, just like JavaScript would do. This means converting the following type of nodes:
This function converts strings. If the string represents an integer, it will be converted to the nearest floating point number. If the string does not represent a number (including an empty string), then the float is set to NaN.
Definition at line 486 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, as2js::Int64::get(), modifying(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, NODE_UNDEFINED, as2js::Float64::set(), as2js::Float64::set_NaN(), and as2js::String::to_float64().
This function converts the node to an identifier. This is used to transform some keywords back to an identifier.
At this point this is used to transform these keywords in labels.
Definition at line 339 of file node_convert.cpp.
References f_type, modifying(), NODE_IDENTIFIER, NODE_PRIVATE, NODE_PROTECTED, NODE_PUBLIC, and set_string().
This function converts the node to an integer number, just like JavaScript would do (outside of the fact that JavaScript only supports floating points...) This means converting the following type of nodes as specified:
This function converts strings. If the string represents a valid integer, convert to that integer. In this case the full 64 bits are supported. If the string represents a floating point number, then the number is first converted to a floating point, then cast to an integer using the floor() function. If the floating point is too large for the integer, then the maximum or minimum number are used as the result. String that do not represent a number (integer or floating point) are transformed to zero (0). This is a similar behavior to the 'undefined' conversion.
Definition at line 404 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, as2js::Float64::get(), as2js::String::is_float64(), as2js::Float64::is_infinity(), as2js::String::is_int64(), as2js::Float64::is_NaN(), modifying(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, NODE_UNDEFINED, as2js::Int64::set(), as2js::String::to_float64(), and as2js::String::to_int64().
This function converts a NODE_IDENTIFIER node to a NODE_LABEL node.
Definition at line 536 of file node_convert.cpp.
References f_type, modifying(), NODE_IDENTIFIER, and NODE_LABEL.
This function converts the node to a number pretty much like JavaScript would do, except that literals that represent an exact integers are converted to an integer instead of a floating point.
If the node already is an integer or a floating point, then no conversion takes place, but it is considered valid and thus the function returns true.
This means converting the following type of nodes:
This function converts strings to a floating point, even if the value represents an integer. It is done that way because JavaScript expects a 'number' and that is expected to be a floating point.
Definition at line 587 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, modifying(), NODE_FALSE, NODE_FLOAT64, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, NODE_UNDEFINED, as2js::Int64::set(), as2js::Float64::set(), as2js::Float64::set_NaN(), and as2js::String::to_float64().
This function transforms a node from what it is to a string. If the transformation is successful, the function returns true. Note that the function does not throw if the type of 'this' cannot be converted to a string.
The nodes that can be converted to a string are:
The conversion of a floating point is not one to one compatible with what a JavaScript implementation would otherwise do. This is due to the fact that Java tends to convert floating points in a slightly different way than C/C++. None the less, the results are generally very close (to the 4th decimal digit.)
The NaN floating point is converted to the string "NaN".
The floating point +0.0 and -0.0 numbers are converted to exactly "0".
The floating point +Infinity is converted to the string "Infinity".
The floating point -Infinity is converted to the string "-Infinity".
Other numbers are converted as floating points with a decimal point, although floating points that represent an integer may be output as an integer.
Definition at line 675 of file node_convert.cpp.
References f_float, f_int, f_str, f_type, as2js::Int64::get(), as2js::Float64::get(), as2js::Float64::is_NaN(), as2js::Float64::is_negative_infinity(), as2js::Float64::is_positive_infinity(), modifying(), NODE_FALSE, NODE_FLOAT64, NODE_IDENTIFIER, NODE_INT64, NODE_NULL, NODE_STRING, NODE_TRUE, and NODE_UNDEFINED.
This function marks the node as unknown. Absolutely any node can be marked as unknown. It is specifically used by the compiler and optimizer to cancel nodes that cannot otherwise be deleted at the time they are working on the tree.
All the children of an unknown node are ignored too (considered as NODE_UNKNOWN, although they do not all get converted.)
To remove all the unknown nodes once the compiler is finished, one can call the clean_tree() function.
Definition at line 88 of file node_convert.cpp.
References f_type, modifying(), and NODE_UNKNOWN.
When compiling the tree, the code in compiler_variable.cpp may detect that a variable is specifically used to represent a list of attributes. When that happens, the compiler transforms the variable calling this function.
The distinction makes it a lot easier to deal with the variable later.
Definition at line 819 of file node_convert.cpp.
References f_type, modifying(), NODE_VAR_ATTRIBUTES, and NODE_VARIABLE.
This function is used to transform an identifier in a variable identifier. By default identifiers may represent object names. However, when written between parenthesis, they always represent a variable. This can be important as certain syntax are not at all equivalent:
In the first case, (a) is transform with the content of variable 'a' and that resulting object is used to access 'field'.
In the second case, 'a' itself represents an object and we are accessing that object's 'field' directly.
Definition at line 791 of file node_convert.cpp.
References f_type, modifying(), NODE_IDENTIFIER, and NODE_VIDENTIFIER.
The type of a Node (node_t::NODE_...) can be retrieved as a string using this function. In pretty much all cases this is done whenever an error occurs and not in normal circumstances. It is also used to debug the node tree.
Note that if you have a node, you probably want to call get_type_name() instead.
type
parameter is not a valid type (i.e. NODE_max, or an undefined number such as 999) then this exception is also generated. Calling this function with an invalid should not happen when you use the get_type_name() function since the Node constructor prevents the use of invalid node types when creating nodes.
Definition at line 396 of file node_type.cpp.
References as2js::anonymous_namespace{node_type.cpp}::type_name_t::f_line, as2js::anonymous_namespace{node_type.cpp}::type_name_t::f_name, as2js::anonymous_namespace{node_type.cpp}::type_name_t::f_type, and as2js::anonymous_namespace{node_type.cpp}::g_node_type_name_size.
Referenced by as2js::Parser::directive().
This function unlocks a node that was previously called with a call to the lock() function.
It cannot be called on a node that was not previously locked.
To make it safe, you should look into using the NodeLock object to lock your nodes, especially because the NodeLock is exception safe.
Definition at line 202 of file node_lock.cpp.
References f_lock.
This function verifies that a
corresponds to a valid attribute according to the type of this Node object.
Definition at line 343 of file node_attribute.cpp.
References attribute_to_string(), f_type, get_type_name(), NODE_ADD, NODE_ARRAY, NODE_ARRAY_LITERAL, NODE_AS, NODE_ASSIGNMENT, NODE_ASSIGNMENT_ADD, NODE_ASSIGNMENT_BITWISE_AND, NODE_ASSIGNMENT_BITWISE_OR, NODE_ASSIGNMENT_BITWISE_XOR, NODE_ASSIGNMENT_DIVIDE, NODE_ASSIGNMENT_LOGICAL_AND, NODE_ASSIGNMENT_LOGICAL_OR, NODE_ASSIGNMENT_LOGICAL_XOR, NODE_ASSIGNMENT_MAXIMUM, NODE_ASSIGNMENT_MINIMUM, NODE_ASSIGNMENT_MODULO, NODE_ASSIGNMENT_MULTIPLY, NODE_ASSIGNMENT_POWER, NODE_ASSIGNMENT_ROTATE_LEFT, NODE_ASSIGNMENT_ROTATE_RIGHT, NODE_ASSIGNMENT_SHIFT_LEFT, NODE_ASSIGNMENT_SHIFT_RIGHT, NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED, NODE_ASSIGNMENT_SUBTRACT, NODE_ATTR_ABSTRACT, NODE_ATTR_ARRAY, NODE_ATTR_AUTOBREAK, NODE_ATTR_CONSTRUCTOR, NODE_ATTR_DEFINED, NODE_ATTR_DEPRECATED, NODE_ATTR_DYNAMIC, NODE_ATTR_ENSURE_THEN, NODE_ATTR_ENUMERABLE, NODE_ATTR_FALSE, NODE_ATTR_FINAL, NODE_ATTR_FOREACH, NODE_ATTR_INLINE, NODE_ATTR_INTERNAL, NODE_ATTR_max, NODE_ATTR_NATIVE, NODE_ATTR_NOBREAK, NODE_ATTR_PRIVATE, NODE_ATTR_PROTECTED, NODE_ATTR_PUBLIC, NODE_ATTR_REQUIRE_ELSE, NODE_ATTR_STATIC, NODE_ATTR_TRANSIENT, NODE_ATTR_TRUE, NODE_ATTR_TYPE, NODE_ATTR_UNSAFE, NODE_ATTR_UNUSED, NODE_ATTR_VIRTUAL, NODE_ATTR_VOLATILE, NODE_BITWISE_AND, NODE_BITWISE_NOT, NODE_BITWISE_OR, NODE_BITWISE_XOR, NODE_CALL, NODE_CONDITIONAL, NODE_DECREMENT, NODE_DELETE, NODE_DIVIDE, NODE_EQUAL, NODE_FALSE, NODE_FLOAT64, NODE_FUNCTION, NODE_GREATER, NODE_GREATER_EQUAL, NODE_IDENTIFIER, NODE_IN, NODE_INCREMENT, NODE_INSTANCEOF, NODE_INT64, NODE_IS, NODE_LESS, NODE_LESS_EQUAL, NODE_LIST, NODE_LOGICAL_AND, NODE_LOGICAL_NOT, NODE_LOGICAL_OR, NODE_LOGICAL_XOR, NODE_MATCH, NODE_MAXIMUM, NODE_MEMBER, NODE_MINIMUM, NODE_MODULO, NODE_MULTIPLY, NODE_NAME, NODE_NEW, NODE_NOT_EQUAL, NODE_NULL, NODE_OBJECT_LITERAL, NODE_POST_DECREMENT, NODE_POST_INCREMENT, NODE_POWER, NODE_PRIVATE, NODE_PROGRAM, NODE_PUBLIC, NODE_RANGE, NODE_ROTATE_LEFT, NODE_ROTATE_RIGHT, NODE_SCOPE, NODE_SHIFT_LEFT, NODE_SHIFT_RIGHT, NODE_SHIFT_RIGHT_UNSIGNED, NODE_STRICTLY_EQUAL, NODE_STRICTLY_NOT_EQUAL, NODE_STRING, NODE_SUBTRACT, NODE_SUPER, NODE_THIS, NODE_TRUE, NODE_TYPEOF, NODE_UNDEFINED, NODE_VIDENTIFIER, and NODE_VOID.
Referenced by get_attribute(), set_attribute(), and set_attribute_tree().
Many attributes are mutually exclusive. This function checks that only one of a group of attributes gets set.
This function is not called if you clear an attribute since in that case the default applies.
When attributes are found to be in conflict, it is not an internal error, so instead the function generates an error message and the function returns false. This means the compiler may end up generating more errors than one might want to get.
a
is invalid.
Definition at line 540 of file node_attribute.cpp.
References as2js::AS_ERR_INVALID_ATTRIBUTES, as2js::anonymous_namespace{node_attribute.cpp}::ATTRIBUTES_GROUP_CONDITIONAL_COMPILATION, as2js::anonymous_namespace{node_attribute.cpp}::ATTRIBUTES_GROUP_FUNCTION_CONTRACT, as2js::anonymous_namespace{node_attribute.cpp}::ATTRIBUTES_GROUP_FUNCTION_TYPE, as2js::anonymous_namespace{node_attribute.cpp}::ATTRIBUTES_GROUP_MEMBER_VISIBILITY, as2js::anonymous_namespace{node_attribute.cpp}::ATTRIBUTES_GROUP_SWITCH_TYPE, f_attributes, f_position, as2js::anonymous_namespace{node_attribute.cpp}::g_attribute_groups, as2js::MESSAGE_LEVEL_ERROR, NODE_ATTR_ABSTRACT, NODE_ATTR_ARRAY, NODE_ATTR_AUTOBREAK, NODE_ATTR_CONSTRUCTOR, NODE_ATTR_DEFINED, NODE_ATTR_DEPRECATED, NODE_ATTR_DYNAMIC, NODE_ATTR_ENSURE_THEN, NODE_ATTR_ENUMERABLE, NODE_ATTR_FALSE, NODE_ATTR_FINAL, NODE_ATTR_FOREACH, NODE_ATTR_INLINE, NODE_ATTR_INTERNAL, NODE_ATTR_max, NODE_ATTR_NATIVE, NODE_ATTR_NOBREAK, NODE_ATTR_PRIVATE, NODE_ATTR_PROTECTED, NODE_ATTR_PUBLIC, NODE_ATTR_REQUIRE_ELSE, NODE_ATTR_STATIC, NODE_ATTR_TRANSIENT, NODE_ATTR_TRUE, NODE_ATTR_TYPE, NODE_ATTR_UNSAFE, NODE_ATTR_UNUSED, NODE_ATTR_VIRTUAL, and NODE_ATTR_VOLATILE.
Referenced by set_attribute(), and set_attribute_tree().
This function verifies that f
corresponds to a valid flag according to the type of this Node object.
Definition at line 150 of file node_flag.cpp.
References f_type, NODE_CATCH, NODE_CATCH_FLAG_TYPED, NODE_CLASS, NODE_DIRECTIVE_LIST, NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES, NODE_ENUM, NODE_ENUM_FLAG_CLASS, NODE_ENUM_FLAG_INUSE, NODE_FLAG_max, NODE_FOR, NODE_FOR_FLAG_CONST, NODE_FOR_FLAG_FOREACH, NODE_FOR_FLAG_IN, NODE_FUNCTION, NODE_FUNCTION_FLAG_GETTER, NODE_FUNCTION_FLAG_NEVER, NODE_FUNCTION_FLAG_NOPARAMS, NODE_FUNCTION_FLAG_OPERATOR, NODE_FUNCTION_FLAG_OUT, NODE_FUNCTION_FLAG_SETTER, NODE_FUNCTION_FLAG_VOID, NODE_IDENTIFIER, NODE_IDENTIFIER_FLAG_TYPED, NODE_IDENTIFIER_FLAG_WITH, NODE_IMPORT, NODE_IMPORT_FLAG_IMPLEMENTS, NODE_PACKAGE, NODE_PACKAGE_FLAG_FOUND_LABELS, NODE_PACKAGE_FLAG_REFERENCED, NODE_PARAM, NODE_PARAM_FLAG_CATCH, NODE_PARAM_FLAG_CONST, NODE_PARAM_FLAG_IN, NODE_PARAM_FLAG_NAMED, NODE_PARAM_FLAG_OUT, NODE_PARAM_FLAG_PARAMREF, NODE_PARAM_FLAG_REFERENCED, NODE_PARAM_FLAG_REST, NODE_PARAM_FLAG_UNCHECKED, NODE_PARAM_FLAG_UNPROTOTYPED, NODE_PARAM_MATCH, NODE_PARAM_MATCH_FLAG_UNPROTOTYPED, NODE_STRING, NODE_SWITCH, NODE_SWITCH_FLAG_DEFAULT, NODE_TYPE, NODE_TYPE_FLAG_MODULO, NODE_VAR_ATTRIBUTES, NODE_VARIABLE, NODE_VARIABLE_FLAG_ATTRIBUTES, NODE_VARIABLE_FLAG_ATTRS, NODE_VARIABLE_FLAG_COMPILED, NODE_VARIABLE_FLAG_CONST, NODE_VARIABLE_FLAG_DEFINED, NODE_VARIABLE_FLAG_DEFINING, NODE_VARIABLE_FLAG_ENUM, NODE_VARIABLE_FLAG_FINAL, NODE_VARIABLE_FLAG_INUSE, NODE_VARIABLE_FLAG_LOCAL, NODE_VARIABLE_FLAG_MEMBER, NODE_VARIABLE_FLAG_TOADD, and NODE_VIDENTIFIER.
Referenced by get_flag(), and set_flag().
Definition at line 597 of file node.h.
Referenced by clone_basic_node(), display(), get_attribute_node(), and set_attribute_node().
Definition at line 598 of file node.h.
Referenced by clone_basic_node(), compare_all_attributes(), display(), get_attribute(), set_attribute(), set_attribute_tree(), and verify_exclusive_attributes().
Definition at line 619 of file node.h.
Referenced by clean_tree(), delete_child(), display(), find_next_child(), get_child(), get_children_size(), and set_attribute_tree().
Definition at line 596 of file node.h.
Referenced by clone_basic_node(), compare_all_flags(), display_data(), get_flag(), and set_flag().
Definition at line 609 of file node.h.
Referenced by clone_basic_node(), display_data(), get_float64(), set_float64(), to_boolean(), to_boolean_type_only(), to_float64(), to_int64(), to_number(), and to_string().
Definition at line 623 of file node.h.
Referenced by clone_basic_node(), display(), get_goto_enter(), and set_goto_enter().
Definition at line 624 of file node.h.
Referenced by clone_basic_node(), display(), get_goto_exit(), and set_goto_exit().
Definition at line 620 of file node.h.
Referenced by clone_basic_node(), display(), get_instance(), and set_instance().
Definition at line 608 of file node.h.
Referenced by clone_basic_node(), display_data(), get_int64(), set_int64(), to_boolean(), to_boolean_type_only(), to_float64(), to_int64(), to_number(), and to_string().
Definition at line 628 of file node.h.
Referenced by add_label(), clone_basic_node(), display(), and find_label().
Definition at line 613 of file node.h.
Referenced by get_param_depth(), get_param_size(), set_param_depth(), and set_param_size().
Definition at line 614 of file node.h.
Referenced by get_param_index(), set_param_index(), and set_param_size().
Definition at line 617 of file node.h.
Referenced by get_offset(), get_parent(), replace_with(), and set_parent().
Definition at line 605 of file node.h.
Referenced by clone_basic_node(), create_replacement(), display(), get_position(), set_position(), and verify_exclusive_attributes().
Definition at line 610 of file node.h.
Referenced by clone_basic_node(), display_data(), get_string(), set_string(), to_boolean(), to_boolean_type_only(), to_float64(), to_int64(), to_number(), and to_string().
Definition at line 599 of file node.h.
Referenced by clone_basic_node(), get_switch_operator(), and set_switch_operator().
Definition at line 594 of file node.h.
Referenced by add_label(), clone_basic_node(), display_data(), get_boolean(), get_float64(), get_int64(), get_string(), get_switch_operator(), set_boolean(), set_float64(), set_int64(), set_param_size(), set_parent(), set_string(), set_switch_operator(), to_as(), to_boolean(), to_boolean_type_only(), to_call(), to_float64(), to_identifier(), to_int64(), to_label(), to_number(), to_string(), to_unknown(), to_var_attributes(), to_videntifier(), verify_attribute(), and verify_flag().
Definition at line 595 of file node.h.
Referenced by clone_basic_node(), and display().
Definition at line 627 of file node.h.
Referenced by add_variable(), clone_basic_node(), display(), get_variable(), and get_variable_size().
Definition at line 77 of file node.h.
Referenced by as2js::Compiler::match_type().
Definition at line 78 of file node.h.
Referenced by as2js::Compiler::match_type().
Definition at line 76 of file node.h.
Referenced by as2js::Compiler::check_function_with_params(), as2js::Compiler::find_class(), and as2js::Compiler::match_type().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.
Snap! Websites
An Open Source CMS System in C++