def handle_node_description(self, child_node): """Replaces an anonymous node description with a reference to a fresh node variable. The node description is stored for later reference. """ variable = NodeVariable(self.get_anon_nodevar(), False) self.node_defs[variable] = child_node self.node_vars[variable.name] = variable return self.REPLACE(create_varref(variable.name))
def handle_node_description(self, child_node): """Replaces an anonymous node description with a reference to a fresh node variable. The node description is stored for later reference. """ variable = NodeVariable(self.get_anon_nodevar(), False) self.node_defs[variable] = child_node self.node_vars[variable.name] = variable return self.REPLACE(create_varref(variable.name))
def handle_node_variable_def(self, child_node): """Replaces a node variable definition with a reference, and stores it. If the variable has already been defined, the node descriptions are merged. """ assert child_node.variable.type == ast.VariableTypes.NodeIdentifier node_variable = NodeVariable.from_node(child_node.variable) self.node_vars[child_node.variable.name] = node_variable if node_variable in self.node_defs: self.node_defs[node_variable] = ast.NodeDescription( ast.Conjunction([self.node_defs[node_variable].expression, child_node.expression.expression])) else: self.node_defs[node_variable] = child_node.expression return self.REPLACE(create_varref(child_node.variable.name, container_type = child_node.variable.container))
def handle_node_variable_def(self, child_node): """Replaces a node variable definition with a reference, and stores it. If the variable has already been defined, the node descriptions are merged. """ assert child_node.variable.type == ast.VariableTypes.NodeIdentifier node_variable = NodeVariable.from_node(child_node.variable) self.node_vars[child_node.variable.name] = node_variable if node_variable in self.node_defs: self.node_defs[node_variable] = ast.NodeDescription( ast.Conjunction([ self.node_defs[node_variable].expression, child_node.expression.expression ])) else: self.node_defs[node_variable] = child_node.expression return self.REPLACE( create_varref(child_node.variable.name, container_type=child_node.variable.container))
def _create_varref(self, node_var): return create_varref(node_var, container_type=self._get_container_type(node_var))
def _create_varref(self, node_var): return create_varref(node_var, container_type = self._get_container_type(node_var))