Skip to content
Permalink
Browse files
[Truffle] Rename RubyMethod to InternalMethod.
  • Loading branch information
chrisseaton committed Jan 11, 2015
1 parent a3ad247 commit 90620c5d316aa03a42276a5d233f78fdf2bc892a
Showing 24 changed files with 131 additions and 149 deletions.
@@ -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 {
@@ -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());

@@ -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 {

@@ -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

@@ -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;

@@ -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));
@@ -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;

@@ -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()));
}
@@ -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()));
}
@@ -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()));
}
@@ -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()));
}

@@ -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;
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}

@@ -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());
@@ -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());
@@ -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);
@@ -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);
@@ -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);
@@ -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()));
@@ -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));
}
@@ -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));
}
@@ -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));
}
@@ -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));
}
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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 {

@@ -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;

@@ -43,7 +42,7 @@ public CachedBoxedDispatchNode(
DispatchNode next,
RubyClass expectedClass,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
this(
@@ -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);
@@ -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;
@@ -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;
@@ -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);

0 comments on commit 90620c5

Please sign in to comment.