Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 94

Show
Ignore:
Timestamp:
11/16/05 09:10:21
Author:
fumanchu
Message:

Fixed up storage/db with the changes to codewalk.LambdaDecompiler? (see #25).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/storage/db.py

    r93 r94  
    453453        return result 
    454454     
    455     def visit_target(self, terms): 
    456         """A target is an AND or OR test.""" 
    457         comp = self.stack.pop() 
    458         trueval = self.adapter.bool_true 
    459         falseval = self.adapter.bool_false 
    460         while terms: 
    461             term, operation = terms.pop() 
    462             if term is cannot_represent: 
    463                 term = trueval 
    464             if comp is cannot_represent: 
    465                 comp = trueval 
    466              
    467             # Blurg. SQL Server is *so* picky. 
    468             if term == self.adapter.coerce_bool(True): 
    469                 term = trueval 
    470             if term == self.adapter.coerce_bool(False): 
    471                 term = falseval 
    472             if comp == self.adapter.coerce_bool(True): 
    473                 comp = trueval 
    474             if comp == self.adapter.coerce_bool(False): 
    475                 comp = falseval 
    476              
    477             comp = "(%s) %s (%s)" % (term, operation.upper(), comp) 
    478         self.stack.append(comp) 
     455    def visit_instruction(self, op, lo=None, hi=None): 
     456        # Get the instruction pointer for the current instruction. 
     457        ip = self.cursor - 3 
     458        if hi is None: 
     459            ip += 1 
     460            if lo is None: 
     461                ip += 1 
     462         
     463        terms = self.targets.get(ip) 
     464        if terms: 
     465            trueval = self.adapter.bool_true 
     466            falseval = self.adapter.bool_false 
     467            clause = self.stack[-1] 
     468            while terms: 
     469                term, oper = terms.pop() 
     470                if term is cannot_represent: 
     471                    term = trueval 
     472                if clause is cannot_represent: 
     473                    clause = trueval 
     474                 
     475                # Blurg. SQL Server is *so* picky. 
     476                if term == self.adapter.coerce_bool(True): 
     477                    term = trueval 
     478                elif term == self.adapter.coerce_bool(False): 
     479                    term = falseval 
     480                if clause == self.adapter.coerce_bool(True): 
     481                    clause = trueval 
     482                elif clause == self.adapter.coerce_bool(False): 
     483                    clause = falseval 
     484                 
     485                clause = "(%s) %s (%s)" % (term, oper.upper(), clause) 
     486             
     487            # Replace TOS with the new clause, so that further 
     488            # combinations have access to it. 
     489            self.stack[-1] = clause 
     490            self.debug("clause:", clause, "\n") 
     491             
     492            if op == 1: 
     493                # Py2.4: The current instruction is POP_TOP, which means 
     494                # the previous is probably JUMP_*. If so, we're going to 
     495                # pop the value we just placed on the stack and lose it. 
     496                # We need to replace the entry that the JUMP_* made in 
     497                # self.targets with our new TOS. 
     498                target = self.targets[self.last_target_ip] 
     499                target[-1] = ((clause, target[-1][1])) 
     500                self.debug("newtarget:", self.last_target_ip, target) 
    479501     
    480502    def visit_LOAD_DEREF(self, lo, hi):