Skip to content

Commit c1eafd0

Browse files
author
Fabrice Le Fessant
committed
add variable assignments to annotations
1 parent ccc3aab commit c1eafd0

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/solidity-typechecker/solidity_primitives.ml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,27 @@ open Solidity_exceptions
1717

1818
let error = type_error
1919

20+
module UTILS = struct
21+
2022
let register id p f_desc =
2123
Solidity_common.add_primitive id p;
2224
Solidity_tenv.add_primitive_desc id f_desc
2325

26+
let primitive_fun_named ?(returns_lvalue=false)
27+
arg_types ret_types function_mutability =
28+
Function { function_abs_name = LongIdent.empty;
29+
function_params = arg_types;
30+
function_returns = List.map (fun t -> (t, None)) ret_types;
31+
function_returns_lvalue = returns_lvalue;
32+
function_visibility = VPublic;
33+
function_mutability;
34+
function_override = None;
35+
function_selector = None;
36+
function_is_method = false; (* can be true *)
37+
function_is_primitive = true;
38+
function_def = None;
39+
function_assigns = [];
40+
}
2441

2542
let make_fun = Solidity_type_builder.primitive_fun
2643

@@ -47,6 +64,8 @@ let preprocess_arg_1 pos t atl_opt =
4764
error pos "Need at least 1 argument for function \
4865
call, but provided only 0"
4966

67+
end
68+
open UTILS
5069

5170
let register_primitives () =
5271

src/solidity-typechecker/solidity_primitives.mli

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,37 @@
1111
(**************************************************************************)
1212

1313
val init : unit -> unit
14+
15+
module UTILS : sig
16+
val register :
17+
int ->
18+
Solidity_common.primitive ->
19+
(Solidity_common.pos ->
20+
Solidity_checker_TYPES.options ->
21+
Solidity_checker_TYPES.type_ option ->
22+
Solidity_checker_TYPES.ident_desc option) ->
23+
unit
24+
val primitive_fun_named :
25+
?returns_lvalue:bool ->
26+
(Solidity_checker_TYPES.type_ *
27+
Solidity_common.IdentSet.elt option)
28+
list ->
29+
Solidity_checker_TYPES.type_ list ->
30+
Solidity_ast.fun_mutability -> Solidity_checker_TYPES.ident_desc
31+
32+
val make_var :
33+
Solidity_checker_TYPES.type_ -> Solidity_checker_TYPES.ident_desc
34+
val make_fun :
35+
?returns_lvalue:bool ->
36+
Solidity_checker_TYPES.type_ list ->
37+
Solidity_checker_TYPES.type_ list ->
38+
Solidity_ast.fun_mutability -> Solidity_checker_TYPES.ident_desc
39+
val make_prim_args :
40+
Solidity_common.pos ->
41+
Solidity_checker_TYPES.options ->
42+
Solidity_checker_TYPES.type_ list option
43+
val preprocess_arg_0 : 'a -> 'b list option -> 'b list
44+
val preprocess_arg_1 :
45+
Solidity_common.pos -> 'a -> 'a list option -> 'a list
46+
47+
end

0 commit comments

Comments
 (0)