def _scope_copy(self, scope):
        """ Copies a scope (e.g. if) in an execution """
        # TODO method uses different scopes than the subscopes property.

        # just check the start_pos, sometimes it's difficult with closures
        # to compare the scopes directly.
        if scope.start_pos == self.start_pos:
            return self
        else:
            copied = helpers.fast_parent_copy(scope)
            copied.parent = self._scope_copy(copied.parent)
            return copied
Example #2
0
    def _scope_copy(self, scope):
        """ Copies a scope (e.g. if) in an execution """
        # TODO method uses different scopes than the subscopes property.

        # just check the start_pos, sometimes it's difficult with closures
        # to compare the scopes directly.
        if scope.start_pos == self.start_pos:
            return self
        else:
            copied = helpers.fast_parent_copy(scope)
            copied.parent = self._scope_copy(copied.parent)
            return copied
 def _copy_properties(self, prop):
     """
     Literally copies a property of a Function. Copying is very expensive,
     because it is something like `copy.deepcopy`. However, these copied
     objects can be used for the executions, as if they were in the
     execution.
     """
     # Copy all these lists into this local function.
     attr = getattr(self.base, prop)
     objects = []
     for element in attr:
         if element is None:
             copied = element
         else:
             copied = helpers.fast_parent_copy(element)
             copied.parent = self._scope_copy(copied.parent)
             if isinstance(copied, pr.Function):
                 copied = Function(self._evaluator, copied)
         objects.append(copied)
     return objects
Example #4
0
 def _copy_properties(self, prop):
     """
     Literally copies a property of a Function. Copying is very expensive,
     because it is something like `copy.deepcopy`. However, these copied
     objects can be used for the executions, as if they were in the
     execution.
     """
     # Copy all these lists into this local function.
     attr = getattr(self.base, prop)
     objects = []
     for element in attr:
         if element is None:
             copied = element
         else:
             copied = helpers.fast_parent_copy(element)
             copied.parent = self._scope_copy(copied.parent)
             if isinstance(copied, pr.Function):
                 copied = Function(self._evaluator, copied)
         objects.append(copied)
     return objects