Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Correct Nil handling on JVM.
  • Loading branch information
jnthn committed Sep 25, 2013
1 parent 3d25fb3 commit 153daeb
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
Expand Up @@ -35,25 +35,27 @@ public void store(ThreadContext tc, SixModelObject cont, SixModelObject value) {
throw ExceptionHandling.dieInternal(tc,
"Cannot assign to a readonly variable or a value");

if (value.st.WHAT == gcx.Nil)
if (value.st.WHAT == gcx.Nil) {
value = desc.get_attribute_boxed(tc,
gcx.ContainerDescriptor, "$!default", RakOps.HINT_CD_DEFAULT);

SixModelObject of = desc.get_attribute_boxed(tc,
gcx.ContainerDescriptor, "$!of", RakOps.HINT_CD_OF);
long ok = Ops.istype(value, of, tc);
if (ok == 0) {
desc.get_attribute_native(tc, gcx.ContainerDescriptor, "$!name", RakOps.HINT_CD_NAME);
String name = tc.native_s;
SixModelObject thrower = RakOps.getThrower(tc, "X::TypeCheck::Assignment");
if (thrower == null)
throw ExceptionHandling.dieInternal(tc,
"Type check failed in assignment to '" + name + "'");
else
Ops.invokeDirect(tc, thrower,
storeThrower, new Object[] { name, value, of });
}

else {
SixModelObject of = desc.get_attribute_boxed(tc,
gcx.ContainerDescriptor, "$!of", RakOps.HINT_CD_OF);
long ok = Ops.istype(value, of, tc);
if (ok == 0) {
desc.get_attribute_native(tc, gcx.ContainerDescriptor, "$!name", RakOps.HINT_CD_NAME);
String name = tc.native_s;
SixModelObject thrower = RakOps.getThrower(tc, "X::TypeCheck::Assignment");
if (thrower == null)
throw ExceptionHandling.dieInternal(tc,
"Type check failed in assignment to '" + name + "'");
else
Ops.invokeDirect(tc, thrower,
storeThrower, new Object[] { name, value, of });
}
}

SixModelObject whence = cont.get_attribute_boxed(tc, gcx.Scalar, "$!whence", HINT_whence);
if (whence != null)
Ops.invokeDirect(tc, whence,
Expand Down

0 comments on commit 153daeb

Please sign in to comment.