mirror of https://github.com/m-labs/artiq.git
compiler.embedding: dedent kernel functions before parsing.
This commit is contained in:
parent
cb225269ff
commit
04bd2421ad
|
@ -5,7 +5,7 @@ the references to the host objects and translates the functions
|
||||||
annotated as ``@kernel`` when they are referenced.
|
annotated as ``@kernel`` when they are referenced.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, re, linecache, inspect
|
import os, re, linecache, inspect, textwrap
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import OrderedDict, defaultdict
|
||||||
|
|
||||||
from pythonparser import ast, source, diagnostic, parse_buffer
|
from pythonparser import ast, source, diagnostic, parse_buffer
|
||||||
|
@ -316,7 +316,7 @@ class Stitcher:
|
||||||
|
|
||||||
# Extract function source.
|
# Extract function source.
|
||||||
embedded_function = function.artiq_embedded.function
|
embedded_function = function.artiq_embedded.function
|
||||||
source_code = inspect.getsource(embedded_function)
|
source_code = textwrap.dedent(inspect.getsource(embedded_function))
|
||||||
filename = embedded_function.__code__.co_filename
|
filename = embedded_function.__code__.co_filename
|
||||||
module_name, _ = os.path.splitext(os.path.basename(filename))
|
module_name, _ = os.path.splitext(os.path.basename(filename))
|
||||||
first_line = embedded_function.__code__.co_firstlineno
|
first_line = embedded_function.__code__.co_firstlineno
|
||||||
|
|
Loading…
Reference in New Issue