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__
32 if hasattr(node, "flags") and "uses_memory" in node.flags:
33 if not inout_contains(node.ins, "mem"):
34 print "ERROR: memory op %s needs an input named 'mem'" % node.__name__
36 if not is_dynamic_pinned(node):
37 print "ERROR: fragile node %s must be dynamically pinned" % node.__name__
38 if not hasattr(node, "throws_init"):
39 print "ERROR: fragile node %s needs a throws_init attribute" % node.__name__
40 if not inout_contains(node.outs, "X_regular"):
41 print "ERROR: fragile node %s needs an output named 'X_regular'" % node.__name__
42 if not inout_contains(node.outs, "X_except"):
43 print "ERROR: fragile node %s needs an output named 'X_except'" % node.__name__
45 if hasattr(node, "throws_init"):
46 print "ERROR: throws_init only makes sense for fragile nodes"
49 def setldefault(node, attr, val):
50 # Don't use hasattr, as these things should not be inherited
51 if attr not in node.__dict__:
52 setattr(node, attr, val)
54 def setdefault(node, attr, val):
55 # Don't use hasattr, as these things should not be inherited
56 if not hasattr(node, attr):
57 setattr(node, attr, val)
59 def setnodedefaults(node):
60 setldefault(node, "name", node.__name__)
64 setdefault(node, "ins", [])
65 setdefault(node, "arity", len(node.ins))
66 setdefault(node, "attrs", [])
67 setdefault(node, "constructor_args", [])
68 setdefault(node, "customSerializer", False)
69 if hasattr(node, "outs"):