Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement $!foo parameters.

Fixes Junction construction, which in turn unbusts various junction
related things.
  • Loading branch information...
commit 5913ce88214bb054bb93c029b9d699e6de577d4f 1 parent 7bd7a6b
@jnthn jnthn authored
Showing with 44 additions and 2 deletions.
  1. +44 −2 src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
View
46 src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
@@ -144,6 +144,36 @@ public static void bindTypeCaptures(ThreadContext tc, SixModelObject typeCaps, C
}
}
+ /* Assigns an attributive parameter to the desired attribute. */
+ private static int assignAttributive(ThreadContext tc, CallFrame cf, String varName,
+ int paramFlags, SixModelObject attrPackage, SixModelObject value, boolean needError) {
+ /* Find self. */
+ StaticCodeInfo sci = cf.codeRef.staticInfo;
+ Integer selfIdx = sci.oTryGetLexicalIdx("self");
+ if (selfIdx == null) {
+ if (needError)
+ lastErrors.put(tc, String.format(
+ "Unable to bind attributive parameter '%s' - could not find self",
+ varName));
+ return BIND_RESULT_FAIL;
+ }
+ SixModelObject self = cf.oLex[selfIdx];
+
+ /* If it's private, just need to fetch the attribute. */
+ SixModelObject assignee;
+ if ((paramFlags & SIG_ELEM_BIND_PRIVATE_ATTR) != 0) {
+ assignee = self.get_attribute_boxed(tc, attrPackage, varName, STable.NO_HINT);
+ }
+
+ /* Otherwise if it's public, do a method call to get the assignee. */
+ else {
+ throw new RuntimeException("$.x parameters NYI");
+ }
+
+ Ops.p6store(assignee, value, tc);
+ return BIND_RESULT_OK;
+ }
+
/* Binds a single argument into the lexpad, after doing any checks that are
* needed. Also handles any type captures. If there is a sub signature, then
* re-enters the binder. Returns one of the BIND_RESULT_* codes. */
@@ -342,11 +372,23 @@ else if ((paramFlags & SIG_ELEM_HASH_SIGIL) != 0) {
/* TODO: post_constraints. */
/* TODO: attributives. */
+ if ((paramFlags & SIG_ELEM_BIND_ATTRIBUTIVE) != 0) {
+ if (flag != CallSiteDescriptor.ARG_OBJ) {
+ if (needError)
+ lastErrors.put(tc,
+ "Native attributive binding not yet implemented");
+ return BIND_RESULT_FAIL;
+ }
+ int result = assignAttributive(tc, cf, varName, paramFlags,
+ param.get_attribute_boxed(tc, Ops.Parameter, "$!attr_package", HINT_attr_package),
+ decontValue, needError);
+ if (result != BIND_RESULT_OK)
+ return result;
+ }
+ /* If it has a sub-signature, bind that. */
SixModelObject subSignature = param.get_attribute_boxed(tc, Ops.Parameter,
"$!sub_signature", HINT_sub_signature);
-
- /* If it has a sub-signature, bind that. */
if (subSignature != null && flag == CallSiteDescriptor.ARG_OBJ) {
/* Turn value into a capture, unless we already have one. */
SixModelObject capture = null;
Please sign in to comment.
Something went wrong with that request. Please try again.