| 1151 | =item C<PMC *clone()> |
| 1152 | |
| 1153 | Creates and returns a clone of the signature. |
| 1154 | |
| 1155 | =cut |
| 1156 | |
| 1157 | */ |
| 1158 | VTABLE PMC *clone() { |
| 1159 | struct Parrot_CallSignature_attributes *sig, *dest_sig; |
| 1160 | PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type); |
| 1161 | Pcc_cell *cell; |
| 1162 | |
| 1163 | sig = PARROT_CALLSIGNATURE(SELF); |
| 1164 | dest_sig = PARROT_CALLSIGNATURE(dest); |
| 1165 | |
| 1166 | /* Copy all positional cells (thanks to APPEND_CELL, this also |
| 1167 | * sets num_positionals). */ |
| 1168 | for (cell = sig->positionals; cell; cell = NEXT_CELL(cell)) { |
| 1169 | Pcc_cell *cloned_cell; |
| 1170 | |
| 1171 | switch (CELL_TYPE_MASK(cell)) { |
| 1172 | case INTCELL: |
| 1173 | cloned_cell = CREATE_INTVAL_CELL(INTERP); |
| 1174 | CELL_INT(cloned_cell) = CELL_INT(cell); |
| 1175 | break; |
| 1176 | case FLOATCELL: |
| 1177 | cloned_cell = CREATE_FLOATVAL_CELL(INTERP); |
| 1178 | CELL_FLOAT(cloned_cell) = CELL_FLOAT(cell); |
| 1179 | break; |
| 1180 | case STRINGCELL: |
| 1181 | cloned_cell = CREATE_STRING_CELL(INTERP); |
| 1182 | CELL_STRING(cloned_cell) = CELL_STRING(cell); |
| 1183 | break; |
| 1184 | case PMCCELL: |
| 1185 | cloned_cell = CREATE_PMC_CELL(INTERP); |
| 1186 | CELL_PMC(cloned_cell) = CELL_PMC(cell); |
| 1187 | break; |
| 1188 | } |
| 1189 | APPEND_CELL(dest, cloned_cell); |
| 1190 | } |
| 1191 | |
| 1192 | if (!PMC_IS_NULL(sig->results)) |
| 1193 | dest_sig->results = VTABLE_clone(INTERP, sig->results); |
| 1194 | |
| 1195 | if (!PMC_IS_NULL(sig->type_tuple)) |
| 1196 | dest_sig->type_tuple = VTABLE_clone(INTERP, sig->type_tuple); |
| 1197 | |
| 1198 | if (sig->short_sig) |
| 1199 | dest_sig->short_sig = Parrot_str_copy(INTERP, sig->short_sig); |
| 1200 | |
| 1201 | if (!PMC_IS_NULL(sig->arg_flags)) |
| 1202 | dest_sig->arg_flags = VTABLE_clone(INTERP, sig->arg_flags); |
| 1203 | |
| 1204 | if (!PMC_IS_NULL(sig->return_flags)) |
| 1205 | dest_sig->return_flags = VTABLE_clone(INTERP, sig->return_flags); |
| 1206 | |
| 1207 | parrot_hash_clone(INTERP, get_hash(INTERP, SELF), |
| 1208 | get_hash(INTERP, dest)); |
| 1209 | |
| 1210 | return dest; |
| 1211 | } |
| 1212 | |
| 1213 | /* |
| 1214 | |