Skip to content
Snippets Groups Projects

Follow-Up Translations

Merged David Schäfer requested to merge translations into develop
Compare and Show latest version
4 files
+ 49
12
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -59,19 +59,26 @@ class DmpTranslator(Translator):
Note
----
Could (and maybe should) be implemented as a method of `CallGraph`
Currently we work around the issue, that we keep track of the
computations we do on a variable using the variable name, but also
allow mutations of that name (i.e. our key) through `tools.rename`
in a somewhat hacky way. There are better ideas, to solve this (i.e.
global function pointers), but for the moment this has to do the trick
"""
out = [SaQCFunction(name="")]
# backtrack name changes and let's look, if our field
# originally had another name
for sel, func in call_stack[::-1]:
if func.name == "tools.rename":
new_name = func.keywords.get("new_name") or func.args[3]
if new_name == field:
field = sel.field
out = [SaQCFunction(name="")]
for sel, func in call_stack:
if sel.field == field:
out.append(func)
# NOTE:
# This is an intermediary hack, to work around
# the problem, that field names are mutable and
# used as an mapping between `History` and
# `call_stack`. There are better ideas, to solve
# this (i.e. global function pointer) but for the
# moment this has to do the trick
# forward track name changes
if func.name == "tools.rename":
field = func.keywords.get("new_name") or func.args[3]
Loading