Commit fc19af69 authored by Zachary Parks's avatar Zachary Parks
Browse files

Python API changes to allow variables in IRGenerator declarations

Signed-off-by: default avatarZachary Parks <>
parent 1c531f68
from _pyxacc import *
import os, time, json
import platform
import sys
import sys, re
import sysconfig
import argparse
import inspect
......@@ -163,6 +163,9 @@ class DecoratorFunction(ABC):
self.accelerator = None
self.src = '\n'.join(inspect.getsource(self.function).split('\n')[1:])
compiler = getCompiler('xacc-py')
if self.accelerator == None:
if 'accelerator' in self.kwargs:
......@@ -186,7 +189,19 @@ class DecoratorFunction(ABC):
def overrideAccelerator(self, acc):
self.accelerator = acc
def processVariables(self):
g = re.findall('=(\w+)', self.src)
frame = inspect.currentframe()
for thing in g:
if thing in frame.f_back.f_locals['f'].__globals__:
if isinstance(frame.f_back.f_locals['f'].__globals__[thing], str):
real = "'" + frame.f_back.f_locals['f'].__globals__[thing] + "'"
real = str(frame.f_back.f_locals['f'].__globals__[thing])
self.src = self.src.replace('='+thing, '='+real)
del frame
def nParameters(self):
return self.getFunction().nParameters()
Supports Markdown
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