[Subversion] / PEAK-Rules / peak / rules / predicates.py  

Diff of /PEAK-Rules/peak/rules/predicates.py

Parent Directory | Revision Log

version 2568, Tue Jul 15 17:09:34 2008 UTC version 2569, Tue Jul 15 17:57:29 2008 UTC
Line 301 
Line 301 
     # Default is to simply test the truth of the expression      # Default is to simply test the truth of the expression
     return Test(Truth(expr), Value(True))      return Test(Truth(expr), Value(True))
   
   when(expressionSignature, (Const,))(lambda expr: bool(expr.value))
   
 def compileIn(expr, criterion):  def compileIn(expr, criterion):
     """Return a signature or predicate (or None) for 'expr in criterion'"""      """Return a signature or predicate (or None) for 'expr in criterion'"""
     try:      try:
Line 324 
Line 326 
   
   
   
   
   
 class IndexedEngine(Engine, TreeBuilder):  class IndexedEngine(Engine, TreeBuilder):
     """A dispatching engine that builds trees using bitmap indexes"""      """A dispatching engine that builds trees using bitmap indexes"""
   
Line 533 
Line 533 
   
 # === As of this point, it should be possible to compile expressions!  # === As of this point, it should be possible to compile expressions!
 #  #
 when(expressionSignature,  meta_function(isinstance)(
     # matches 'issubclass/isinstance(?, Const)'      lambda __star__, __dstar__, *args, **kw:
     "expr in Call and expr.func in Const"          compileIsXCall(isinstance, IsInstance, args, kw, __star__, __dstar__)
     " and (expr.func.value is issubclass or expr.func.value is isinstance)"  )
     " and len(expr.args)==2 and expr.args[1] in Const"  meta_function(issubclass)(
 )      lambda __star__, __dstar__, *args, **kw:
 def convertIsXCall(expr):          compileIsXCall(issubclass, IsSubclass, args, kw, __star__, __dstar__)
     func, (expr, seq) = expr.func.value, expr.args  )
     if func is isinstance:  def compileIsXCall(func, test, args, kw, star, dstar):
         expr = IsInstance(expr)      if (
     elif func is issubclass:          kw or len(args)!=2 or not isinstance(args[1], Const)
         expr = IsSubclass(expr)          or isinstance(args[0], Const) or star is not None or dstar is not None
     else:      ):
         raise AssertionError("Should only be called for isinstance/issubclass")          return expressionSignature(
               Call(Const(func), args, tuple(kw.items()), star, dstar)
     return Test(expr, Disjunction(map(Class, _yield_tuples(seq.value))))          )
       expr, seq = args
       return Test(test(expr), Disjunction(map(Class, _yield_tuples(seq.value))))
   
 def _yield_tuples(ob):  def _yield_tuples(ob):
     if type(ob) is tuple:      if type(ob) is tuple:
Line 570 
Line 572 
   
   
   
   
   


Generate output suitable for use with a patch program
Legend:
Removed from v.2568  
changed lines
  Added in v.2569

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help