123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102(**************************************************************************)(* *)(* 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). *)(* *)(**************************************************************************)moduleDictionary=State_builder.Hashtbl(Obfuscator_kind.Hashtbl)(Datatype.String.Hashtbl.Make(Datatype.String))(structletname="Obfuscator.Dictionary"letsize=97letdependencies=[Ast.self]end)moduleLiteral_strings=State_builder.Hashtbl(Datatype.String.Hashtbl)(Datatype.String)(structletname="Obfuscator.Literal_strings"letsize=17letdependencies=[Dictionary.self]end)letfreshkindname=leth=Dictionary.memo(fun_->Datatype.String.Hashtbl.create17)kindinletidx=Datatype.String.Hashtbl.lengthh+1inletfresh=Obfuscator_kind.prefixkind^string_of_intidxinDatatype.String.Hashtbl.addhfreshname;ifkind=Obfuscator_kind.Literal_string&¬(Literal_strings.memname)thenLiteral_strings.addnamefresh;freshletid_of_literal_string=Literal_strings.findletiter_sorted_kindfkh=ifDatatype.String.Hashtbl.lengthh>0thenletf=fkinDatatype.String.Hashtbl.iter_sortedfhletiter_sortedf=letcmpk1k2=Datatype.String.compare(Obfuscator_kind.prefixk1)(Obfuscator_kind.prefixk2)inDictionary.iter_sorted~cmp(iter_sorted_kindf)letpretty_entryfmtk=Format.fprintffmt"// %as@\n"Obfuscator_kind.prettyk;letquote=k=Obfuscator_kind.Literal_stringinfunnew_old->ifquotethenFormat.fprintffmt"#define %s %S@\n"new_oldelseFormat.fprintffmt"#define %s %s@\n"new_oldletpretty_kindfmtk=tryleth=Dictionary.findkiniter_sorted_kind(pretty_entryfmt)khwithNot_found->()letprettyfmt=Format.fprintffmt"\
/* *********************************** */@\n\
/* start of dictionary for obfuscation */@\n\
/* *********************************** */@\n";iter_sorted(funk->ifk=Obfuscator_kind.Literal_stringthenfun__->()elsepretty_entryfmtk);Format.fprintffmt"\
/*********************************** */@\n\
/* end of dictionary for obfuscation */@\n\
/*********************************** */@\n@\n"letmark_as_computed()=Dictionary.mark_as_computed()letis_computed()=Dictionary.is_computed()(*
Local Variables:
compile-command: "make -C ../../.."
End:
*)