| 1 |
/* |
| 2 |
* Ikarus Scheme -- A compiler for R6RS Scheme. |
| 3 |
* Copyright (C) 2006,2007,2008 Abdulaziz Ghuloum |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License version 3 as |
| 7 |
* published by the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, but |
| 10 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "ikarus-data.h" |
| 21 |
|
| 22 |
ikptr |
| 23 |
ikrt_weak_cons(ikptr a, ikptr d, ikpcb* pcb){ |
| 24 |
ikptr ap = pcb->weak_pairs_ap; |
| 25 |
ikptr nap = ap + pair_size; |
| 26 |
ikptr p; |
| 27 |
if(nap > pcb->weak_pairs_ep){ |
| 28 |
ikptr mem = ik_mmap_typed(pagesize, weak_pairs_mt, pcb); |
| 29 |
pcb->weak_pairs_ap = mem + pair_size; |
| 30 |
pcb->weak_pairs_ep = mem + pagesize; |
| 31 |
p = mem + pair_tag; |
| 32 |
} |
| 33 |
else { |
| 34 |
pcb->weak_pairs_ap = nap; |
| 35 |
p = ap + pair_tag; |
| 36 |
} |
| 37 |
ref(p, off_car) = a; |
| 38 |
ref(p, off_cdr) = d; |
| 39 |
return p; |
| 40 |
} |
| 41 |
|
| 42 |
ikptr |
| 43 |
ikrt_is_weak_pair(ikptr x, ikpcb* pcb){ |
| 44 |
if(tagof(x) != pair_tag){ |
| 45 |
return false_object; |
| 46 |
} |
| 47 |
unsigned int t = pcb->segment_vector[page_index(x)]; |
| 48 |
if((t & type_mask) == weak_pairs_type){ |
| 49 |
return true_object; |
| 50 |
} else { |
| 51 |
return false_object; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
|