Skip to content
Permalink
Browse files
[Truffle] Implement Regexp#source.
* RubyRegexp.source should obviously be a String.
  • Loading branch information
eregon committed Oct 31, 2014
1 parent 7bce91f commit 42561902f6c09f5cb0da79631f25435e5d0ee458
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
@@ -172,4 +172,22 @@ public Object match(RubyRegexp regexp, RubyString string) {

}

@CoreMethod(names = "source")
public abstract static class SourceNode extends CoreMethodNode {

public SourceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public SourceNode(SourceNode prev) {
super(prev);
}

@Specialization
public Object source(RubyRegexp regexp) {
return getContext().makeString(regexp.getSource());
}

}

}
@@ -51,7 +51,7 @@ public RubyBasicObject newInstance(RubyNode currentNode) {
}

@CompilationFinal private Regex regex;
@CompilationFinal private Object source;
@CompilationFinal private String source;

public RubyRegexp(RubyClass regexpClass) {
super(regexpClass);
@@ -81,6 +81,10 @@ public Regex getRegex() {
return regex;
}

public String getSource() {
return source;
}

@CompilerDirectives.SlowPath
public Object matchOperator(String string) {
// TODO(CS) merge with match

0 comments on commit 4256190

Please sign in to comment.