Front page | perl.perl6.internals |
Postings from July 2002
[PATCH] pmc.c
From:
Josef Höök
Date:
July 18, 2002 06:47
Subject:
[PATCH] pmc.c
Message ID:
Pine.GSO.4.21.0207181544530.24420-200000@chicken.stacken.kth.se
--- ../parrot.key.orig/pmc.c Thu Jul 18 00:37:54 2002
+++ pmc.c Thu Jul 18 15:32:20 2002
@@ -96,6 +96,41 @@
return pmc;
}
+PMC *
+pmc_new_sized_pmc(struct Parrot_Interp *interpreter,
+ INTVAL base_type, PMC *p)
+{
+ PMC *pmc = new_pmc_header(interpreter);
+
+ if (!pmc) {
+ internal_exception(ALLOCATION_ERROR,
+ "Parrot VM: PMC allocation failed!\n");
+ return NULL;
+ }
+
+ /* Ensure the PMC survives DOD during this function */
+ pmc->flags |= PMC_immune_FLAG;
+
+ pmc->vtable = &(Parrot_base_vtables[base_type]);
+
+ if (!pmc->vtable || !pmc->vtable->init_pmc) {
+ /* This is usually because you either didn't call init_world early
+ * enough or you added a new PMC class without adding
+ * Parrot_(classname)_class_init to init_world. */
+ PANIC("Null vtable used");
+ return NULL;
+ }
+
+ /* Call init_pmc with correct pmc */
+ pmc->vtable->init_pmc(interpreter, pmc, p);
+
+ /* Let the caller track this PMC */
+ pmc->flags &= ~PMC_immune_FLAG;
+ return pmc;
+}
+
+
+
/*
* Local variables:
* c-indentation-style: bsd
--- ../parrot.key.orig/include/parrot/pmc.h Thu Jul 18 00:37:54 2002
+++ include/parrot/pmc.h Thu Jul 18 15:36:28 2002
@@ -122,6 +122,9 @@
PMC *pmc_new(struct Parrot_Interp *interpreter, INTVAL base_type);
PMC *pmc_new_sized(struct Parrot_Interp *interpreter, INTVAL base_type,
INTVAL size);
+PMC *pmc_new_sized_pmc(struct Parrot_Interp *interpreter, INTVAL base_type,
+ PMC *p);
+
#endif
-
[PATCH] pmc.c
by Josef Höök