Skip to content
Snippets Groups Projects
Commit 1c9741d7 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

new ParNode to represent parentheses in source code

parent b21dc601
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ import com.oracle.truffle.r.nodes.control.BreakNode;
import com.oracle.truffle.r.nodes.control.ForNode;
import com.oracle.truffle.r.nodes.control.IfNode;
import com.oracle.truffle.r.nodes.control.NextNode;
import com.oracle.truffle.r.nodes.control.ParNode;
import com.oracle.truffle.r.nodes.control.RepeatNode;
import com.oracle.truffle.r.nodes.control.ReplacementDispatchNode;
import com.oracle.truffle.r.nodes.control.WhileNode;
......@@ -100,7 +101,7 @@ public final class RASTBuilder implements RCodeBuilder<RSyntaxNode> {
case "repeat":
return new RepeatNode(source, lhsLookup, args.get(0).value);
case "(":
return args.get(0).value;
return new ParNode(source, args.get(0).value);
}
} else if (args.size() == 2) {
switch (symbol) {
......
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.r.nodes.control;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.r.runtime.ArgumentsSignature;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSourceSectionNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxCall;
import com.oracle.truffle.r.runtime.nodes.RSyntaxElement;
import com.oracle.truffle.r.runtime.nodes.RSyntaxLookup;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;
/**
* A {@link ParNode} represents parentheses in source code.
*/
public final class ParNode extends RSourceSectionNode implements RSyntaxNode, RSyntaxCall {
@Child private RNode value;
public ParNode(SourceSection src, RSyntaxNode value) {
super(src);
this.value = value.asRNode();
}
@Override
@ExplodeLoop
public Object execute(VirtualFrame frame) {
return value.execute(frame);
}
@Override
public RSyntaxElement getSyntaxLHS() {
return RSyntaxLookup.createDummyLookup(getSourceSection(), "(", true);
}
@Override
public RSyntaxNode[] getSyntaxArguments() {
return new RSyntaxNode[]{value.asRSyntaxNode()};
}
@Override
public ArgumentsSignature getSyntaxSignature() {
return ArgumentsSignature.empty(1);
}
}
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