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: d0f581594743
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 438e4a0c02f5
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 8, 2014

  1. Copy the full SHA
    f647732 View commit details
  2. [Truffle] Add ModuleChain.getActualModule() for polymorphism.

    * Remove now useless getIncludedModule.
    * We might get a problem if RubyClass are no more RubyModule,
      but then we should have a ModuleLike interface.
    eregon committed Oct 8, 2014
    Copy the full SHA
    438e4a0 View commit details
Original file line number Diff line number Diff line change
@@ -185,14 +185,9 @@ public RubyArray ancestors(RubyModule self) {

ModuleOperations.debugModuleChain(self);

final List<ModuleChain> ancestors = new ArrayList<>();

final List<RubyModule> ancestors = new ArrayList<>();
for (ModuleChain module = self; module != null; module = module.getParentModule()) {
if (module instanceof IncludedModule) {
ancestors.add(((IncludedModule) module).getIncludedModule());
} else {
ancestors.add(module);
}
ancestors.add(module.getActualModule());
}

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), ancestors.toArray(new Object[ancestors.size()]));
Original file line number Diff line number Diff line change
@@ -37,6 +37,11 @@ public ModuleChain getLexicalParentModule() {
return includedModule.getLexicalParentModule();
}

@Override
public RubyModule getActualModule() {
return includedModule;
}

@Override
public Map<String, RubyConstant> getConstants() {
return includedModule.getConstants();
@@ -78,7 +83,4 @@ public Assumption getUnmodifiedAssumption() {
throw new UnsupportedOperationException();
}

public RubyModule getIncludedModule() {
return includedModule;
}
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@

import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.nodes.Node;
import org.jruby.RubyModule;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.RubyMethod;

import java.util.Map;
@@ -23,6 +23,8 @@ public interface ModuleChain {

ModuleChain getLexicalParentModule();

RubyModule getActualModule();

Map<String, RubyConstant> getConstants();

Map<String, RubyMethod> getMethods();
Original file line number Diff line number Diff line change
@@ -281,12 +281,8 @@ public static void debugModuleChain(ModuleChain module) {
while (module != null) {
System.err.print(module.getClass());

ModuleChain real = module;
if (module instanceof IncludedModule) {
real = ((IncludedModule) module).getIncludedModule();
}

System.err.print(" " + ((RubyModule) real).getName());
RubyModule real = module.getActualModule();
System.err.print(" " + real.getName());

System.err.println();
module = module.getParentModule();
Original file line number Diff line number Diff line change
@@ -241,6 +241,11 @@ public String getName() {
return name;
}

@Override
public String toString() {
return super.toString() + "(" + name + ")";
}

@Override
public int hashCode() {
return name.hashCode();
@@ -358,4 +363,8 @@ public ModuleChain getParentModule() {
return parentModule;
}

public RubyModule getActualModule() {
return this;
}

}