| 285 | } |
| 286 | |
| 287 | BOOLEAN newstruct_Assign(leftv l, leftv r) |
| 288 | { |
| 289 | assume(l->Typ() > MAX_TOK); |
| 290 | if (l->Typ()==r->Typ()) |
| 291 | { |
| 292 | return newstruct_Assign_same(l,r); |
| 293 | } |
| 294 | if (r->Typ()>MAX_TOK) |
| 295 | { |
| 296 | blackbox *rr=getBlackboxStuff(r->Typ()); |
| 297 | if (l->Typ()!=r->Typ()) |
| 298 | { |
| 299 | newstruct_desc rrn=(newstruct_desc)rr->data; |
| 300 | |
| 301 | if (rrn==NULL) // this is not a newstruct |
| 302 | { |
| 303 | Werror("custom type %s(%d) cannot be assigned to newstruct %s(%d)", |
| 304 | Tok2Cmdname(r->Typ()), r->Typ(), Tok2Cmdname(l->Typ()), l->Typ()); |
| 305 | return TRUE; |
| 306 | } |
| 307 | |
| 308 | // try to find a parent newstruct: |
| 309 | newstruct_desc rrp=rrn->parent; |
| 310 | while ((rrp!=NULL)&&(rrp->id!=l->Typ())) rrp=rrp->parent; |
| 311 | if (rrp!=NULL) |
| 312 | { |
| 313 | if (l->rtyp==IDHDL) |
| 314 | { |
| 315 | IDTYP((idhdl)l->data)=r->Typ(); |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | l->rtyp=r->Typ(); |
| 320 | } |
| 321 | } |
| 322 | else // unrelated types - look for custom conversion |
| 323 | { |
| 324 | sleftv tmp; |
| 325 | if (! newstruct_Op1(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp); |
| 326 | if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp); |
| 327 | } |
| 328 | } |
| 329 | if (l->Typ()==r->Typ()) |
| 330 | { |
| 331 | return newstruct_Assign_same(l,r); |
| 332 | } |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | sleftv tmp; |
| 337 | if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp); |
| 338 | } |
| 339 | Werror("assign %s(%d) = %s(%d)", |
| 340 | Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ()); |
| 341 | return TRUE; |
| 342 | } |
| 343 | |
| 344 | BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2) |
nothing calls this directly
no test coverage detected