@@ -132,6 +132,37 @@ void * newstruct_Copy(blackbox*b, void *d)
132132 return (void *)lCopy_newstruct (n1);
133133}
134134
135+ // Used by newstruct_Assign for overloaded '='
136+ BOOLEAN newstruct_equal (int op, leftv l, leftv r)
137+ {
138+ blackbox *ll=getBlackboxStuff (op);
139+ assume (ll->data != NULL );
140+ newstruct_desc nt=(newstruct_desc)ll->data ;
141+ newstruct_proc p=nt->procs ;
142+
143+ while ( (p!=NULL ) && ((p->t !=' =' )||(p->args !=1 )) ) p=p->next ;
144+
145+ if (p!=NULL )
146+ {
147+ leftv sl;
148+ idrec hh;
149+ memset (&hh,0 ,sizeof (hh));
150+ hh.id =Tok2Cmdname (p->t );
151+ hh.typ =PROC_CMD;
152+ hh.data .pinf =p->p ;
153+ sleftv tmp;
154+ memset (&tmp,0 ,sizeof (sleftv));
155+ tmp.Copy (r);
156+ sl = iiMake_proc (&hh, NULL , &tmp);
157+ if (sl != NULL )
158+ {
159+ if (sl->Typ () == op) { l->Copy (sl); return FALSE ;}
160+ else sl->CleanUp ();
161+ }
162+ }
163+ return TRUE ;
164+ }
165+
135166BOOLEAN newstruct_Assign (leftv l, leftv r)
136167{
137168 if (r->Typ ()>MAX_TOK)
@@ -192,30 +223,8 @@ BOOLEAN newstruct_Assign(leftv l, leftv r)
192223 else
193224 {
194225 assume (l->Typ () > MAX_TOK);
195- blackbox *ll=getBlackboxStuff (l->Typ ());
196- newstruct_desc nt=(newstruct_desc)ll->data ;
197- assume (l->Typ () == nt->id );
198- newstruct_proc p=nt->procs ;
199-
200- while ( (p!=NULL ) && ((p->t !=' =' )||(p->args !=1 )) ) p=p->next ;
201-
202- if (p!=NULL )
203- {
204- idrec hh;
205- memset (&hh,0 ,sizeof (hh));
206- hh.id =Tok2Cmdname (p->t );
207- hh.typ =PROC_CMD;
208- hh.data .pinf =p->p ;
209- sleftv tmp;
210- memset (&tmp,0 ,sizeof (sleftv));
211- tmp.Copy (r);
212- leftv sl = iiMake_proc (&hh, NULL , &tmp);
213- if (sl != NULL )
214- {
215- if (sl->Typ ()==l->Typ ()) return newstruct_Assign (l, sl);
216- else sl->CleanUp ();
217- }
218- }
226+ sleftv tmp;
227+ if (!newstruct_equal (l->Typ (), &tmp, r)) return newstruct_Assign (l, &tmp);
219228 }
220229 Werror (" assign %s(%d) = %s(%d)" ,
221230 Tok2Cmdname (l->Typ ()),l->Typ (),Tok2Cmdname (r->Typ ()),r->Typ ());
0 commit comments