From 04bd2421ad5ee944ef886090e778284d53de1e2b Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 27 Aug 2015 05:44:56 -0500 Subject: [PATCH] compiler.embedding: dedent kernel functions before parsing. --- artiq/compiler/embedding.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index d6e4403a2..c56ea7681 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -5,7 +5,7 @@ the references to the host objects and translates the functions annotated as ``@kernel`` when they are referenced. """ -import os, re, linecache, inspect +import os, re, linecache, inspect, textwrap from collections import OrderedDict, defaultdict from pythonparser import ast, source, diagnostic, parse_buffer @@ -316,7 +316,7 @@ class Stitcher: # Extract function source. 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 module_name, _ = os.path.splitext(os.path.basename(filename)) first_line = embedded_function.__code__.co_firstlineno