Skip to content

Commit c11251c

Browse files
committed
Implement support for maintaining a stack of currently compiling SCs.
1 parent f9eb249 commit c11251c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/ops/nqp.ops

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ static PMC *KnowHOWAttribute = NULL;
3838
static PMC *nqpevent_fh = NULL;
3939
static INTVAL nqpdebflags_i = 0;
4040

41+
/* Serialization context upside-down stack (element 0 is the latest, new entries
42+
* unshifted). Tracks the SC (if any) that we are currently in; stack because we
43+
* may have multiple on the go due to compiling nested module dependencies. */
44+
PMC *compiling_scs = NULL;
45+
4146
END_OPS_PREAMBLE
4247

4348
/*
@@ -60,6 +65,10 @@ inline op nqp_dynop_setup() :base_core {
6065

6166
/* Initialize the object model. */
6267
SixModelObject_initialize(interp, &KnowHOW, &KnowHOWAttribute);
68+
69+
/* Initialize compiling SCs list. */
70+
compiling_scs = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
71+
Parrot_pmc_gc_register(interp, compiling_scs);
6372
}
6473
}
6574

@@ -1638,6 +1647,34 @@ inline op nqp_get_sc_for_object(out PMC, in PMC) :base_core {
16381647
}
16391648

16401649

1650+
/*
1651+
1652+
=item nqp_push_compiling_sc()
1653+
1654+
Pushes an SC on to the stack of those currently being compiled.
1655+
1656+
=cut
1657+
1658+
*/
1659+
inline op nqp_push_compiling_sc(in PMC) :base_core {
1660+
VTABLE_unshift_pmc(interp, compiling_scs, $1);
1661+
}
1662+
1663+
1664+
/*
1665+
1666+
=item nqp_pop_compiling_sc()
1667+
1668+
Pops an SC off the stack of those currently being compiled.
1669+
1670+
=cut
1671+
1672+
*/
1673+
inline op nqp_pop_compiling_sc() :base_core {
1674+
VTABLE_shift_pmc(interp, compiling_scs);
1675+
}
1676+
1677+
16411678
/*
16421679

16431680
=item nqp_get_package_through_who

0 commit comments

Comments
 (0)