Commit 3044a1e0 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

fixes.__init__: move dynamic-related code to the correct subclass

parent 4ed07470
...@@ -14,15 +14,27 @@ class BaseStaticTraceFix(BaseFix): ...@@ -14,15 +14,27 @@ class BaseStaticTraceFix(BaseFix):
super(BaseStaticTraceFix, self).__init__(*args, **kwargs) super(BaseStaticTraceFix, self).__init__(*args, **kwargs)
# Note: id is used to differentiate the divisions of the same line. # Note: id is used to differentiate the divisions of the same line.
shared_columns = "filename", "lineno", "id" self.insert_trace = create_table(self.basename + "_trace", "filename", "lineno", "id", *self.traced_information)
self.insert_trace = create_table(self.basename + "_trace", *(shared_columns + self.traced_information))
self.insert_modified = create_table(self.basename + "_modified", *shared_columns)
def start_tree(self, *args, **kwargs): def start_tree(self, *args, **kwargs):
super(BaseStaticTraceFix, self).start_tree(*args, **kwargs) super(BaseStaticTraceFix, self).start_tree(*args, **kwargs)
self.ids = defaultdict(int) self.ids = defaultdict(int)
class BaseDynamicTraceFix(BaseStaticTraceFix):
def __init__(self, *args, **kwargs):
super(BaseDynamicTraceFix, self).__init__(*args, **kwargs)
def f(filename, lineno, id_, *args, **kwargs):
result, values = self._dynamic_trace(*args, **kwargs)
self.insert_trace(filename, lineno, id_, *values)
return result
f.__name__ = self.basename + "_traced"
tracing_functions.append(f)
self.insert_modified = create_table(self.basename + "_modified", "filename", "lineno", "id")
def traced_call(self, node, children): def traced_call(self, node, children):
# Important: every node inside "children" should be cloned before this # Important: every node inside "children" should be cloned before this
# function is called. # function is called.
...@@ -54,18 +66,6 @@ class BaseStaticTraceFix(BaseFix): ...@@ -54,18 +66,6 @@ class BaseStaticTraceFix(BaseFix):
return new_node return new_node
class BaseDynamicTraceFix(BaseStaticTraceFix):
def __init__(self, *args, **kwargs):
super(BaseDynamicTraceFix, self).__init__(*args, **kwargs)
def f(filename, lineno, id_, *args, **kwargs):
result, values = self._dynamic_trace(*args, **kwargs)
self.insert_trace(filename, lineno, id_, *values)
return result
f.__name__ = self.basename + "_traced"
tracing_functions.append(f)
class BaseSupportFix(BaseFix): class BaseSupportFix(BaseFix):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(BaseSupportFix, self).__init__(*args, **kwargs) super(BaseSupportFix, self).__init__(*args, **kwargs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment