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

Fixed QIRInterface and IsExportableVisitor

parent 9991b129
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,10 @@ public class IsExportableVisitor implements RSyntaxNodeVisitor<Boolean> {
@Override
public final Boolean visit(final RCallNode call) {
final Arguments<RSyntaxNode> args = call.getArguments();
try {
return visitBuiltin(((LookupNode) call.getFunction()).getIdentifier());
} catch (RuntimeException e) {
}
if (!call.getFunction().asRSyntaxNode().accept(this))
return false;
for (int i = 0; i < args.getLength(); i++)
......@@ -109,13 +113,42 @@ public class IsExportableVisitor implements RSyntaxNodeVisitor<Boolean> {
@Override
public final Boolean visit(final RCallSpecialNode call) {
final RSyntaxElement[] args = call.getSyntaxArguments();
// TODO: Handle builtin
if (!visitBuiltin(call.expectedFunction.getName()))
return false;
for (int i = 0; i < args.length; i++)
if (!((RSyntaxNode) args[i]).accept(this))
return false;
return true;
}
private final static Boolean visitBuiltin(final String name) {
switch (name) {
case "c":
case "$":
case "+":
case "-":
case "*":
case "/":
case "==":
case "!=":
case "&":
case "&&":
case "|":
case "||":
case "<=":
case "<":
case ">=":
case ">":
case "!":
case "(":
return true;
case "print":
return false;
default:
throw new RuntimeException("Unknown call special node: " + name);
}
}
@Override
public final Boolean visit(final ReplacementDispatchNode repl) {
return repl.lhs.asRSyntaxNode().accept(this) && repl.rhs.asRSyntaxNode().accept(this);
......
......@@ -286,7 +286,8 @@ public final class QIRInterface {
} catch (UnsupportedOperationException e) {
final SourceSection funSrc = fun.getCallTarget().getRootNode().getSourceSection();
// TODO: Handle dependencies and exportability
return new QIRExportableTruffleNode(funSrc, "r", QIRInterface::execute, QIRInterface::apply, funSrc.getCharacters().toString());
return fun.getBody().accept(IsExportableVisitor.instance) ? new QIRExportableTruffleNode(funSrc, "r", QIRInterface::execute, QIRInterface::apply, funSrc.getCharacters().toString())
: new QIRUnexportableTruffleNode(funSrc, "r", QIRInterface::execute, QIRInterface::apply, funSrc.getCharacters().toString());
}
}
}
\ No newline at end of file
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