Commit 31a6d847 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fixing bug in xasm not adding vars to expandable insts


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 3dd392c8
Pipeline #80576 passed with stage
in 4 minutes and 12 seconds
......@@ -323,7 +323,6 @@ service.
xacc.qasm('''
.compiler xasm
.circuit foo
.parameters x,y,z
.qbit q
H(q[0]);
CX(q[0], q[1]);
......@@ -342,6 +341,7 @@ service.
assert(4 == f.nInstructions())
Extending Accelerator for new Simulators
-----------------------------------------
Here we document how one might extend the ``Accelerator`` interface for
new simulators.
\ No newline at end of file
......@@ -450,7 +450,6 @@ service.</p>
<span class="n">xacc</span><span class="o">.</span><span class="n">qasm</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
<span class="s1">.compiler xasm</span>
<span class="s1">.circuit foo</span>
<span class="s1">.parameters x,y,z</span>
<span class="s1">.qbit q</span>
<span class="s1">H(q[0]);</span>
<span class="s1">CX(q[0], q[1]);</span>
......@@ -472,6 +471,8 @@ service.</p>
</div>
<div class="section" id="extending-accelerator-for-new-simulators">
<h2>Extending Accelerator for new Simulators<a class="headerlink" href="#extending-accelerator-for-new-simulators" title="Permalink to this headline"></a></h2>
<p>Here we document how one might extend the <code class="docutils literal notranslate"><span class="pre">Accelerator</span></code> interface for
new simulators.</p>
</div>
</div>
......
This diff is collapsed.
......@@ -323,7 +323,6 @@ service.
xacc.qasm('''
.compiler xasm
.circuit foo
.parameters x,y,z
.qbit q
H(q[0]);
CX(q[0], q[1]);
......@@ -342,6 +341,7 @@ service.
assert(4 == f.nInstructions())
Extending Accelerator for new Simulators
-----------------------------------------
Here we document how one might extend the ``Accelerator`` interface for
new simulators.
\ No newline at end of file
......@@ -315,7 +315,16 @@ void XASMListener::enterInstruction(xasmParser::InstructionContext *ctx) {
runtimeOptions.get_mutable<std::string>("param_id") =
params[1].toString(); // first one is qbit
}
auto comp = std::dynamic_pointer_cast<CompositeInstruction>(tmpInst);
// If this composite inst has parameters that match
// any of the function vars, then we need to add them here
auto vars = function->getVariables();
for (auto& p : params) {
if (std::find(vars.begin(), vars.end(), p.toString()) != std::end(vars)) {
comp->addVariable(p.toString());
}
}
comp->expand(runtimeOptions);
}
......
Markdown is supported
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