Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement nqp::p6parcel on JVM.
  • Loading branch information
jnthn committed May 10, 2013
1 parent 380909f commit 395f577
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/vm/jvm/runtime/org/perl6/rakudo/Ops.java
Expand Up @@ -7,6 +7,7 @@
* Contains implementation of nqp:: ops specific to Rakudo Perl 6.
*/
public final class Ops {
private static SixModelObject Parcel;
private static SixModelObject Code;
private static SixModelObject Signature;
public static SixModelObject Parameter;
Expand All @@ -15,6 +16,7 @@ public final class Ops {
private static boolean initialized = false;

/* Parameter hints for fast lookups. */
private static final int HINT_PARCEL_STORAGE = 0;
private static final int HINT_CODE_DO = 0;
private static final int HINT_CODE_SIG = 1;
private static final int HINT_SIG_PARAMS = 0;
Expand All @@ -28,6 +30,7 @@ public static SixModelObject p6init(ThreadContext tc) {
}

public static SixModelObject p6settypes(SixModelObject conf, ThreadContext tc) {
Parcel = conf.at_key_boxed(tc, "Parcel");
Code = conf.at_key_boxed(tc, "Code");
Signature = conf.at_key_boxed(tc, "Signature");
Parameter = conf.at_key_boxed(tc, "Parameter");
Expand Down Expand Up @@ -67,4 +70,20 @@ public static CallSiteDescriptor p6bindsig(ThreadContext tc, CallSiteDescriptor

return csd;
}

public static SixModelObject p6parcel(SixModelObject array, SixModelObject fill, ThreadContext tc) {
SixModelObject parcel = Parcel.st.REPR.allocate(tc, Parcel.st);
parcel.initialize(tc);
parcel.bind_attribute_boxed(tc, Parcel, "$!storage", HINT_PARCEL_STORAGE, array);

if (fill != null) {
long elems = array.elems(tc);
for (long i = 0; i < elems; i++) {
if (array.at_pos_boxed(tc, i) == null)
array.bind_pos_boxed(tc, i, fill);
}
}

return parcel;
}
}

0 comments on commit 395f577

Please sign in to comment.