Changeset 3676:cd013d254a9d in livinglogic.python.xist

Show
Ignore:
Timestamp:
01/04/09 10:52:13 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Factor aut calculation of line and column info in Location. Add repr output for neg opcode.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r3674 r3676  
    8585        return "<%s.%s %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self, id(self)) 
    8686 
    87     def __str__(self): 
     87    def pos(self): 
    8888        lastlinefeed = self.source.rfind("\n", 0, self.starttag) 
    8989        if lastlinefeed >= 0: 
    90             line = self.source.count("\n", 0, self.starttag)+1 
    91             col = self.starttag - lastlinefeed 
     90            return (self.source.count("\n", 0, self.starttag)+1, self.starttag-lastlinefeed) 
    9291        else: 
    93             line = 1 
    94             col = self.starttag + 1 
     92            return (1, self.starttag + 1) 
     93 
     94    def __str__(self): 
     95        (line, col) = self.pos() 
    9596        return "%r at %d (line %d, col %d)" % (self.tag, self.starttag+1, line, col) 
    9697 
     
    582583        elif self.code == "mod": 
    583584            return "r%r = r%r %% r%r" % (self.r1, self.r2, self.r3) 
     585        elif self.code == "neg": 
     586            return "r%r = -r%r" % (self.r1, self.r2) 
    584587        elif self.code == "callfunc0": 
    585588            return "r%r = %s()" % (self.r1, self.arg)