cvsuser 03/12/19 02:01:44
Modified: classes array.pmc closure.pmc continuation.pmc csub.pmc
intlist.pmc iterator.pmc key.pmc nci.pmc
orderedhash.pmc parrotinterpreter.pmc parrotio.pmc
parrotlibrary.pmc parrotthread.pmc perlhash.pmc
perlstring.pmc pointer.pmc retcontinuation.pmc
sarray.pmc scalar.pmc scratchpad.pmc sub.pmc
ops set.ops
src hash.c list.c objects.c
. vtable.tbl
Log:
clone - the patch
As discussed on p6i the clone vtables signature is now back again to
PMC* clone()
returning a newly created PMC of type SELF.
Patch is a bit lengthy - there are a lot of clones out in the wild.
Please make realclean ; perl Configure.pl ...
Revision Changes Path
1.76 +4 -2 parrot/classes/array.pmc
Index: array.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/array.pmc,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -w -r1.75 -r1.76
--- array.pmc 4 Dec 2003 11:50:36 -0000 1.75
+++ array.pmc 19 Dec 2003 10:01:36 -0000 1.76
@@ -1,7 +1,7 @@
/* array.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: array.pmc,v 1.75 2003/12/04 11:50:36 leo Exp $
+ * $Id: array.pmc,v 1.76 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Array base class
* Data Structure and Algorithms:
@@ -105,9 +105,11 @@
list_mark(INTERP, (List *) PMC_data(SELF));
}
- void clone (PMC *dest) {
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_SET(dest);
PMC_data(dest) = list_clone(INTERP, (List *) PMC_data(SELF));
+ return dest;
}
INTVAL get_integer () {
1.10 +4 -3 parrot/classes/closure.pmc
Index: closure.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/closure.pmc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- closure.pmc 25 Oct 2003 07:43:54 -0000 1.9
+++ closure.pmc 19 Dec 2003 10:01:36 -0000 1.10
@@ -1,7 +1,7 @@
/* Closure.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: closure.pmc,v 1.9 2003/10/25 07:43:54 leo Exp $
+ * $Id: closure.pmc,v 1.10 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Closure (subroutine) base class.
* This are subroutines which take a context structure.
@@ -39,11 +39,12 @@
return SUPER(next);
}
- void clone (PMC *ret) {
+ PMC* clone () {
struct Parrot_Sub * sub;
- SUPER(ret);
+ PMC* ret = SUPER();
sub = PMC_sub(ret);
stack_mark_cow(sub->ctx.pad_stack);
+ return ret;
}
void set_same (PMC* value) {
1.17 +4 -3 parrot/classes/continuation.pmc
Index: continuation.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/continuation.pmc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -r1.16 -r1.17
--- continuation.pmc 28 Aug 2003 08:11:05 -0000 1.16
+++ continuation.pmc 19 Dec 2003 10:01:36 -0000 1.17
@@ -1,7 +1,7 @@
/* Continuation.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: continuation.pmc,v 1.16 2003/08/28 08:11:05 leo Exp $
+ * $Id: continuation.pmc,v 1.17 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Continuation base class
* Data Structure and Algorithms:
@@ -31,12 +31,13 @@
SUPER(); /* mark pad_stack, warns in closure */
}
- void clone(PMC *ret) {
+ PMC* clone() {
struct Parrot_Sub * sub;
- SUPER(ret);
+ PMC* ret = SUPER();
sub = PMC_sub(ret);
stack_mark_cow(sub->ctx.user_stack);
stack_mark_cow(sub->ctx.control_stack);
+ return ret;
}
void* invoke (void* next) {
1.9 +4 -2 parrot/classes/csub.pmc
Index: csub.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/csub.pmc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- csub.pmc 25 Aug 2003 09:46:23 -0000 1.8
+++ csub.pmc 19 Dec 2003 10:01:36 -0000 1.9
@@ -1,7 +1,7 @@
/* CSub.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: csub.pmc,v 1.8 2003/08/25 09:46:23 leo Exp $
+ * $Id: csub.pmc,v 1.9 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the CSub base class
* Data Structure and Algorithms:
@@ -16,8 +16,10 @@
pmclass CSub {
- void clone (PMC *dest) {
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
dest->cache.struct_val = SELF->cache.struct_val;
+ return dest;
}
PMC* get_pmc () {
1.16 +4 -2 parrot/classes/intlist.pmc
Index: intlist.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/intlist.pmc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- intlist.pmc 28 Aug 2003 13:17:01 -0000 1.15
+++ intlist.pmc 19 Dec 2003 10:01:36 -0000 1.16
@@ -1,7 +1,7 @@
/* intlist.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: intlist.pmc,v 1.15 2003/08/28 13:17:01 leo Exp $
+ * $Id: intlist.pmc,v 1.16 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the IntList class
* Data Structure and Algorithms:
@@ -16,9 +16,11 @@
pmclass IntList need_ext {
- void clone (PMC *dest) {
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_SET(dest);
PMC_data(dest) = intlist_clone(INTERP, (IntList *) PMC_data(SELF));
+ return dest;
}
void init () {
1.15 +3 -2 parrot/classes/iterator.pmc
Index: iterator.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/iterator.pmc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- iterator.pmc 11 Dec 2003 07:06:16 -0000 1.14
+++ iterator.pmc 19 Dec 2003 10:01:36 -0000 1.15
@@ -1,7 +1,7 @@
/* Iterator.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: iterator.pmc,v 1.14 2003/12/11 07:06:16 petergibbs Exp $
+ * $Id: iterator.pmc,v 1.15 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Iterator base class
* Data Structure and Algorithms:
@@ -31,7 +31,8 @@
pobject_lives(INTERP, (PObj *) PMC_ptr2p(SELF));
}
- void clone (PMC* dest) {
+ PMC* clone () {
+ return SUPER();
/* XXX TODO */
}
1.15 +6 -6 parrot/classes/key.pmc
Index: key.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/key.pmc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- key.pmc 4 Dec 2003 11:50:36 -0000 1.14
+++ key.pmc 19 Dec 2003 10:01:36 -0000 1.15
@@ -1,6 +1,6 @@
/* key.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
- * CVS Info $Id: key.pmc,v 1.14 2003/12/04 11:50:36 leo Exp $
+ * CVS Info $Id: key.pmc,v 1.15 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the default PMC class
* Data Structure and Algorithms:
@@ -17,10 +17,11 @@
PObj_custom_mark_SET(SELF);
}
- void clone(PMC *dest) {
+ PMC* clone() {
+ PMC *dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PMC *dkey = dest;
PMC *key = SELF;
- PMC *p, *c;
+ PMC *p;
PObj_custom_mark_SET(dest);
for (; key ; ) {
@@ -42,9 +43,7 @@
case KEY_pmc_FLAG:
case KEY_pmc_FLAG|KEY_register_FLAG:
p = key_pmc(INTERP, key);
- c = pmc_new_noinit(INTERP, VTABLE_type(INTERP, p));
- key_set_pmc(INTERP, dkey, c);
- VTABLE_clone(INTERP, p, c);
+ key_set_pmc(INTERP, dkey, VTABLE_clone(INTERP, p));
break;
}
key = key_next(INTERP, key);
@@ -54,6 +53,7 @@
dkey = p;
}
}
+ return dest;
}
void mark () {
1.18 +4 -2 parrot/classes/nci.pmc
Index: nci.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/nci.pmc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -w -r1.17 -r1.18
--- nci.pmc 24 Oct 2003 21:33:25 -0000 1.17
+++ nci.pmc 19 Dec 2003 10:01:36 -0000 1.18
@@ -1,7 +1,7 @@
/* NCI.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: nci.pmc,v 1.17 2003/10/24 21:33:25 dan Exp $
+ * $Id: nci.pmc,v 1.18 2003/12/19 10:01:36 leo Exp $
* Overview:
* The vtable functions for the native C call functions
* Data Structure and Algorithms:
@@ -34,13 +34,15 @@
mem_sys_free(PMC_data(SELF));
}
- void clone (PMC *ret) {
+ PMC* clone () {
+ PMC* ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
ret->cache.struct_val = SELF->cache.struct_val;
/* FIXME if data is malloced (JIT/i386!) then we need
* the length of data here, to memcpy it
* ManagedStruct or Buffer?
*/
PMC_data(ret) = PMC_data(SELF);
+ return ret;
}
INTVAL defined () {
1.11 +5 -4 parrot/classes/orderedhash.pmc
Index: orderedhash.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/orderedhash.pmc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- orderedhash.pmc 5 Dec 2003 12:07:38 -0000 1.10
+++ orderedhash.pmc 19 Dec 2003 10:01:36 -0000 1.11
@@ -1,7 +1,7 @@
/* orderedhash.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: orderedhash.pmc,v 1.10 2003/12/05 12:07:38 leo Exp $
+ * $Id: orderedhash.pmc,v 1.11 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the OrderedHash base class
* Data Structure and Algorithms:
@@ -39,9 +39,10 @@
PerlHash.SUPER();
}
- void clone (PMC *dest) {
- SUPER(dest);
- PerlHash.SUPER(dest);
+ PMC* clone () {
+ PMC* dest = SUPER();
+ hash_clone(INTERP, (Hash *)PMC_ptr1v(SELF), (Hash**)&PMC_ptr1v(dest));
+ return dest;
}
PMC* get_pmc_keyed (PMC* key) {
1.16 +35 -33 parrot/classes/parrotinterpreter.pmc
Index: parrotinterpreter.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotinterpreter.pmc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- parrotinterpreter.pmc 18 Dec 2003 16:14:54 -0000 1.15
+++ parrotinterpreter.pmc 19 Dec 2003 10:01:36 -0000 1.16
@@ -1,7 +1,7 @@
/* parrotinterpreter.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: parrotinterpreter.pmc,v 1.15 2003/12/18 16:14:54 leo Exp $
+ * $Id: parrotinterpreter.pmc,v 1.16 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the ParrotInterpreter base class
* Data Structure and Algorithms:
@@ -20,6 +20,7 @@
#include "parrot/embed.h"
#include <assert.h>
+void clone_interpreter(PMC* dest, PMC* self);
/*
* copy / clone interpreter registers
* all resources are created in the destination interpreter
@@ -46,14 +47,41 @@
sp->vtable->base_type == enum_class_ParrotThread))
d->pmc_reg.registers[i] = dest;
else {
- PMC *dp = pmc_new_noinit(d, sp->vtable->base_type);
- VTABLE_clone(d, sp, dp);
+ PMC* dp = VTABLE_clone(d, sp);
d->pmc_reg.registers[i] = dp;
}
}
}
}
+void
+clone_interpreter(PMC* dest, PMC* self)
+{
+
+ Parrot_Interp s = PMC_data(self);
+ Parrot_Interp d;
+
+ d = PMC_data(dest);
+
+ /*
+ * copy register files
+ */
+ clone_regs(d, s, dest);
+ /*
+ * copy over packfile - done currently in the runinterp opcode
+ * for multi-threading we have to generate separate
+ * profile, prederef, and JIT data
+ */
+#if 0
+ pt_clone_code(d, s);
+#endif
+ /*
+ * set flags and run core
+ */
+ d->run_core = s->run_core;
+ d->flags = s->flags;
+}
+
/*
* copied from parrotio.pmc - this ought to be a global
* helper function
@@ -201,36 +229,10 @@
*
* XXX this should of course call Parrot_clone() and use freeze/thaw
*/
- void clone(PMC* dest) {
- Parrot_Interp s = PMC_data(SELF);
- Parrot_Interp d;
-
- /*
- * clone may be called internally (from thread creation in
- * ParrotThread::init_pmc() or stand-alone
- * so we check, if the interpreter is already setup
- */
- if (!PMC_data(dest))
- VTABLE_init_pmc(s, dest, SELF);
- d = PMC_data(dest);
-
- /*
- * copy register files
- */
- clone_regs(d, s, dest);
- /*
- * copy over packfile - done currently in the runinterp opcode
- * for multi-threading we have to generate separate
- * profile, prederef, and JIT data
- */
-#if 0
- pt_clone_code(d, s);
-#endif
- /*
- * set flags and run core
- */
- d->run_core = s->run_core;
- d->flags = s->flags;
+ PMC* clone() {
+ PMC* dest = pmc_new(INTERP, SELF->vtable->base_type);
+ clone_interpreter(dest, SELF);
+ return dest;
}
}
1.15 +4 -3 parrot/classes/parrotio.pmc
Index: parrotio.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotio.pmc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- parrotio.pmc 3 Dec 2003 14:43:11 -0000 1.14
+++ parrotio.pmc 19 Dec 2003 10:01:36 -0000 1.15
@@ -1,7 +1,7 @@
/* ParrotIO.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: parrotio.pmc,v 1.14 2003/12/03 14:43:11 leo Exp $
+ * $Id: parrotio.pmc,v 1.15 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for Parrot IO
* Data Structure and Algorithms:
@@ -88,13 +88,14 @@
}
}
- void clone (PMC *dest) {
- VTABLE_init(INTERP, dest);
+ PMC* clone () {
+ PMC* dest = pmc_new(INTERP, SELF->vtable->base_type);
/* For now both PMCs refer to the same ParrotIO object.
* If we have different IO layers, we might copy these structures
*/
PMC_data(dest) = PMC_data(SELF);
dest->cache.struct_val = SELF->cache.struct_val;
+ return dest;
}
INTVAL get_bool() {
1.4 +9 -9 parrot/classes/parrotlibrary.pmc
Index: parrotlibrary.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotlibrary.pmc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- parrotlibrary.pmc 17 Dec 2003 11:26:10 -0000 1.3
+++ parrotlibrary.pmc 19 Dec 2003 10:01:36 -0000 1.4
@@ -1,7 +1,7 @@
/* parrotlibrary.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: parrotlibrary.pmc,v 1.3 2003/12/17 11:26:10 leo Exp $
+ * $Id: parrotlibrary.pmc,v 1.4 2003/12/19 10:01:36 leo Exp $
* Overview:
* Class for holding info about dynamic libraries.
* Data Structure and Algorithms:
@@ -39,13 +39,13 @@
SUPER(type);
}
- void clone(PMC* dest) {
+ PMC* clone() {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
dest->cache.struct_val = SELF->cache.struct_val;
PMC_data(dest) = PMC_data(SELF);
if (SELF->metadata) {
- dest->metadata = pmc_new_noinit(INTERP,
- SELF->metadata->vtable->base_type);
- VTABLE_clone(INTERP, SELF->metadata, dest->metadata);
+ dest->metadata = VTABLE_clone(INTERP, SELF->metadata);
}
+ return dest;
}
}
1.3 +4 -3 parrot/classes/parrotthread.pmc
Index: parrotthread.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotthread.pmc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- parrotthread.pmc 18 Dec 2003 14:51:13 -0000 1.2
+++ parrotthread.pmc 19 Dec 2003 10:01:36 -0000 1.3
@@ -1,7 +1,7 @@
/* parrotthread.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: parrotthread.pmc,v 1.2 2003/12/18 14:51:13 leo Exp $
+ * $Id: parrotthread.pmc,v 1.3 2003/12/19 10:01:36 leo Exp $
* Overview:
* ParrotThread is a threaded ParrotInterpreter subclass
* Data Structure and Algorithms:
@@ -28,6 +28,7 @@
#include "parrot/embed.h"
#include <assert.h>
+void clone_interpreter(PMC* dest, PMC* self);
pmclass ParrotThread extends ParrotInterpreter need_ext {
@@ -51,7 +52,7 @@
UNLOCK(interpreter_array_mutex);
parent = VTABLE_get_pmc_keyed_int(interpreter, interpreter->iglobals,
IGLOBALS_INTERPRETER);
- VTABLE_clone(INTERP, parent, SELF);
+ clone_interpreter(SELF, parent);
}
/*
@@ -62,7 +63,7 @@
SUPER(parent);
pt_add_to_interpreters(PMC_data(parent), PMC_data(SELF));
UNLOCK(interpreter_array_mutex);
- VTABLE_clone(INTERP, parent, SELF);
+ clone_interpreter(SELF, parent);
}
}
1.64 +6 -4 parrot/classes/perlhash.pmc
Index: perlhash.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlhash.pmc,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -w -r1.63 -r1.64
--- perlhash.pmc 3 Dec 2003 12:20:37 -0000 1.63
+++ perlhash.pmc 19 Dec 2003 10:01:36 -0000 1.64
@@ -1,7 +1,7 @@
/* perlhash.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: perlhash.pmc,v 1.63 2003/12/03 12:20:37 leo Exp $
+ * $Id: perlhash.pmc,v 1.64 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the PerlHash base class
* Data Structure and Algorithms:
@@ -74,9 +74,11 @@
return VTABLE_type_keyed(INTERP, valpmc, nextkey);
}
- void clone (PMC *ret) {
- PObj_custom_mark_SET(ret);
- hash_clone(INTERP, (Hash *)PMC_ptr1v(SELF), (Hash**)&PMC_ptr1v(ret));
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ PObj_custom_mark_SET(dest);
+ hash_clone(INTERP, (Hash *)PMC_ptr1v(SELF), (Hash**)&PMC_ptr1v(dest));
+ return dest;
}
INTVAL get_integer () {
1.59 +4 -2 parrot/classes/perlstring.pmc
Index: perlstring.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlstring.pmc,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -w -r1.58 -r1.59
--- perlstring.pmc 11 Dec 2003 15:22:57 -0000 1.58
+++ perlstring.pmc 19 Dec 2003 10:01:36 -0000 1.59
@@ -1,7 +1,7 @@
/* perlstring.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: perlstring.pmc,v 1.58 2003/12/11 15:22:57 leo Exp $
+ * $Id: perlstring.pmc,v 1.59 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the PerlString base class
* Data Structure and Algorithms:
@@ -26,9 +26,11 @@
pobject_lives(INTERP, (PObj *)SELF->cache.string_val);
}
- void clone (PMC *dest) {
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_SET(dest);
dest->cache.string_val = string_copy(INTERP,SELF->cache.string_val);
+ return dest;
}
INTVAL get_integer () {
1.14 +4 -2 parrot/classes/pointer.pmc
Index: pointer.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/pointer.pmc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- pointer.pmc 4 Dec 2003 11:50:36 -0000 1.13
+++ pointer.pmc 19 Dec 2003 10:01:36 -0000 1.14
@@ -1,7 +1,7 @@
/* Pointer.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: pointer.pmc,v 1.13 2003/12/04 11:50:36 leo Exp $
+ * $Id: pointer.pmc,v 1.14 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Pointer base class
* Data Structure and Algorithms:
@@ -32,9 +32,11 @@
(*mark_function)(INTERP, PMC_data(SELF));
}
- void clone (PMC *dest) {
+ PMC* clone () {
+ PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_SET(dest);
PMC_data(dest) = PMC_data(SELF);
+ return dest;
}
INTVAL get_integer () {
1.6 +4 -2 parrot/classes/retcontinuation.pmc
Index: retcontinuation.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/retcontinuation.pmc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- retcontinuation.pmc 17 Dec 2003 17:03:41 -0000 1.5
+++ retcontinuation.pmc 19 Dec 2003 10:01:36 -0000 1.6
@@ -1,7 +1,7 @@
/* RetContinuation.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: retcontinuation.pmc,v 1.5 2003/12/17 17:03:41 leo Exp $
+ * $Id: retcontinuation.pmc,v 1.6 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the RetContinuation base class.
* Data Structure and Algorithms:
@@ -24,12 +24,14 @@
PObj_custom_mark_destroy_SETALL(SELF);
}
- void clone(PMC *ret) {
+ PMC* clone() {
struct Parrot_Sub * sub;
+ PMC* ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
sub = PMC_sub(ret) = mem_sys_allocate(sizeof(struct Parrot_Sub));
memcpy(sub, PMC_sub(SELF), sizeof(struct Parrot_Sub));
ret->cache.struct_val = SELF->cache.struct_val;
PObj_custom_mark_destroy_SETALL(ret);
+ return ret;
}
}
1.22 +6 -8 parrot/classes/sarray.pmc
Index: sarray.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/sarray.pmc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -r1.21 -r1.22
--- sarray.pmc 12 Dec 2003 08:00:08 -0000 1.21
+++ sarray.pmc 19 Dec 2003 10:01:36 -0000 1.22
@@ -1,7 +1,7 @@
/* sarray.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: sarray.pmc,v 1.21 2003/12/12 08:00:08 leo Exp $
+ * $Id: sarray.pmc,v 1.22 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the SArray base class
* Data Structure and Algorithms:
@@ -170,14 +170,14 @@
PMC_data(SELF) = NULL;
}
- void clone (PMC *dest) {
+ PMC* clone () {
HashEntry *e, *d;
int i, start, end;
INTVAL size;
- PMC * np;
+ PMC * dest = pmc_new(INTERP, SELF->vtable->base_type);
if (!PMC_data(SELF))
- return;
+ return dest;
size = SELF->cache.int_val;
dest->cache.int_val = size;
PMC_data(dest) = mem_sys_allocate_zeroed((2 + size) *
@@ -203,16 +203,14 @@
d->val.string_val = string_copy(INTERP, e->val.string_val);
break;
case enum_hash_pmc:
- np = pmc_new_noinit(interpreter,
- e->val.pmc_val->vtable->base_type);
- d->val.pmc_val = np;
- VTABLE_clone(INTERP, e->val.pmc_val, np);
+ d->val.pmc_val = VTABLE_clone(INTERP, e->val.pmc_val);
break;
default:
break;
}
}
PObj_custom_mark_destroy_SETALL(dest);
+ return dest;
}
INTVAL get_bool () {
1.14 +4 -3 parrot/classes/scalar.pmc
Index: scalar.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/scalar.pmc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- scalar.pmc 4 Dec 2003 11:50:36 -0000 1.13
+++ scalar.pmc 19 Dec 2003 10:01:36 -0000 1.14
@@ -1,7 +1,7 @@
/* scalar.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info:
- * $Id: scalar.pmc,v 1.13 2003/12/04 11:50:36 leo Exp $
+ * $Id: scalar.pmc,v 1.14 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the scalar base PMC class
* Data Structure and Algorithms:
@@ -16,9 +16,10 @@
pmclass scalar abstract noinit {
- void clone (PMC *dest) {
- VTABLE_init(INTERP, dest);
+ PMC* clone () {
+ PMC* dest = pmc_new(INTERP, SELF->vtable->base_type);
memcpy(&dest->cache, &SELF->cache, sizeof(UnionVal));
+ return dest;
}
INTVAL get_integer () {
1.15 +4 -3 parrot/classes/scratchpad.pmc
Index: scratchpad.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/scratchpad.pmc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- scratchpad.pmc 28 Aug 2003 13:17:01 -0000 1.14
+++ scratchpad.pmc 19 Dec 2003 10:01:36 -0000 1.15
@@ -1,7 +1,7 @@
/* Scratchpad.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: scratchpad.pmc,v 1.14 2003/08/28 13:17:01 leo Exp $
+ * $Id: scratchpad.pmc,v 1.15 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Scratchpad base class.
* Data Structure and Algorithms:
@@ -35,13 +35,14 @@
mem_sys_free(PMC_data(SELF));
}
- void clone (PMC *ret) {
- PObj_custom_mark_destroy_SETALL(ret);
+ PMC* clone () {
+ PMC* ret = pmc_new(INTERP, SELF->vtable->base_type);
PMC_data(ret) = mem_sys_allocate(SELF->cache.int_val *
sizeof(struct Parrot_Lexicals));
ret->cache.int_val = SELF->cache.int_val;
mem_sys_memcopy(PMC_data(ret), PMC_data(SELF),
SELF->cache.int_val * sizeof(struct Parrot_Lexicals));
+ return ret;
}
INTVAL elements () {
1.33 +4 -2 parrot/classes/sub.pmc
Index: sub.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/sub.pmc,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- sub.pmc 28 Nov 2003 12:54:52 -0000 1.32
+++ sub.pmc 19 Dec 2003 10:01:36 -0000 1.33
@@ -1,7 +1,7 @@
/* Sub.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: sub.pmc,v 1.32 2003/11/28 12:54:52 leo Exp $
+ * $Id: sub.pmc,v 1.33 2003/12/19 10:01:36 leo Exp $
* Overview:
* These are the vtable functions for the Sub (subroutine) base class
* Data Structure and Algorithms:
@@ -66,13 +66,15 @@
return SELF->cache.struct_val;
}
- void clone (PMC *ret) {
+ PMC* clone () {
struct Parrot_Sub * sub;
+ PMC* ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_destroy_SETALL(ret);
sub = PMC_sub(ret) = mem_sys_allocate(sizeof(struct Parrot_Sub));
memcpy(sub, PMC_sub(SELF), sizeof(struct Parrot_Sub));
buffer_mark_COW(sub->ctx.warns);
ret->cache.struct_val = SELF->cache.struct_val;
+ return ret;
}
void set_same (PMC* value) {
1.9 +1 -5 parrot/ops/set.ops
Index: set.ops
===================================================================
RCS file: /cvs/public/parrot/ops/set.ops,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- set.ops 31 Oct 2003 15:16:41 -0000 1.8
+++ set.ops 19 Dec 2003 10:01:40 -0000 1.9
@@ -484,11 +484,7 @@
=cut
inline op clone(out PMC, in PMC) {
- /* P6C emits clone P0, P0 */
- if (&$1 != &$2) {
- $1 = pmc_new_noinit(interpreter, $2->vtable->base_type);
- $2->vtable->clone(interpreter, $2, $1);
- }
+ $1 = VTABLE_clone(interpreter, $2);
goto NEXT();
}
1.66 +2 -4 parrot/src/hash.c
Index: hash.c
===================================================================
RCS file: /cvs/public/parrot/src/hash.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -w -r1.65 -r1.66
--- hash.c 26 Nov 2003 10:40:16 -0000 1.65
+++ hash.c 19 Dec 2003 10:01:42 -0000 1.66
@@ -1,7 +1,7 @@
/* hash.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: hash.c,v 1.65 2003/11/26 10:40:16 leo Exp $
+ * $Id: hash.c,v 1.66 2003/12/19 10:01:42 leo Exp $
* Overview:
* Data Structure and Algorithms:
* A hashtable contains an array of bucket indexes. Buckets
@@ -725,9 +725,7 @@
break;
case enum_type_PMC:
- valtmp = pmc_new_noinit(interp,
- ((PMC*)b->value)->vtable->base_type);
- VTABLE_clone(interp, (PMC*)b->value, valtmp);
+ valtmp = VTABLE_clone(interp, (PMC*)b->value);
break;
default:
1.42 +5 -9 parrot/src/list.c
Index: list.c
===================================================================
RCS file: /cvs/public/parrot/src/list.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- list.c 25 Nov 2003 13:20:37 -0000 1.41
+++ list.c 19 Dec 2003 10:01:42 -0000 1.42
@@ -3,7 +3,7 @@
* Copyright: (c) 2002 Leopold Toetsch <[EMAIL PROTECTED]>
* License: Artistic/GPL, see README and LICENSES for details
* CVS Info
- * $Id: list.c,v 1.41 2003/11/25 13:20:37 leo Exp $
+ * $Id: list.c,v 1.42 2003/12/19 10:01:42 leo Exp $
* Overview:
* list aka array routines for Parrot
* History:
@@ -1073,7 +1073,7 @@
List *l;
List_chunk *chunk, *prev, *new_chunk;
UINTVAL i;
- PMC *op, *np;
+ PMC *op;
STRING *s;
Parrot_block_DOD(interpreter);
@@ -1100,10 +1100,8 @@
for (i = 0; i < chunk->items; i++) {
op = ((PMC **)chunk->data.bufstart)[i];
if (op) {
- np = pmc_new_noinit(interpreter,
- op->vtable->base_type);
- ((PMC **)new_chunk->data.bufstart)[i] = np;
- VTABLE_clone(interpreter, op, np);
+ ((PMC **)new_chunk->data.bufstart)[i] =
+ VTABLE_clone(interpreter, op);
}
}
break;
@@ -1124,9 +1122,7 @@
}
}
if (other->user_data) {
- l->user_data = pmc_new_noinit(interpreter, enum_class_SArray);
- VTABLE_clone(interpreter, other->user_data,
- l->user_data);
+ l->user_data = VTABLE_clone(interpreter, other->user_data);
}
rebuild_chunk_list(interpreter, l);
Parrot_unblock_DOD(interpreter);
1.28 +9 -14 parrot/src/objects.c
Index: objects.c
===================================================================
RCS file: /cvs/public/parrot/src/objects.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -r1.27 -r1.28
--- objects.c 12 Dec 2003 09:36:54 -0000 1.27
+++ objects.c 19 Dec 2003 10:01:42 -0000 1.28
@@ -1,7 +1,7 @@
/* objects.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: objects.c,v 1.27 2003/12/12 09:36:54 leo Exp $
+ * $Id: objects.c,v 1.28 2003/12/19 10:01:42 leo Exp $
* Overview:
* Handles class and object manipulation
* Data Structure and Algorithms:
@@ -81,30 +81,25 @@
/* Our penultimate parent list is a clone of our parent's parent
list, with our parent unshifted onto the beginning */
- temp_pmc = pmc_new_noinit(interpreter, enum_class_Array);
+ temp_pmc =
VTABLE_clone(interpreter,
VTABLE_get_pmc_keyed_int(interpreter,
- (PMC *)PMC_data(base_class), PCD_ALL_PARENTS),
- temp_pmc);
+ (PMC *)PMC_data(base_class), PCD_ALL_PARENTS));
VTABLE_unshift_pmc(interpreter, temp_pmc, base_class);
VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ALL_PARENTS,
temp_pmc);
/* Our attribute list is our parent's attribute list */
- temp_pmc = pmc_new_noinit(interpreter, enum_class_OrderedHash);
- VTABLE_clone(interpreter,
+ temp_pmc = VTABLE_clone(interpreter,
VTABLE_get_pmc_keyed_int(interpreter,
- (PMC *)PMC_data(base_class), PCD_ATTRIB_OFFS),
- temp_pmc);
+ (PMC *)PMC_data(base_class), PCD_ATTRIB_OFFS));
VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIB_OFFS,
temp_pmc);
/* And our full keyed attribute list is our parent's */
- temp_pmc = pmc_new_noinit(interpreter, enum_class_OrderedHash);
- VTABLE_clone(interpreter,
+ temp_pmc = VTABLE_clone(interpreter,
VTABLE_get_pmc_keyed_int(interpreter,
- (PMC *)PMC_data(base_class), PCD_ATTRIBUTES),
- temp_pmc);
+ (PMC *)PMC_data(base_class), PCD_ATTRIBUTES));
VTABLE_set_pmc_keyed_int(interpreter, child_class_array, PCD_ATTRIBUTES,
temp_pmc);
1.53 +2 -2 parrot/vtable.tbl
Index: vtable.tbl
===================================================================
RCS file: /cvs/public/parrot/vtable.tbl,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -w -r1.52 -r1.53
--- vtable.tbl 3 Dec 2003 12:20:47 -0000 1.52
+++ vtable.tbl 19 Dec 2003 10:01:44 -0000 1.53
@@ -1,4 +1,4 @@
-# $Id: vtable.tbl,v 1.52 2003/12/03 12:20:47 leo Exp $
+# $Id: vtable.tbl,v 1.53 2003/12/19 10:01:44 leo Exp $
# [MAIN] #default section name
void init()
@@ -23,7 +23,7 @@
STRING* name()
-void clone(PMC* dest)
+PMC* clone()
PMC* find_method(STRING* method_name)