MCPcopy
hub / github.com/Nuitka/Nuitka / _addFromNode

Function _addFromNode

nuitka/tools/specialize/SpecializePython.py:682–737  ·  view source on GitHub ↗
(node_class)

Source from the content-addressed store, hash-verified

680
681
682def _addFromNode(node_class):
683 named_children = getattr(node_class, "named_children", ())
684 # assert not hasattr(node_class, "named_child"), node_class
685
686 if hasattr(node_class, "auto_compute_handling"):
687 auto_compute_handling = frozenset(
688 getattr(node_class, "auto_compute_handling").split(",")
689 )
690 else:
691 auto_compute_handling = ()
692
693 node_attributes = getattr(node_class, "node_attributes", ())
694
695 if not named_children and not auto_compute_handling and not node_attributes:
696 return
697
698 (
699 new_named_children,
700 named_children_types,
701 named_children_checkers,
702 setters_needed,
703 ) = _parseNamedChildrenSpec(named_children)
704
705 mixin_name = makeMixinName(
706 # TODO: Subject to dying, we now make this up on the fly.
707 node_class.kind.startswith("EXPRESSION"),
708 node_class.kind.startswith("STATEMENT"),
709 tuple(new_named_children),
710 named_children_types,
711 named_children_checkers,
712 auto_compute_handling,
713 node_attributes,
714 )
715
716 if mixin_name not in children_mixing_setters_needed:
717 children_mixing_setters_needed[mixin_name] = set()
718 children_mixing_setters_needed[mixin_name].update(setters_needed)
719
720 for base in node_class.__mro__:
721 if base.__name__ == mixin_name:
722 break
723 else:
724 # if named_children == ("operand",):
725 print("Not done", node_class.__name__, named_children, mixin_name)
726
727 addChildrenMixin(
728 # TODO: Subject to dying, we now make this up on the fly.
729 node_class.kind.startswith("EXPRESSION"),
730 node_class.kind.startswith("STATEMENT"),
731 node_class.__name__,
732 tuple(new_named_children),
733 named_children_types,
734 named_children_checkers,
735 auto_compute_handling,
736 node_attributes,
737 )
738
739

Callers 1

addFromNodesFunction · 0.85

Calls 5

_parseNamedChildrenSpecFunction · 0.85
makeMixinNameFunction · 0.85
addChildrenMixinFunction · 0.85
splitMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…