[svn:parrot] r41108 - trunk/src/pmc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Mon Sep 7 12:34:54 UTC 2009
Author: whiteknight
Date: Mon Sep 7 12:34:51 2009
New Revision: 41108
URL: https://trac.parrot.org/parrot/changeset/41108
Log:
[pmc] lots of misc cleanups for some PMC types that have been affected by recent branch merges. Convert ParrotRunningThread to use auto_attrs
Modified:
trunk/src/pmc/continuation.pmc
trunk/src/pmc/eventhandler.pmc
trunk/src/pmc/exceptionhandler.pmc
trunk/src/pmc/parrotrunningthread.pmc
trunk/src/pmc/sub.pmc
trunk/src/pmc/task.pmc
trunk/src/pmc/timer.pmc
Modified: trunk/src/pmc/continuation.pmc
==============================================================================
--- trunk/src/pmc/continuation.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/continuation.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -47,15 +47,15 @@
pmclass Continuation auto_attrs {
/* continuation destination */
- ATTR PackFile_ByteCode *seg; /* bytecode segment */
- ATTR opcode_t *address; /* start of bytecode, addr to continue */
- ATTR PMC *to_ctx; /* pointer to dest context */
+ ATTR PackFile_ByteCode *seg; /* bytecode segment */
+ ATTR opcode_t *address; /* start of bytecode, addr to continue */
+ ATTR PMC *to_ctx; /* pointer to dest context */
/* a Continuation keeps the from_ctx alive */
- ATTR PMC *from_ctx; /* sub, this cont is returning from */
- ATTR opcode_t *current_results; /* ptr into code with get_results opcode
- full continuation only */
- ATTR int runloop_id; /* id of the creating runloop. */
- ATTR int invoked; /* flag when a handler has been invoked. */
+ ATTR PMC *from_ctx; /* sub, this cont is returning from */
+ ATTR opcode_t *current_results; /* ptr into code with get_results opcode
+ full continuation only */
+ ATTR int runloop_id; /* id of the creating runloop. */
+ ATTR int invoked; /* flag when a handler has been invoked. */
/*
=item C<void init()>
@@ -127,7 +127,7 @@
*/
VTABLE void mark() {
- Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF);
+ Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
if (cc->seg)
Parrot_gc_mark_PObj_alive(interp, (PObj *)cc->seg);
@@ -148,7 +148,9 @@
*/
VTABLE PMC *clone() {
- PMC * ret = pmc_new_init(interp, enum_class_Continuation, SELF);
+ /* Start to prepare for subclassable continuations */
+ INTVAL type = SELF->vtable->base_type;
+ PMC * ret = pmc_new_init(interp, type, SELF);
return ret;
}
@@ -179,11 +181,11 @@
*/
VTABLE void set_pointer(void *value) {
- opcode_t * const pos = (opcode_t *)value;
+ opcode_t * const pos = (opcode_t *)value;
Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
- cc->address = (opcode_t *)value;
- cc->runloop_id = INTERP->current_runloop_id;
+ cc->address = pos;
+ cc->runloop_id = INTERP->current_runloop_id;
if (pos && (*pos == PARROT_OP_get_results_pc))
cc->current_results = pos;
@@ -204,6 +206,7 @@
VTABLE void *get_pointer() {
return PARROT_CONTINUATION(SELF)->address;
}
+
/*
=item C<INTVAL defined()>
@@ -303,11 +306,11 @@
METHOD caller() {
Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF);
PMC *caller = Parrot_pcc_get_sub(interp, cc->to_ctx);
- Parrot_Sub_attributes *sub;
if (!caller)
caller = PMCNULL;
else {
+ Parrot_Sub_attributes *sub;
PMC_get_sub(INTERP, caller, sub);
if (!sub->seg)
caller = PMCNULL;
Modified: trunk/src/pmc/eventhandler.pmc
==============================================================================
--- trunk/src/pmc/eventhandler.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/eventhandler.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -120,7 +120,7 @@
*/
VTABLE void mark() {
- Parrot_EventHandler_attributes *e = PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e) {
if (e->type)
@@ -147,7 +147,7 @@
*/
VTABLE void set_string(STRING *type) {
- Parrot_EventHandler_attributes *e = PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e)
e->type = type;
@@ -164,8 +164,7 @@
*/
VTABLE STRING *get_string() {
- Parrot_EventHandler_attributes *e =
- PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e)
return Parrot_str_copy(INTERP, e->type);
@@ -183,7 +182,7 @@
*/
VTABLE void set_integer_native(INTVAL priority) {
- Parrot_EventHandler_attributes *e = PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e)
e->priority = priority;
@@ -200,8 +199,7 @@
*/
VTABLE void set_pmc(PMC *interpreter) {
- Parrot_EventHandler_attributes *e =
- PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
if (e)
e->interp = interpreter;
@@ -216,12 +214,11 @@
*/
VTABLE PMC *get_attr_str(STRING *name) {
- Parrot_EventHandler_attributes *core_struct
- = PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
PMC *value = PMCNULL;
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "code"))) {
- value = core_struct->code;
+ value = e->code;
}
return value;
@@ -237,8 +234,8 @@
*/
VTABLE opcode_t *invoke(void *next) {
- Parrot_EventHandler_attributes *e = PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
- void *unused;
+ Parrot_EventHandler_attributes * const e = PARROT_EVENTHANDLER(SELF);
+ void *unused;
/* can't invoke on INTERP and can't return its result; this may not be
* the right interpreter */
@@ -274,8 +271,7 @@
*/
METHOD can_handle(PMC *event) {
- Parrot_EventHandler_attributes *handler_struct =
- PMC_data_typed(SELF, Parrot_EventHandler_attributes *);
+ Parrot_EventHandler_attributes * const handler_struct = PARROT_EVENTHANDLER(SELF);
if (event->vtable->base_type == enum_class_Task) {
PMC *type = VTABLE_get_attr_str(interp, event, CONST_STRING(interp, "type"));
STRING *type_str = VTABLE_get_string(interp, type);
Modified: trunk/src/pmc/exceptionhandler.pmc
==============================================================================
--- trunk/src/pmc/exceptionhandler.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/exceptionhandler.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -40,13 +40,12 @@
*/
VTABLE void init() {
- Parrot_ExceptionHandler_attributes * const attrs =
- (Parrot_ExceptionHandler_attributes *)PMC_data(SELF);
+ Parrot_ExceptionHandler_attributes * const attrs = PARROT_EXCEPTIONHANDLER(SELF);
SUPER();
- attrs->invoked = 0;
- attrs->min_severity = 0;
- attrs->max_severity = 0;
- attrs->handled_types = PMCNULL;
+ attrs->invoked = 0;
+ attrs->min_severity = 0;
+ attrs->max_severity = 0;
+ attrs->handled_types = PMCNULL;
attrs->handled_types_except = PMCNULL;
/* an exception handler has no separate context; it's only a snapshot
@@ -75,8 +74,7 @@
SUPER();
}
- VTABLE void destroy(){
-
+ VTABLE void destroy() {
Parrot_ExceptionHandler_attributes *attrs = PARROT_EXCEPTIONHANDLER(SELF);
if (attrs->handled_types){
@@ -90,6 +88,7 @@
VTABLE PMC *clone() {
PMC * const result = SUPER();
+ /* This looks wrong, why wouldn't we want to mark the clone? */
PObj_custom_mark_CLEAR(result);
return result;
}
Modified: trunk/src/pmc/parrotrunningthread.pmc
==============================================================================
--- trunk/src/pmc/parrotrunningthread.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/parrotrunningthread.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -30,9 +30,9 @@
#include "parrot/embed.h"
-#define PMC_tid(x) ((Parrot_ParrotRunningThread_attributes *)PMC_data(x))->tid
+#define PMC_tid(x) (PARROT_PARROTRUNNINGTHREAD(x))->tid
-pmclass ParrotRunningThread no_ro {
+pmclass ParrotRunningThread no_ro auto_attrs {
ATTR INTVAL tid; /* thread id */
/*
@@ -46,30 +46,13 @@
*/
VTABLE void init() {
- Parrot_ParrotRunningThread_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_ParrotRunningThread_attributes);
+ Parrot_ParrotRunningThread_attributes *attrs = PARROT_PARROTRUNNINGTHREAD(SELF);
attrs->tid = -1;
- PMC_data(SELF) = attrs;
PObj_custom_destroy_SET(SELF);
}
/*
-=item C<void destroy()>
-
-Destroy this PMC.
-
-=cut
-
-*/
-
- VTABLE void destroy() {
- mem_sys_free(PMC_data(SELF));
- PMC_data(SELF) = NULL;
- }
-
-/*
-
=item C<void init_pmc(PMC *tid)>
Create a new running thread referring to the thread with
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/sub.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -463,7 +463,7 @@
*/
VTABLE void mark() {
- Parrot_Sub_attributes *sub = PARROT_SUB(SELF);
+ Parrot_Sub_attributes * const sub = PARROT_SUB(SELF);
if (!sub)
return;
@@ -671,13 +671,13 @@
{
/* Create a hash, then use inspect_str to get all of the data to
* fill it up with. */
- PMC * const metadata = pmc_new(interp, enum_class_Hash);
- STRING * const pos_required_str = CONST_STRING(interp, "pos_required");
- STRING * const pos_optional_str = CONST_STRING(interp, "pos_optional");
+ PMC * const metadata = pmc_new(interp, enum_class_Hash);
+ STRING * const pos_required_str = CONST_STRING(interp, "pos_required");
+ STRING * const pos_optional_str = CONST_STRING(interp, "pos_optional");
STRING * const named_required_str = CONST_STRING(interp, "named_required");
STRING * const named_optional_str = CONST_STRING(interp, "named_optional");
- STRING * const pos_slurpy_str = CONST_STRING(interp, "pos_slurpy");
- STRING * const named_slurpy_str = CONST_STRING(interp, "named_slurpy");
+ STRING * const pos_slurpy_str = CONST_STRING(interp, "pos_slurpy");
+ STRING * const named_slurpy_str = CONST_STRING(interp, "named_slurpy");
VTABLE_set_pmc_keyed_str(interp, metadata, pos_required_str,
VTABLE_inspect_str(interp, SELF, pos_required_str));
Modified: trunk/src/pmc/task.pmc
==============================================================================
--- trunk/src/pmc/task.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/task.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -43,8 +43,7 @@
*/
VTABLE void init() {
- Parrot_Task_attributes * const core_struct =
- (Parrot_Task_attributes *) PMC_data(SELF);
+ Parrot_Task_attributes * const core_struct = PARROT_TASK(SELF);
/* Set flags for custom GC mark. */
PObj_custom_mark_SET(SELF);
@@ -285,7 +284,7 @@
*/
VTABLE INTVAL get_integer() {
- const Parrot_Task_attributes * const core_struct = PARROT_TASK(SELF);
+ Parrot_Task_attributes * const core_struct = PARROT_TASK(SELF);
return core_struct->id;
}
Modified: trunk/src/pmc/timer.pmc
==============================================================================
--- trunk/src/pmc/timer.pmc Mon Sep 7 12:04:57 2009 (r41107)
+++ trunk/src/pmc/timer.pmc Mon Sep 7 12:34:51 2009 (r41108)
@@ -58,10 +58,10 @@
#include "parrot/scheduler_private.h"
pmclass Timer extends Task provides event auto_attrs {
- ATTR FLOATVAL duration; /* The duration of the timer pause */
- ATTR FLOATVAL interval; /* How often to repeat */
- ATTR INTVAL repeat; /* Whether to repeat:
- * 0 = run once (no repeat), -1 = forever */
+ ATTR FLOATVAL duration; /* The duration of the timer pause */
+ ATTR FLOATVAL interval; /* How often to repeat */
+ ATTR INTVAL repeat; /* Whether to repeat:
+ * 0 = run once (no repeat), -1 = forever */
/*
@@ -74,8 +74,7 @@
*/
VTABLE void init() {
- Parrot_Timer_attributes * const core_struct =
- (Parrot_Timer_attributes *) PMC_data(SELF);
+ Parrot_Timer_attributes * const core_struct = PARROT_TIMER(SELF);
/* Set flags for custom GC mark and destroy. */
PObj_custom_mark_SET(SELF);
@@ -155,7 +154,7 @@
*/
VTABLE PMC *clone() {
- PMC * const copy = SUPER();
+ PMC * const copy = SUPER();
Parrot_Timer_attributes * const new_struct = PARROT_TIMER(copy);
Parrot_Timer_attributes * const old_struct = PARROT_TIMER(SELF);
@@ -240,7 +239,7 @@
*/
VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
- const Parrot_Timer_attributes * const core_struct = PARROT_TIMER(SELF);
+ Parrot_Timer_attributes * const core_struct = PARROT_TIMER(SELF);
switch (key) {
case PARROT_TIMER_NSEC:
More information about the parrot-commits
mailing list