Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Rename RubyMethod to InternalMethod.
  • Loading branch information
chrisseaton committed Jan 11, 2015
1 parent a3ad247 commit 90620c5
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 149 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
Expand Up @@ -25,7 +25,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.util.ArrayUtils;

public class RubyCallNode extends RubyNode {
Expand Down Expand Up @@ -193,7 +193,7 @@ public Object isDefined(VirtualFrame frame) {

// TODO(CS): this lookup should be cached

final RubyMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(receiverObject), methodName);
final InternalMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(receiverObject), methodName);

final Object self = RubyArguments.getSelf(frame.getArguments());

Expand Down
Expand Up @@ -15,7 +15,7 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public class LambdaNode extends RubyNode {

Expand All @@ -32,7 +32,7 @@ public LambdaNode(RubyContext context, SourceSection sourceSection, RubyNode def
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final RubyMethod method = (RubyMethod) definition.execute(frame);
final InternalMethod method = (InternalMethod) definition.execute(frame);

// TODO(CS): not sure we're closing over the correct state here

Expand Down
Expand Up @@ -26,7 +26,7 @@
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.Arity;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.runtime.util.ArrayUtils;

Expand Down Expand Up @@ -118,7 +118,7 @@ private static void addMethod(RubyModule module, RubyRootNode rootNode, List<Str
coreMethodNode.setName(name);
}

final RubyMethod method = new RubyMethod(rootNodeCopy.getSharedMethodInfo(), name, module, visibility, false,
final InternalMethod method = new InternalMethod(rootNodeCopy.getSharedMethodInfo(), name, module, visibility, false,
Truffle.getRuntime().createCallTarget(rootNodeCopy), null);

module.addMethod(null, method.withVisibility(visibility).withNewName(name));
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Expand Up @@ -39,7 +39,7 @@
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.hash.KeyValue;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;

Expand Down Expand Up @@ -1338,15 +1338,15 @@ public RubyArray methods(RubyBasicObject self, boolean includeInherited) {

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getMetaClass());
} else {
methods = self.getMetaClass().getMethods();
}

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PUBLIC || method.getVisibility() == Visibility.PROTECTED) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
Expand Down Expand Up @@ -1450,15 +1450,15 @@ public RubyArray private_methods(RubyBasicObject self, boolean includeInherited)

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getMetaClass());
} else {
methods = self.getMetaClass().getMethods();
}

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PRIVATE) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
Expand Down Expand Up @@ -1518,9 +1518,9 @@ public RubyArray methods(RubyBasicObject self, UndefinedPlaceholder includeInher

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

final Map<String, RubyMethod> methods = self.getMetaClass().getMethods();
final Map<String, InternalMethod> methods = self.getMetaClass().getMethods();

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PUBLIC) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
Expand Down Expand Up @@ -1846,15 +1846,15 @@ public RubyArray singletonMethods(RubyBasicObject self, boolean includeInherited

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

final Collection<RubyMethod> methods;
final Collection<InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getSingletonClass(this)).values();
} else {
methods = self.getSingletonClass(this).getMethods().values();
}

for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
array.slowPush(RubySymbol.newSymbol(self.getContext(), method.getName()));
}

Expand Down
32 changes: 16 additions & 16 deletions core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Expand Up @@ -37,8 +37,8 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.methods.Arity;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
Expand Down Expand Up @@ -282,7 +282,7 @@ public static void attrReader(RubyNode currentNode, RubyContext context, SourceS
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, null, indicativeName, false, null, false);
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final RubyMethod method = new RubyMethod(sharedMethodInfo, name, module, Visibility.PUBLIC, false, callTarget, null);
final InternalMethod method = new InternalMethod(sharedMethodInfo, name, module, Visibility.PUBLIC, false, callTarget, null);
module.addMethod(currentNode, method);
}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ public static void attrWriter(RubyNode currentNode, RubyContext context, SourceS
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, null, indicativeName, false, null, false);
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final RubyMethod method = new RubyMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
final InternalMethod method = new InternalMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
module.addMethod(currentNode, method);
}
}
Expand Down Expand Up @@ -764,7 +764,7 @@ private void defineMethod(RubyModule module, RubySymbol name, RubyProc proc) {
notDesignedForCompilation();

final CallTarget modifiedCallTarget = proc.getCallTargetForMethods();
final RubyMethod modifiedMethod = new RubyMethod(proc.getSharedMethodInfo(), name.toString(), module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
final InternalMethod modifiedMethod = new InternalMethod(proc.getSharedMethodInfo(), name.toString(), module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
module.addMethod(this, modifiedMethod);
}

Expand Down Expand Up @@ -1070,7 +1070,7 @@ public RubyModule publicClassMethod(RubyModule module, Object... args) {
throw new UnsupportedOperationException();
}

final RubyMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);
final InternalMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
Expand Down Expand Up @@ -1131,7 +1131,7 @@ public RubyModule privateClassMethod(RubyModule module, Object... args) {
throw new UnsupportedOperationException();
}

final RubyMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);
final InternalMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
Expand Down Expand Up @@ -1165,14 +1165,14 @@ public RubyArray privateInstanceMethods(RubyModule module, boolean includeAncest
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
final List<InternalMethod> methods = new ArrayList<>(module.getMethods().values());

if (includeAncestors) {
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
}
}
for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
if (method.getVisibility() == Visibility.PRIVATE){
RubySymbol m = getContext().newSymbol(method.getName());
array.slowPush(m);
Expand Down Expand Up @@ -1203,13 +1203,13 @@ public RubyArray publicInstanceMethods(RubyModule module, boolean includeAncesto
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
final List<InternalMethod> methods = new ArrayList<>(module.getMethods().values());
if (includeAncestors) {
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
}
}
for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
if (method.getVisibility() == Visibility.PUBLIC){
RubySymbol m = getContext().newSymbol(method.getName());
array.slowPush(m);
Expand Down Expand Up @@ -1241,7 +1241,7 @@ public RubyArray instanceMethods(RubyModule module, UndefinedPlaceholder argumen
public RubyArray instanceMethods(RubyModule module, boolean includeAncestors) {
notDesignedForCompilation();

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeAncestors) {
methods = ModuleOperations.getAllMethods(module);
Expand All @@ -1250,7 +1250,7 @@ public RubyArray instanceMethods(RubyModule module, boolean includeAncestors) {
}

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() != Visibility.PRIVATE && !method.isUndefined()) {
// TODO(CS): shoudln't be using this
array.slowPush(getContext().newSymbol(method.getName()));
Expand Down Expand Up @@ -1402,7 +1402,7 @@ public UndefMethodNode(UndefMethodNode prev) {
public RubyModule undefMethod(RubyClass rubyClass, RubyString name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), rubyClass.toString(), this));
}
Expand All @@ -1414,7 +1414,7 @@ public RubyModule undefMethod(RubyClass rubyClass, RubyString name) {
public RubyModule undefMethod(RubyClass rubyClass, RubySymbol name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), rubyClass.toString(), this));
}
Expand All @@ -1426,7 +1426,7 @@ public RubyModule undefMethod(RubyClass rubyClass, RubySymbol name) {
public RubyModule undefMethod(RubyModule module, RubyString name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(module, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(module, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), module.toString(), this));
}
Expand All @@ -1438,7 +1438,7 @@ public RubyModule undefMethod(RubyModule module, RubyString name) {
public RubyModule undefMethod(RubyModule module, RubySymbol name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(module, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(module, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), module.toString(), this));
}
Expand Down
Expand Up @@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
Expand All @@ -22,19 +21,19 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBooleanDispatchNode extends CachedDispatchNode {

private final Assumption falseUnmodifiedAssumption;
private final RubyMethod falseMethod;
private final InternalMethod falseMethod;
private final BranchProfile falseProfile = BranchProfile.create();

private final Object falseValue;
@Child private DirectCallNode falseCallDirect;

private final Assumption trueUnmodifiedAssumption;
private final RubyMethod trueMethod;
private final InternalMethod trueMethod;
private final BranchProfile trueProfile = BranchProfile.create();

private final Object trueValue;
Expand All @@ -48,10 +47,10 @@ public CachedBooleanDispatchNode(
DispatchNode next,
Assumption falseUnmodifiedAssumption,
Object falseValue,
RubyMethod falseMethod,
InternalMethod falseMethod,
Assumption trueUnmodifiedAssumption,
Object trueValue,
RubyMethod trueMethod,
InternalMethod trueMethod,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Expand Down
Expand Up @@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
Expand All @@ -24,7 +23,7 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {

Expand All @@ -33,7 +32,7 @@ public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {

private final Object value;

private final RubyMethod method;
private final InternalMethod method;
@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;

Expand All @@ -43,7 +42,7 @@ public CachedBoxedDispatchNode(
DispatchNode next,
RubyClass expectedClass,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
this(
Expand All @@ -68,7 +67,7 @@ public CachedBoxedDispatchNode(
RubyClass expectedClass,
Assumption unmodifiedAssumption,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Expand Down
Expand Up @@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
Expand All @@ -23,14 +22,14 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.cli.Options;

public abstract class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {

private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;
private final RubyMethod method;
private final InternalMethod method;

@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;
Expand All @@ -40,7 +39,7 @@ public CachedBoxedMethodMissingDispatchNode(
Object cachedName,
DispatchNode next,
RubyClass expectedClass,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Expand Down

0 comments on commit 90620c5

Please sign in to comment.