Skip to content
Snippets Groups Projects
Commit 83e14a0f authored by Julien Lopez's avatar Julien Lopez
Browse files

Fixes in QIR evaluation

parent e5f8c299
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> { ...@@ -29,7 +29,7 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> {
if (!(input instanceof QIRLcons)) if (!(input instanceof QIRLcons))
throw new QIRException("Typing error: project expected list as input, got: " + input.getClass().getName() + "."); throw new QIRException("Typing error: project expected list as input, got: " + input.getClass().getName() + ".");
for (QIRNode e = input; e instanceof QIRLcons; e = ((QIRLcons) e).getTail()) for (QIRNode e = input; e instanceof QIRLcons; e = ((QIRLcons) e).getTail())
tmp.push(new QIRApply(null, formatter, e).accept(this)); tmp.push(new QIRApply(null, formatter, ((QIRLcons) e).getValue()).accept(this));
while (!tmp.isEmpty()) while (!tmp.isEmpty())
result = new QIRLcons(null, tmp.pop(), result); result = new QIRLcons(null, tmp.pop(), result);
return result; return result;
...@@ -114,9 +114,9 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> { ...@@ -114,9 +114,9 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> {
return fun.getBody(); return fun.getBody();
final String varName = var.getId(); final String varName = var.getId();
env.put(varName, right); env.put(varName, right);
final QIRLambda res = (QIRLambda) fun.accept(this); final QIRNode res = fun.getBody().accept(this);
env.remove(varName); env.remove(varName);
return res.getBody(); return res;
} }
if (left instanceof QIRTruffleNode) if (left instanceof QIRTruffleNode)
throw new QIRException("Evaluation of Truffle application not implemented yet."); throw new QIRException("Evaluation of Truffle application not implemented yet.");
...@@ -326,7 +326,7 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> { ...@@ -326,7 +326,7 @@ public final class QIREvaluationVisitor implements IQIRVisitor<QIRNode> {
final String colName = qirTdestr.getColName(); final String colName = qirTdestr.getColName();
for (QIRNode current = tuple; current instanceof QIRTcons; current = ((QIRTcons) current).getTail()) for (QIRNode current = tuple; current instanceof QIRTcons; current = ((QIRTcons) current).getTail())
if (colName == ((QIRTcons) current).getId()) if (colName.equals(((QIRTcons) current).getId()))
return ((QIRTcons) current).getValue(); return ((QIRTcons) current).getValue();
throw new QIRException("Typing error: destructor of tuple could not find " + colName + " in tuple " + tuple + "."); throw new QIRException("Typing error: destructor of tuple could not find " + colName + " in tuple " + tuple + ".");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment