Exemplo n.º 1
0
def initialize(config: Config = None, smt_disable: bool = False) -> None:
    """initialize klara to a different configuration
    :param config: a config object of type Klara.Config to fine tune configuration
    :param smt_disable: disable z3 solver support
    :return: None
    """
    if smt_disable:
        manager = _core_manager.AstManager()
        manager.initialize(config or Config())
        _infer_extension.disable()
    else:
        MANAGER.initialize(config or Config())
        _infer_extension.enable()
Exemplo n.º 2
0
 def run_fcf_with_arg(self, args):
     MANAGER = manager.AstManager()
     MANAGER.unload_all_extensions()
     with MANAGER.temp_manager():
         c = fcf_config.ConfigNamespace()
         fcf_mod.parse_args(args, namespace=c)
         klara.initialize(c, smt_disable=True)
         try:
             fcf_mod.run(c,
                         output_stream=self.result,
                         error_stream=self.result)
         except SystemExit:
             pass
         return self.result.getvalue()
Exemplo n.º 3
0
from ...common import common
from klara.core import exceptions, manager, nodes, protocols
from klara.core.cfg import ParentScopeBlock
from klara.core.context_mod import InferenceContext
from klara.core.ssa_visitors import AstVisitor
from klara.core.utilities import methdispatch

from .config import ConfigNamespace
from .html import report
from .result_banner import decorate
from .terminal import TerminalFormatter

MANAGER = manager.AstManager()
try:
    from klara.core.html import infer_server
except ImportError as e:
    infer_server = None


class WarningItem:
    __slots__ = ("value", "value_repr", "col_offset", "optional_type", "infer_path")

    def __init__(self, value, value_repr, col_offset, optional_type=None, infer_path=None):
        self.value = value
        self.value_repr = value_repr
        self.col_offset = col_offset
        self.infer_path = infer_path or []
        if optional_type is not None:
            self.optional_type = optional_type
        else:
            self.optional_type = type(self.value)
 def setUpClass(cls):
     man = manager.AstManager()
     man.initialize(config.Config())