Skip to content

Commit

Permalink
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/module/append_features_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import org.jruby.truffle.nodes.arguments.ReadPreArgumentNode;
import org.jruby.truffle.nodes.cast.BooleanCastNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeGen;
import org.jruby.truffle.nodes.cast.TaintResultNode;
import org.jruby.truffle.nodes.coerce.*;
import org.jruby.truffle.nodes.constants.GetConstantNode;
import org.jruby.truffle.nodes.constants.GetConstantNodeGen;
@@ -341,15 +342,21 @@ public RubyBasicObject ancestors(RubyModule self) {
@CoreMethod(names = "append_features", required = 1, visibility = Visibility.PRIVATE)
public abstract static class AppendFeaturesNode extends CoreMethodArrayArgumentsNode {

@Child TaintResultNode taintResultNode;

public AppendFeaturesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
taintResultNode = new TaintResultNode(context, sourceSection);
}

@Specialization
public RubyBasicObject appendFeatures(RubyModule module, RubyModule other) {
CompilerDirectives.transferToInterpreter();

if (module instanceof RubyClass) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError("append_features must be called only on modules", this));
}
module.appendFeatures(this, other);
taintResultNode.maybeTaint(module, other);
return nil();
}
}
Original file line number Diff line number Diff line change
@@ -349,7 +349,9 @@ public void changeConstantVisibility(Node currentNode, String name, boolean isPr

@TruffleBoundary
public void appendFeatures(Node currentNode, RubyModule other) {
// TODO(CS): check only run once
if (ModuleOperations.includesModule(this, other)) {
throw new RaiseException(getContext().getCoreLibrary().argumentError("cyclic include detected", currentNode));
}
other.include(currentNode, this);
}

0 comments on commit 195761e

Please sign in to comment.