Ejemplo n.º 1
0
def _reduce(self, f, init):
    assert isinstance(self, Path)
    for dirpath, dirnames, filenames in os.walk(str(self._path)):
        for dirname in dirnames:
            init = f.invoke([init, Path(rt.wrap(dirpath + "/" + dirname))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        for filename in filenames:
            init = f.invoke([init, Path(rt.wrap(dirpath + "/" + filename))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

    return init
Ejemplo n.º 2
0
def _reduce(self, f, init):
    assert isinstance(self, Path)
    for dirpath, dirnames, filenames in os.walk(str(self._path)):
        for dirname in dirnames:
            init = f.invoke([init, Path(rt.wrap(dirpath + "/" + dirname))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        for filename in filenames:
            init = f.invoke([init, Path(rt.wrap(dirpath + "/" + filename))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

    return init
Ejemplo n.º 3
0
def _reduce(self, f, init):
    assert isinstance(self, Environment)
    val = self.reduce_vars(f, init)
    if rt.reduced_QMARK_(val):
        return rt.deref(val)

    return val
Ejemplo n.º 4
0
def _reduce(self, f, init):
    assert isinstance(self, FileList)
    for dirpath, dirnames, filenames in os.walk(str(self._top)):
        for dirname in dirnames:
            init = f.invoke([init, rt.vector(rt.wrap(dirpath), KW_DIR, rt.wrap(dirname))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        for filename in filenames:
            init = f.invoke([init, rt.vector(rt.wrap(dirpath), KW_FILE, rt.wrap(filename))])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)



    return init
Ejemplo n.º 5
0
def _reduce(self, f, init):
    assert isinstance(self, Environment)
    val = self.reduce_vars(f, init)
    if rt.reduced_QMARK_(val):
        return rt.deref(val)

    return val
Ejemplo n.º 6
0
def _reduce(self, f, init):
    if self._root is None:
        return init
    val = self._root.reduce_inode(f, init)
    if rt.reduced_QMARK_(val):
        return rt.deref(val)

    return val
Ejemplo n.º 7
0
    def reduce_inode(self, f, init):
        for x in range(len(self._array)):
            node = self._array[x]
            if node is not None:
                init = node.reduce_inode(f, init)
                if rt.reduced_QMARK_(init):
                    return init

        return init
Ejemplo n.º 8
0
def _reduce(self, f, init):
    assert isinstance(self, PersistentHashMap)
    if self._root is None:
        return init
    val = self._root.reduce_inode(f, init)
    if rt.reduced_QMARK_(val):
        return rt.deref(val)

    return val
Ejemplo n.º 9
0
    def reduce_inode(self, f, init):
        for x in range(len(self._array)):
            node = self._array[x]
            if node is not None:
                init = node.reduce_inode(f, init)
                if rt.reduced_QMARK_(init):
                    return init

        return init
Ejemplo n.º 10
0
def _reduce(self, f, init):
    assert isinstance(self, PersistentHashMap)
    if self._root is None:
        return init
    val = self._root.reduce_inode(f, init)
    if rt.reduced_QMARK_(val):
        return rt.deref(val)

    return val
Ejemplo n.º 11
0
 def reduce_inode(self, f, init):
     for x in range(0, len(self._array), 2):
         key_or_none = self._array[x]
         val_or_node = self._array[x + 1]
         if key_or_none is None and val_or_node is not None:
             init = val_or_node.reduce_inode(f, init)
         else:
             init = f.invoke([init, rt.map_entry(key_or_none, val_or_node)])
         if rt.reduced_QMARK_(init):
             return init
     return init
Ejemplo n.º 12
0
    def reduce_inode(self, f, init):
        for x in range(0, len(self._array), 2):
            key_or_nil = self._array[x]
            if key_or_nil is None:
                continue

            val = self._array[x + 1]
            init = f.invoke([init, val])
            if rt.reduced_QMARK_(init):
                return init
        return init
Ejemplo n.º 13
0
 def reduce_inode(self, f, init):
     for x in range(0, len(self._array), 2):
         key_or_none = self._array[x]
         val_or_node = self._array[x + 1]
         if key_or_none is None and val_or_node is not None:
             init = val_or_node.reduce_inode(f, init)
         else:
             init = f.invoke([init, rt.map_entry(key_or_none, val_or_node)])
         if rt.reduced_QMARK_(init):
             return init
     return init
Ejemplo n.º 14
0
    def reduce_inode(self, f, init):
        for x in range(0, len(self._array), 2):
            key_or_nil = self._array[x]
            if key_or_nil is None:
                continue

            val = self._array[x + 1]
            init = f.invoke([init, rt.map_entry(key_or_nil, val)])
            if rt.reduced_QMARK_(init):
                return init
        return init
Ejemplo n.º 15
0
def _reduce(self, f, init):
    i = 0
    while i < self._cnt:
        array = self.array_for(i)
        for j in range(len(array)):
            item = array[j]
            _reduce_driver.jit_merge_point(f=f)

            init = f.invoke([init, array[j]])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        step = len(array)
        i += step
    return init
Ejemplo n.º 16
0
def _reduce(self, f, init):
    assert isinstance(self, PersistentVector)
    i = 0
    while i < self._cnt:
        array = self.array_for(i)
        for j in range(len(array)):
            _reduce_driver.jit_merge_point(f=f)

            init = f.invoke([init, array[j]])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        step = len(array)
        i += step
    return init
Ejemplo n.º 17
0
def _reduce(self, f, init):
    assert isinstance(self, PersistentVector)
    i = 0
    while i < self._cnt:
        array = self.array_for(i)
        for j in range(len(array)):
            _reduce_driver.jit_merge_point(f=f)

            init = f.invoke([init, array[j]])
            if rt.reduced_QMARK_(init):
                return rt.deref(init)

        step = len(array)
        i += step
    return init
Ejemplo n.º 18
0
 def reduce(self, f, init):
     for x in range(self._idx, rt.count(self._w_array)):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, rt.nth(self._w_array, rt.wrap(x))])
     return init
Ejemplo n.º 19
0
 def reduce_large(self, f, init):
     for x in range(len(self._list)):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, self._list[x]])
     return init
Ejemplo n.º 20
0
 def reduce_large(self, f, init):
     for x in range(self._cnt):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, rt.wrap(ord(self._buffer[x]))])
     return init
Ejemplo n.º 21
0
 def reduce_vars(self, f, init):
     for k, v in os.environ.items():
         init = f.invoke([init, rt.map_entry(rt.wrap(k), rt.wrap(v))])
         if rt.reduced_QMARK_(init):
             return init
     return init
Ejemplo n.º 22
0
 def reduce_large(self, f, init):
     for x in range(len(self._list)):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, self._list[x]])
     return init
Ejemplo n.º 23
0
 def reduce_large(self, f, init):
     for x in range(self._cnt):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, rt.wrap(ord(self._buffer[x]))])
     return init
Ejemplo n.º 24
0
 def reduce(self, f, init):
     for x in range(self._idx, rt.count(self._w_array)):
         if rt.reduced_QMARK_(init):
             return rt.deref(init)
         init = f.invoke([init, rt.nth(self._w_array, rt.wrap(x))])
     return init
Ejemplo n.º 25
0
 def reduce_vars(self, f, init):
     for k, v in os.environ.items():
         init = f.invoke([init, rt.map_entry(rt.wrap(k), rt.wrap(v))])
         if rt.reduced_QMARK_(init):
             return init
     return init