Skip to content
Permalink
Browse files
Remove Null operand in favor of UndefinedValue.
  • Loading branch information
headius committed Nov 4, 2014
1 parent 9a83034 commit f0cd1043dd6c8e7cfd75ecaf04dc7ee95d00d9d8
Showing 5 changed files with 26 additions and 52 deletions.
@@ -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); }

This file was deleted.

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

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

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