package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file scope_code.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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 t = 
  | 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", []))
OCaml

Innovation. Community. Security.