Author: fperrad
Date: Tue Apr  3 07:12:26 2007
New Revision: 17957

Modified:
   trunk/languages/lua/pmc/luaclosure.pmc
   trunk/languages/lua/pmc/luafunction.pmc

Log:
[Lua]
- PMC clone : refactoring with using SUPER

Modified: trunk/languages/lua/pmc/luaclosure.pmc
==============================================================================
--- trunk/languages/lua/pmc/luaclosure.pmc      (original)
+++ trunk/languages/lua/pmc/luaclosure.pmc      Tue Apr  3 07:12:26 2007
@@ -69,18 +69,7 @@
 
 */
     PMC* clone() {
-        struct Parrot_sub * sub;
-        PMC* const ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
-        /*
-         * we have to mark it ourselves
-         */
-        PObj_custom_mark_destroy_SETALL(ret);
-        sub = mem_sys_allocate(sizeof (struct Parrot_sub));
-        /* first set the sub struct, string_copy may cause GC */
-        PMC_struct_val(ret) = sub;
-        PMC_pmc_val(ret) = NULL;
-        memcpy(sub, PMC_sub(SELF), sizeof (struct Parrot_sub));
-        sub->name = string_copy(INTERP, sub->name);
+        PMC* ret = SUPER();
         PMC_metadata(ret) = PMC_metadata(SELF);
         return ret;
     }

Modified: trunk/languages/lua/pmc/luafunction.pmc
==============================================================================
--- trunk/languages/lua/pmc/luafunction.pmc     (original)
+++ trunk/languages/lua/pmc/luafunction.pmc     Tue Apr  3 07:12:26 2007
@@ -70,18 +70,7 @@
 
 */
     PMC* clone() {
-        struct Parrot_sub * sub;
-        PMC* const ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
-        /*
-         * we have to mark it ourselves
-         */
-        PObj_custom_mark_destroy_SETALL(ret);
-        sub = mem_sys_allocate(sizeof (struct Parrot_sub));
-        /* first set the sub struct, string_copy may cause GC */
-        PMC_struct_val(ret) = sub;
-        PMC_pmc_val(ret) = NULL;
-        memcpy(sub, PMC_sub(SELF), sizeof (struct Parrot_sub));
-        sub->name = string_copy(INTERP, sub->name);
+        PMC* ret = SUPER();
         PMC_metadata(ret) = PMC_metadata(SELF);
         return ret;
     }

Reply via email to