123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384(* Yoann Padioleau
*
* Copyright (C) 2009-2010 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library 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 file
* license.txt for more details.
*)(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*
* It would be more convenient to move this file elsewhere like in analyse_xxx/
* but we want our AST to contain scope annotations so it's convenient to
* have the type definition of scope there.
*)(*****************************************************************************)(* Types *)(*****************************************************************************)(* todo? could use open polymorphic variant for that ? the scoping will
* be differerent for each language but they will also have stuff
* in common which may be a good spot for open polymorphic variant.
*)typet=|Global|Local|Param|Static|Class|LocalExn|LocalIterator(* php specific? *)|ListBinded(* closure, could be same as Local, but can be good to visually
* differentiate them in codemap
*)|Closed|NoScope(*****************************************************************************)(* String-of *)(*****************************************************************************)letstring_of_scope=function|Global->"Global"|Local->"Local"|Param->"Param"|Static->"Static"|Class->"Class"|LocalExn->"LocalExn"|LocalIterator->"LocalIterator"|ListBinded->"ListBinded"|Closed->"Closed"|NoScope->"NoScope"(*****************************************************************************)(* Meta *)(*****************************************************************************)letvof_scopex=matchxwith|Global->Ocaml.VSum(("Global",[]))|Local->Ocaml.VSum(("Local",[]))|Param->Ocaml.VSum(("Param",[]))|Static->Ocaml.VSum(("Static",[]))|Class->Ocaml.VSum(("Class",[]))|LocalExn->Ocaml.VSum(("LocalExn",[]))|LocalIterator->Ocaml.VSum(("LocalIterator",[]))|ListBinded->Ocaml.VSum(("ListBinded",[]))|Closed->Ocaml.VSum(("Closed",[]))|NoScope->Ocaml.VSum(("NoScope",[]))