as2js: as2js::Node Class Reference

#include <node.h>

Inheritance diagram for as2js::Node:
Collaboration diagram for as2js::Node:
Public Types typedef std::bitset< static_cast< int >attribute_t::NODE_ATTR_max)> attribute_set_t   enum  attribute_t {
  attribute_t::NODE_ATTR_PUBLIC,
  attribute_t::NODE_ATTR_PRIVATE,
  attribute_t::NODE_ATTR_PROTECTED,
  attribute_t::NODE_ATTR_INTERNAL,
  attribute_t::NODE_ATTR_TRANSIENT,
  attribute_t::NODE_ATTR_VOLATILE,
  attribute_t::NODE_ATTR_STATIC,
  attribute_t::NODE_ATTR_ABSTRACT,
  attribute_t::NODE_ATTR_VIRTUAL,
  attribute_t::NODE_ATTR_ARRAY,
  attribute_t::NODE_ATTR_INLINE,
  attribute_t::NODE_ATTR_REQUIRE_ELSE,
  attribute_t::NODE_ATTR_ENSURE_THEN,
  attribute_t::NODE_ATTR_NATIVE,
  attribute_t::NODE_ATTR_DEPRECATED,
  attribute_t::NODE_ATTR_UNSAFE,
  attribute_t::NODE_ATTR_CONSTRUCTOR,
  attribute_t::NODE_ATTR_FINAL,
  attribute_t::NODE_ATTR_ENUMERABLE,
  attribute_t::NODE_ATTR_TRUE,
  attribute_t::NODE_ATTR_FALSE,
  attribute_t::NODE_ATTR_UNUSED,
  attribute_t::NODE_ATTR_DYNAMIC,
  attribute_t::NODE_ATTR_FOREACH,
  attribute_t::NODE_ATTR_NOBREAK,
  attribute_t::NODE_ATTR_AUTOBREAK,
  attribute_t::NODE_ATTR_TYPE,
  attribute_t::NODE_ATTR_DEFINED,
  attribute_t::NODE_ATTR_max
}   enum  compare_mode_t {
  compare_mode_t::COMPARE_STRICT,
  compare_mode_t::COMPARE_LOOSE,
  compare_mode_t::COMPARE_SMART
}   typedef ssize_t depth_t   typedef std::bitset< static_cast< size_t >flag_t::NODE_FLAG_max)> flag_set_t   enum  flag_t {
  flag_t::NODE_CATCH_FLAG_TYPED,
  flag_t::NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES,
  flag_t::NODE_ENUM_FLAG_CLASS,
  flag_t::NODE_ENUM_FLAG_INUSE,
  flag_t::NODE_FOR_FLAG_CONST,
  flag_t::NODE_FOR_FLAG_FOREACH,
  flag_t::NODE_FOR_FLAG_IN,
  flag_t::NODE_FUNCTION_FLAG_GETTER,
  flag_t::NODE_FUNCTION_FLAG_SETTER,
  flag_t::NODE_FUNCTION_FLAG_OUT,
  flag_t::NODE_FUNCTION_FLAG_VOID,
  flag_t::NODE_FUNCTION_FLAG_NEVER,
  flag_t::NODE_FUNCTION_FLAG_NOPARAMS,
  flag_t::NODE_FUNCTION_FLAG_OPERATOR,
  flag_t::NODE_IDENTIFIER_FLAG_WITH,
  flag_t::NODE_IDENTIFIER_FLAG_TYPED,
  flag_t::NODE_IMPORT_FLAG_IMPLEMENTS,
  flag_t::NODE_PACKAGE_FLAG_FOUND_LABELS,
  flag_t::NODE_PACKAGE_FLAG_REFERENCED,
  flag_t::NODE_PARAM_FLAG_CONST,
  flag_t::NODE_PARAM_FLAG_IN,
  flag_t::NODE_PARAM_FLAG_OUT,
  flag_t::NODE_PARAM_FLAG_NAMED,
  flag_t::NODE_PARAM_FLAG_REST,
  flag_t::NODE_PARAM_FLAG_UNCHECKED,
  flag_t::NODE_PARAM_FLAG_UNPROTOTYPED,
  flag_t::NODE_PARAM_FLAG_REFERENCED,
  flag_t::NODE_PARAM_FLAG_PARAMREF,
  flag_t::NODE_PARAM_FLAG_CATCH,
  flag_t::NODE_PARAM_MATCH_FLAG_UNPROTOTYPED,
  flag_t::NODE_SWITCH_FLAG_DEFAULT,
  flag_t::NODE_TYPE_FLAG_MODULO,
  flag_t::NODE_VARIABLE_FLAG_CONST,
  flag_t::NODE_VARIABLE_FLAG_FINAL,
  flag_t::NODE_VARIABLE_FLAG_LOCAL,
  flag_t::NODE_VARIABLE_FLAG_MEMBER,
  flag_t::NODE_VARIABLE_FLAG_ATTRIBUTES,
  flag_t::NODE_VARIABLE_FLAG_ENUM,
  flag_t::NODE_VARIABLE_FLAG_COMPILED,
  flag_t::NODE_VARIABLE_FLAG_INUSE,
  flag_t::NODE_VARIABLE_FLAG_ATTRS,
  flag_t::NODE_VARIABLE_FLAG_DEFINED,
  flag_t::NODE_VARIABLE_FLAG_DEFINING,
  flag_t::NODE_VARIABLE_FLAG_TOADD,
  flag_t::NODE_FLAG_max
}   typedef std::map< String, weak_pointer_tmap_of_weak_pointers_t   enum  node_t {
  node_t::NODE_EOF = -1,
  node_t::NODE_UNKNOWN = 0,
  node_t::NODE_ADD = '+',
  node_t::NODE_ASSIGNMENT = '=',
  node_t::NODE_BITWISE_AND = '&',
  node_t::NODE_BITWISE_NOT = '~',
  node_t::NODE_BITWISE_OR = '|',
  node_t::NODE_BITWISE_XOR = '^',
  node_t::NODE_CLOSE_CURVLY_BRACKET = '}',
  node_t::NODE_CLOSE_PARENTHESIS = ')',
  node_t::NODE_CLOSE_SQUARE_BRACKET = ']',
  node_t::NODE_COLON = ':',
  node_t::NODE_COMMA = ',',
  node_t::NODE_CONDITIONAL = '?',
  node_t::NODE_DIVIDE = '/',
  node_t::NODE_GREATER = '>',
  node_t::NODE_LESS = '<',
  node_t::NODE_LOGICAL_NOT = '!',
  node_t::NODE_MODULO = '',
  node_t::NODE_MULTIPLY = '*',
  node_t::NODE_OPEN_CURVLY_BRACKET = '{',
  node_t::NODE_OPEN_PARENTHESIS = '(',
  node_t::NODE_OPEN_SQUARE_BRACKET = '[',
  node_t::NODE_MEMBER = '.',
  node_t::NODE_SEMICOLON = ';',
  node_t::NODE_SUBTRACT = '-',
  node_t::NODE_other = 1000,
  node_t::NODE_ABSTRACT,
  node_t::NODE_ARRAY,
  node_t::NODE_ARRAY_LITERAL,
  node_t::NODE_AS,
  node_t::NODE_ASSIGNMENT_ADD,
  node_t::NODE_ASSIGNMENT_BITWISE_AND,
  node_t::NODE_ASSIGNMENT_BITWISE_OR,
  node_t::NODE_ASSIGNMENT_BITWISE_XOR,
  node_t::NODE_ASSIGNMENT_DIVIDE,
  node_t::NODE_ASSIGNMENT_LOGICAL_AND,
  node_t::NODE_ASSIGNMENT_LOGICAL_OR,
  node_t::NODE_ASSIGNMENT_LOGICAL_XOR,
  node_t::NODE_ASSIGNMENT_MAXIMUM,
  node_t::NODE_ASSIGNMENT_MINIMUM,
  node_t::NODE_ASSIGNMENT_MODULO,
  node_t::NODE_ASSIGNMENT_MULTIPLY,
  node_t::NODE_ASSIGNMENT_POWER,
  node_t::NODE_ASSIGNMENT_ROTATE_LEFT,
  node_t::NODE_ASSIGNMENT_ROTATE_RIGHT,
  node_t::NODE_ASSIGNMENT_SHIFT_LEFT,
  node_t::NODE_ASSIGNMENT_SHIFT_RIGHT,
  node_t::NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED,
  node_t::NODE_ASSIGNMENT_SUBTRACT,
  node_t::NODE_ATTRIBUTES,
  node_t::NODE_AUTO,
  node_t::NODE_BOOLEAN,
  node_t::NODE_BREAK,
  node_t::NODE_BYTE,
  node_t::NODE_CALL,
  node_t::NODE_CASE,
  node_t::NODE_CATCH,
  node_t::NODE_CHAR,
  node_t::NODE_CLASS,
  node_t::NODE_COMPARE,
  node_t::NODE_CONST,
  node_t::NODE_CONTINUE,
  node_t::NODE_DEBUGGER,
  node_t::NODE_DECREMENT,
  node_t::NODE_DEFAULT,
  node_t::NODE_DELETE,
  node_t::NODE_DIRECTIVE_LIST,
  node_t::NODE_DO,
  node_t::NODE_DOUBLE,
  node_t::NODE_ELSE,
  node_t::NODE_EMPTY,
  node_t::NODE_ENSURE,
  node_t::NODE_ENUM,
  node_t::NODE_EQUAL,
  node_t::NODE_EXCLUDE,
  node_t::NODE_EXTENDS,
  node_t::NODE_EXPORT,
  node_t::NODE_FALSE,
  node_t::NODE_FINAL,
  node_t::NODE_FINALLY,
  node_t::NODE_FLOAT,
  node_t::NODE_FLOAT64,
  node_t::NODE_FOR,
  node_t::NODE_FUNCTION,
  node_t::NODE_GOTO,
  node_t::NODE_GREATER_EQUAL,
  node_t::NODE_IDENTIFIER,
  node_t::NODE_IF,
  node_t::NODE_IMPLEMENTS,
  node_t::NODE_IMPORT,
  node_t::NODE_IN,
  node_t::NODE_INCLUDE,
  node_t::NODE_INCREMENT,
  node_t::NODE_INLINE,
  node_t::NODE_INSTANCEOF,
  node_t::NODE_INT64,
  node_t::NODE_INTERFACE,
  node_t::NODE_INVARIANT,
  node_t::NODE_IS,
  node_t::NODE_LABEL,
  node_t::NODE_LESS_EQUAL,
  node_t::NODE_LIST,
  node_t::NODE_LOGICAL_AND,
  node_t::NODE_LOGICAL_OR,
  node_t::NODE_LOGICAL_XOR,
  node_t::NODE_LONG,
  node_t::NODE_MATCH,
  node_t::NODE_MAXIMUM,
  node_t::NODE_MINIMUM,
  node_t::NODE_NAME,
  node_t::NODE_NAMESPACE,
  node_t::NODE_NATIVE,
  node_t::NODE_NEW,
  node_t::NODE_NOT_EQUAL,
  node_t::NODE_NOT_MATCH,
  node_t::NODE_NULL,
  node_t::NODE_OBJECT_LITERAL,
  node_t::NODE_PACKAGE,
  node_t::NODE_PARAM,
  node_t::NODE_PARAMETERS,
  node_t::NODE_PARAM_MATCH,
  node_t::NODE_POST_DECREMENT,
  node_t::NODE_POST_INCREMENT,
  node_t::NODE_POWER,
  node_t::NODE_PRIVATE,
  node_t::NODE_PROGRAM,
  node_t::NODE_PROTECTED,
  node_t::NODE_PUBLIC,
  node_t::NODE_RANGE,
  node_t::NODE_REGULAR_EXPRESSION,
  node_t::NODE_REQUIRE,
  node_t::NODE_REST,
  node_t::NODE_RETURN,
  node_t::NODE_ROOT,
  node_t::NODE_ROTATE_LEFT,
  node_t::NODE_ROTATE_RIGHT,
  node_t::NODE_SCOPE,
  node_t::NODE_SET,
  node_t::NODE_SHIFT_LEFT,
  node_t::NODE_SHIFT_RIGHT,
  node_t::NODE_SHIFT_RIGHT_UNSIGNED,
  node_t::NODE_SHORT,
  node_t::NODE_SMART_MATCH,
  node_t::NODE_STATIC,
  node_t::NODE_STRICTLY_EQUAL,
  node_t::NODE_STRICTLY_NOT_EQUAL,
  node_t::NODE_STRING,
  node_t::NODE_SUPER,
  node_t::NODE_SWITCH,
  node_t::NODE_SYNCHRONIZED,
  node_t::NODE_THEN,
  node_t::NODE_THIS,
  node_t::NODE_THROW,
  node_t::NODE_THROWS,
  node_t::NODE_TRANSIENT,
  node_t::NODE_TRUE,
  node_t::NODE_TRY,
  node_t::NODE_TYPE,
  node_t::NODE_TYPEOF,
  node_t::NODE_UNDEFINED,
  node_t::NODE_USE,
  node_t::NODE_VAR,
  node_t::NODE_VARIABLE,
  node_t::NODE_VAR_ATTRIBUTES,
  node_t::NODE_VIDENTIFIER,
  node_t::NODE_VOID,
  node_t::NODE_VOLATILE,
  node_t::NODE_WHILE,
  node_t::NODE_WITH,
  node_t::NODE_YIELD,
  node_t::NODE_max
}   typedef std::shared_ptr< Nodepointer_t   typedef std::vector< pointer_tvector_of_pointers_t   typedef std::vector< weak_pointer_tvector_of_weak_pointers_t   typedef std::weak_ptr< Nodeweak_pointer_t   Public Member Functions  Node (node_t type)  Initialize a node. More...
   Node (Node const &)=delete  Do not allow direct copies of nodes. More...
  virtual ~Node () noexcept(false)  Verify that a node is clean when deleting it. More...
  void add_label (pointer_t label)  Add a label to a function. More...
  void add_variable (pointer_t variable)  Add a variable to this node. More...
  void append_child (pointer_t child)  Append a child to 'this' node. More...
  void clean_tree ()  Remove all the unknown nodes. More...
  pointer_t clone_basic_node () const  Create a clone of a basic node. More...
  bool compare_all_attributes (attribute_set_t const &s) const  Compare a set of attributes with the current attributes of this node. More...
  bool compare_all_flags (flag_set_t const &s) const  Compare a set of flags with the current flags of this node. More...
  pointer_t create_replacement (node_t type) const  Create a new node with the given type. More...
  void delete_child (int index)  Delete the specified child from the parent. More...
  void display (std::ostream &out, int indent, char c) const  Display a node tree. More...
  pointer_t find_first_child (node_t type) const  Find the first child of a given type. More...
  pointer_t find_label (String const &name) const  Find a label previously added with the add_label() function. More...
  pointer_t find_next_child (pointer_t start, node_t type) const  Find the next child with the specified type. More...
  bool get_attribute (attribute_t const a) const  Get the current status of an attribute. More...
  pointer_t get_attribute_node () const   bool get_boolean () const  Get the Boolean value of this node. More...
  pointer_t get_child (int index) const  Retrieve a child. More...
  size_t get_children_size () const  Return the number of children available in this node. More...
  bool get_flag (flag_t f) const  Get the current status of a flag. More...
  Float64 get_float64 () const  Get the Float64 of this node. More...
  pointer_t get_goto_enter () const  Save a link in this node. More...
  pointer_t get_goto_exit () const  Retrieve the "Goto Exit" pointer. More...
  pointer_t get_instance () const   Int64 get_int64 () const  Get the Int64 of this node. More...
  size_t get_offset () const  Find the offset of this node in its parent array of children. More...
  depth_t get_param_depth (size_t j) const  Get the depth at the specified index. More...
  size_t get_param_index (size_t idx) const  Get the index of the parameter. More...
  size_t get_param_size () const  Return the size of the parameter index and depth vectors. More...
  pointer_t get_parent () const  Get a pointer to the parent of this node. More...
  Position const & get_position () const  The position of the node. More...
  String const & get_string () const  Get the string of this node. More...
  node_t get_switch_operator () const  Retrieve the switch operator. More...
  node_t get_type () const  Retrieve the type of the node. More...
  char const * get_type_name () const  Retrieve the type of this node. More...
  pointer_t get_type_node () const   pointer_t get_variable (int index) const  Retrieve the variable at the specified index. More...
  size_t get_variable_size () const  Retrieve the number of variables defined in this node. More...
  bool has_side_effects () const  Check whether a node has side effects. More...
  void insert_child (int index, pointer_t child)  Insert the specified child at the specified location. More...
  bool is_boolean () const  Check whether a node is a Boolean value. More...
  bool is_false () const  Check whether a node represents the false Boolean value. More...
  bool is_float64 () const  Check whether a node is a floating point. More...
  bool is_identifier () const  Check whether a node is an identifier. More...
  bool is_int64 () const  Check whether a node is an integer. More...
  bool is_literal () const  Check whether this node represents a literal. More...
  bool is_locked () const  Check whether a node is locked. More...
  bool is_nan () const  Check whether this node represents a NaN if converted to a number. More...
  bool is_null () const  Check whether a node is the special value null. More...
  bool is_number () const  Return true if Node represents a number. More...
  bool is_string () const  Check whether a node is a string. More...
  bool is_true () const  Check whether a node represents the true Boolean value. More...
  bool is_undefined () const  Check whether a node is the special value undefined. More...
  void lock ()  Lock this node. More...
  Nodeoperator= (Node const &)=delete  Do not allow direct copies of nodes. More...
  void replace_with (pointer_t node)  Replace this node with the node parameter. More...
  void set_attribute (attribute_t const a, bool const v)  Set an attribute. More...
  void set_attribute_node (pointer_t node)   void set_attribute_tree (attribute_t const a, bool const v)  Set an attribute in a whole tree. More...
  void set_boolean (bool value)  Set the Boolean value of this node. More...
  void set_child (int index, pointer_t child)  Replace the current child at position index with child. More...
  void set_flag (flag_t f, bool v)  Set a flag. More...
  void set_float64 (Float64 value)  Set the Float64 of this node. More...
  void set_goto_enter (pointer_t node)  Define the "Goto Enter" pointer. More...
  void set_goto_exit (pointer_t node)  Define the "Goto Exit" pointer. More...
  void set_instance (pointer_t node)   void set_int64 (Int64 value)  Set the Int64 of this node. More...
  void set_param_depth (size_t j, depth_t depth)  Set the depth of a parameter. More...
  void set_param_index (size_t idx, size_t j)  Set the parameter index. More...
  void set_param_size (size_t size)  Define the size of the parameter index and depth vectors. More...
  void set_parent (pointer_t parent=pointer_t(), int index=-1)  This function sets the parent of a node. More...
  void set_position (Position const &position)  Change the position of the node. More...
  void set_string (String const &value)  Set the string of this node. More...
  void set_switch_operator (node_t op)  Set the switch statement operator. More...
  void set_type_node (Node::pointer_t node)   bool to_as ()  Transform a call in a NODE_AS node. More...
  bool to_boolean ()  Convert this node to a Boolean node. More...
  node_t to_boolean_type_only () const  Check whether a node can be converted to Boolean. More...
  bool to_call ()  Convert a getter or setter to a function call. More...
  bool to_float64 ()  Convert this node to a NODE_FLOAT64. More...
  bool to_identifier ()  Convert this node to a NODE_IDENTIFIER. More...
  bool to_int64 ()  Convert this node to a NODE_INT64. More...
  bool to_label ()  Convert this node to a label. More...
  bool to_number ()  Convert this node to a number. More...
  bool to_string ()  Transform a node to a string. More...
  void to_unknown ()  Transform any node to NODE_UNKNOWN. More...
  void to_var_attributes ()  Transform a variable into a variable of attributes. More...
  void to_videntifier ()  Transform an identifier into a NODE_VIDENTIFIER. More...
  void unlock ()  Unlock a node that was previously locked. More...
  Static Public Member Functions static char const * attribute_to_string (attribute_t const attr)  Convert an attribute to a string. More...
  static compare_t compare (Node::pointer_t const lhs, Node::pointer_t const rhs, compare_mode_t const mode)  Compare two nodes together. More...
  static char const * operator_to_string (node_t op)  Transform an operator to a string. More...
  static node_t string_to_operator (String const &str)  Transform a string in an operator. More...
  static char const * type_to_string (node_t type)  Convert the specified type to a string. More...
  Static Public Attributes static depth_t const MATCH_HIGHEST_DEPTH = 1   static depth_t const MATCH_LOWEST_DEPTH = std::numeric_limits<int>::max() / 2   static depth_t const MATCH_NOT_FOUND = 0   Private Types typedef std::vector< int32_t > param_depth_t   typedef std::vector< uint32_t > param_index_t   Private Member Functions void display_data (std::ostream &out) const  Display a node. More...
  void modifying () const  Test whether the node can be modified. More...
  void verify_attribute (attribute_t const f) const  Verify that a corresponds to the Node type. More...
  bool verify_exclusive_attributes (attribute_t f) const  Verify that we can indeed set an attribute. More...
  void verify_flag (flag_t f) const  Verify that f corresponds to the node type. More...
  Private Attributes pointer_t f_attribute_node = pointer_t()   attribute_set_t f_attributes = attribute_set_t()   vector_of_pointers_t f_children = vector_of_pointers_t()   flag_set_t f_flags = flag_set_t()   Float64 f_float = Float64()   weak_pointer_t f_goto_enter = weak_pointer_t()   weak_pointer_t f_goto_exit = weak_pointer_t()   weak_pointer_t f_instance = weak_pointer_t()   Int64 f_int = Int64()   map_of_weak_pointers_t f_labels = map_of_weak_pointers_t()   int32_t f_lock = 0   int32_t f_offset = 0   param_depth_t f_param_depth = param_depth_t()   param_index_t f_param_index = param_index_t()   weak_pointer_t f_parent = weak_pointer_t()   Position f_position = Position()   String f_str = String()   node_t f_switch_operator = node_t::NODE_UNKNOWN   node_t f_type = node_t::NODE_UNKNOWN   weak_pointer_t f_type_node = weak_pointer_t()   vector_of_weak_pointers_t f_variables = vector_of_weak_pointers_t()   Detailed Description

Definition at line 63 of file node.h.

Member Typedef Documentation
typedef std::bitset<static_cast<int>attribute_t::NODE_ATTR_max)> as2js::Node::attribute_set_t

Definition at line 421 of file node.h.

typedef ssize_t as2js::Node::depth_t

Definition at line 74 of file node.h.

typedef std::bitset<static_cast<size_t>flag_t::NODE_FLAG_max)> as2js::Node::flag_set_t

Definition at line 345 of file node.h.

Definition at line 69 of file node.h.

typedef std::vector<int32_t> as2js::Node::param_depth_t private

Definition at line 581 of file node.h.

typedef std::vector<uint32_t> as2js::Node::param_index_t private

Definition at line 582 of file node.h.

typedef std::shared_ptr<Node> as2js::Node::pointer_t

Definition at line 67 of file node.h.

Definition at line 70 of file node.h.

Definition at line 71 of file node.h.

typedef std::weak_ptr<Node> as2js::Node::weak_pointer_t

Definition at line 68 of file node.h.

Member Enumeration Documentation
EnumeratorNODE_ATTR_PUBLIC  NODE_ATTR_PRIVATE  NODE_ATTR_PROTECTED  NODE_ATTR_INTERNAL  NODE_ATTR_TRANSIENT  NODE_ATTR_VOLATILE  NODE_ATTR_STATIC  NODE_ATTR_ABSTRACT  NODE_ATTR_VIRTUAL  NODE_ATTR_ARRAY  NODE_ATTR_INLINE  NODE_ATTR_REQUIRE_ELSE  NODE_ATTR_ENSURE_THEN  NODE_ATTR_NATIVE  NODE_ATTR_DEPRECATED  NODE_ATTR_UNSAFE  NODE_ATTR_CONSTRUCTOR  NODE_ATTR_FINAL  NODE_ATTR_ENUMERABLE  NODE_ATTR_TRUE  NODE_ATTR_FALSE  NODE_ATTR_UNUSED  NODE_ATTR_DYNAMIC  NODE_ATTR_FOREACH  NODE_ATTR_NOBREAK  NODE_ATTR_AUTOBREAK  NODE_ATTR_TYPE  NODE_ATTR_DEFINED  NODE_ATTR_max 

Definition at line 352 of file node.h.

EnumeratorCOMPARE_STRICT  COMPARE_LOOSE  COMPARE_SMART 

Definition at line 433 of file node.h.

enum as2js::Node::flag_t strong
EnumeratorNODE_CATCH_FLAG_TYPED  NODE_DIRECTIVE_LIST_FLAG_NEW_VARIABLES  NODE_ENUM_FLAG_CLASS  NODE_ENUM_FLAG_INUSE  NODE_FOR_FLAG_CONST  NODE_FOR_FLAG_FOREACH  NODE_FOR_FLAG_IN  NODE_FUNCTION_FLAG_GETTER  NODE_FUNCTION_FLAG_SETTER  NODE_FUNCTION_FLAG_OUT  NODE_FUNCTION_FLAG_VOID  NODE_FUNCTION_FLAG_NEVER  NODE_FUNCTION_FLAG_NOPARAMS  NODE_FUNCTION_FLAG_OPERATOR  NODE_IDENTIFIER_FLAG_WITH  NODE_IDENTIFIER_FLAG_TYPED  NODE_IMPORT_FLAG_IMPLEMENTS  NODE_PACKAGE_FLAG_FOUND_LABELS  NODE_PACKAGE_FLAG_REFERENCED  NODE_PARAM_FLAG_CONST  NODE_PARAM_FLAG_IN  NODE_PARAM_FLAG_OUT  NODE_PARAM_FLAG_NAMED  NODE_PARAM_FLAG_REST  NODE_PARAM_FLAG_UNCHECKED  NODE_PARAM_FLAG_UNPROTOTYPED  NODE_PARAM_FLAG_REFERENCED  NODE_PARAM_FLAG_PARAMREF  NODE_PARAM_FLAG_CATCH  NODE_PARAM_MATCH_FLAG_UNPROTOTYPED  NODE_SWITCH_FLAG_DEFAULT  NODE_TYPE_FLAG_MODULO  NODE_VARIABLE_FLAG_CONST  NODE_VARIABLE_FLAG_FINAL  NODE_VARIABLE_FLAG_LOCAL  NODE_VARIABLE_FLAG_MEMBER  NODE_VARIABLE_FLAG_ATTRIBUTES  NODE_VARIABLE_FLAG_ENUM  NODE_VARIABLE_FLAG_COMPILED  NODE_VARIABLE_FLAG_INUSE  NODE_VARIABLE_FLAG_ATTRS  NODE_VARIABLE_FLAG_DEFINED  NODE_VARIABLE_FLAG_DEFINING  NODE_VARIABLE_FLAG_TOADD  NODE_FLAG_max 

Definition at line 270 of file node.h.

enum as2js::Node::node_t strong
EnumeratorNODE_EOF  NODE_UNKNOWN  NODE_ADD  NODE_ASSIGNMENT  NODE_BITWISE_AND  NODE_BITWISE_NOT  NODE_BITWISE_OR  NODE_BITWISE_XOR  NODE_CLOSE_CURVLY_BRACKET  NODE_CLOSE_PARENTHESIS  NODE_CLOSE_SQUARE_BRACKET  NODE_COLON  NODE_COMMA  NODE_CONDITIONAL  NODE_DIVIDE  NODE_GREATER  NODE_LESS  NODE_LOGICAL_NOT  NODE_MODULO  NODE_MULTIPLY  NODE_OPEN_CURVLY_BRACKET  NODE_OPEN_PARENTHESIS  NODE_OPEN_SQUARE_BRACKET  NODE_MEMBER  NODE_SEMICOLON  NODE_SUBTRACT  NODE_other  NODE_ABSTRACT  NODE_ARRAY  NODE_ARRAY_LITERAL  NODE_AS  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_BOOLEAN  NODE_BREAK  NODE_BYTE  NODE_CALL  NODE_CASE  NODE_CATCH  NODE_CHAR  NODE_CLASS  NODE_COMPARE  NODE_CONST  NODE_CONTINUE  NODE_DEBUGGER  NODE_DECREMENT  NODE_DEFAULT  NODE_DELETE  NODE_DIRECTIVE_LIST  NODE_DO  NODE_DOUBLE  NODE_ELSE  NODE_EMPTY  NODE_ENSURE  NODE_ENUM  NODE_EQUAL  NODE_EXCLUDE  NODE_EXTENDS  NODE_EXPORT  NODE_FALSE  NODE_FINAL  NODE_FINALLY  NODE_FLOAT  NODE_FLOAT64  NODE_FOR  NODE_FUNCTION  NODE_GOTO  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_EQUAL  NODE_LIST  NODE_LOGICAL_AND  NODE_LOGICAL_OR  NODE_LOGICAL_XOR  NODE_LONG  NODE_MATCH  NODE_MAXIMUM  NODE_MINIMUM  NODE_NAME  NODE_NAMESPACE  NODE_NATIVE  NODE_NEW  NODE_NOT_EQUAL  NODE_NOT_MATCH  NODE_NULL  NODE_OBJECT_LITERAL  NODE_PACKAGE  NODE_PARAM  NODE_PARAMETERS  NODE_PARAM_MATCH  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_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_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_USE  NODE_VAR  NODE_VARIABLE  NODE_VAR_ATTRIBUTES  NODE_VIDENTIFIER  NODE_VOID  NODE_VOLATILE  NODE_WHILE  NODE_WITH  NODE_YIELD  NODE_max 

Definition at line 81 of file node.h.

Constructor & Destructor Documentation
as2js::Node::Node ( node_t  type)

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.

Note
At this time we accept all the different types at creation time. We may restrict this later to only nodes that are expected to be created in this way. For example, a NODE_VIDENTIFIER cannot be created directly, instead it is expected that you would create a NODE_IDENTIFIER and then call the to_videntifier() function to conver the node.
Exceptions
exception_incompatible_node_typeThis exception is raised of the specified type does not correspond to one of the allowed node_t::NODE_... definitions.
Parameters
[in]typeThe type of node to create.
See also
to_videntifier()
set_boolean()
set_int64()
set_float64()
set_string()
set_position()

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().

as2js::Node::~Node ( ) virtualnoexcept

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.

Exceptions
exception_exitA destructor should not throw, yet we want to have a drastic error because deleting a locked node is a bug. So the exit exception is raised here. This way, also, we can capture the exception in our unit tests. The side effect is that other parts of the Node object do not get properly cleaned up. It is fine in the unit test, and it is a totally fatal error otherwise, so I am not concerned with that problem. std::abort(), on the other hand, could not be properly tested from our unit tests (at least, not easily).

Definition at line 325 of file node.cpp.

References as2js::AS_ERR_NOT_ALLOWED, f_lock, and as2js::MESSAGE_LEVEL_FATAL.

as2js::Node::Node ( Node const &  ) delete

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.

Member Function Documentation
void as2js::Node::add_label ( pointer_t  label)

This function adds a label to this function node. Labels are saved using a map so we can quickly find them.

Note
After a label was added to a function, its name should never get modified or it will be out of synchronization with the function.
Exceptions
exception_incompatible_node_typeIf this function is called with objects other than a NODE_LABEL as the label parameter and a NODE_FUNCTION as 'this' parameter, then this exception is raised. exception_incompatible_node_dataIf the node representing the label does not have a valid string attached to it (i.e. if it is empty) then this exception is raised. exception_already_definedIf the label was already defined, then this exception is raised. Within one function each label must be unique, however, sub-functions have their own scope and thus can be a label with the same name as a label in their parent function.
Parameters
[in]labelA smart pointer to the label node to add.
See also
find_label()

Definition at line 930 of file node.cpp.

References f_labels, f_type, NODE_FUNCTION, and NODE_LABEL.

void as2js::Node::add_variable ( pointer_t  variable)

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.

Note
This is not an execution environment and as such the variables are simply added one after another (not sorted, no attempt to later retrieve variables by name.) This may change in the future though.
Todo:
Add a test of the node type so we can make sure we do not call this function on nodes that cannot have variables. For that purpose, we need to know what those types are.
Exceptions
exception_incompatible_node_typeThis exception is raised if the variable parameter is not of type NODE_VARIABLE.
Parameters
[in]variableThe variable to be added.
See also
get_variable()
get_variable_size()

Definition at line 827 of file node.cpp.

References f_variables, and NODE_VARIABLE.

void as2js::Node::append_child ( pointer_t  child)

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:

parent->append_child(child);
// or
child->set_parent(parent);
Exceptions
exception_invalid_dataThis function verifies that the child pointer is not null. If null, this exception is raised.
Parameters
[in]childThe child to be added at the end of 'this' vector of children.
See also
set_parent()

Definition at line 524 of file node_tree.cpp.

char const * as2js::Node::attribute_to_string ( attribute_t const  attr) static

This function converts an attribute to a string. This is most often used to print out an error about an attribute.

Parameters
[in]attrThe attribute to convert to a string.
Returns
A static string pointer representing the 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().

void as2js::Node::clean_tree ( )

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.

Note
The nodes themselves do not get deleted by this function. If it was their last reference then it will be deleted by the shared pointer code as expected.
See also
set_parent()
delete_child()

Definition at line 804 of file node_tree.cpp.

References delete_child(), f_children, get_type(), and NODE_UNKNOWN.

Node::pointer_t as2js::Node::clone_basic_node ( ) const

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.

Returns
A new node pointer.
See also
create_replacement()

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.

compare_t as2js::Node::compare ( Node::pointer_t const  lhs, Node::pointer_t const  rhs, compare_mode_t const  mode  ) static

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.

Note
The compare is expected to work as defined in ECMAScript 5 (see 11.8.5, 11.9.3, and 11.9.6).

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.

Parameters
[in]lhsThe left hand side node. [in]rhsThe right hand side node. [in]modeWhether the compare is strict, lousy, or smart (===, ==, ~~).
Returns
One of the compare_t values representing the comparison result.

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().

bool as2js::Node::compare_all_attributes ( attribute_set_t const &  s) const

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.

Parameters
[in]sThe set of attributes to compare with.
Returns
true if s is equal to the node attributes.

Definition at line 704 of file node_attribute.cpp.

References f_attributes.

bool as2js::Node::compare_all_flags ( flag_set_t const &  s) const

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.

Parameters
[in]sThe set of flags to compare with.
Returns
true if s is equal to the node flags.
See also
get_flag()

Definition at line 309 of file node_flag.cpp.

References f_flags.

Node::pointer_t as2js::Node::create_replacement ( node_t  type) const

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:

Node::pointer_t n(new Node(type));
n->set_position(node->get_position());
Parameters
[in]typeThe type of the new node.
Returns
A new node pointer.
See also
set_position()
clone_basic_node()

Definition at line 554 of file node.cpp.

References f_position, and Node().

void as2js::Node::delete_child ( int  index)

This function removes a child from its parent (i.e. "unparent" a node.)

The following two lines of code are identical:

parent->delete_child(index);
// or
parent->set_parent(nullptr, index);

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.

Note
The child node being "deleted" is not actively deleted. That is, if anyone still holds a shared pointer of that node, it will not actually get deleted. If that was the last shared pointer holding that node, then it gets deleted automatically by the smart pointer implementation.
Parameters
[in]indexThe index of the child node to remove from 'this' node.
See also
lock()
set_parent()

Definition at line 495 of file node_tree.cpp.

References f_children.

Referenced by clean_tree(), and set_child().

void as2js::Node::display ( std::ostream &  out, int  indent, char  c  ) const

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 (:).

Parameters
[in,out]outThe output stream. [in]indentThe current indentation. We start with 2. [in]cA character to start each line of output.

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<<().

void as2js::Node::display_data ( std::ostream &  out) const private

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.

Parameters
[in]outThe output stream where the node is displayed.

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().

Node::pointer_t as2js::Node::find_first_child ( node_t  type) const

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.

Note
This function calls the find_next_child() with a null pointer in the child parameter.
find_next_child(nullptr, type);
Parameters
[in]typeThe type of nodes you are interested in.
Returns
A pointer to the first node of that type or a null pointer.
See also
find_next_child()

Definition at line 735 of file node_tree.cpp.

References find_next_child().

Node::pointer_t as2js::Node::find_label ( String const &  name) const

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.

Parameters
[in]nameThe name of the label to retrieve.
Returns
A pointer to the label if it exists, a null pointer otherwise.
See also
add_label()

Definition at line 964 of file node.cpp.

References f_labels.

Node::pointer_t as2js::Node::find_next_child ( pointer_t  child, node_t  type  ) const

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.)

Bug:
If you have to manage all the nodes of a given type in a large list, it is wise to create your own loop because this loop restarts from index zero every single time. This should get fixed in a future release, although I am not so sure there a way to do that without a context.
Parameters
[in]childA pointer to the previously returned child node. [in]typeThe type of children to look for.
Returns
The next child of that type or a null pointer.
See also
find_first_child()

Definition at line 766 of file node_tree.cpp.

References f_children, and get_type().

Referenced by find_first_child().

bool as2js::Node::get_attribute ( attribute_t const  a) const

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.

Note
All attributes are always considered false by default.
Parameters
[in]aThe attribute to retrieve.
Returns
true if the attribute was set, false otherwise.
See also
set_attribute()
verify_attribute()

Definition at line 240 of file node_attribute.cpp.

References f_attributes, and verify_attribute().

Node::pointer_t as2js::Node::get_attribute_node ( ) const

Definition at line 214 of file node_attribute.cpp.

References f_attribute_node.

bool as2js::Node::get_boolean ( ) const

This function returns true or false depending on the node type: NODE_TRUE or NODE_FALSE.

Exceptions
exception_internal_errorThis exception is raised if the get_boolean() function is called on a type of node which is not NODE_TRUE or NODE_FALSE.
Returns
The Boolean value attached to this node.

Definition at line 229 of file node_value.cpp.

References f_type, NODE_FALSE, and NODE_TRUE.

Node::pointer_t as2js::Node::get_child ( int  index) const

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.

Exceptions
std::out_of_rangeIf the index is out of bounds, the function throws this exception.
Parameters
[in]indexThe index of the child to retrieve.
Returns
A shared pointer to the specified child.
See also
set_parent()
get_parent()
get_children_size()

Definition at line 709 of file node_tree.cpp.

References f_children.

size_t as2js::Node::get_children_size ( ) const

This function returns the number of children we have available in this node.

Returns
The number of children, may be zero.
See also
set_parent()

Definition at line 461 of file node_tree.cpp.

References f_children.

bool as2js::Node::get_flag ( flag_t  f) const

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.

Parameters
[in]fThe flag to retrieve.
Returns
true if the flag was set to true, false otherwise.
See also
set_flag()
verify_flag()
compare_all_flags()

Definition at line 101 of file node_flag.cpp.

References f_flags, and verify_flag().

Float64 as2js::Node::get_float64 ( ) const

This function returns the Float64 of this node.

Note that only one type of nodes can be assigned a Float64:

NODE_FLOAT64

Exceptions
exception_internal_errorThis exception is raised if the get_float64() function is called on a type of node that does not support a float.
Returns
The float attached to this node.

Definition at line 293 of file node_value.cpp.

References f_float, f_type, and NODE_FLOAT64.

Node::pointer_t as2js::Node::get_goto_enter ( ) const

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.

// * // do not throw because we reset the link first:
// * node->set_link(Node::link_t::LINK_TYPE, nullptr);
// * node->set_link(Node::link_t::LINK_TYPE, link);
// *
  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.

Exceptions
exception_index_out_of_rangeThe 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.
Parameters
[in]indexThe index of the link to retrieve.
Returns
A smart pointer to this link node.Retrieve the "Goto Enter" pointer.

This function returns a pointer to the "Goto Enter" node. The pointer may be null.

Returns
The "Goto Enter" pointer or nullptr.

Definition at line 748 of file node.cpp.

References f_goto_enter.

Node::pointer_t as2js::Node::get_goto_exit ( ) const

This function returns a pointer to the "Goto Exit" node. The pointer may be null.

Returns
The "Goto Exit" pointer or nullptr.

Definition at line 761 of file node.cpp.

References f_goto_exit.

Node::pointer_t as2js::Node::get_instance ( ) const

Definition at line 872 of file node_tree.cpp.

References f_instance.

Int64 as2js::Node::get_int64 ( ) const

This function returns the Int64 of this node.

Note that only one type of nodes can be assigned an Int64:

NODE_INT64

Exceptions
exception_internal_errorThis exception is raised if the get_int64() function is called on a type of node that does not support a float.
Returns
The integer attached to this node.

Definition at line 262 of file node_value.cpp.

References f_int, f_type, and NODE_INT64.

size_t as2js::Node::get_offset ( ) const

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.

Exceptions
exception_no_parentThis exception is raised if this Node object does not have a parent. exception_internal_errorThis exception is raised if the node has a parent, but the function cannot find the child in the f_children vector of the parent. (This should never occur because the set_parent() makes sure to always keep this relationship proper.)
Returns
The offset (index, position) of the child in its parent f_children vector.
See also
set_parent()
replace_with()

Definition at line 844 of file node_tree.cpp.

References f_parent.

Referenced by replace_with().

Node::depth_t as2js::Node::get_param_depth ( size_t  j) const

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.

Note
The index here is named 'j' because it represents the final index in the function being called and not the index of the parameter being matched. See the set_param_index() to see the difference between the 'idx' and 'j' indexes.
Exceptions
std::out_of_rangeThe function throws an exception if the j parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Parameters
[in]jThe index of the depth to retrieve.
Returns
The depth of the type of this parameter.
See also
set_param_size()
get_param_size()
set_param_depth()

Definition at line 140 of file node_param.cpp.

References f_param_depth.

size_t as2js::Node::get_param_index ( size_t  idx) const

When a user writes a function call, he can spell out the parameter names as in:

pos = find(size => 123, characer => 'c', haystack => str);

The parameters, in the function declaration, may not be in the same order:

function find(haystack: string, character: string, size: number = -1);

The parameter index vector holds the indices so we can reorganize the call as in:

pos = find(str, 'c', 123);

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.

Exceptions
std::out_of_rangeThe function throws an exception if the idx parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Parameters
[in]idxThe index of the parameter in the function being called.
Returns
The index in the function definition.
See also
set_param_size()
get_param_size()
set_param_index()

Definition at line 216 of file node_param.cpp.

References f_param_index.

size_t as2js::Node::get_param_size ( ) const

This function returns zero until set_param_size() is successfully called with a valid size.

Returns
The current size of the parameter index and depth vectors.
See also
set_param_size()

Definition at line 109 of file node_param.cpp.

References f_param_depth.

Node::pointer_t as2js::Node::get_parent ( ) const

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.

Returns
A smart pointer to the parent node, may be null.
See also
set_parent()

Definition at line 446 of file node_tree.cpp.

References f_parent.

Position const & as2js::Node::get_position ( ) const

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.

Returns
The position of this node.
See also
set_position()

Definition at line 609 of file node.cpp.

References f_position.

String const & as2js::Node::get_string ( ) const

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

Exceptions
exception_internal_errorThis exception is raised if the get_string() function is called on a type of node that does not support a string.
Returns
The string attached to this node.

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.

Node::node_t as2js::Node::get_switch_operator ( ) const

A switch statement can be constrained to use a specific operator using the with() syntax as in:

switch(foo) with(===)
{
...
}

This operator is saved in the switch node and can later be retrieved with this function.

Exceptions
exception_internal_errorIf the function is called on a node of a type other than NODE_SWITCH then this exception is raised.
Returns
The operator of the switch statement, or NODE_UNKNOWN if undefined.
See also
set_switch_operator()

Definition at line 369 of file node.cpp.

References f_switch_operator, f_type, and NODE_SWITCH.

Node::node_t as2js::Node::get_type ( ) const

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.

Returns
The current type of the node.
See also
to_unknown()
to_as()
to_boolean()
to_call()
to_int64()
to_float64()
to_number()
to_string()
to_videntifier()
to_var_attributes()
set_boolean()

Definition at line 367 of file node_type.cpp.

Referenced by clean_tree(), and find_next_child().

char const * as2js::Node::get_type_name ( ) const

This function retrieves the type of this node.

This function is equivalent to:

char const *name(Node::type_to_string(node->get_type()));
Returns
The type of this node as a string.
See also
type_to_string()

Definition at line 475 of file node_type.cpp.

Referenced by display_data(), get_string(), set_parent(), and verify_attribute().

Node::pointer_t as2js::Node::get_type_node ( ) const

Definition at line 455 of file node_type.cpp.

Node::pointer_t as2js::Node::get_variable ( int  index) const

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.

Todo:
Add a test of the node type so we can make sure we do not call this function on nodes that cannot have variables.
Todo:
The returned pointer may be a null pointer since we use a weak pointer for variables.
Parameters
[in]indexThe index of the variable to retrieve.
Returns
A pointer to the specified variable or a null pointer.
See also
add_variable()
get_variable_size()

Definition at line 888 of file node.cpp.

References f_variables.

size_t as2js::Node::get_variable_size ( ) const

A node can hold variable pointers. This is used to handle variable scopes properly.

Todo:
Add a test of the node type so we can make sure we do not call this function on nodes that cannot have variables.
Returns
The number of variables currently held in this node.
See also
add_variable()
get_variable()

Definition at line 855 of file node.cpp.

References f_variables.

bool as2js::Node::has_side_effects ( ) const

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:

  • NODE_ASSIGNMENT[_...] – all the assignment
  • NODE_CALL – a function call
  • NODE_DECREMENT – the '–' operator
  • NODE_DELETE – the 'delete' operator
  • NODE_INCREMENT – the '++' operator
  • NODE_NEW – the 'new' operator
  • NODE_POST_DECREMENT – the '–' operator
  • NODE_POST_INCREMENT – the '++' operator

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:

a + (b = 3);
// can be optimized to
b = 3;

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:

a.operator_add(b = 3);
Returns
true if this node has a side effect.

Definition at line 864 of file node_type.cpp.

void as2js::Node::insert_child ( int  index, pointer_t  child  )

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:

parent->insert_child(index, child);
// or
child->set_parent(parent, index);
Exceptions
exception_invalid_dataThis function verifies that the child pointer is not null. If null, this exception is raised.
Parameters
[in]indexThe index where the child will be inserted. [in,out]childThe child to insert at that index.
See also
set_parent()

Definition at line 560 of file node_tree.cpp.

Referenced by set_child().

bool as2js::Node::is_boolean ( ) const

This function checks whether the type of the node is NODE_TRUE or NODE_FALSE.

Returns
true if the node type represents a boolean value.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 621 of file node_type.cpp.

bool as2js::Node::is_false ( ) const

This function checks whether the type of the node is NODE_FALSE.

Returns
true if the node type represents false.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 669 of file node_type.cpp.

bool as2js::Node::is_float64 ( ) const

This function checks whether the type of the node is NODE_FLOAT64.

Returns
true if the node type is NODE_FLOAT64.
See also
is_number()
is_boolean()
is_int64()
is_nan()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 596 of file node_type.cpp.

bool as2js::Node::is_identifier ( ) const

This function checks whether the type of the node is NODE_IDENTIFIER or NODE_VIDENTIFIER.

Returns
true if the node type represents an identifier value.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_literal()

Definition at line 766 of file node_type.cpp.

bool as2js::Node::is_int64 ( ) const

This function checks whether the type of the node is NODE_INT64.

Returns
true if the node type is NODE_INT64.
See also
is_number()
is_boolean()
is_float64()
is_nan()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 572 of file node_type.cpp.

bool as2js::Node::is_literal ( ) const

Literals are:

  • true or false
  • floating point
  • integer
  • null
  • string
  • undefined

If this node represents any one of those types, this function returns true.

Returns
true if the node is a literal.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()

Definition at line 800 of file node_type.cpp.

bool as2js::Node::is_locked ( ) const

This function returns true if the specified node is currently locked. False otherwise.

Returns
true if the node is locked.
See also
lock()
unlock()
modifying()

Definition at line 114 of file node_lock.cpp.

References f_lock.

Referenced by modifying().

bool as2js::Node::is_nan ( ) const

When converting a node to a number (to_number() function) we accept a certain number of parameters as numbers:

  • integers (unchanged)
  • float points (unchanged)
  • true (1) or false (0)
  • null (0)
  • strings that represent valid numbers as a whole
  • undefined (NaN)
Returns
true if the value could not be converted to a number other than NaN.
See also
is_number()
is_int64()
is_boolean()
is_float64()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 539 of file node_type.cpp.

bool as2js::Node::is_null ( ) const

This function checks whether the type of the node is NODE_NULL.

Returns
true if the node type represents the null value.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_false()
is_string()
is_undefined()
is_identifier()
is_literal()

Definition at line 741 of file node_type.cpp.

bool as2js::Node::is_number ( ) const

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.

Returns
true if this node represents a number
See also
is_nan()
is_int64()
is_boolean()
is_float64()
is_true()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 507 of file node_type.cpp.

bool as2js::Node::is_string ( ) const

This function checks whether the type of the node is NODE_STRING.

Returns
true if the node type represents a string value.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_false()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 693 of file node_type.cpp.

bool as2js::Node::is_true ( ) const

This function checks whether the type of the node is NODE_TRUE.

Returns
true if the node type represents true.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_false()
is_string()
is_undefined()
is_null()
is_identifier()
is_literal()

Definition at line 645 of file node_type.cpp.

bool as2js::Node::is_undefined ( ) const

This function checks whether the type of the node is NODE_UNDEFINED.

Returns
true if the node type represents the undefined value.
See also
is_number()
is_int64()
is_float64()
is_nan()
is_boolean()
is_true()
is_false()
is_string()
is_null()
is_identifier()
is_literal()

Definition at line 717 of file node_type.cpp.

void as2js::Node::lock ( )

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.

{
NodeLock lock(my_node);
...do work...
} // auto-unlock here
Note
This library is NOT multi-thread safe. This lock has nothing to do with protecting a node from multiple accesses via multiple threads.
Warning
The f_parent makes use of a weak pointer, and thus you will see a call to a lock() function. This is the lock of the smart pointer and not the lock of the node:
p = f_parent.lock(); // return a shared_ptr
f_parent->lock(); // lock the parent node (call this function)
Bug:
This function does not verify that the lock counter does not go over the limit. However, the limit is 2 billion and if you reach such, you probably have an enormous stack... which is rather unlikely. More or less, technically, it just should not ever overflow.
See also
is_locked()
unlock()
modifying()

Definition at line 164 of file node_lock.cpp.

References f_lock.

Referenced by display().

void as2js::Node::modifying ( ) const private

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.

Note
This function is expected to be called BEFORE your function attemps any modification of the node.
Exceptions
exception_locked_nodeIf the function detects a lock on this node (i.e. the node should not get modified,) then it raises this exception.
See also
lock()
unlock()
is_locked()

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().

Node& as2js::Node::operator= ( Node const &  ) delete

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.

char const * as2js::Node::operator_to_string ( node_t  op) static

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.)

Parameters
[in]opThe operator to convert to a string.
Returns
A basic null terminated C string with the operator name or nullptr.
See also
string_to_operator()

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().

void as2js::Node::replace_with ( pointer_t  node)

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:

if(true)
blah;
else
foo;

can be optimized by just this:

blah;

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):

child->replace_with(node);
// or
int index(child->get_offset());
Node::pointer_t parent(child->get_parent());
parent->set_child(index, node);
Warning
This function modifies the tree in a way that may break loops over node children.
Exceptions
exception_no_parentIf 'this' node does not have a parent node, then this exception is raised.
Parameters
[in]nodeThe node to replace 'this' node with.
See also
set_parent()

Definition at line 655 of file node_tree.cpp.

References f_parent, and get_offset().

void as2js::Node::set_attribute ( attribute_t const  a, bool const  v  )

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.

Parameters
[in]aThe flag to set. [in]vThe new value for the flag.
See also
set_attribute_tree()
get_attribute()
verify_attribute()
verify_exclusive_attributes()

Definition at line 263 of file node_attribute.cpp.

References f_attributes, verify_attribute(), and verify_exclusive_attributes().

void as2js::Node::set_attribute_node ( pointer_t  node)

Definition at line 208 of file node_attribute.cpp.

References f_attribute_node.

void as2js::Node::set_attribute_tree ( attribute_t const  a, bool const  v  )

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.

Parameters
[in]aThe flag to set. [in]vThe new value for the flag.
See also
set_attribute_tree()
get_attribute()
verify_attribute()
verify_exclusive_attributes()

Definition at line 297 of file node_attribute.cpp.

References f_attributes, f_children, verify_attribute(), and verify_exclusive_attributes().

void as2js::Node::set_boolean ( bool  value)

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.

Exceptions
exception_internal_errorThis exception is raised if the set_boolean() function is called on a type of node that is not a Boolean node.
Parameters
[in]valueThe C++ Boolean value to save in this node.

Definition at line 84 of file node_value.cpp.

References f_type, NODE_FALSE, and NODE_TRUE.

void as2js::Node::set_child ( int  index, pointer_t  child  )

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:

parent->set_child(index, child);
// or
parent->set_parent(nullptr, index);
child->set_parent(index, parent);
Exceptions
exception_invalid_dataThis function verifies that the child pointer is not null. If null, this exception is raised.
Parameters
[in]indexThe position where the new child is to be placed. [in,out]childThe new child replacing the existing child at index.
See also
set_parent()

Definition at line 594 of file node_tree.cpp.

References delete_child(), and insert_child().

void as2js::Node::set_flag ( flag_t  f, bool  v  )

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.

Parameters
[in]fThe flag to set. [in]vThe new value for the flag.
See also
get_flag()
verify_flag()

Definition at line 122 of file node_flag.cpp.

References f_flags, and verify_flag().

void as2js::Node::set_float64 ( Float64  value)

This function saves a Float64 in this node.

Note that only one type of node can be assigned a Float64:

NODE_FLOAT64

Exceptions
exception_internal_errorThis exception is raised if the set_float64() function is called on a type of node that does not support a string.
Parameters
[in]valueThe Float64 to save in this node.

Definition at line 147 of file node_value.cpp.

References f_float, f_type, and NODE_FLOAT64.

void as2js::Node::set_goto_enter ( pointer_t  node)

This function saves the specified node pointer as the "Goto Enter" node. The pointer may be null.

Parameters
[in]nodeThe "Goto Enter" pointer.

Definition at line 774 of file node.cpp.

References f_goto_enter.

void as2js::Node::set_goto_exit ( pointer_t  node)

This function saves the specified node pointer as the "Goto Exit" node. The pointer may be null.

Parameters
[in]nodeThe "Goto Exit" pointer.

Definition at line 787 of file node.cpp.

References f_goto_exit.

void as2js::Node::set_instance ( pointer_t  node)

Definition at line 866 of file node_tree.cpp.

References f_instance.

void as2js::Node::set_int64 ( Int64  value)

This function saves an Int64 in this node.

Note that only one type of node can be assigned an Int64:

NODE_INT64

Exceptions
exception_internal_errorThis exception is raised if the set_int64() function is called on a type of node that does not support a string.
Parameters
[in]valueThe Int64 to save in this node.

Definition at line 116 of file node_value.cpp.

References f_int, f_type, and NODE_INT64.

void as2js::Node::set_param_depth ( size_t  j, depth_t  depth  )

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.

Note
The index here is named 'j' because it represents the final index in the function being called and not the index of the parameter being matched. See the set_param_index() to see the difference between the 'idx' and 'j' indexes.
Exceptions
std::out_of_rangeThe function throws an exception if the j parameter is out of range. It should be defined between 0 and get_param_size() - 1.
Parameters
[in]jThe index of the parameter for which we define the depth. (The order is the function being called order.) [in]depthThe new depth.

Definition at line 166 of file node_param.cpp.

References f_param_depth.

void as2js::Node::set_param_index ( size_t  idx, size_t  j  )

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.

Exceptions
std::out_of_rangeThe function throws an exception if the idx or j parameters are out of range. They should both be defined between 0 and get_param_size() - 1.
Parameters
[in]idxThe index in the function call. [in]jThe index in the function being called.
See also
set_param_size()
get_param_size()
get_param_index()

Definition at line 241 of file node_param.cpp.

References f_param_index.

void as2js::Node::set_param_size ( size_t  size)

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.

Exceptions
exception_internal_errorIf this node is not of type NODE_PARAM_MATCH, if the function had been called before, or if the size parameter is zero, this exception is raised.
Parameters
[in]sizeThe number of parameters (size > 0 must be true).
See also
get_param_size()
get_param_depth()
get_param_index()

Definition at line 81 of file node_param.cpp.

References f_param_depth, f_param_index, f_type, and NODE_PARAM_MATCH.

void as2js::Node::set_parent ( pointer_t  parent = pointer_t(), int  index = -1  )

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:

Note
This Node and the parent Node must not be locked. If the parent is being changed, then the other existing parent must also not be locked either.
The vector of children of the parent node changes, be careful. Whenever possible, to avoid bugs, you may want to consider using the lock() function through the NodeLock object to avoid having such changes happen on nodes you are currently working on.
Exceptions
exception_incompatible_node_typeThe parent must be a node of a type which is compatible with being a parent. We actually limit the type to exactly and just and only the types of nodes that receive children. For example, a NODE_INT64 cannot receive children. Trying to add a child to such a node raises this exception. Similarly, some nodes, such as NODE_CLOSE_PARENTHESIS, cannot be children of another. The same exception is raised if such a node receives a parent. exception_internal_errorWhen the Node already had a parent and it gets replaced, we have to remove that existing parent first. This exception is raised if we cannot find this Node in the list of children of the existing parent. exception_index_out_of_rangeIf the 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.
Parameters
[in]parentThe new parent of the node. May be set to nullptr. [in]indexThe position where the new item is inserted in the parent array of children. If -1, append at the end of the list.
See also
lock()
get_parent()
get_children_size()
delete_child()
append_child()
insert_child()
set_child()
replace_with()
get_child()
find_first_child()
find_next_child()
clean_tree()
get_offset()

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.

void as2js::Node::set_position ( Position const &  position)

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.

Parameters
[in]positionThe new position to copy in this node.
See also
get_position()

Definition at line 587 of file node.cpp.

References f_position.

void as2js::Node::set_string ( String const &  value)

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

Exceptions
exception_internal_errorThis exception is raised if the set_string() function is called on a type of node that does not support a string.
Parameters
[in]valueThe String to save in this node.

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().

void as2js::Node::set_switch_operator ( node_t  op)

This function saves the operator defined following the switch statement using the with() instruction as in:

switch(foo) with(===)
{
...
}

The currently supported operators are:

  • NODE_UNKNOWN – remove the operator
  • NODE_STRICTLY_EQUAL – "===", this is considered the default behavior for a JavaScript switch()
  • NODE_EQUAL – "=="
  • NODE_NOT_EQUAL – "!="
  • NODE_STRICTLY_NOT_EQUAL – "!=="
  • NODE_MATCH – "~="
  • NODE_IN – "in", this makes use of ranges
  • NODE_IS – "is"
  • NODE_AS – "as"
  • NODE_INSTANCEOF – "instanceof"
  • NODE_LESS – "<"
  • NODE_LESS_EQUAL – "<="
  • NODE_GREATER – ">"
  • NODE_GREATER_EQUAL – ">="
  • NODE_DEFAULT – this is the default label case
Exceptions
exception_internal_errorIf the function is called on a node of a type other than NODE_SWITCH then this exception is raised. It will also raise this exception if the specified operator is not an operator supported by the switch statement.
Parameters
[in]opThe new operator to save in this switch statement.
See also
get_switch_operator()

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.

void as2js::Node::set_type_node ( Node::pointer_t  node)

Definition at line 449 of file node_type.cpp.

Node::node_t as2js::Node::string_to_operator ( String const &  str) static

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.

Todo:
The table is sorted by type_t::NODE_... value. It would be good to create another table sorted by name. We could declare a static table which gets initialized on a first call to this function. Then we could also make use of the binary search here.
Todo:
This is a TBD, I think it is okay, but the compiler may need some tweaking to work... It seems that the ++x and x++ (and corresponding –) won't work right. We should be able to detect that once we try to declare such operators in a class. The "x" is nice when outputing the result, but it is problematic when searching for a node type. However, we certainly have to add it anyway depending on whether the function has a parameter or not because otherwise we cannot know whether it is a pre- or a post-increment or -decrement.
Parameters
[in]strThe string representing the operator to convert.
Returns
The node type representing this operator.
See also
operator_to_string()

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().

bool as2js::Node::to_as ( )

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:

type ( expression )
expression AS type
Note
The Node must not be locked.
Todo:
We will need to verify that this is correct and does not introduce other problems. However, remember that we do not use prototypes in our world. We have well defined classes so it should work just fine.
Returns
true if the conversion happens.

Definition at line 123 of file node_convert.cpp.

References f_type, modifying(), NODE_AS, and NODE_CALL.

bool as2js::Node::to_boolean ( )

This function converts 'this' node to a Boolean node:

  • NODE_TRUE – no conversion
  • NODE_FALSE – no conversion
  • NODE_NULL – converted to NODE_FALSE
  • NODE_UNDEFINED – converted to NODE_FALSE
  • NODE_INT64 – converted to NODE_TRUE unless it is 0 in which case it gets converted to NODE_FALSE
  • NODE_FLOAT64 – converted to NODE_TRUE unless it is 0.0 in which case it gets converted to NODE_FALSE
  • NODE_STRING – converted to NODE_TRUE unless the string is empty in which case it gets converted to NODE_FALSE

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.

Note
The Node must not be locked.
Returns
true if the conversion succeeds.
See also
to_boolean_type_only()
set_boolean()

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.

Node::node_t as2js::Node::to_boolean_type_only ( ) const

This function is constant and can be used to see whether a node represents true or false without actually converting the node.

  • NODE_TRUE – returned as is
  • NODE_FALSE – returned as is
  • NODE_NULL – returns NODE_FALSE
  • NODE_UNDEFINED – returns NODE_FALSE
  • NODE_INT64 – returns NODE_TRUE unless the interger is zero in which case NODE_FALSE is returned
  • NODE_FLOAT64 – returns NODE_TRUE unless the floating point is exactly zero in which case NODE_FALSE is returned
  • NODE_STRING – returns NODE_TRUE unless the string is empty in which case NODE_FALSE is returned
  • Any other node type – returns NODE_UNDEFINED

Note that in this case we completely ignore the content of a string. The strings "false", "0.0", and "0" all represent Boolean 'true'.

Returns
NODE_TRUE, NODE_FALSE, or NODE_UNDEFINED depending on 'this' node
See also
to_boolean()
set_boolean()

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.

bool as2js::Node::to_call ( )

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.

class foo_class
{
function get field() { ... }
function set field() { ... }
};
// Convert a getter to a function call
a = foo.field;
a = foo.field_getter();
// Convert a setter to a function call
foo.field = a;
foo.field_setter(a);

The function returns false if 'this' node is not a NODE_MEMBER or a NODE_ASSIGNMENT.

Note
This function has no way of knowing what's what. It just changes the f_type parameter of this node.
The Node must not be locked.
Returns
true if the conversion succeeded.

Definition at line 306 of file node_convert.cpp.

References f_type, modifying(), NODE_ASSIGNMENT, NODE_CALL, and NODE_MEMBER.

bool as2js::Node::to_float64 ( )

This function converts the node to a floating point number, just like JavaScript would do. This means converting the following type of nodes:

  • NODE_INT64 – convert to a float
  • NODE_FLOAT64 – no conversion
  • NODE_TRUE – convert to 1.0
  • NODE_FALSE – convert to 0.0
  • NODE_NULL – convert to 0.0
  • NODE_STRING – convert to float if valid, otherwise NaN
  • NODE_UNDEFINED – convert to NaN

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.

Note
The Node must not be locked.
Returns
true if the conversion succeeded.

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().

bool as2js::Node::to_identifier ( )

This function converts the node to an identifier. This is used to transform some keywords back to an identifier.

  • NODE_PRIVATE – "private"
  • NODE_PROTECTED – "protected"
  • NODE_PUBLIC – "public"

At this point this is used to transform these keywords in labels.

Note
The Node must not be locked.
Returns
true if the conversion succeeded.

Definition at line 339 of file node_convert.cpp.

References f_type, modifying(), NODE_IDENTIFIER, NODE_PRIVATE, NODE_PROTECTED, NODE_PUBLIC, and set_string().

bool as2js::Node::to_int64 ( )

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:

  • NODE_INT64 – no conversion
  • NODE_FLOAT64 – convert to integer
  • NODE_TRUE – convert to 1
  • NODE_FALSE – convert to 0
  • NODE_NULL – convert to 0
  • NODE_STRING – convert to integer if valid, zero otherwise (NaN is not possible in an integer)
  • NODE_UNDEFINED – convert to 0 (NaN is not possible in an integer)

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.

Note
The Node must not be locked.
Returns
true if the conversion succeeded.

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().

bool as2js::Node::to_label ( )

This function converts a NODE_IDENTIFIER node to a NODE_LABEL node.

Note
The Node must not be locked.
Returns
true if the conversion succeeded.

Definition at line 536 of file node_convert.cpp.

References f_type, modifying(), NODE_IDENTIFIER, and NODE_LABEL.

bool as2js::Node::to_number ( )

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:

  • NODE_INT64 – no conversion
  • NODE_FLOAT64 – no conversion
  • NODE_TRUE – convert to 1 (INT64)
  • NODE_FALSE – convert to 0 (INT64)
  • NODE_NULL – convert to 0 (INT64)
  • NODE_UNDEFINED – convert to NaN (FLOAT64)
  • NODE_STRING – converted to a float, NaN if not a valid float, however, zero if empty.

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.

Note
The Node must not be locked.
Returns
true if the conversion succeeded.

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().

bool as2js::Node::to_string ( )

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:

  • NODE_STRING – unchanged
  • NODE_IDENTIFIER – the identifier is now a string
  • NODE_UNDEFINED – changed to "undefined"
  • NODE_NULL – changed to "null"
  • NODE_TRUE – changed to "true"
  • NODE_FALSE – changed to "false"
  • NODE_INT64 – changed to a string representation
  • NODE_FLOAT64 – changed to a string representation

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.

Note
The Node must not be locked.
Returns
true if the conversion succeeded, false otherwise.

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.

void as2js::Node::to_unknown ( )

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.

Note
The Node must not be locked.

Definition at line 88 of file node_convert.cpp.

References f_type, modifying(), and NODE_UNKNOWN.

void as2js::Node::to_var_attributes ( )

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.

Note
The Node must not be locked.
Exceptions
exception_internal_errorThis exception is raised if 'this' node is not a NODE_VARIABLE.

Definition at line 819 of file node_convert.cpp.

References f_type, modifying(), NODE_VAR_ATTRIBUTES, and NODE_VARIABLE.

void as2js::Node::to_videntifier ( )

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:

(a).field // a becomes a NODE_VIDENTIFIER
a.field

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.

Note
Why do we need this distinction? Parenthesis used for grouping are not saved in the resulting tree of nodes. For that reason, at the time we parse that result, we could not distinguish between both expressions. With the NODE_VIDENTIFIER, we can correct that problem.
The Node must not be locked.
Exceptions
exception_internal_errorThis exception is raised if the input node is not a NODE_IDENTIFIER.

Definition at line 791 of file node_convert.cpp.

References f_type, modifying(), NODE_IDENTIFIER, and NODE_VIDENTIFIER.

char const * as2js::Node::type_to_string ( node_t  type) static

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.

Exceptions
exception_internal_errorIf the table of node type to name is invalid, then we raise this exception. Also, if the 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.
Returns
A null terminated C-like string with the node name.
See also
get_type_name()

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().

void as2js::Node::unlock ( )

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.

{
NodeLock lock(my_node);
...do work...
} // auto-unlock here
Note
This library is NOT multi-thread safe. This lock has nothing to do with protecting a node from multiple accesses via multiple threads.
Exceptions
exception_internal_errorThis exception is raised if the unlock() function is called more times than the lock() function was called. It is considered an internal error since it should never happen, especially if you make sure to use the NodeLock object.
See also
lock()
is_locked()
modifying()

Definition at line 202 of file node_lock.cpp.

References f_lock.

void as2js::Node::verify_attribute ( attribute_t const  f) const private

This function verifies that a corresponds to a valid attribute according to the type of this Node object.

Note
At this point attributes can be assigned to any type of node exception a NODE_PROGRAM which only accepts the NODE_ATTR_DEFINED attribute.
Exceptions
exception_internal_errorIf the attribute is not valid for this node type, then this exception is raised.
Parameters
[in]aThe attribute to check.
See also
set_attribute()
get_attribute()

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().

bool as2js::Node::verify_exclusive_attributes ( attribute_t  f) const private

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.

Exceptions
exception_internal_errorThis exception is raised whenever the parameter a is invalid.
Parameters
[in]aThe attribute being set.
Returns
true if the attributes are not in conflict.
See also
set_attribute()

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().

void as2js::Node::verify_flag ( flag_t  f) const private

This function verifies that f corresponds to a valid flag according to the type of this Node object.

Todo:
Move some of the external tests (tests done by code in other places like the parser) to here because some flags are mutally exclusive and we should prevent such from being set simultaneously.
Exceptions
exception_internal_errorThis function checks that the flag is allowed in the type of node. If not, this exception is raised because that represents a compiler bug.
Parameters
[in]fThe flag to check.
See also
set_flag()
get_flag()

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().

Member Data Documentation
pointer_t as2js::Node::f_attribute_node = pointer_t() private

Definition at line 597 of file node.h.

Referenced by clone_basic_node(), display(), get_attribute_node(), and set_attribute_node().

vector_of_pointers_t as2js::Node::f_children = vector_of_pointers_t() private
flag_set_t as2js::Node::f_flags = flag_set_t() private

Definition at line 596 of file node.h.

Referenced by clone_basic_node(), compare_all_flags(), display_data(), get_flag(), and set_flag().

weak_pointer_t as2js::Node::f_goto_enter = weak_pointer_t() private

Definition at line 623 of file node.h.

Referenced by clone_basic_node(), display(), get_goto_enter(), and set_goto_enter().

weak_pointer_t as2js::Node::f_goto_exit = weak_pointer_t() private

Definition at line 624 of file node.h.

Referenced by clone_basic_node(), display(), get_goto_exit(), and set_goto_exit().

weak_pointer_t as2js::Node::f_instance = weak_pointer_t() private

Definition at line 620 of file node.h.

Referenced by clone_basic_node(), display(), get_instance(), and set_instance().

Int64 as2js::Node::f_int = Int64() private
map_of_weak_pointers_t as2js::Node::f_labels = map_of_weak_pointers_t() private

Definition at line 628 of file node.h.

Referenced by add_label(), clone_basic_node(), display(), and find_label().

int32_t as2js::Node::f_lock = 0 private

Definition at line 602 of file node.h.

Referenced by display(), is_locked(), lock(), unlock(), and ~Node().

int32_t as2js::Node::f_offset = 0 private

Definition at line 618 of file node.h.

param_depth_t as2js::Node::f_param_depth = param_depth_t() private

Definition at line 613 of file node.h.

Referenced by get_param_depth(), get_param_size(), set_param_depth(), and set_param_size().

param_index_t as2js::Node::f_param_index = param_index_t() private

Definition at line 614 of file node.h.

Referenced by get_param_index(), set_param_index(), and set_param_size().

weak_pointer_t as2js::Node::f_parent = weak_pointer_t() private

Definition at line 617 of file node.h.

Referenced by get_offset(), get_parent(), replace_with(), and set_parent().

Position as2js::Node::f_position = Position() private
node_t as2js::Node::f_switch_operator = node_t::NODE_UNKNOWN private

Definition at line 599 of file node.h.

Referenced by clone_basic_node(), get_switch_operator(), and set_switch_operator().

weak_pointer_t as2js::Node::f_type_node = weak_pointer_t() private

Definition at line 595 of file node.h.

Referenced by clone_basic_node(), and display().

vector_of_weak_pointers_t as2js::Node::f_variables = vector_of_weak_pointers_t() private

Definition at line 627 of file node.h.

Referenced by add_variable(), clone_basic_node(), display(), get_variable(), and get_variable_size().

depth_t const as2js::Node::MATCH_HIGHEST_DEPTH = 1 static

Definition at line 77 of file node.h.

Referenced by as2js::Compiler::match_type().

depth_t const as2js::Node::MATCH_LOWEST_DEPTH = std::numeric_limits<int>::max() / 2 static

Definition at line 78 of file node.h.

Referenced by as2js::Compiler::match_type().

depth_t const as2js::Node::MATCH_NOT_FOUND = 0 static

The documentation for this class was generated from the following files:

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly