-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into truffle-head
- Loading branch information
Showing
28 changed files
with
307 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
core/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes.core; | ||
|
||
import com.oracle.truffle.api.Truffle; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.frame.FrameInstance; | ||
import com.oracle.truffle.api.frame.FrameInstanceVisitor; | ||
import com.oracle.truffle.api.frame.MaterializedFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
import org.jruby.truffle.runtime.DebugOperations; | ||
import org.jruby.truffle.runtime.RubyArguments; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.core.RubyBinding; | ||
import org.jruby.util.Memo; | ||
|
||
@CoreClass(name = "Truffle::Primitive") | ||
public abstract class TrufflePrimitiveNodes { | ||
|
||
@CoreMethod(names = "binding_of_caller", onSingleton = true) | ||
public abstract static class BindingOfCallerNode extends CoreMethodNode { | ||
|
||
public BindingOfCallerNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
public BindingOfCallerNode(BindingOfCallerNode prev) { | ||
super(prev); | ||
} | ||
|
||
@Specialization | ||
public RubyBinding bindingOfCaller() { | ||
/* | ||
* When you use this method you're asking for the binding of the caller at the call site. When we get into | ||
* this method, that is then the binding of the caller of the caller. | ||
*/ | ||
|
||
notDesignedForCompilation(); | ||
|
||
final Memo<Integer> frameCount = new Memo<>(0); | ||
|
||
final MaterializedFrame frame = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<MaterializedFrame>() { | ||
|
||
@Override | ||
public MaterializedFrame visitFrame(FrameInstance frameInstance) { | ||
if (frameCount.get() == 1) { | ||
return frameInstance.getFrame(FrameInstance.FrameAccess.READ_WRITE, false).materialize(); | ||
} else { | ||
frameCount.set(frameCount.get() + 1); | ||
return null; | ||
} | ||
} | ||
|
||
}); | ||
|
||
return new RubyBinding( | ||
getContext().getCoreLibrary().getBindingClass(), | ||
RubyArguments.getSelf(frame.getArguments()), | ||
frame); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.