Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 177

Show
Ignore:
Timestamp:
09/25/07 00:40:24
Author:
fumanchu
Message:

New test and fix for adding Expressions with LOAD_GLOBAL instructions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/logic.py

    r176 r177  
    229229     
    230230    def visit_LOAD_ATTR(self, lo, hi): 
     231        src = self.instr_index[self.cursor] 
     232        if src: 
     233            value = src.co_names[lo + (hi << 8)] 
     234            newindex = self.name_index(value) 
     235            self.newcode[-2:] = [newindex & 0xFF, newindex >> 8] 
     236     
     237    def visit_LOAD_GLOBAL(self, lo, hi): 
    231238        src = self.instr_index[self.cursor] 
    232239        if src: 
  • trunk/geniusql/test/test_logic.py

    r176 r177  
    100100            'and ((x.DateTo == None) or (x.DateTo >= datetime.date(2005, 11, 17)))) ' 
    101101            'and ((x.DirectoryID == None) or (x.DirectoryID == 0))') 
     102         
     103        base_expr = logic.Expression(lambda x: x.BirthDate != None) 
     104        stnd_expr = logic.Expression(lambda x: month(x.BirthDate) == 3 and 
     105                                     day(x.BirthDate) == 12) 
     106        combo = base_expr + stnd_expr 
     107        self.assertEqual(map(ord, combo.func.func_code.co_code), 
     108                         nums(['LOAD_FAST', 0, 0, 
     109                               'LOAD_ATTR', 1, 0, 
     110                               'LOAD_CONST', 0, 0, 
     111                               'COMPARE_OP', 3, 0, 
     112                               'JUMP_IF_FALSE', 41, 0, 
     113                               'POP_TOP', 
     114                               'LOAD_GLOBAL', 3, 0, 
     115                               'LOAD_FAST', 0, 0, 
     116                               'LOAD_ATTR', 1, 0, 
     117                               'CALL_FUNCTION', 1, 0, 
     118                               'LOAD_CONST', 1, 0, 
     119                               'COMPARE_OP', 2, 0, 
     120                               'JUMP_IF_FALSE', 19, 0, 
     121                               'POP_TOP', 
     122                               'LOAD_GLOBAL', 4, 0, 
     123                               'LOAD_FAST', 0, 0, 
     124                               'LOAD_ATTR', 1, 0, 
     125                               'CALL_FUNCTION', 1, 0, 
     126                               'LOAD_CONST', 2, 0, 
     127                               'COMPARE_OP', 2, 0, 
     128                               'RETURN_VALUE'])) 
    102129     
    103130    def test_Aggregator(self):