[Libre-soc-bugs] [Bug 980] Implement C-based Power ISA pseudocode compiler

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Wed Dec 6 17:20:29 GMT 2023


https://bugs.libre-soc.org/show_bug.cgi?id=980

--- Comment #29 from Dmitry Selyutin <ghostmansd at gmail.com> ---
I need the pseudocode printing for both the debugging and ensuring the overall
approach are fine. The code goes like this (example handlers for particular
node types):


    @Hook(If)
    def If(self, node):
        yield node
        stmt = " ".join(["if", str(self[node.test]), "then"])
        self[node].emit(stmt=stmt)
        for (level, stmt) in self[node.body]:
            self[node].emit(stmt=stmt, level=level)
        if node.orelse:
            self[node].emit("else")
            stmt = str(self[node.orelse])
            self[node].emit(stmt=stmt)

    @Hook(Symbol)
    def Symbol(self, node):
        yield node
        self[node].emit(stmt=str(node))


As you see, each node gets some code object associated with it. The code object
has an emit method, which feeds yet another statement considering the current
indentation level for it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list