コード例 #1
0
ファイル: py.py プロジェクト: mvaled/xotl.ql
 def e(node):
     if isinstance(node, Term):
         return var(node, self.vm)
     if isinstance(node, ExpressionTree):
         _args = tuple(e(x) for x in node.children)
         _kwargs = {k: e(v) for k, v in iteritems_(node.named_children)}
         if node.operation not in self.vmcodeset.table:
             raise TypeError('I don\'t know how to translate %r' % node.operation)
         def op():
             a = tuple(x for x in _args)
             kw = {k: x for k, x in iteritems_(_kwargs)}
             return self.vmcodeset.table[node.operation](self, *a, **kw)
         return vminstr.mylambda(op)
     return node  # assumed to be as is
コード例 #2
0
 def log_signature(cls, self, method, *args, **kwargs):
     if self:
         # Since many of our objects implement __getattribute__, we get
         # into an infinite recursion, so let's avoid calling str and
         # repr.
         args = (('<{0} at {1:#x}>'.format(nameof(type(self)),
                                           id(self)), ) + args)
     arguments = ', '.join('%r' % a for a in args) if args else ''
     if kwargs:
         arguments += ', '.join('%s=%r' % (k, v)
                                for k, v in iteritems_(kwargs))
     if self:
         method_name = '{cls}.{method}'.format(cls=type(self),
                                               method=nameof(method))
     else:
         method_name = nameof(method)
     message = '\t' * cls.get_padding()
     message += ('Calling {method}({arguments}) ...'.format(
         method=method_name, arguments=arguments))
     cls.log_for(type(self) if self else None, message)
コード例 #3
0
ファイル: __init__.py プロジェクト: pvergain/xotl.ql
 def log_signature(cls, self, method, *args, **kwargs):
     if self:
         # Since many of our objects implement __getattribute__, we get
         # into an infinite recursion, so let's avoid calling str and
         # repr.
         args = (('<{0} at {1:#x}>'.format(nameof(type(self)),
                                           id(self)), ) + args)
     arguments = ', '.join('%r' % a for a in args) if args else ''
     if kwargs:
         arguments += ', '.join('%s=%r' % (k, v)
                                for k, v in iteritems_(kwargs))
     if self:
         method_name = '{cls}.{method}'.format(cls=type(self),
                                               method=nameof(method))
     else:
         method_name = nameof(method)
     message = '\t' * cls.get_padding()
     message += ('Calling {method}({arguments}) ...'.
                 format(method=method_name, arguments=arguments))
     cls.log_for(type(self) if self else None, message)
コード例 #4
0
ファイル: py.py プロジェクト: mvaled/xotl.ql
 def op():
     a = tuple(x for x in _args)
     kw = {k: x for k, x in iteritems_(_kwargs)}
     return self.vmcodeset.table[node.operation](self, *a, **kw)
コード例 #5
0
ファイル: test_translate.py プロジェクト: mvaled/xotl.ql
 def __init__(self, **attrs):
     for k, v in iteritems_(attrs):
         setattr(self, k, v)
コード例 #6
0
ファイル: expressions.py プロジェクト: mvaled/xotl.ql
 def __hash__(self):
     from xoutil.compat import iteritems_
     children_signature = tuple(hash(c) for c in self.children)
     named_children_signature = tuple(sorted((n, hash(c)) for n, c in iteritems_(self.named_children)))
     signature = (hash(self.operation), children_signature, named_children_signature)
     return hash(signature)