5 # include "splintMacros.nf"
8 void exprData_freeShallow (/*@only@*/ exprData data
, exprKind kind
)
12 if (data
== exprData_undefined
)
21 exprNode_freeShallow (data
->call
->fcn
);
22 exprNodeList_freeShallow (data
->call
->args
);
35 exprNode_freeShallow (data
->op
->a
);
36 exprNode_freeShallow (data
->op
->b
);
44 exprNode_freeShallow (data
->uop
->a
);
53 exprNode_freeShallow (data
->single
);
58 exprNode_freeShallow (data
->cast
->exp
);
59 /* NO: qtype_free (data->cast->q); */
64 exprNodeList_freeShallow (data
->itercall
->args
);
65 sfree (data
->itercall
);
69 exprNodeList_freeShallow (data
->iter
->args
);
70 exprNode_freeShallow (data
->iter
->body
);
77 exprNode_freeShallow (data
->triple
->pred
);
78 exprNode_freeShallow (data
->triple
->tbranch
);
79 exprNode_freeShallow (data
->triple
->fbranch
);
84 exprNode_freeShallow (data
->init
->exp
);
85 /* NO: idDecl_free (data->init->id); */
91 exprNode_freeShallow (data
->field
->rec
);
92 /* NO: cstring_free (data->field->field); */
115 case XPR_STRINGLITERAL
:
117 llcontbuglit ("exprData_freeShallow: not shallow!");
121 llcontbuglit ("XPR_EMPTY case!");
125 llcontbuglit ("XPR_BODY case!");
128 llcontbuglit ("XPR_NODE case!");
136 void exprData_free (/*@only@*/ exprData data
, exprKind kind
)
138 if (data
== exprData_undefined
)
147 exprNode_free (data
->call
->fcn
);
148 exprNodeList_free (data
->call
->args
);
155 cstring_free (data
->id
);
168 exprNode_free (data
->op
->a
);
169 exprNode_free (data
->op
->b
);
177 exprNode_free (data
->uop
->a
);
182 qtype_free (data
->offset
->q
);
183 cstringList_free (data
->offset
->field
);
184 sfree (data
->offset
);
189 qtype_free (data
->qt
);
199 exprNode_free (data
->single
);
204 exprNode_free (data
->cast
->exp
);
205 qtype_free (data
->cast
->q
);
210 exprNodeList_free (data
->itercall
->args
);
211 sfree (data
->itercall
);
215 exprNodeList_free (data
->iter
->args
);
216 exprNode_free (data
->iter
->body
);
223 exprNode_free (data
->triple
->pred
);
224 exprNode_free (data
->triple
->tbranch
);
225 exprNode_free (data
->triple
->fbranch
);
226 sfree (data
->triple
);
230 case XPR_STRINGLITERAL
:
232 cstring_free (data
->literal
);
246 exprNode_free (data
->init
->exp
);
247 idDecl_free (data
->init
->id
);
253 exprNode_free (data
->field
->rec
);
254 cstring_free (data
->field
->field
);
259 llcontbuglit ("XPR_EMPTY case!");
262 llcontbuglit ("XPR_BODY case!");
265 llcontbuglit ("XPR_NODE case!");
272 /*@exposed@*/ exprNode
exprData_getInitNode (exprData data
) /*@*/
274 llassert (data
!= exprData_undefined
);
275 return (data
->init
->exp
);
278 /*@exposed@*/ idDecl
exprData_getInitId (exprData data
) /*@*/
280 llassert (data
!= exprData_undefined
);
281 return (data
->init
->id
);
284 /*@exposed@*/ exprNode
exprData_getOpA (exprData data
) /*@*/
286 llassert (data
!= exprData_undefined
);
287 return (data
->op
->a
);
290 /*@exposed@*/ exprNode
exprData_getOpB (exprData data
) /*@*/
292 llassertretval (data
!= exprData_undefined
, exprNode_undefined
);
293 return (data
->op
->b
);
296 /*@observer@*/ lltok
exprData_getOpTok (exprData data
) /*@*/
298 llassert (data
!= exprData_undefined
);
299 return (data
->op
->op
);
302 /*@exposed@*/ exprNode
exprData_getPairA (exprData data
) /*@*/
304 llassertretval (data
!= exprData_undefined
, exprNode_undefined
);
305 return (data
->pair
->a
);
308 /*@exposed@*/ exprNode
exprData_getPairB (exprData data
) /*@*/
310 llassertretval (data
!= exprData_undefined
, exprNode_undefined
);
311 return (data
->pair
->b
);
314 /*@exposed@*/ uentry
exprData_getIterSname (exprData data
) /*@*/
316 llassertretval (data
!= exprData_undefined
, uentry_undefined
);
317 return (data
->iter
->sname
);
320 /*@exposed@*/ exprNodeList
exprData_getIterAlist (exprData data
) /*@*/
322 llassert (data
!= exprData_undefined
);
323 return (data
->iter
->args
);
326 /*@exposed@*/ exprNode
exprData_getIterBody (exprData data
) /*@*/
328 llassertretval (data
!= exprData_undefined
, exprNode_undefined
);
329 return (data
->iter
->body
);
332 /*@exposed@*/ uentry
exprData_getIterEname (exprData data
) /*@*/
334 llassertretval (data
!= exprData_undefined
, uentry_undefined
);
335 return (data
->iter
->ename
);
338 /*@exposed@*/ exprNode
exprData_getFcn (exprData data
) /*@*/
340 llassertretval (data
!= exprData_undefined
, exprNode_undefined
);
341 return (data
->call
->fcn
);
344 /*@exposed@*/ exprNodeList
exprData_getArgs (exprData data
) /*@*/
346 llassert (data
!= exprData_undefined
);
347 return (data
->call
->args
);
350 /*@exposed@*/ exprNode
exprData_getTriplePred (exprData data
) /*@*/
352 llassert (data
!= exprData_undefined
);
353 return (data
->triple
->pred
);
356 /*@exposed@*/ uentry
exprData_getIterCallIter (exprData data
) /*@*/
358 llassert (data
!= exprData_undefined
);
359 return (data
->itercall
->iter
);
362 /*@exposed@*/ exprNodeList
363 exprData_getIterCallArgs (exprData data
) /*@*/
365 llassert (data
!= exprData_undefined
);
366 return (data
->itercall
->args
);
369 /*@exposed@*/ exprNode
exprData_getTripleInit (exprData data
) /*@*/
371 llassert (data
!= exprData_undefined
);
372 return (data
->triple
->pred
);
375 /*@exposed@*/ exprNode
exprData_getTripleTrue (exprData data
) /*@*/
377 llassert (data
!= exprData_undefined
);
378 return (data
->triple
->tbranch
);
381 /*@exposed@*/ exprNode
exprData_getTripleTest (exprData data
) /*@*/
383 llassert (data
!= exprData_undefined
);
384 return (data
->triple
->tbranch
);
387 /*@exposed@*/ exprNode
exprData_getTripleFalse (exprData data
) /*@*/
389 llassert (data
!= exprData_undefined
);
390 return (data
->triple
->fbranch
);
393 /*@exposed@*/ exprNode
exprData_getTripleInc (exprData data
) /*@*/
395 llassert (data
!= exprData_undefined
);
396 return (data
->triple
->fbranch
);
399 /*@exposed@*/ exprNode
exprData_getFieldNode (exprData data
) /*@*/
401 llassert (data
!= exprData_undefined
);
402 return (data
->field
->rec
);
405 /*@exposed@*/ cstring
exprData_getFieldName (exprData data
) /*@*/
407 llassert (data
!= exprData_undefined
);
408 return (data
->field
->field
);
411 /*@observer@*/ lltok
exprData_getUopTok (exprData data
) /*@*/
413 llassert (data
!= exprData_undefined
);
414 return (data
->uop
->op
);
417 /*@exposed@*/ exprNode
exprData_getUopNode (exprData data
) /*@*/
419 llassert (data
!= exprData_undefined
);
420 return (data
->uop
->a
);
423 /*@exposed@*/ exprNode
exprData_getCastNode (exprData data
) /*@*/
425 llassert (data
!= exprData_undefined
);
426 return (data
->cast
->exp
);
429 /*@observer@*/ lltok
exprData_getCastTok (exprData data
) /*@*/
431 llassert (data
!= exprData_undefined
);
432 return (data
->cast
->tok
);
435 /*@exposed@*/ qtype
exprData_getCastType (exprData data
) /*@*/
437 llassert (data
!= exprData_undefined
);
438 return (data
->cast
->q
);
441 /*@exposed@*/ cstring
exprData_getLiteral (exprData data
) /*@*/
443 llassert (data
!= exprData_undefined
);
444 return (data
->literal
);
447 /*@exposed@*/ cstring
exprData_getId (exprData data
) /*@*/
449 llassert (data
!= exprData_undefined
);
453 /*@observer@*/ lltok
exprData_getTok (exprData data
) /*@*/
455 llassert (data
!= exprData_undefined
);
459 /*@exposed@*/ qtype
exprData_getType (exprData data
) /*@*/
461 llassert (data
!= exprData_undefined
);
465 /*@exposed@*/ qtype
exprData_getOffsetType (exprData data
) /*@*/
467 llassert (data
!= exprData_undefined
);
468 return (data
->offset
->q
);
471 /*@exposed@*/ cstringList
exprData_getOffsetName (exprData data
) /*@*/
473 llassert (data
!= exprData_undefined
);
474 return (data
->offset
->field
);
477 /*@exposed@*/ exprNode
exprData_getSingle (exprData data
) /*@*/
480 llassert (data
!= exprData_undefined
);
488 exprData_makeOp (/*@keep@*/ exprNode a
, /*@keep@*/ exprNode b
, /*@keep@*/ lltok op
)
490 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
492 ed
->op
= (exprOp
) dmalloc (sizeof (*ed
->op
));
500 /*@only@*/ exprData
exprData_makeUop (/*@keep@*/ exprNode a
, /*@keep@*/ lltok op
)
502 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
504 ed
->uop
= (exprUop
) dmalloc (sizeof (*ed
->uop
));
511 /*@only@*/ exprData
exprData_makeSingle (/*@only@*/ exprNode a
)
513 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
519 /*@only@*/ exprData
exprData_makeTok (/*@only@*/ lltok op
)
521 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
528 exprData_makeIter (/*@exposed@*/ uentry sname
, /*@keep@*/ exprNodeList args
,
529 /*@keep@*/ exprNode body
, /*@exposed@*/ uentry ename
)
531 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
533 ed
->iter
= (exprIter
) dmalloc (sizeof (*ed
->iter
));
534 ed
->iter
->sname
= uentry_isVar (sname
) ? uentry_copy (sname
) : sname
;
535 ed
->iter
->args
= args
;
536 ed
->iter
->body
= body
;
537 ed
->iter
->ename
= uentry_isVar (ename
) ? uentry_copy (ename
) : ename
;
541 static /*@only@*/ exprData
exprData_makeTriple (/*@keep@*/ exprNode pred
,
542 /*@keep@*/ exprNode tbranch
,
543 /*@keep@*/ exprNode fbranch
)
545 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
547 ed
->triple
= (exprTriple
) dmalloc (sizeof (*ed
->triple
));
548 ed
->triple
->pred
= pred
;
549 ed
->triple
->tbranch
= tbranch
;
550 ed
->triple
->fbranch
= fbranch
;
555 /*@only@*/ exprData
exprData_makeCall (/*@keep@*/ exprNode fcn
,
556 /*@keep@*/ exprNodeList args
)
558 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
560 ed
->call
= (exprCall
) dmalloc (sizeof (*ed
->call
));
562 ed
->call
->args
= args
;
567 /*@only@*/ exprData
exprData_makeIterCall (/*@dependent@*/ uentry iter
,
568 /*@keep@*/ exprNodeList args
)
570 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
572 ed
->itercall
= (exprIterCall
) dmalloc (sizeof (*ed
->itercall
));
573 ed
->itercall
->iter
= uentry_isVar (iter
) ? uentry_copy (iter
) : iter
;
574 ed
->itercall
->args
= args
;
579 /*@only@*/ exprData
exprData_makeField (/*@keep@*/ exprNode rec
,
580 /*@keep@*/ cstring field
)
582 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
584 ed
->field
= (exprField
) dmalloc (sizeof (*ed
->field
));
585 ed
->field
->rec
= rec
;
586 ed
->field
->field
= field
;
591 /*@only@*/ exprData
exprData_makeOffsetof (/*@only@*/ qtype q
,
592 /*@keep@*/ cstringList s
)
594 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
595 ed
->offset
= (exprOffsetof
) dmalloc (sizeof (*ed
->offset
));
598 ed
->offset
->field
= s
;
602 /*@only@*/ exprData
exprData_makeSizeofType (/*@only@*/ qtype q
)
604 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
611 exprData_makeCast (/*@keep@*/ lltok tok
, /*@keep@*/ exprNode e
, /*@only@*/ qtype q
)
613 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
615 ed
->cast
= (exprCast
) dmalloc (sizeof (*ed
->cast
));
624 exprData_makeInit (/*@keep@*/ idDecl t
, /*@keep@*/ exprNode e
)
626 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
628 ed
->init
= (exprInit
) dmalloc (sizeof (*ed
->init
));
635 /*@only@*/ exprData
exprData_makeCond (/*@keep@*/ exprNode pred
,
636 /*@keep@*/ exprNode ifclause
,
637 /*@keep@*/ exprNode elseclause
)
639 return exprData_makeTriple (pred
, ifclause
, elseclause
);
642 /*@only@*/ exprData
exprData_makeFor (/*@keep@*/ exprNode init
,
643 /*@keep@*/ exprNode pred
,
644 /*@keep@*/ exprNode inc
)
646 return exprData_makeTriple (init
, pred
, inc
);
650 /*@only@*/ exprData
exprData_makeLiteral (/*@only@*/ cstring s
)
652 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
658 /*@only@*/ exprData
exprData_makeId (/*@temp@*/ uentry id
)
660 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
661 ed
->id
= cstring_copy (uentry_rawName (id
));
665 /*@only@*/ exprData
exprData_makePair (/*@keep@*/ exprNode a
, /*@keep@*/ exprNode b
)
667 exprData ed
= (exprData
) dmalloc (sizeof (*ed
));
669 ed
->pair
= (exprPair
) dmalloc (sizeof (*ed
->pair
));