Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correct Nil handling.

  • Loading branch information...
commit 1964396953ef69c5014c7246db72633f7e721656 1 parent 7f1cd51
@jnthn jnthn authored
Showing with 15 additions and 17 deletions.
  1. +15 −17 src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
View
32 src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
@@ -23,7 +23,7 @@ public SixModelObject fetch(ThreadContext tc, SixModelObject cont) {
new byte[] { CallSiteDescriptor.ARG_STR, CallSiteDescriptor.ARG_OBJ, CallSiteDescriptor.ARG_OBJ }, null);
public void store(ThreadContext tc, SixModelObject cont, SixModelObject value) {
RakOps.GlobalExt gcx = RakOps.key.getGC(tc);
-
+
long rw = 0;
SixModelObject desc = cont.get_attribute_boxed(tc, gcx.Scalar,
"$!descriptor", HINT_descriptor);
@@ -34,26 +34,24 @@ public void store(ThreadContext tc, SixModelObject cont, SixModelObject value) {
if (rw == 0)
throw ExceptionHandling.dieInternal(tc,
"Cannot assign to a readonly variable or a value");
-
+
+ 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) {
- if (value.st.WHAT == gcx.Nil) {
- value = desc.get_attribute_boxed(tc,
- gcx.ContainerDescriptor, "$!default", RakOps.HINT_CD_DEFAULT);
- }
- else {
- 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 });
- }
+ 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);
Please sign in to comment.
Something went wrong with that request. Please try again.