Skip to content

Commit 368c4c9

Browse files
author
Fabrice Le Fessant
committed
update for TON
1 parent 59cb39c commit 368c4c9

File tree

11 files changed

+29
-66
lines changed

11 files changed

+29
-66
lines changed

src/solidity-alcotest/version.mlt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ let query cmd =
1414
let commit_hash = query "git show -s --pretty=format:%H"
1515
let commit_date = query "git show -s --pretty=format:%ci"
1616
let version = "0.3.6"
17-
let version =
18-
match commit_hash with
19-
| Some commit_hash ->
20-
let commit_hash =
21-
if String.length commit_hash > 8 then
22-
String.sub commit_hash 0 8
23-
else commit_hash
24-
in
25-
Printf.sprintf "%s-%s" version commit_hash
26-
| None -> version
2717

2818
let string_option = function
2919
| None -> "None"

src/solidity-common/solidity_common.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ let add_primitive id p =
523523
begin
524524
match prim_by_id.(id) with
525525
| None -> prim_by_id.(id) <- Some p;
526-
| Some _ -> error "Primitive id already defined"
526+
| Some _ -> error "Primitive id %d already defined" id
527527
end;
528528
begin
529529
match prim_of_ident (Ident.of_string p.prim_name) with

src/solidity-common/version.mlt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ let query cmd =
1414
let commit_hash = query "git show -s --pretty=format:%H"
1515
let commit_date = query "git show -s --pretty=format:%ci"
1616
let version = "0.3.6"
17-
let version =
18-
match commit_hash with
19-
| Some commit_hash ->
20-
let commit_hash =
21-
if String.length commit_hash > 8 then
22-
String.sub commit_hash 0 8
23-
else commit_hash
24-
in
25-
Printf.sprintf "%s-%s" version commit_hash
26-
| None -> version
2717

2818
let string_option = function
2919
| None -> "None"

src/solidity-parser/solidity_lexer.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
(**************************************************************************)
1212

1313
val init : freeton:bool -> unit
14+
val init2 : ?list:(string * Solidity_raw_parser.token) list -> unit -> unit
1415

1516
val reset : unit -> unit
1617

src/solidity-parser/solidity_lexer.mll

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ and end_pragma = parse
236236

237237
{
238238
let initialized = ref false
239-
let init ~freeton =
239+
let init2 ?(list=[]) () =
240240
if not !initialized then begin
241241
initialized := true;
242242
List.iter (fun (kwd, token) ->
243243
add_keyword kwd token
244-
) [ "import", IMPORT;
244+
) ( [ "import", IMPORT;
245245
"as", AS;
246246
"from", FROM;
247247
"abstract", ABSTRACT;
@@ -312,18 +312,23 @@ let init ~freeton =
312312
"days", NUMBERUNIT (Days);
313313
"weeks", NUMBERUNIT (Weeks);
314314
"years", NUMBERUNIT (Years);
315-
];
316-
if freeton then
317-
List.iter (fun (kwd, token) ->
318-
add_keyword kwd token
319-
) [
315+
] @ list)
316+
end
317+
318+
let init ~freeton =
319+
if freeton then
320+
init2 () ~list:[
320321
"inline", INLINE;
321322
"static", STATIC;
322323
"optional", OPTIONAL;
323324
"onBounce", ONBOUNCE;
324325
"repeat", REPEAT;
325326
"responsible", RESPONSIBLE;
326327

328+
"TvmCell", TYPEABSTRACT "TvmCell";
329+
"TvmSlice", TYPEABSTRACT "TvmSlice";
330+
"TvmBuilder", TYPEABSTRACT "TvmBuilder";
331+
327332
"nano", NUMBERUNIT (Nanoton);
328333
"nanoton", NUMBERUNIT (Nanoton);
329334
"nTon", NUMBERUNIT (Nanoton);
@@ -367,7 +372,8 @@ if freeton then
367372

368373
"gigaever", NUMBERUNIT (Gigaever);
369374
"GEver", NUMBERUNIT (Gigaever);
370-
];
371-
()
372-
end
375+
]
376+
else
377+
init2 ()
378+
373379
}

src/solidity-parser/solidity_raw_parser.mly

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@
201201
| AmbiguousIdentifier l ->
202202
begin
203203
match List.map (fun id -> id.contents) l with
204-
| [ id ] when !for_freeton
204+
(* | [ id ] when !for_freeton
205205
&& ( match Ident.to_string id with
206206
| "TvmCell"
207207
| "TvmBuilder"
208208
| "TvmSlice"-> true
209209
| _ -> false ) ->
210-
ElementaryType ( TypeAbstract ( Ident.to_string id ) )
210+
ElementaryType ( TypeAbstract ( Ident.to_string id ) ) *)
211211
| list ->
212212
let contents =
213213
LongIdent.of_ident_list_rel list in
@@ -266,6 +266,7 @@
266266
%token OPTIONAL (* freeton *)
267267
%token ONBOUNCE (* freeton *)
268268
%token REPEAT (* freeton *)
269+
%token <string> TYPEABSTRACT
269270
%token PRIVATE
270271
%token EXTERNAL
271272
%token INTERNAL
@@ -977,6 +978,7 @@ elementary_type_name:
977978
| BYTES { TypeBytes ($1) }
978979
| BYTE { TypeBytes (Some 1) }
979980
| BOOL { TypeBool }
981+
| TYPEABSTRACT { TypeAbstract $1 }
980982
| INT { TypeInt (Option.value ~default:256 $1) }
981983
| UINT { TypeUint (Option.value ~default:256 $1) }
982984
| FIXED

src/solidity-parser/version.mlt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ let query cmd =
1414
let commit_hash = query "git show -s --pretty=format:%H"
1515
let commit_date = query "git show -s --pretty=format:%ci"
1616
let version = "0.3.6"
17-
let version =
18-
match commit_hash with
19-
| Some commit_hash ->
20-
let commit_hash =
21-
if String.length commit_hash > 8 then
22-
String.sub commit_hash 0 8
23-
else commit_hash
24-
in
25-
Printf.sprintf "%s-%s" version commit_hash
26-
| None -> version
2717

2818
let string_option = function
2919
| None -> "None"

src/solidity-test/version.mlt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ let query cmd =
1414
let commit_hash = query "git show -s --pretty=format:%H"
1515
let commit_date = query "git show -s --pretty=format:%ci"
1616
let version = "0.3.6"
17-
let version =
18-
match commit_hash with
19-
| Some commit_hash ->
20-
let commit_hash =
21-
if String.length commit_hash > 8 then
22-
String.sub commit_hash 0 8
23-
else commit_hash
24-
in
25-
Printf.sprintf "%s-%s" version commit_hash
26-
| None -> version
2717

2818
let string_option = function
2919
| None -> "None"

src/solidity-typechecker/solidity_tenv.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ let is_visible lookup visibility ~origin ~variable =
6464
| LStatic (Contract, false) ->
6565
false
6666
| LStatic (Contract, true) ->
67-
is_statically_visible visibility ~library:false &&
68-
not (is_inherited origin)
67+
(* Fabrice: I set ~library:true for a freeton contract in
68+
tvm.functionId(D4Auct) *)
69+
let a = is_statically_visible visibility ~library:true in
70+
let b = not (is_inherited origin) in
71+
a && b
6972
| LStatic (Library, false) ->
7073
is_statically_visible visibility ~library:true
7174
| LStatic (Library, true) -> (* i.e. call from the library itself *)

src/solidity-typechecker/solidity_typechecker.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ let unop_type pos op t : type_ =
119119
TEnum _ | TStruct _ | TContract _ |
120120
TArray _ | TFunction _), UDelete ->
121121
TTuple []
122+
| (TMapping _), UDelete when !for_freeton -> TTuple []
122123
| _, UDelete ->
123124
error_incompat ()
124125
| _, (UMinus | UNot | UInc | UDec) ->
@@ -1838,7 +1839,7 @@ let preprocess_contract_definitions cd =
18381839
begin
18391840
if is_none fd.fun_body then
18401841
error pos "Constructor must be implemented if declared";
1841-
if fd.fun_virtual then
1842+
if not !for_freeton && fd.fun_virtual then
18421843
error pos "Constructors cannot be virtual";
18431844
if not !for_freeton &&
18441845
( is_private || is_external ) then

0 commit comments

Comments
 (0)