Add poc files
This commit is contained in:
parent
30da2412e3
commit
fa600b98f7
220 changed files with 45679 additions and 0 deletions
84
h_program-lang/scope_code.ml
Normal file
84
h_program-lang/scope_code.ml
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
(* 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.
|
||||
*)
|
||||
type scope =
|
||||
| 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 *)
|
||||
(*****************************************************************************)
|
||||
|
||||
let string_of_scope = function
|
||||
| Global -> "Global"
|
||||
| Local -> "Local"
|
||||
| Param -> "Param"
|
||||
| Static -> "Static"
|
||||
| Class -> "Class"
|
||||
| LocalExn -> "LocalExn"
|
||||
| LocalIterator -> "LocalIterator"
|
||||
| ListBinded -> "ListBinded"
|
||||
| Closed -> "Closed"
|
||||
| NoScope -> "NoScope"
|
||||
|
||||
(*****************************************************************************)
|
||||
(* Meta *)
|
||||
(*****************************************************************************)
|
||||
|
||||
let vof_scope x =
|
||||
match x with
|
||||
| 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", []))
|
||||
Loading…
Add table
Add a link
Reference in a new issue