Permalink
Browse files

* lang_php/analyze/foundation/ast_php_simple.ml: use of constant_def

  • Loading branch information...
1 parent 8d76261 commit 45d863fa14f24c39ad84e8816ecde7b0e677da85 @aryx aryx committed Jul 6, 2012
@@ -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 =
@@ -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;
}
@@ -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 *)
(*****************************************************************************)
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 45d863f

Please sign in to comment.