Convert recovered reaching conditions from claripy ASTs to ailment Expressions

        :return: None
771112
def _convert_claripy_bool_ast(self, cond):
        

        if isinstance(cond, ailment.Expr.Expression):
            return cond

        if cond.op == "BoolS" and claripy.is_true(cond):
            return cond
        if cond in self._condition_mapping:
            return self._condition_mapping[cond]

        _mapping = {
            'Not': lambda cond_: ailment.Expr.UnaryOp(None, 'Not', self._convert_claripy_bool_ast(cond_.args[0])),
            'And': lambda cond_: ailment.Expr.BinaryOp(None, 'LogicalAnd', (
                self._convert_claripy_bool_ast(cond_.args[0]),
                self._convert_claripy_bool_ast(cond_.args[1]),
            )),
            'Or': lambda cond_: ailment.Expr.BinaryOp(None, 'LogicalOr', (
                self._convert_claripy_bool_ast(cond_.args[0]),
                self._convert_claripy_bool_ast(cond_.args[1]),
            )),
            'ULE': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpULE',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            '__le__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpLE',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            'UGT': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpUGT',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            '__gt__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpGT',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            '__eq__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpEQ',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            '__ne__': lambda cond_: ailment.Expr.BinaryOp(None, 'CmpNE',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            '__xor__': lambda cond_: ailment.Expr.BinaryOp(None, 'Xor',
                                                          tuple(map(self._convert_claripy_bool_ast, cond_.args)),
                                                          ),
            'BVV': lambda cond_: ailment.Expr.Const(None, None, cond_.args[0], cond_.size()),
            'BoolV': lambda cond_: ailment.Expr.Const(None, None, True, 1) if cond_.args[0] is True
                                                                        else ailment.Expr.Const(None, None, False, 1),
        }

        if cond.op in _mapping:
            return _mapping[cond.op](cond)
        raise NotImplementedError(("Condition variable %s has an unsupported operator %s. "
                                   "Consider implementing.") % (cond, cond.op))
1278949
def parsed_to_ast(parsed: Parsed, errors: Errors, component_type: str = ""):
    

    ast = {}
    sorted_keys = sorted(parsed.keys())

    # Setup top-level tree
    for key in sorted_keys:
        if parsed[key]["type"] == "Nested":
            nested_component_stack = ["subject", "object"]

    if component_type:
        component_stack = [component_type]
    else:
        component_stack = ["subject", "object"]

    for key in sorted_keys:
        if parsed[key]["type"] == "Function" and parsed[key]["function_level"] == "top":
            ast[component_stack.pop(0)] = parsed_function_to_ast(parsed, key)
        elif parsed[key]["type"] == "Relation" and "relation" not in ast:
            ast["relation"] = {
                "name": parsed[key]["name"],
                "type": "Relation",
                "span": key,
            }
        elif parsed[key]["type"] == "Nested":
            ast["nested"] = {}
            for nested_key in sorted_keys:
                if nested_key <= key:
                    continue

                if (
                    parsed[nested_key]["type"] == "Function"
                    and parsed[nested_key]["function_level"] == "top"
                ):
                    ast["nested"][
                        nested_component_stack.pop(0)
                    ] = parsed_function_to_ast(parsed, nested_key)
                elif (
                    parsed[nested_key]["type"] == "Relation"
                    and "relation" not in ast["nested"]
                ):
                    ast["nested"]["relation"] = {
                        "name": parsed[nested_key]["name"],
                        "type": "Relation",
                        "span": parsed[nested_key]["span"],
                    }

            return ast, errors

    return ast, errors
485229
def ElemMatch(q, *conditions):
    
    new_condition = {}
    for condition in conditions:
        deep_merge(condition.to_dict(), new_condition)

    return Condition(q._path, new_condition, '$elemMatch')
369523
def resolved_ok(self):
    
    left_braces, right_braces = self.count_braces()
    return len(self.unresolved_symbols()) == left_braces == right_braces == 0
939839
def _slice_where_conditions(self, wheres, offset, length):
        
        where_group = self.get_query().for_nested_where()
        where_group.wheres = wheres[offset : (offset + length)]

        return {"type": "nested", "query": where_group, "boolean": "and"}
888462
def token(cls: Type[ConditionType], left: Any, op: Optional[Any] = None,
              right: Optional[Any] = None) -> ConditionType:
        
        condition = cls()
        condition.left = left
        if op:
            condition.op = op
        if right:
            condition.right = right
        return condition
53681
def evaluate_stop_condition(errdata, stop_condition):
    
    if stop_condition:
        return_code = stop_condition(list(errdata))
        if return_code != -1:
            log.info(
                'Stop condition triggered!  Relay is terminating.',
                extra=dict(return_code=return_code))
            sys.exit(return_code)
438709
def resolve(self, ts):
        
        if isinstance(ts, six.string_types):
            ts = [ts]

        obj = self
        while len(ts) > 0:
            t = ts.pop(0)

            if issubclass(obj.__class__, BaseObj):
                obj = getattr(obj, t)
            elif isinstance(obj, list):
                obj = obj[int(t)]
            elif isinstance(obj, dict):
                obj = obj[t]

        return obj
900414
function processLogicalCondition(tokenizer, scope) {
  let node = processAddSubtract(tokenizer, scope);

  while (tokenizer.token.match(types.LOGICAL_CONDITION)) {
    node = createOperatorNode(tokenizer.token.value, [node, processAddSubtract(tokenizer.skipToken(), scope)]);
  }

  return node;
}
1274170
def _op_generic_Clz(self, args):
        """"""
        wtf_expr = claripy.BVV(self._from_size, self._from_size)
        for a in range(self._from_size):
            bit = claripy.Extract(a, a, args[0])
            wtf_expr = claripy.If(bit==1, claripy.BVV(self._from_size-a-1, self._from_size), wtf_expr)
        return wtf_expr
328258
def convert(self, expr): #pylint:disable=R0201
        
        ast_queue = [[expr]]
        arg_queue = []
        op_queue = []

        try:
            while ast_queue:
                args_list = ast_queue[-1]

                if args_list:
                    ast = args_list.pop(0)

                    if type(ast) in {bool, int, str, float} or not isinstance(ast, Base):
                        converted = self._convert(ast)
                        arg_queue.append(converted)
                        continue

                    if self in ast._errored:
                        raise BackendError("%s can't handle operation %s (%s) due to a failed "
                                           "conversion on a child node" % (self, ast.op, ast.__class__.__name__))

                    if self._cache_objects:
                        cached_obj = self._object_cache.get(ast._cache_key, None)
                        if cached_obj is not None:
                            arg_queue.append(cached_obj)
                            continue

                    op_queue.append(ast)
                    if ast.op in self._op_expr:
                        ast_queue.append(None)
                    else:
                        ast_queue.append(list(ast.args))

                else:
                    ast_queue.pop()

                    if op_queue:
                        ast = op_queue.pop()

                        op = self._op_expr.get(ast.op, None)
                        if op is not None:
                            r = op(ast)

                        else:
                            args = arg_queue[-len(ast.args):]
                            del arg_queue[-len(ast.args):]

                            try:
                                r = self._call(ast.op, args)
                            except BackendUnsupportedError:
                                r = self.default_op(ast)

                        for a in ast.annotations:
                            r = self.apply_annotation(r, a)

                        if self._cache_objects:
                            self._object_cache[ast._cache_key] = r

                        arg_queue.append(r)

        except (RuntimeError, ctypes.ArgumentError) as e:
            raise ClaripyRecursionError("Recursion limit reached. Sorry about that.") from e

        except BackendError:
            for ast in op_queue:
                ast._errored.add(self)
            if isinstance(expr, Base):
                expr._errored.add(self)
            raise

        # Note: Uncomment the following assertions if you are touching the above implementation
        # assert len(op_queue) == 0, "op_queue is not empty"
        # assert len(ast_queue) == 0, "ast_queue is not empty"
        # assert len(arg_queue) == 1, ("arg_queue has unexpected length", len(arg_queue))

        return arg_queue.pop()
1278292
def index(self, value: Any) -> int:
        
        for i, cond in ((j[0], j[1][0]) for j in enumerate(self.handlers)):
            try:
                match = cond(value)
            except:
                if self.raiseconditionerrors:
                    raise
                match = False
            if match:
                return i
        raise TypedloadValueError('Unable to dump %s' % value, value=value)
291658
def raise_infinitive_error(sentence_str):
    """"""
    sent_doc = textacy.Doc(sentence_str, lang='en_core_web_lg')
    inf_pattern = r'<PART|ADP><VERB>' # To aux/auxpass* csubj
    infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern)
    for inf in infinitives:
        if inf[0].text.lower() != 'to':
            continue
        if inf[-1].tag_ != 'VB':
            raise Exception('InfinitivePhraseError')
601588
def _surpress_formatting_errors(fn):
    
    @wraps(fn)
    def inner(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except ValueError:
            return ""
    return inner
664995
def do_elif(self, t):
        
        d = self.dispatch_table
        if self.eval_expression(t):
            self.start_handling_includes()
            d['elif'] = self.stop_handling_includes
            d['else'] = self.stop_handling_includes
355292
def method_missing(method, *args)
      if method.to_s.starts_with? "*"
        condition_name = method.to_s.split("*")[1].to_sym
        conditions = self.class.scram_conditions
        if conditions && !conditions[condition_name].nil?
          return conditions[condition_name].call(self)
        end
      end
      super
    end
1133545
def execute_condition(cond):
    

    condition_method = 'rulengine.conditions.c_{0}_{1}'.format(
        cond.data_type, cond.operator)
    try:
        func = import_class(condition_method)
    except AttributeError:
        condition_method = 'rulengine.conditions.c_{0}'.format(
            cond.data_type)
        func = import_class(condition_method)

    executable_cond = convert_condition_to_executable(cond)
    return func(executable_cond)