forked from avantgardnerio/as3parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Assigning a node
Matheus Dias de Souza edited this page Jul 27, 2024
·
2 revisions
Compilers and applications over AS3Parser may need to assign data to nodes.
They can do so by using the NodeAssignment mapping, which works just as a hash map, but using an efficient implementation for the different node types and splitting of dictionaries for large compilation units.
use as3_parser::ns::*;
// Construct a NodeAssignment structure, where Entity
// is any Rust type that implements Clone.
let mapping = NodeAssignment::<Entity>::new();
// Retrieve data of a node.
let data = mapping.get(&node);
// Assign data to a node.
mapping.set(&node, data);
// Delete data from a node.
mapping.delete(&node);
// Check whether a node contains data.
let has_data = mapping.has(&node);Almost every node type that is used behind a Rust Rc container may be used as a node type in NodeAssignment, such as Rc<Expression>, Rc<Directive>, and Rc<FunctionCommon>.