5 def isAbstract(nodetype):
6 return nodetype in abstracts
8 def is_dynamic_pinned(node):
9 return node.pinned in ["memory", "exception"]
12 return hasattr(node, "flags") and "fragile" in node.flags
14 def inout_contains(l, name):
20 def verify_node(node):
21 if not hasattr(node, "pinned"):
22 print "%s: NO PINNED SET" % node.__name__
23 elif node.pinned not in ["yes", "no", "memory", "exception"]:
24 print "%s: UNKNOWN PINNED MODE: %s" % (node.__name__, node.pinned)
26 if not hasattr(node, "flags") and not isAbstract(node):
27 print "WARNING: no flags specified for %s\n" % node.__name__
28 elif type(node.flags) != list:
29 print "ERROR: flags of %s not a list" % node.__name__
30 if hasattr(node, "pinned_init") and not is_dynamic_pinned(node):
31 print "ERROR: node %s has pinned_init attribute but is not marked as dynamically pinned" % node.__name__
33 if not is_dynamic_pinned(node):
34 print "ERROR: fragile node %s must be dynamically pinned" % node.__name__
35 if not hasattr(node, "throws_init"):
36 print "ERROR: fragile node %s needs a throws_init attribute" % node.__name__
37 if not inout_contains(node.ins, "mem"):
38 print "ERROR: fragile node %s needs an input named 'mem'" % node.__name__
39 if not inout_contains(node.outs, "X_regular"):
40 print "ERROR: fragile node %s needs an output named 'X_regular'" % node.__name__
41 if not inout_contains(node.outs, "X_except"):
42 print "ERROR: fragile node %s needs an output named 'X_except'" % node.__name__
44 if hasattr(node, "throws_init"):
45 print "ERROR: throws_init only makes sense for fragile nodes"
48 def setldefault(node, attr, val):
49 # Don't use hasattr, as these things should not be inherited
50 if attr not in node.__dict__:
51 setattr(node, attr, val)
53 def setdefault(node, attr, val):
54 # Don't use hasattr, as these things should not be inherited
55 if not hasattr(node, attr):
56 setattr(node, attr, val)
58 def setnodedefaults(node):
59 setldefault(node, "name", node.__name__)
63 setdefault(node, "ins", [])
64 setdefault(node, "arity", len(node.ins))
65 setdefault(node, "attrs", [])
66 setdefault(node, "constructor_args", [])
67 setdefault(node, "customSerializer", False)
68 if hasattr(node, "outs"):