X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=scripts%2Fspec_util.py;h=c33d9c330dd81eba343bfaeff5315f94afe14775;hb=d311af24184ae55feb4e6a68df134274dfc1357d;hp=000ec7a251b856a9bd990f171719daca21ffd447;hpb=b856bc7f5572524a763ca6534321551d86db1ba3;p=libfirm diff --git a/scripts/spec_util.py b/scripts/spec_util.py index 000ec7a25..c33d9c330 100644 --- a/scripts/spec_util.py +++ b/scripts/spec_util.py @@ -1,8 +1,43 @@ +abstracts = set() +def abstract(cls): + abstracts.add(cls) + return cls +def isAbstract(nodetype): + return nodetype in abstracts + def is_dynamic_pinned(node): - return node["pinned"] in ["memory", "exception"] + return node.pinned in ["memory", "exception"] + +def verify_node(node): + if not hasattr(node, "pinned"): + print "%s: NO PINNED SET" % node.__name__ + elif node.pinned not in ["yes", "no", "memory", "exception"]: + print "%s: UNKNOWN PINNED MODE: %s" % (node.__name__, node.pinned) + + if not hasattr(node, "flags") and not isAbstract(node): + print "WARNING: no flags specified for %s\n" % node.__name__ + elif type(node.flags) != list: + print "ERROR: flags of %s not a list" % node.__name__ + +def setldefault(node, attr, val): + # Don't use hasattr, as these things should not be inherited + if attr not in node.__dict__: + setattr(node, attr, val) + +def setdefault(node, attr, val): + # Don't use hasattr, as these things should not be inherited + if not hasattr(node, attr): + setattr(node, attr, val) + +def setnodedefaults(node): + setldefault(node, "name", node.__name__) + if isAbstract(node): + return -def verify_node(nodename, node): - if "pinned" not in node: - print "%s: NO PINNED SET" % nodename - elif node["pinned"] not in ["yes", "no", "memory", "exception"]: - print "%s: UNKNOWN PINNED MODE: %s" % (nodename, node["pinned"]) + setdefault(node, "ins", []) + setdefault(node, "arity", len(node.ins)) + setdefault(node, "attrs", []) + setdefault(node, "constructor_args", []) + setdefault(node, "customSerializer", False) + if hasattr(node, "outs"): + node.mode = "mode_T"