Example #1
0
    def __init__(self, trimming_dict=None, progress_cb=None):
        self.trimming_dict = trimming_dict
        self.types_cast_to_void = set()
        self.progress_cb = progress_cb or (lambda *_: None)
        self.parser = c_parser.Parser(type_manager=self)
        self.variables = {}
        self.types = types.get_64bit_types()
        self.functions = functions.get_arithmetic_functions()
        self.functions.update(functions.get_builtins())
        self.expression_evaluator = (
            expression_evaluator_visitor.ExpressionEvaluatorVisitor(
                type_manager=self))

        self.dependency_visitor = type_collecting_visitor.DependencyVisitor(
            type_manager=self)

        self.field_collector = field_collecting_visitor.FieldCollectingVisitor(
            type_manager=self)

        self.layout_computer = layout_computing_visitor.LayoutComputingVisitor(
            type_manager=self)

        # Add the constants from the trimming dict. These represent global enum
        # values.
        if trimming_dict:
            self.variables = self.trimming_dict.get("$VARS", {})
Example #2
0
    def __init__(self,
                 pre_ast,
                 config_text,
                 system_map_text,
                 progress_cb=None,
                 cache_dir=None,
                 overwrite=False):
        """Initialize the ProfileBuilder.

        Args:
          pre_ast: A Preprocessor AST object.
          config_text: The content text of the kernel .config file
            (e.g. /boot/config-3.13.0-71-generic)
          system_map_text: The content text of the system map.
            (e.g. /boot/System.map-3.13.0-71-generic)
        """
        self.pre_ast_forest = pre_ast
        self.config_text = config_text
        self.system_map_text = system_map_text
        self.cache = util.CacheManager(cache_dir, force=overwrite)
        self.functions_ = functions.get_arithmetic_functions()

        if progress_cb:
            self.progress_cb = progress_cb
        else:
            self.progress_cb = ProgressReporter().report_progress
Example #3
0
    def __init__(self, trimming_dict=None, progress_cb=None):
        self.trimming_dict = trimming_dict
        self.types_cast_to_void = set()
        self.progress_cb = progress_cb or (lambda *_: None)
        self.parser = parser.Parser(type_manager=self)
        self.variables = {}
        self.types = types.get_64bit_types()
        self.functions = functions.get_arithmetic_functions()
        self.functions.update(functions.get_builtins())
        self.expression_evaluator = (
            expression_evaluator_visitor.ExpressionEvaluatorVisitor(
                type_manager=self))

        self.dependency_visitor = type_collecting_visitor.DependencyVisitor(
            type_manager=self)

        self.field_collector = field_collecting_visitor.FieldCollectingVisitor(
            type_manager=self)

        self.layout_computer = layout_computing_visitor.LayoutComputingVisitor(
            type_manager=self)

        # Add the constants from the trimming dict. These represent global enum
        # values.
        if trimming_dict:
            self.variables = self.trimming_dict.get("$VARS", {})
Example #4
0
    def __init__(self, config_flags=None):
        self.config_flags = config_flags or {}
        self.object_likes = {}

        # Macro function_likes.
        self.function_likes = {}

        # Built in functions.
        self.functions = {}

        # Defined is a built in keyword.
        self.symbols = set(["defined"] + EXCLUDED_FUNCTION_LIKE)

        # Initialize the MacroManager.
        self.add_object_likes(**self._get_object_like_macros())
        self.add_functions(**functions.get_arithmetic_functions())

        for name, args, repl in STANDARD_FUNCTION_LIKE:
            self.add_function_like(
                name, pre_ast.DefineFunctionLike(name, args, repl))
Example #5
0
    def __init__(self, config_flags=None):
        self.config_flags = config_flags or {}
        self.object_likes = {}

        # Macro function_likes.
        self.function_likes = {}

        # Built in functions.
        self.functions = {}

        # Defined is a built in keyword.
        self.symbols = set(["defined"] + EXCLUDED_FUNCTION_LIKE)

        # Initialize the MacroManager.
        self.add_object_likes(**self._get_object_like_macros())
        self.add_functions(**functions.get_arithmetic_functions())

        for name, args, repl in STANDARD_FUNCTION_LIKE:
            self.add_function_like(
                name, pre_ast.DefineFunctionLike(name, args, repl))
Example #6
0
    def __init__(self, pre_ast, config_text, system_map_text, progress_cb=None,
                 cache_dir=None, overwrite=False):
        """Initialize the ProfileBuilder.

        Args:
          pre_ast: A Preprocessor AST object.
          config_text: The content text of the kernel .config file
            (e.g. /boot/config-3.13.0-71-generic)
          system_map_text: The content text of the system map.
            (e.g. /boot/System.map-3.13.0-71-generic)
        """
        self.pre_ast_forest = pre_ast
        self.config_text = config_text
        self.system_map_text = system_map_text
        self.cache = util.CacheManager(cache_dir, force=overwrite)
        self.functions_ = functions.get_arithmetic_functions()

        if progress_cb:
            self.progress_cb = progress_cb
        else:
            self.progress_cb = ProgressReporter().report_progress
Example #7
0
 def setUp(self):
     self.functions = functions.get_arithmetic_functions()
     self.evaluator = lambda x: x
Example #8
0
 def setUp(self):
     self.functions = functions.get_arithmetic_functions()