Skip to content

Commit

Permalink
Merge pull request #13 from lefessan/z-2021-06-15-solidity-for-freeton
Browse files Browse the repository at this point in the history
v0.3.2 with fewer for_freeton
  • Loading branch information
lefessan authored Jul 22, 2021
2 parents 0e42132 + e6576b4 commit 42ad735
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 81 deletions.
28 changes: 14 additions & 14 deletions .drom
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# hash of toml configuration files
# used for generation of all files
0c9d153828991ed03dadaee3e6e912de:.
bb15025d460dd55499bf2bc9c5f0999d:.
# end context for .

# begin context for .github/workflows/doc-deploy.yml
Expand Down Expand Up @@ -37,7 +37,7 @@ a8d1bcd6f62c6b813b77d3ff8959d8d2:.ocamlformat-ignore

# begin context for CHANGES.md
# file CHANGES.md
873ca123aaa4f12aedad55595c52d1ea:CHANGES.md
d56aaadd8e0fec3ee5e644de78212d04:CHANGES.md
# end context for CHANGES.md

# begin context for LICENSE.md
Expand Down Expand Up @@ -97,12 +97,12 @@ c8281f46ba9a11d0b61bc8ef67eaa357:docs/style.css

# begin context for dune-project
# file dune-project
b877b563b3a1da795b26be4319d5dcc2:dune-project
541e00af0f32fd619fcb9aca4e3ade30:dune-project
# end context for dune-project

# begin context for ez_hash.opam
# file ez_hash.opam
62344d70f0815962091e077cca95a645:ez_hash.opam
adc64b244d25333acc55f7c38036f253:ez_hash.opam
# end context for ez_hash.opam

# begin context for scripts/after.sh
Expand All @@ -122,27 +122,27 @@ bb3a9d286f0dc64021db4194427263ee:scripts/copy-bin.sh

# begin context for solidity-alcotest.opam
# file solidity-alcotest.opam
54623069b08f8d7342d62e5d21abf615:solidity-alcotest.opam
f958c6503f3651e8e4859f3ee7763c9a:solidity-alcotest.opam
# end context for solidity-alcotest.opam

# begin context for solidity-common.opam
# file solidity-common.opam
42a80a0071000e29f533534d2e640113:solidity-common.opam
f10218980e927b8cd0b2487e7f3de7b7:solidity-common.opam
# end context for solidity-common.opam

# begin context for solidity-parser.opam
# file solidity-parser.opam
c105f5cd63f7bdc137cacd90655d3960:solidity-parser.opam
f5ff692dad3f98ac6ac96d1a29e88b8f:solidity-parser.opam
# end context for solidity-parser.opam

# begin context for solidity-test.opam
# file solidity-test.opam
386c907f168ab33fb2489810d9b8321d:solidity-test.opam
133ababf9254e0141d3ef6f8fa311667:solidity-test.opam
# end context for solidity-test.opam

# begin context for solidity-typechecker.opam
# file solidity-typechecker.opam
4675cef4797ec67b1c5959d5973396db:solidity-typechecker.opam
26a81559f44a76a7b2612c2e4fce13f4:solidity-typechecker.opam
# end context for solidity-typechecker.opam

# begin context for sphinx/_static/css/fixes.css
Expand Down Expand Up @@ -197,7 +197,7 @@ e86f9a67236dac57aaae3ca819cb7dbb:src/ocaml-solidity/package.toml

# begin context for src/solidity-alcotest/version.mlt
# file src/solidity-alcotest/version.mlt
47d835b1b3ec0a463928fd2af319b6c0:src/solidity-alcotest/version.mlt
4857ca979c211e298734d127807f6a09:src/solidity-alcotest/version.mlt
# end context for src/solidity-alcotest/version.mlt

# begin context for src/solidity-common/dune
Expand All @@ -217,7 +217,7 @@ e86f9a67236dac57aaae3ca819cb7dbb:src/ocaml-solidity/package.toml

# begin context for src/solidity-common/version.mlt
# file src/solidity-common/version.mlt
47d835b1b3ec0a463928fd2af319b6c0:src/solidity-common/version.mlt
4857ca979c211e298734d127807f6a09:src/solidity-common/version.mlt
# end context for src/solidity-common/version.mlt

# begin context for src/solidity-parser/dune
Expand All @@ -237,7 +237,7 @@ be413a351ddaf3cdf0d44e91ad35680e:src/solidity-parser/main.ml

# begin context for src/solidity-parser/version.mlt
# file src/solidity-parser/version.mlt
47d835b1b3ec0a463928fd2af319b6c0:src/solidity-parser/version.mlt
4857ca979c211e298734d127807f6a09:src/solidity-parser/version.mlt
# end context for src/solidity-parser/version.mlt

# begin context for src/solidity-test/dune
Expand All @@ -247,7 +247,7 @@ be413a351ddaf3cdf0d44e91ad35680e:src/solidity-parser/main.ml

# begin context for src/solidity-test/version.mlt
# file src/solidity-test/version.mlt
47d835b1b3ec0a463928fd2af319b6c0:src/solidity-test/version.mlt
4857ca979c211e298734d127807f6a09:src/solidity-test/version.mlt
# end context for src/solidity-test/version.mlt

# begin context for src/solidity-typechecker/dune
Expand All @@ -267,5 +267,5 @@ be413a351ddaf3cdf0d44e91ad35680e:src/solidity-parser/main.ml

# begin context for src/solidity-typechecker/version.mlt
# file src/solidity-typechecker/version.mlt
47d835b1b3ec0a463928fd2af319b6c0:src/solidity-typechecker/version.mlt
4857ca979c211e298734d127807f6a09:src/solidity-typechecker/version.mlt
# end context for src/solidity-typechecker/version.mlt
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

## v0.1.0 ( 2021-07-20 )
## v0.1.0 ( 2021-07-22 )

* Initial commit
2 changes: 1 addition & 1 deletion drom.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license = "LGPL2"
min-edition = "4.08.0"
name = "ocaml-solidity"
synopsis = "The ocaml-solidity project"
version = "0.3.1"
version = "0.3.2"

# keys that you could also define:
# odoc-target = "...odoc-target..."
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(name ocaml-solidity)
(allow_approximate_merlin)
(generate_opam_files false)
(version 0.3.1)
(version 0.3.2)
(formatting (enabled_for ocaml reason))
(using menhir 2.0)

Expand Down
2 changes: 1 addition & 1 deletion ez_hash.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "ez_hash"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "Hash functions: sha3, sha256, blake2b"
description: """
Expand Down
2 changes: 1 addition & 1 deletion solidity-alcotest.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "solidity-alcotest"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "The ocaml-solidity project"
description: """
Expand Down
2 changes: 1 addition & 1 deletion solidity-common.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "solidity-common"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "The ocaml-solidity project"
description: """
Expand Down
2 changes: 1 addition & 1 deletion solidity-parser.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "solidity-parser"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "The ocaml-solidity project"
description: """
Expand Down
2 changes: 1 addition & 1 deletion solidity-test.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "solidity-test"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "The ocaml-solidity project"
description: """
Expand Down
2 changes: 1 addition & 1 deletion solidity-typechecker.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify, or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "solidity-typechecker"
version: "0.3.1"
version: "0.3.2"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis: "The ocaml-solidity project"
description: """
Expand Down
2 changes: 1 addition & 1 deletion src/solidity-alcotest/version.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let query cmd =

let commit_hash = query "git show -s --pretty=format:%H"
let commit_date = query "git show -s --pretty=format:%ci"
let version = "0.3.1"
let version = "0.3.2"
let version =
match commit_hash with
| Some commit_hash ->
Expand Down
6 changes: 3 additions & 3 deletions src/solidity-common/solidity_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ let string_of_pos (file, pos1, pos2) =
Buffer.contents b
with _ -> ""
in
Printf.sprintf "%s:%d-%d:%d-%d"
Printf.sprintf "%s:%d.%d-%d.%d"
file
(fst pos1) (snd pos1)
(fst pos2) (snd pos2),
(fst pos1) (snd pos1+1)
(fst pos2) (snd pos2+1),
source

let set_annot n annot =
Expand Down
4 changes: 2 additions & 2 deletions src/solidity-common/solidity_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ and variable_definition b indent ~freeton {
var_mutability; var_override; var_init;
var_static } =
bprint b indent
(Format.sprintf "%s%s%s %s%s%s%s%s"
(Format.sprintf "%s%s%s%s %s%s%s%s"
(string_of_type var_type)
(if var_static then " static" else "")
(if freeton then
Expand All @@ -266,10 +266,10 @@ and variable_definition b indent ~freeton {
| m -> " " ^ (string_of_var_mutability m)
else ""
)
(string_of_ident var_name)
(match var_visibility with
| VInternal -> ""
| v -> " " ^ (string_of_visibility v))
(string_of_ident var_name)
(if freeton then ""
else
match var_mutability with
Expand Down
2 changes: 1 addition & 1 deletion src/solidity-common/version.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let query cmd =

let commit_hash = query "git show -s --pretty=format:%H"
let commit_date = query "git show -s --pretty=format:%ci"
let version = "0.3.1"
let version = "0.3.2"
let version =
match commit_hash with
| Some commit_hash ->
Expand Down
2 changes: 1 addition & 1 deletion src/solidity-parser/version.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let query cmd =

let commit_hash = query "git show -s --pretty=format:%H"
let commit_date = query "git show -s --pretty=format:%ci"
let version = "0.3.1"
let version = "0.3.2"
let version =
match commit_hash with
| Some commit_hash ->
Expand Down
2 changes: 1 addition & 1 deletion src/solidity-test/version.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let query cmd =

let commit_hash = query "git show -s --pretty=format:%H"
let commit_date = query "git show -s --pretty=format:%ci"
let version = "0.3.1"
let version = "0.3.2"
let version =
match commit_hash with
| Some commit_hash ->
Expand Down
2 changes: 2 additions & 0 deletions src/solidity-typechecker/solidity_checker_TYPES.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ and fun_kind =
| KOther
| KNewContract
| KExtContractFun
| KReturn

and function_options = {
kind : fun_kind;
value : bool;
gas : bool;
salt : bool;
fields : StringSet.t ;
}

and location =
Expand Down
3 changes: 2 additions & 1 deletion src/solidity-typechecker/solidity_type_builder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ let compute_selector pos ~library id args =
Bytes.to_string (Bytes.sub (sha3kec (Bytes.of_string fun_sig)) 0 4)

let new_fun_options = {
kind = KOther; value = false; gas = false; salt = false
kind = KOther; value = false; gas = false; salt = false ;
fields = StringSet.empty ;
}

let eval_array_length_exp env e =
Expand Down
58 changes: 11 additions & 47 deletions src/solidity-typechecker/solidity_typechecker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ let type_ident opt env base_t_opt id_node =
set_annot id_node a;
t, lv


let type_options_ref = ref ( fun _ -> assert false )

let type_options opt env pos is_payable fo opts =
!type_options_ref opt env pos is_payable fo opts

let rec type_expression opt env exp : type_ =
let t, _lv = type_expression_lv opt env exp in
t
Expand Down Expand Up @@ -963,7 +969,7 @@ and expect_type pos ~expected ~provided =
(Solidity_type_printer.string_of_type provided)
(Solidity_type_printer.string_of_type expected)

and type_options opt env pos is_payable fo opts =
and type_options_fun opt env pos is_payable fo opts =
List.fold_left (fun fo (id, e) ->
let id = strip id in
let fo, already_set =
Expand Down Expand Up @@ -993,51 +999,6 @@ and type_options opt env pos is_payable fo opts =
error pos "Function call option \"%s\" can \
only be used with \"new\""
(Ident.to_string id);
(* FREETON *)
(* TODO: check that mandatory fields are provided *)
| "pubkey", ( KNewContract | KExtContractFun )
when !for_freeton ->
expect_expression_type opt env e
( TOptional (TUint 256));
fo, false (* TODO *)
| "code", KNewContract when !for_freeton ->
expect_expression_type opt env e (TAbstract TvmCell);
fo, false (* TODO *)
| "flag", ( KExtContractFun | KNewContract ) when !for_freeton ->
expect_expression_type opt env e (TUint 8);
fo, false (* TODO *)
| "varInit", KNewContract when !for_freeton ->
fo, false (* TODO *)
| "abiVer", KExtContractFun when !for_freeton ->
expect_expression_type opt env e (TUint 8);
fo, false (* TODO *)
| "extMsg", KExtContractFun when !for_freeton ->
expect_expression_type opt env e TBool ;
fo, false (* TODO *)
| "sign", KExtContractFun when !for_freeton ->
expect_expression_type opt env e TBool ;
fo, false (* TODO *)
| "bounce", KExtContractFun when !for_freeton ->
expect_expression_type opt env e TBool ;
fo, false (* TODO *)
| "stateInit", KNewContract when !for_freeton ->
expect_expression_type opt env e (TAbstract TvmCell) ;
fo, false (* TODO *)
| "wid", KNewContract when !for_freeton ->
expect_expression_type opt env e (TUint 8) ;
fo, false (* TODO *)
| "time", KExtContractFun when !for_freeton ->
expect_expression_type opt env e (TUint 64) ;
fo, false (* TODO *)
| "expire", KExtContractFun when !for_freeton ->
expect_expression_type opt env e (TUint 64) ;
fo, false (* TODO *)
| "callbackId", KExtContractFun when !for_freeton ->
expect_expression_type opt env e (TUint 64) ;
fo, false (* TODO *)
| "onErrorId", KExtContractFun when !for_freeton ->
expect_expression_type opt env e (TUint 64) ;
fo, false (* TODO *)
| _, KOther ->
error pos "Function call options can only be set on \
external function calls or contract creations"
Expand Down Expand Up @@ -1177,7 +1138,7 @@ let rec type_statement opt env s =
in
let is_payable = true in
let fo = { Solidity_type_builder.new_fun_options
with kind = KExtContractFun } in
with kind = KReturn } in
let _fo = type_options opt env pos is_payable fo opts in
set_annot s (AType annot);
begin
Expand Down Expand Up @@ -2168,3 +2129,6 @@ let type_program ?(init = Solidity_primitives.init) p =
) ordered_modules;

{p with program_modules = ordered_modules}

let () =
type_options_ref := type_options_fun
16 changes: 16 additions & 0 deletions src/solidity-typechecker/solidity_typechecker.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@
val type_program :
?init:(unit -> unit) ->
Solidity_ast.program -> Solidity_ast.program


val expect_expression_type :
Solidity_checker_TYPES.options ->
Solidity_checker_TYPES.env ->
Solidity_ast.expression -> Solidity_checker_TYPES.type_ -> unit

val type_options_ref :
(Solidity_checker_TYPES.options ->
Solidity_checker_TYPES.env ->
Solidity_common.pos ->
bool ->
Solidity_checker_TYPES.function_options ->
(Solidity_ast.ident * Solidity_ast.expression) list ->
Solidity_checker_TYPES.function_options)
ref
Loading

0 comments on commit 42ad735

Please sign in to comment.