5 def isAbstract(nodetype):
6 return nodetype in abstracts
8 def is_dynamic_pinned(node):
9 return node.pinned in ["memory", "exception"]
11 def inout_contains(l, name):
17 def verify_node(node):
18 if not hasattr(node, "pinned"):
19 print "%s: NO PINNED SET" % node.__name__
20 elif node.pinned not in ["yes", "no", "memory", "exception"]:
21 print "%s: UNKNOWN PINNED MODE: %s" % (node.__name__, node.pinned)
23 if not hasattr(node, "flags") and not isAbstract(node):
24 print "WARNING: no flags specified for %s\n" % node.__name__
25 elif type(node.flags) != list:
26 print "ERROR: flags of %s not a list" % node.__name__
27 if hasattr(node, "flags"):
29 if "fragile" in flags:
30 if not inout_contains(node.ins, "mem"):
31 print "ERROR: fragile node %s needs an input named 'mem'" % node.__name__
32 if not inout_contains(node.outs, "X_regular"):
33 print "ERROR: fragile node %s needs an output named 'X_regular'" % node.__name__
34 if not inout_contains(node.outs, "X_except"):
35 print "ERROR: fragile node %s needs an output named 'X_except'" % node.__name__
37 def setldefault(node, attr, val):
38 # Don't use hasattr, as these things should not be inherited
39 if attr not in node.__dict__:
40 setattr(node, attr, val)
42 def setdefault(node, attr, val):
43 # Don't use hasattr, as these things should not be inherited
44 if not hasattr(node, attr):
45 setattr(node, attr, val)
47 def setnodedefaults(node):
48 setldefault(node, "name", node.__name__)
52 setdefault(node, "ins", [])
53 setdefault(node, "arity", len(node.ins))
54 setdefault(node, "attrs", [])
55 setdefault(node, "constructor_args", [])
56 setdefault(node, "customSerializer", False)
57 if hasattr(node, "outs"):