2 * Copyright (c) 2018, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
12 module SN
= Naming_special_names
14 let check_param _env params p user_attributes f_type name
=
15 List.iter params
(fun param
->
16 match param
.param_callconv
with
17 | Some
Ast_defs.Pinout
->
18 let pos = param
.param_pos
in
19 if Ast_defs.(equal_fun_kind f_type FCoroutine
) then
20 Errors.inout_params_in_coroutine
pos;
21 if SSet.mem name
SN.Members.as_set
then Errors.inout_params_special
pos
24 List.find params
(fun x
->
26 Ast_defs.equal_param_kind
28 (Some
Ast_defs.Pinout
))
33 Naming_attributes.mem2
34 SN.UserAttributes.uaMemoize
35 SN.UserAttributes.uaMemoizeLSB
38 Errors.inout_params_memoize p param
.param_pos
41 let is_dynamic_call func_expr
=
43 (* regular function call, e.g. func() *)
45 (* instance method call, e.g. $x->method() *)
46 | Obj_get
(_
, (_
, Id _
), _
) -> false
47 (* static method call, e.g. Foo::method() *)
48 | Class_const
(_
, _
) -> false
52 let check_callconv_expr e
=
53 let rec check_callconv_expr_helper e1
=
57 ( String.equal
(Local_id.to_string x
) SN.SpecialIdents.this
59 (Local_id.to_string x
)
60 SN.SpecialIdents.dollardollar
) ->
62 | Array_get
(e2
, Some _
) -> check_callconv_expr_helper e2
63 | _
-> Errors.inout_argument_bad_expr
(fst e
)
65 check_callconv_expr_helper e
69 inherit Nast_visitor.handler_base
71 method! at_fun_ env f
=
72 let (p
, name
) = f
.f_name
in
73 let f_type = f
.f_fun_kind
in
74 check_param env f
.f_params p f
.f_user_attributes
f_type name
76 method! at_method_ env m
=
77 let (p
, name
) = m
.m_name
in
78 let f_type = m
.m_fun_kind
in
79 check_param env m
.m_params p m
.m_user_attributes
f_type name
81 method! at_expr _
(_
, e
) =
83 | Callconv
(_
, e
) -> check_callconv_expr e