Skip to content

Commit ccc3aab

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

File tree

5 files changed

+133
-72
lines changed

5 files changed

+133
-72
lines changed

src/solidity-common/solidity_common.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ module Ident = struct
8787
let to_string id = id
8888
let of_string id = id
8989
let printf fmt id = Format.fprintf fmt "%s" id
90-
let constructor = "#"
91-
let onBounce = "!"
92-
let receive = "@"
93-
let fallback = "*"
90+
let constructor = ":constructor"
91+
let onBounce = ":onBounce"
92+
let receive = ":receive"
93+
let fallback = ":fallback"
9494
end
9595

9696
module LongIdent = struct

src/solidity-typechecker/solidity_checker_TYPES.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ and variable_desc = {
102102
mutable variable_getter : function_desc option; (* when the variable has a getter*)
103103
variable_is_primitive : bool;
104104
variable_def : Solidity_ast.state_variable_definition option; (* module/contract*)
105+
mutable variable_assigns : function_desc list ;
105106
}
106107

107108
and function_desc = {
@@ -116,6 +117,7 @@ and function_desc = {
116117
function_is_method : bool;
117118
function_is_primitive : bool;
118119
function_def : Solidity_ast.function_definition option; (* Primitives have no definition *)
120+
mutable function_assigns : variable_desc list ;
119121
}
120122

121123
and modifier_desc = {
@@ -241,7 +243,7 @@ type options = {
241243
call_args: args option; (* could just have an in_lvalue flag *)
242244
fun_returns : type_ list;
243245
in_loop: bool;
244-
in_function: bool;
246+
in_function: function_desc option;
245247
in_modifier: bool;
246248
current_hierarchy: absolute LongIdent.t list;
247249
current_contract: contract_desc option;

src/solidity-typechecker/solidity_tenv.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ let find_constructor pos { contract_abs_name; contract_env; _ } =
194194
function_selector = None;
195195
function_is_method = true;
196196
function_is_primitive = false;
197-
function_def = None; }
197+
function_def = None;
198+
function_assigns = [];
199+
}
198200

199201
let has_abstract_function cd =
200202
let exception Found of Ident.t in

src/solidity-typechecker/solidity_type_builder.ml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ and function_type_to_desc pos env ft =
257257
function_selector = None;
258258
function_is_method = false;
259259
function_is_primitive = false;
260-
function_def = None; }
260+
function_def = None;
261+
function_assigns = [];
262+
}
261263

262264
and process_fun_params pos env ~ext params =
263265
List.map (fun (t, loc_opt, name_opt) ->
@@ -321,7 +323,9 @@ let variable_desc_to_function_desc pos vid variable_abs_name vt :
321323
function_selector;
322324
function_is_method = true;
323325
function_is_primitive = false;
324-
function_def = None; }
326+
function_def = None;
327+
function_assigns = [];
328+
}
325329

326330
(* Build the function corresponding to an event *)
327331
let event_desc_to_function_desc (ed : event_desc) : function_desc =
@@ -335,7 +339,9 @@ let event_desc_to_function_desc (ed : event_desc) : function_desc =
335339
function_selector = None;
336340
function_is_method = false;
337341
function_is_primitive = false;
338-
function_def = None; }
342+
function_def = None;
343+
function_assigns = [];
344+
}
339345

340346
(* Make a ident description for a local variable *)
341347
let local_variable_desc variable_type : variable_desc =
@@ -347,7 +353,9 @@ let local_variable_desc variable_type : variable_desc =
347353
variable_override = None;
348354
variable_getter = None;
349355
variable_is_primitive = false;
350-
variable_def = None; }
356+
variable_def = None;
357+
variable_assigns = [] ;
358+
}
351359

352360

353361

@@ -395,7 +403,9 @@ let make_variable_desc vlid vd =
395403
variable_override = None;
396404
variable_getter = None;
397405
variable_is_primitive = false;
398-
variable_def = Some (vd); }
406+
variable_def = Some (vd);
407+
variable_assigns = [] ;
408+
}
399409

400410
let update_variable_desc pos env vd kind_opt =
401411
let vd' =
@@ -428,7 +438,9 @@ let make_function_desc flid fd method_ =
428438
function_selector = None;
429439
function_is_method = method_;
430440
function_is_primitive = false;
431-
function_def = Some (fd); }
441+
function_def = Some (fd);
442+
function_assigns = [];
443+
}
432444

433445
let update_function_desc pos env fd kind_opt =
434446
let fd' =
@@ -479,7 +491,9 @@ let primitive_fun_desc ?(returns_lvalue=false)
479491
function_selector = None;
480492
function_is_method = false; (* can be true *)
481493
function_is_primitive = true;
482-
function_def = None; }
494+
function_def = None;
495+
function_assigns = [];
496+
}
483497

484498
let primitive_fun_type ?(kind=KOther) ?(returns_lvalue=false)
485499
arg_types ret_types function_mutability =
@@ -502,7 +516,9 @@ let primitive_var_desc (*?(is_lvalue=false)*) variable_type =
502516
variable_override = None;
503517
variable_getter = None;
504518
variable_is_primitive = true;
505-
variable_def = None; }
519+
variable_def = None;
520+
variable_assigns = [] ;
521+
}
506522

507523
let primitive_var (*?(is_lvalue=false)*) variable_type =
508524
let vd = primitive_var_desc variable_type in

0 commit comments

Comments
 (0)