Permalink
Browse files

Check rw-ness on Scalar assignment.

Fixes the one failure left in S03-operators/increment.t, and probably
more.
  • Loading branch information...
1 parent 614d9e0 commit 03e005cd278938fe968cb839e29650f2c016a418 @jnthn jnthn committed Jun 22, 2013
View
2 src/vm/jvm/runtime/org/perl6/rakudo/Ops.java
@@ -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;
View
20 src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
@@ -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

0 comments on commit 03e005c

Please sign in to comment.