@@ -54,6 +54,9 @@ PMC *compiling_scs = NULL;
54
54
* number of nested enable/disable we are in. */
55
55
INTVAL sc_write_barrier_off_depth = 0;
56
56
57
+ /* Empty hash, used in deconstruct op. */
58
+ static PMC *empty_hash = NULL;
59
+
57
60
/* SC write barrier for objects. */
58
61
static void SC_write_barrier_obj(PARROT_INTERP, PMC *obj) {
59
62
if (!sc_write_barrier_off_depth && VTABLE_get_bool(interp, compiling_scs)) {
@@ -340,6 +343,10 @@ inline op nqp_dynop_setup() :base_core {
340
343
nfa_nextst = Parrot_pmc_new(interp, enum_class_ResizableIntegerArray);
341
344
Parrot_pmc_gc_register(interp, nfa_nextst);
342
345
346
+ /* Create and anchor empty hash. */
347
+ empty_hash = Parrot_pmc_new(interp, enum_class_Hash);
348
+ Parrot_pmc_gc_register(interp, empty_hash);
349
+
343
350
/* Mark initialized. */
344
351
initialized = 1;
345
352
}
@@ -1576,14 +1583,64 @@ Invokes the specified target with the specified capture.
1576
1583
inline op invoke_with_capture(out PMC, in PMC, in PMC) :base_core {
1577
1584
PMC *arg_copy = VTABLE_clone(interp, $3);
1578
1585
PMC *result;
1579
- PMC *prev_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
1586
+ /* PMC *prev_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));*/
1580
1587
Parrot_pcc_invoke_from_sig_object(interp, $2, arg_copy);
1581
1588
result = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
1582
- Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), prev_ctx);
1589
+ /* Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), prev_ctx);*/
1583
1590
$1 = VTABLE_get_pmc_keyed_int(interp, result, 0);
1584
1591
}
1585
1592
1586
1593
1594
+ /*
1595
+
1596
+ =item deconstruct_capture()
1597
+
1598
+ Puts something that will flatten to the position part of the capture in $1
1599
+ into $2, and soemthing that will flatten to the named part into $3.
1600
+
1601
+ =cut
1602
+
1603
+ */
1604
+ inline op deconstruct_capture(invar PMC, out PMC, out PMC) :base_core {
1605
+ PMC *capture = $1;
1606
+ if (capture->vtable->base_type == enum_class_CallContext) {
1607
+ Hash *nameds;
1608
+ INTVAL has_nameds;
1609
+
1610
+ /* The call context itself will do for the positionals. */
1611
+ $2 = capture;
1612
+
1613
+ /* See if there are any nameds */
1614
+ GETATTR_CallContext_hash(interp, capture, nameds);
1615
+ has_nameds = nameds && Parrot_hash_size(interp, nameds) ? 1 : 0;
1616
+
1617
+ /* If there's a named part, create a hash with the values. */
1618
+ if (has_nameds) {
1619
+ PMC *result = Parrot_pmc_new(interp, enum_class_Hash);
1620
+ PMC *named_names = VTABLE_get_attr_str(interp, capture,
1621
+ Parrot_str_new_constant(interp, "named"));
1622
+ INTVAL n = VTABLE_elements(interp, named_names);
1623
+ INTVAL i;
1624
+ for (i = 0; i < n; i++) {
1625
+ STRING *name = VTABLE_get_string_keyed_int(interp, named_names, i);
1626
+ VTABLE_set_pmc_keyed_str(interp, result, name,
1627
+ VTABLE_get_pmc_keyed_str(interp, capture, name));
1628
+ }
1629
+ $3 = result;
1630
+ }
1631
+
1632
+ /* Otherwise, use empty hash. */
1633
+ else {
1634
+ $3 = empty_hash;
1635
+ }
1636
+ }
1637
+ else {
1638
+ $2 = $1;
1639
+ $3 = empty_hash;
1640
+ }
1641
+ }
1642
+
1643
+
1587
1644
/*
1588
1645
1589
1646
=item multi_cache_add()
0 commit comments