forked from M-Labs/artiq
1
0
Fork 0

compiler.embedding: dedent kernel functions before parsing.

This commit is contained in:
whitequark 2015-08-27 05:44:56 -05:00
parent cb225269ff
commit 04bd2421ad
1 changed files with 2 additions and 2 deletions

View File

@ -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