Permalink
Browse files

retab

  • Loading branch information...
1 parent 46a0d96 commit fc65b78940ceb196fe32de06b91562d062e66adb @plobsing committed Aug 7, 2010
Showing with 99 additions and 99 deletions.
  1. +99 −99 src/deepclone.winxed
View
@@ -14,17 +14,17 @@ function onload[anon, load] () {
using static nci;
var core_nci_funcs = {
- "Parrot_pmc_new_noinit" : "PJi",
- "Parrot_PMC_visit" : "vJPP",
- "Parrot_PMC_freeze" : "vJPP",
- "Parrot_PMC_thaw" : "vJPP",
- "Parrot_PMC_thawfinish" : "vJPP"
+ "Parrot_pmc_new_noinit" : "PJi",
+ "Parrot_PMC_visit" : "vJPP",
+ "Parrot_PMC_freeze" : "vJPP",
+ "Parrot_PMC_thaw" : "vJPP",
+ "Parrot_PMC_thawfinish" : "vJPP"
};
var lib = null;
for (string name in core_nci_funcs) {
- string sig = core_nci_funcs[name];
- var func = dlfunc(lib, name, sig);
- nci[name] = func;
+ string sig = core_nci_funcs[name];
+ var func = dlfunc(lib, name, sig);
+ nci[name] = func;
}
/*
@@ -35,16 +35,16 @@ function onload[anon, load] () {
*/
var my_lib = loadlib("libdeepclonehelper");
var my_nci_funcs = {
- "pmc_addr" : "iJP",
- "pmc_get_meta" : "PJP",
- "pmc_set_meta" : "vJPP",
- "pmc_typenum" : "iJP"
+ "pmc_addr" : "iJP",
+ "pmc_get_meta" : "PJP",
+ "pmc_set_meta" : "vJPP",
+ "pmc_typenum" : "iJP"
};
for (string name in my_nci_funcs) {
- string sig = my_nci_funcs[name];
- var func = dlfunc(my_lib, name, sig);
- nci[name] = func;
+ string sig = my_nci_funcs[name];
+ var func = dlfunc(my_lib, name, sig);
+ nci[name] = func;
}
}
@@ -59,121 +59,121 @@ class DeepClone {
var pmc_queue;
function set_pmc[vtable] (var orig) {
- self.todo = new 'ResizablePMCArray'();
- self.seen = new 'Hash'();
- // XXX can't create (ptr => pmc) hashes in HLLs
- // self.seen.set_key_type(Hash_key_type_ptr);
- self.seen.set_key_type(Hash_key_type_int);
- self.state = new 'Integer'();
-
- self.int_queue = new 'ResizableIntegerArray'();
- self.num_queue = new 'ResizableFloatArray'();
- self.str_queue = new 'ResizableStringArray'();
- self.pmc_queue = new 'ResizablePMCArray'();
-
- var todo = self.todo;
- ${ push todo, orig };
+ self.todo = new 'ResizablePMCArray'();
+ self.seen = new 'Hash'();
+ // XXX can't create (ptr => pmc) hashes in HLLs
+ // self.seen.set_key_type(Hash_key_type_ptr);
+ self.seen.set_key_type(Hash_key_type_int);
+ self.state = new 'Integer'();
+
+ self.int_queue = new 'ResizableIntegerArray'();
+ self.num_queue = new 'ResizableFloatArray'();
+ self.str_queue = new 'ResizableStringArray'();
+ self.pmc_queue = new 'ResizablePMCArray'();
+
+ var todo = self.todo;
+ ${ push todo, orig };
}
function get_pmc[vtable] () {
- using static nci;
-
- for (int i = 0; i < self.todo; i++) {
- var orig = self.todo[i];
- var meta = nci['pmc_get_meta'](orig);
- self.state = VISIT_FREEZE_NORMAL;
- nci['Parrot_PMC_visit'](orig, self);
- nci['Parrot_PMC_freeze'](orig, self);
- self.push_pmc(meta);
-
- int addr = nci['pmc_addr'](orig);
- var dup = self.seen[addr];
- self.state = VISIT_THAW_NORMAL;
- nci['Parrot_PMC_visit'](dup, self);
- nci['Parrot_PMC_thaw'](dup, self);
- nci['pmc_set_meta'](dup, self.shift_pmc());
- }
-
- for (int i = 0; i < self.todo; i++) {
- var dup = self.seen[nci['pmc_addr'](self.todo[i])];
- nci['Parrot_PMC_thawfinish'](dup, self);
- }
-
- return self.seen[nci['pmc_addr'](self.todo[0])];
+ using static nci;
+
+ for (int i = 0; i < self.todo; i++) {
+ var orig = self.todo[i];
+ var meta = nci['pmc_get_meta'](orig);
+ self.state = VISIT_FREEZE_NORMAL;
+ nci['Parrot_PMC_visit'](orig, self);
+ nci['Parrot_PMC_freeze'](orig, self);
+ self.push_pmc(meta);
+
+ int addr = nci['pmc_addr'](orig);
+ var dup = self.seen[addr];
+ self.state = VISIT_THAW_NORMAL;
+ nci['Parrot_PMC_visit'](dup, self);
+ nci['Parrot_PMC_thaw'](dup, self);
+ nci['pmc_set_meta'](dup, self.shift_pmc());
+ }
+
+ for (int i = 0; i < self.todo; i++) {
+ var dup = self.seen[nci['pmc_addr'](self.todo[i])];
+ nci['Parrot_PMC_thawfinish'](dup, self);
+ }
+
+ return self.seen[nci['pmc_addr'](self.todo[0])];
}
function get_integer[vtable] () {
- int i = self.state;
- return i;
+ int i = self.state;
+ return i;
}
function push_pmc[vtable] (var v) {
- using static nci;
- int addr = nci['pmc_addr'](v);
-
- var dup;
- int nullp;
- ${ isnull nullp, v };
- if (nullp) {
- dup = null;
- }
- else {
- dup = self.seen[addr];
- ${ isnull nullp, dup };
- if (nullp) {
- int i = nci['pmc_typenum'](v);
- dup = nci['Parrot_pmc_new_noinit'](i);
- self.seen[addr] = dup;
- var todo = self.todo;
- ${ push todo, v };
- }
- }
-
- var pmc_queue = self.pmc_queue;
- ${ push pmc_queue, dup };
+ using static nci;
+ int addr = nci['pmc_addr'](v);
+
+ var dup;
+ int nullp;
+ ${ isnull nullp, v };
+ if (nullp) {
+ dup = null;
+ }
+ else {
+ dup = self.seen[addr];
+ ${ isnull nullp, dup };
+ if (nullp) {
+ int i = nci['pmc_typenum'](v);
+ dup = nci['Parrot_pmc_new_noinit'](i);
+ self.seen[addr] = dup;
+ var todo = self.todo;
+ ${ push todo, v };
+ }
+ }
+
+ var pmc_queue = self.pmc_queue;
+ ${ push pmc_queue, dup };
}
function shift_pmc[vtable] () {
- var v;
- var pmc_queue = self.pmc_queue;
- ${ shift v, pmc_queue };
- return v;
+ var v;
+ var pmc_queue = self.pmc_queue;
+ ${ shift v, pmc_queue };
+ return v;
}
function push_integer[vtable] (int v) {
- var int_queue = self.int_queue;
- ${ push int_queue, v };
+ var int_queue = self.int_queue;
+ ${ push int_queue, v };
}
function shift_integer[vtable] () {
- int v;
- var int_queue = self.int_queue;
- ${ shift v, int_queue };
- return v;
+ int v;
+ var int_queue = self.int_queue;
+ ${ shift v, int_queue };
+ return v;
}
function push_float[vtable] (float v) {
- var num_queue = self.num_queue;
- ${ push num_queue, v };
+ var num_queue = self.num_queue;
+ ${ push num_queue, v };
}
function shift_float[vtable] () {
- float v;
- var num_queue = self.num_queue;
+ float v;
+ var num_queue = self.num_queue;
${ shift v, num_queue };
- return v;
+ return v;
}
function push_string[vtable] (string v) {
- var str_queue = self.str_queue;
- ${ push str_queue, v };
+ var str_queue = self.str_queue;
+ ${ push str_queue, v };
}
function shift_string[vtable] () {
- string v;
- var str_queue = self.str_queue;
- ${ shift v, str_queue };
- return v;
+ string v;
+ var str_queue = self.str_queue;
+ ${ shift v, str_queue };
+ return v;
}
}

0 comments on commit fc65b78

Please sign in to comment.