Skip to content

Commit

Permalink
add variable assignments to annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice Le Fessant committed Jul 27, 2021
1 parent ccc3aab commit c1eafd0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/solidity-typechecker/solidity_primitives.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ open Solidity_exceptions

let error = type_error

module UTILS = struct

let register id p f_desc =
Solidity_common.add_primitive id p;
Solidity_tenv.add_primitive_desc id f_desc

let primitive_fun_named ?(returns_lvalue=false)
arg_types ret_types function_mutability =
Function { function_abs_name = LongIdent.empty;
function_params = arg_types;
function_returns = List.map (fun t -> (t, None)) ret_types;
function_returns_lvalue = returns_lvalue;
function_visibility = VPublic;
function_mutability;
function_override = None;
function_selector = None;
function_is_method = false; (* can be true *)
function_is_primitive = true;
function_def = None;
function_assigns = [];
}

let make_fun = Solidity_type_builder.primitive_fun

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

end
open UTILS

let register_primitives () =

Expand Down
34 changes: 34 additions & 0 deletions src/solidity-typechecker/solidity_primitives.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,37 @@
(**************************************************************************)

val init : unit -> unit

module UTILS : sig
val register :
int ->
Solidity_common.primitive ->
(Solidity_common.pos ->
Solidity_checker_TYPES.options ->
Solidity_checker_TYPES.type_ option ->
Solidity_checker_TYPES.ident_desc option) ->
unit
val primitive_fun_named :
?returns_lvalue:bool ->
(Solidity_checker_TYPES.type_ *
Solidity_common.IdentSet.elt option)
list ->
Solidity_checker_TYPES.type_ list ->
Solidity_ast.fun_mutability -> Solidity_checker_TYPES.ident_desc

val make_var :
Solidity_checker_TYPES.type_ -> Solidity_checker_TYPES.ident_desc
val make_fun :
?returns_lvalue:bool ->
Solidity_checker_TYPES.type_ list ->
Solidity_checker_TYPES.type_ list ->
Solidity_ast.fun_mutability -> Solidity_checker_TYPES.ident_desc
val make_prim_args :
Solidity_common.pos ->
Solidity_checker_TYPES.options ->
Solidity_checker_TYPES.type_ list option
val preprocess_arg_0 : 'a -> 'b list option -> 'b list
val preprocess_arg_1 :
Solidity_common.pos -> 'a -> 'a list option -> 'a list

end

0 comments on commit c1eafd0

Please sign in to comment.