mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Added the return_copy macro
This commit is contained in:
parent
506a7e6136
commit
5bc26c072a
1 changed files with 28 additions and 0 deletions
|
@ -1040,6 +1040,34 @@ typedef union {
|
|||
bignum_type bignum_t;
|
||||
} common_type;
|
||||
|
||||
#define return_copy(ptr, obj) \
|
||||
{ \
|
||||
tag_type t; \
|
||||
if (is_value_type(obj)) \
|
||||
return obj; \
|
||||
t = type_of(obj); \
|
||||
if (t == boolean_tag || /* Pre-allocated */ \
|
||||
t == symbol_tag || /* Allocated in their own area */ \
|
||||
t == bignum_tag) { /* Always heap allocated */ \
|
||||
return obj; \
|
||||
} else if (t == pair_tag) { \
|
||||
((common_type *)ptr)->pair_t.hdr.mark = gc_color_red; \
|
||||
((common_type *)ptr)->pair_t.hdr.grayed = 0; \
|
||||
((common_type *)ptr)->pair_t.tag = pair_tag; \
|
||||
((common_type *)ptr)->pair_t.pair_car = car(obj); \
|
||||
((common_type *)ptr)->pair_t.pair_cdr = cdr(obj); \
|
||||
return ptr; \
|
||||
} else if (t == double_tag) { \
|
||||
((common_type *)ptr)->double_t.hdr.mark = gc_color_red; \
|
||||
((common_type *)ptr)->double_t.hdr.grayed = 0; \
|
||||
((common_type *)ptr)->double_t.tag = double_tag; \
|
||||
((common_type *)ptr)->double_t.value = double_value(obj); \
|
||||
return ptr; \
|
||||
} else { \
|
||||
return obj; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
/**@}*/
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue