123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openDive_typesmoduleDatatypeInput=structincludeDatatype.UndefinedopenCil_datatypetypet=node_kindlet(<?>)c(cmp,x,y)=ifc=0thencmpxyelsecletname="Node_kind"letreprs=[Scalar(List.hdVarinfo.reprs,List.hdTyp.reprs,List.hdOffset.reprs)]letcomparek1k2=matchk1,k2with|Scalar(vi1,_,offset1),Scalar(vi2,_,offset2)->Varinfo.comparevi1vi2<?>(OffsetStructEq.compare,offset1,offset2)|Scalar_,_->1|_,Scalar_->-1|Compositevi1,Compositevi2->Varinfo.comparevi1vi2|Composite_,_->1|_,Composite_->-1|Scattered(lv1,stmt1),Scattered(lv2,stmt2)->LvalStructEq.comparelv1lv2<?>(Stmt.compare,stmt1,stmt2)|Scattered_,_->1|_,Scattered_->-1|Unknown(lv1,stmt1),Unknown(lv2,stmt2)->LvalStructEq.comparelv1lv2<?>(Stmt.compare,stmt1,stmt2)|Unknown_,_->1|_,Unknown_->-1|Alarm(stmt1,alarm1),Alarm(stmt2,alarm2)->Stmt.comparestmt1stmt2<?>(Alarms.compare,alarm1,alarm2)|Alarm_,_->1|_,Alarm_->-1|AbsoluteMemory,AbsoluteMemory->0|AbsoluteMemory,_->1|_,AbsoluteMemory->-1|String(i1,_),String(i2,_)->Datatype.Int.comparei1i2|String_,_->1|_,String_->-1|Conste1,Conste2->Cil_datatype.Exp.comparee1e2|Const_,_->1|_,Const_->-1|Errors1,Errors2->Datatype.String.compares1s2letequalk1k2=matchk1,k2with|Scalar(vi1,_,offset1),Scalar(vi2,_,offset2)->Varinfo.equalvi1vi2&&OffsetStructEq.equaloffset1offset2|Compositevi1,Compositevi2->Varinfo.equalvi1vi2|Scattered(lv1,stmt1),Scattered(lv2,stmt2)->LvalStructEq.equallv1lv2&&Stmt.equalstmt1stmt2|Unknown(lv1,stmt1),Unknown(lv2,stmt2)->LvalStructEq.equallv1lv2&&Stmt.equalstmt1stmt2|Alarm(stmt1,alarm1),Alarm(stmt2,alarm2)->Stmt.equalstmt1stmt2&&Alarms.equalalarm1alarm2|AbsoluteMemory,AbsoluteMemory->true|String(i,_),String(j,_)->Datatype.Int.equalij|Conste1,Conste2->Cil_datatype.Exp.equale1e2|Errors1,Errors2->Datatype.String.equals1s2|_->falselethashk=matchkwith|Scalar(vi,_,offset)->Hashtbl.hash(1,Varinfo.hashvi,OffsetStructEq.hashoffset)|Compositevi->Hashtbl.hash(2,Varinfo.hashvi)|Scattered(lv,stmt)->Hashtbl.hash(3,LvalStructEq.hashlv,Stmt.hashstmt)|Unknown(lv,stmt)->Hashtbl.hash(4,LvalStructEq.hashlv,Stmt.hashstmt)|Alarm(stmt,alarm)->Hashtbl.hash(5,Stmt.hashstmt,Alarms.hashalarm)|AbsoluteMemory->6|String(i,_)->Hashtbl.hash(7,i)|Conste->Hashtbl.hash(8,Cil_datatype.Exp.hashe)|Errors->Hashtbl.hash(9,s)endincludeDatatype.Make(DatatypeInput)letget_base=function|Scalar(vi,_,_)|Composite(vi)->Somevi|Scattered_|Unknown_|Alarm_|AbsoluteMemory|String_|Const_|Error_->Noneletto_lval=function|Scalar(vi,_typ,offset)->Some(Cil_types.Varvi,offset)|Composite(vi)->Some(Cil_types.Varvi,Cil_types.NoOffset)|Scattered(lval,_)->Somelval|Unknown(lval,_)->Somelval|Alarm(_,_)|AbsoluteMemory|String_|Const_|Error_->Noneletprettyfmt=function|(Scalar_|Composite_|Scattered_|Unknown_)askind->Cil_printer.pp_lvalfmt(Option.get(to_lvalkind))|Alarm(_stmt,alarm)->Cil_printer.pp_predicatefmt(Alarms.create_predicatealarm)|AbsoluteMemory->Format.fprintffmt"%s"(Kernel.AbsoluteValidRange.get())|String(_,CSStrings)->Format.fprintffmt"%S"s|String(_,CSWstrings)->Format.fprintffmt"L\"%s\""(Escape.escape_wstrings)|Conste->Format.fprintffmt"%a"Cil_printer.pp_expe|Errors->Format.fprintffmt"%s"s