Skip to content

Commit

Permalink
[Truffle] Flatten the AST at new lines [pass, trace, child], not [pas…
Browse files Browse the repository at this point in the history
…s, (trace child)]
  • Loading branch information
chrisseaton committed Jan 28, 2015
1 parent a003621 commit effa2bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Expand Up @@ -24,7 +24,6 @@
public class TraceNode extends RubyNode {

private final RubyContext context;
@Child private RubyNode child;

@CompilerDirectives.CompilationFinal private Assumption traceAssumption;
@CompilerDirectives.CompilationFinal private RubyProc traceFunc;
Expand All @@ -34,9 +33,8 @@ public class TraceNode extends RubyNode {
private final RubyString file;
private final int line;

public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
public TraceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
this.child = child;
this.context = context;
traceAssumption = context.getTraceManager().getTraceAssumption();
traceFunc = null;
Expand All @@ -48,15 +46,13 @@ public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode chil

@Override
public Object execute(VirtualFrame frame) {
trace(frame);
return child.execute(frame);
throw new UnsupportedOperationException();
}


@Override
public void executeVoid(VirtualFrame frame) {
trace(frame);
child.executeVoid(frame);
}

public void trace(VirtualFrame frame) {
Expand Down Expand Up @@ -95,8 +91,4 @@ public void trace(VirtualFrame frame) {
}
}

@Override
public Object isDefined(VirtualFrame frame) {
return child.isDefined(frame);
}
}
Expand Up @@ -1958,22 +1958,20 @@ private RubyNode translateDummyAssignment(org.jruby.ast.Node dummyAssignment, Ru

@Override
public RubyNode visitNewlineNode(org.jruby.ast.NewlineNode node) {
final RubyNode child = node.getNextNode().accept(this);
final SourceSection sourceSection = translate(node.getPosition());

RubyNode translated = new TraceNode(context, child.getSourceSection(), child);
final List<RubyNode> lineSequence = new ArrayList<>();

if (Options.TRUFFLE_PASSALOT.load() > 0) {
if (Options.TRUFFLE_PASSALOT.load() > Math.random() * 100) {

translated = SequenceNode.sequence(
translated.getContext(),
translated.getSourceSection(),
new ThreadPassNode(translated.getContext(), translated.getSourceSection()),
translated);
lineSequence.add(new ThreadPassNode(context, sourceSection));
}
}

return translated;
lineSequence.add(new TraceNode(context, sourceSection));
lineSequence.add(node.getNextNode().accept(this));

return SequenceNode.sequence(context, sourceSection, lineSequence);
}

@Override
Expand Down

0 comments on commit effa2bc

Please sign in to comment.