Skip to content

Commit

Permalink
Remove Null operand in favor of UndefinedValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 4, 2014
1 parent 9a83034 commit f0cd104
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 52 deletions.
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/IRVisitor.java
Expand Up @@ -156,7 +156,6 @@ private void error(Object object) {
public void MethodHandle(MethodHandle methodhandle) { error(methodhandle); }
public void Nil(Nil nil) { error(nil); }
public void NthRef(NthRef nthref) { error(nthref); }
public void Null(Null nul) { error(nul); }
public void ObjectClass(ObjectClass objectclass) { error(objectclass); }
public void Rational(Rational rational) { error(rational); }
public void Regexp(Regexp regexp) { error(regexp); }
Expand Down
42 changes: 0 additions & 42 deletions core/src/main/java/org/jruby/ir/operands/Null.java

This file was deleted.

1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/operands/OperandType.java
Expand Up @@ -29,7 +29,6 @@ public enum OperandType {
METHOD_HANDLE((byte) 'm'),
NIL((byte) 'N'),
NTH_REF((byte) '1'),
NULL((byte) '0'),
OBJECT_CLASS((byte) 'O'),
RANGE((byte) '.'),
RATIONAL((byte) 'r'),
Expand Down
15 changes: 7 additions & 8 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Expand Up @@ -1118,7 +1118,11 @@ private void superCommon(String name, CallInstr instr, Operand[] args, Operand d
m.loadContext();
m.loadSelf(); // TODO: get rid of caller
m.loadSelf();
visit(definingModule);
if (definingModule == UndefinedValue.UNDEFINED) {
jvmAdapter().aconst_null();
} else {
visit(definingModule);
}

// TODO: CON: is this safe?
jvmAdapter().checkcast(p(RubyClass.class));
Expand Down Expand Up @@ -1749,7 +1753,7 @@ public void UnresolvedSuperInstr(UnresolvedSuperInstr unresolvedsuperinstr) {
String name = unresolvedsuperinstr.getMethodAddr().getName();
Operand[] args = unresolvedsuperinstr.getCallArgs();
// this would be getDefiningModule but that is not used for unresolved super
Operand definingModule = Null.INSTANCE;
Operand definingModule = UndefinedValue.UNDEFINED;
boolean containsArgSplat = unresolvedsuperinstr.containsArgSplat();
Operand closure = unresolvedsuperinstr.getClosureArg(null);

Expand Down Expand Up @@ -1777,7 +1781,7 @@ public void ZSuperInstr(ZSuperInstr zsuperinstr) {
String name = zsuperinstr.getMethodAddr().getName();
Operand[] args = zsuperinstr.getCallArgs();
// this would be getDefiningModule but that is not used for unresolved super
Operand definingModule = Null.INSTANCE;
Operand definingModule = UndefinedValue.UNDEFINED;
boolean containsArgSplat = zsuperinstr.containsArgSplat();
Operand closure = zsuperinstr.getClosureArg(null);

Expand Down Expand Up @@ -1974,11 +1978,6 @@ public void NthRef(NthRef nthref) {
jvmMethod().invokeIRHelper("nthMatch", sig(IRubyObject.class, ThreadContext.class, int.class));
}

@Override
public void Null(Null nul) {
jvmAdapter().aconst_null();
}

@Override
public void ObjectClass(ObjectClass objectclass) {
jvmMethod().pushObjectClass();
Expand Down
19 changes: 19 additions & 0 deletions spec/compiler/general_spec.rb
Expand Up @@ -889,4 +889,23 @@ def foo(*args)
expect(x).to eq 6
end
end

it "performs super calls within a closure" do
run '
class SplatSuperArgs0
def foo(a)
a
end
end
class SplatSuperArgs1 < SplatSuperArgs0
def foo(a)
1.times do
super(a)
end
end
end
SplatSuperArgs1.new.foo(1)' do |x|
expect(x).to eq 1
end
end
end

0 comments on commit f0cd104

Please sign in to comment.