@@ -332,6 +332,7 @@ let env : (string, envdata * location) H.t = H.create 307
332332(* Just like env, except that it simply collects all the information (i.e. entries
333333 * are never removed and it is also not emptied after every file). *)
334334let environment : (string, envdata * location) H.t = H. create 307
335+ let genvironment : (string, envdata * location) H.t = H. create 307
335336
336337(* We also keep a global environment. This is always a subset of the env *)
337338let genv : (string, envdata * location) H.t = H. create 307
@@ -373,7 +374,8 @@ let addGlobalToEnv (k: string) (d: envdata) : unit =
373374 H. add env k (d, ! currentLoc);
374375 H. add environment k (d, ! currentLoc);
375376 (* Also add it to the global environment *)
376- H. add genv k (d, ! currentLoc)
377+ H. add genv k (d, ! currentLoc);
378+ H. add genvironment k (d, ! currentLoc)
377379
378380
379381
@@ -6988,3 +6990,45 @@ let convFile (f : A.file) : Cil.file =
69886990 globinit = None ;
69896991 globinitcalled = false ;
69906992 }
6993+
6994+
6995+ let convStandaloneExp ~genv :genv' ~env :env' (e : A.expression ) : Cil.exp option =
6996+ Cil. initCIL () ; (* make sure we have initialized CIL *)
6997+
6998+ (* remove parentheses from the Cabs *)
6999+ let e = V. visitCabsExpression (new stripParenClass) e in
7000+
7001+ (* Clean up the global types *)
7002+ initGlobals() ;
7003+ startFile () ;
7004+ IH. clear noProtoFunctions;
7005+ H. clear compInfoNameEnv;
7006+ H. clear enumInfoNameEnv;
7007+ IH. clear mustTurnIntoDef;
7008+ H. clear alreadyDefined;
7009+ H. clear staticLocals;
7010+ H. clear typedefs;
7011+ H. clear isomorphicStructs;
7012+ annonCompFieldNameId := 0 ;
7013+ if ! E. verboseFlag || ! Cilutil. printStages then
7014+ ignore (E. log " Converting CABS->CIL\n " );
7015+
7016+ H. iter (H. add genv) genv';
7017+ H. iter (H. add env) env';
7018+
7019+ let cil_exp = doPureExp e in
7020+
7021+ IH. clear noProtoFunctions;
7022+ IH. clear mustTurnIntoDef;
7023+ H. clear alreadyDefined;
7024+ H. clear compInfoNameEnv;
7025+ H. clear enumInfoNameEnv;
7026+ H. clear isomorphicStructs;
7027+ H. clear staticLocals;
7028+ H. clear typedefs;
7029+ H. clear env;
7030+ H. clear genv;
7031+ IH. clear callTempVars;
7032+
7033+ (* We are done *)
7034+ cil_exp
0 commit comments