MCPcopy Create free account
hub / github.com/Singular/Singular / newstruct_Assign

Function newstruct_Assign

Singular/newstruct.cc:287–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287BOOLEAN 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
344BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)

Callers

nothing calls this directly

Calls 7

newstruct_Assign_sameFunction · 0.85
getBlackboxStuffFunction · 0.85
WerrorFunction · 0.85
newstruct_Op1Function · 0.85
newstruct_Assign_userFunction · 0.85
Tok2CmdnameFunction · 0.70
TypMethod · 0.45

Tested by

no test coverage detected