Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check rw-ness on Scalar assignment.
Fixes the one failure left in S03-operators/increment.t, and probably
more.
  • Loading branch information
jnthn committed Jun 22, 2013
1 parent 614d9e0 commit 03e005c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/vm/jvm/runtime/org/perl6/rakudo/Ops.java
Expand Up @@ -55,7 +55,7 @@ public GlobalExt(ThreadContext tc) { }
private static final int HINT_CODE_SIG = 1;
private static final int HINT_ROUTINE_RW = 7;
private static final int HINT_SIG_PARAMS = 0;
private static final int HINT_CD_RW = 1;
public static final int HINT_CD_RW = 1;
private static final int HINT_LIST_items = 0;
private static final int HINT_LIST_flattens = 1;
private static final int HINT_LIST_nextiter = 2;
Expand Down
20 changes: 16 additions & 4 deletions src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
Expand Up @@ -20,16 +20,28 @@ public SixModelObject fetch(ThreadContext tc, SixModelObject cont) {

/* Stores a value in a container. Used for assignment. */
public void store(ThreadContext tc, SixModelObject cont, SixModelObject obj) {
SixModelObject Scalar = Ops.key.getGC(tc).Scalar;
Ops.GlobalExt gcx = Ops.key.getGC(tc);

long rw = 0;
SixModelObject desc = cont.get_attribute_boxed(tc, gcx.Scalar,
"$!descriptor", HINT_descriptor);
if (desc != null) {
desc.get_attribute_native(tc, gcx.ContainerDescriptor, "$!rw", Ops.HINT_CD_RW);
rw = tc.native_i;
}
if (rw == 0)
throw ExceptionHandling.dieInternal(tc,
"Cannot assign to a readonly variable or a value");

if (Ops.DEBUG_MODE)
System.err.println("scalar store typecheck / rwcheck NYI");
System.err.println("scalar store typecheck NYI");

SixModelObject whence = cont.get_attribute_boxed(tc, Scalar, "$!whence", HINT_whence);
SixModelObject whence = cont.get_attribute_boxed(tc, gcx.Scalar, "$!whence", HINT_whence);
if (whence != null)
org.perl6.nqp.runtime.Ops.invokeDirect(tc, whence,
WHENCE, new Object[] { });

cont.bind_attribute_boxed(tc, Scalar, "$!value", HINT_value, obj);
cont.bind_attribute_boxed(tc, gcx.Scalar, "$!value", HINT_value, obj);
}

/* Stores a value in a container, without any checking of it (this
Expand Down

0 comments on commit 03e005c

Please sign in to comment.