Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 69fcbdfb5649
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e0a9a3116cb6
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 5, 2015

  1. Copy the full SHA
    fb25767 View commit details
  2. Copy the full SHA
    e0a9a31 View commit details
30 changes: 30 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.NullSourceSection;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.ast.ArgsNode;
import org.jruby.runtime.Helpers;
@@ -24,6 +25,7 @@
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.runtime.core.RubyNilClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;

@CoreClass(name = "Proc")
public abstract class ProcNodes {
@@ -165,4 +167,32 @@ public RubyArray parameters(RubyProc proc) {

}

@CoreMethod(names = "source_location")
public abstract static class SourceLocationNode extends CoreMethodNode {

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

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

@Specialization
public Object sourceLocation(RubyProc proc) {
notDesignedForCompilation();

SourceSection sourceSection = proc.getSharedMethodInfo().getSourceSection();

if (sourceSection instanceof NullSourceSection) {
return getContext().getCoreLibrary().getNilObject();
} else {
RubyString file = getContext().makeString(sourceSection.getSource().getName());
return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(),
file, sourceSection.getStartLine());
}
}

}

}
1 change: 1 addition & 0 deletions truffle/src/main/ruby/jruby/truffle/core.rb
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@
require_relative 'core/rubinius/kernel/common/marshal'
require_relative 'core/rubinius/kernel/common/nil'
require_relative 'core/rubinius/kernel/common/object_space'
require_relative 'core/rubinius/kernel/common/proc'
require_relative 'core/rubinius/kernel/common/string'
require_relative 'core/rubinius/kernel/common/struct'
require_relative 'core/rubinius/kernel/common/regexp'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2007-2014, Evan Phoenix and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Rubinius nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Only part of Rubinius's proc.rb

class Proc

def to_s
file, line = source_location

l = " (lambda)" if lambda?
if file and line
"#<#{self.class}:0x#{self.object_id.to_s(16)}@#{file}:#{line}#{l}>"
else
"#<#{self.class}:0x#{self.object_id.to_s(16)}#{l}>"
end
end

alias_method :inspect, :to_s

end