Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
* lang_php/analyze/foundation/ast_php_simple.ml: use of constant_def
Browse files Browse the repository at this point in the history
  • Loading branch information
pad committed Jul 6, 2012
1 parent 8d76261 commit 45d863f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lang_php/analyze/foundation/abstract_interpreter_php.ml
Expand Up @@ -1339,9 +1339,9 @@ and build_new_ env heap pname parent self c m =
heap, ptr


and cconstants env (heap, m) ((s, tok), e) =
let heap, v = expr env heap e in
heap, SMap.add s v m
and cconstants env (heap, m) cst =
let heap, v = expr env heap cst.cst_body in
heap, SMap.add (A.unwrap cst.cst_name) v m

(* static is to indicate if we want create members for static variables. *)
and class_vars env static (heap, m) cv =
Expand Down
5 changes: 3 additions & 2 deletions lang_php/analyze/foundation/ast_php_simple.ml
Expand Up @@ -270,7 +270,7 @@ and class_def = {
(* todo: What about XHP class attributes? right now they
* are skipped at parsing time
*)
c_constants: (name * expr) list;
c_constants: constant_def list;
c_variables: class_var list;
c_methods: method_def list;
}
Expand All @@ -280,14 +280,15 @@ and class_def = {
| Interface
| Trait

and modifier = Ast_php.modifier

and class_var = {
cv_name: name;
cv_type: hint_type option;
cv_value: expr option;
cv_modifiers: modifier list;
}
and method_def = func_def
and modifier = Ast_php.modifier
(* with tarzan *)

(*****************************************************************************)
Expand Down
2 changes: 1 addition & 1 deletion lang_php/analyze/foundation/ast_php_simple_build.ml
Expand Up @@ -505,7 +505,7 @@ and class_constants env st acc =
| ClassConstants (_, cl, _) ->
List.fold_right (
fun (n, ss) acc ->
((name env n), static_scalar_affect env ss) :: acc
({A.cst_name = name env n; cst_body= static_scalar_affect env ss})::acc
) (comma_list cl) acc
| _ -> acc

Expand Down
2 changes: 1 addition & 1 deletion lang_php/analyze/foundation/dependencies_toposort_php.ml
Expand Up @@ -172,7 +172,7 @@ module Dependencies = struct
| Some (x, _) -> SSet.add x acc

and cconstants acc l = List.fold_left cconstant acc l
and cconstant acc (_, e) = expr acc e
and cconstant acc cst = expr acc cst.cst_body
and cvariables acc cvl = List.fold_left class_var acc cvl
and method_defl acc l = List.fold_left method_def acc l

Expand Down
8 changes: 1 addition & 7 deletions lang_php/analyze/foundation/meta_ast_php_simple.ml
Expand Up @@ -284,13 +284,7 @@ and
let arg = Ocaml.vof_list vof_class_var v_c_variables in
let bnd = ("c_variables", arg) in
let bnds = bnd :: bnds in
let arg =
Ocaml.vof_list
(fun (v1, v2) ->
let v1 = vof_name v1
and v2 = vof_expr v2
in Ocaml.VTuple [ v1; v2 ])
v_c_constants in
let arg = Ocaml.vof_list vof_constant_def v_c_constants in
let bnd = ("c_constants", arg) in
let bnds = bnd :: bnds in
let arg = Ocaml.vof_list vof_name v_c_implements in
Expand Down
8 changes: 6 additions & 2 deletions lang_php/analyze/foundation/typing_php.ml
Expand Up @@ -761,13 +761,17 @@ and filter_privates privates obj =
else SMap.add x t acc
) obj SMap.empty

and constant_enum is_enum cname (ien, sen) ((x, tok), e) =
and constant_enum is_enum cname (ien, sen) cst =
let x = A.unwrap cst.cst_name in
let e = cst.cst_body in
match e with
| Int _ -> SSet.add (A.unwrap cname^"::"^x) ien, sen
| String _ -> ien, SSet.add (A.unwrap cname^"::"^x) sen
| _ -> ien, sen

and constant is_enum env ien sen acc ((x, tok), e) =
and constant is_enum env ien sen acc cst =
let x = A.unwrap cst.cst_name in
let e = cst.cst_body in
match e with
| Int _ when is_enum -> SMap.add x (Tsum [Tienum ien]) acc
| String _ when is_enum -> SMap.add x (Tsum [Tsenum sen]) acc
Expand Down

0 comments on commit 45d863f

Please sign in to comment.