diff --git a/src/solidity-common/solidity_ast.ml b/src/solidity-common/solidity_ast.ml index 1a84cb7..d4f0cbe 100644 --- a/src/solidity-common/solidity_ast.ml +++ b/src/solidity-common/solidity_ast.ml @@ -248,13 +248,20 @@ and number_unit = | Days | Weeks | Years - | Nanoton (* freeton *) - | Microton (* freeton *) - | Milliton (* freeton *) - | Ton (* freeton *) - | Kiloton (* freeton *) - | Megaton (* freeton *) - | Gigaton (* freeton *) + | Nanoton (* freeton / everscale *) + | Microton (* freeton / everscale *) + | Milliton (* freeton / everscale *) + | Ton (* freeton / everscale *) + | Kiloton (* freeton / everscale *) + | Megaton (* freeton / everscale *) + | Gigaton (* freeton / everscale *) + | Nanoever (* freeton / everscale *) + | Microever (* freeton / everscale *) + | Milliever (* freeton / everscale *) + | Ever (* freeton / everscale *) + | Kiloever (* freeton / everscale *) + | Megaever (* freeton / everscale *) + | Gigaever (* freeton / everscale *) and unary_operator = | UPlus @@ -393,27 +400,34 @@ let convertible_visibility ~from ~to_ = let unit_factor unit = let z = match unit with - | Unit -> Z.one - | Wei -> Z.one - | Kwei -> ExtZ._10_3 - | Mwei -> ExtZ._10_6 - | Gwei -> ExtZ._10_9 - | Twei -> ExtZ._10_12 - | Pwei -> ExtZ._10_15 - | Ether -> ExtZ._10_18 - | Hours -> ExtZ._3600 - | Minutes -> ExtZ._60 - | Seconds -> Z.one - | Days -> ExtZ._24x3600 - | Weeks -> ExtZ._7x24x3600 - | Years -> ExtZ._365x24x3600 - | Nanoton -> Z.one - | Microton -> ExtZ._10_3 - | Milliton -> ExtZ._10_6 - | Ton -> ExtZ._10_9 - | Kiloton -> ExtZ._10_12 - | Megaton -> ExtZ._10_15 - | Gigaton -> ExtZ._10_18 + | Unit -> Z.one + | Wei -> Z.one + | Kwei -> ExtZ._10_3 + | Mwei -> ExtZ._10_6 + | Gwei -> ExtZ._10_9 + | Twei -> ExtZ._10_12 + | Pwei -> ExtZ._10_15 + | Ether -> ExtZ._10_18 + | Hours -> ExtZ._3600 + | Minutes -> ExtZ._60 + | Seconds -> Z.one + | Days -> ExtZ._24x3600 + | Weeks -> ExtZ._7x24x3600 + | Years -> ExtZ._365x24x3600 + | Nanoton -> Z.one + | Microton -> ExtZ._10_3 + | Milliton -> ExtZ._10_6 + | Ton -> ExtZ._10_9 + | Kiloton -> ExtZ._10_12 + | Megaton -> ExtZ._10_15 + | Gigaton -> ExtZ._10_18 + | Nanoever -> Z.one + | Microever -> ExtZ._10_3 + | Milliever -> ExtZ._10_6 + | Ever -> ExtZ._10_9 + | Kiloever -> ExtZ._10_12 + | Megaever -> ExtZ._10_15 + | Gigaever -> ExtZ._10_18 in Q.of_bigint z @@ -449,7 +463,7 @@ let apply_binop q1 op q2 = | BDiv -> Some (Q.div q1 q2) | BMod -> -(* TODO: Solidity allows this on fractions *) + (* TODO: Solidity allows this on fractions *) if ExtQ.is_int q1 && ExtQ.is_int q2 then Some (Q.of_bigint (snd (Z.ediv_rem (Q.num q1) (Q.num q2)))) else diff --git a/src/solidity-common/solidity_ast.mli b/src/solidity-common/solidity_ast.mli index d46d78c..d4fe270 100644 --- a/src/solidity-common/solidity_ast.mli +++ b/src/solidity-common/solidity_ast.mli @@ -329,13 +329,20 @@ and number_unit = | Days | Weeks | Years - | Nanoton (* freeton *) - | Microton (* freeton *) - | Milliton (* freeton *) - | Ton (* freeton *) - | Kiloton (* freeton *) - | Megaton (* freeton *) - | Gigaton (* freeton *) + | Nanoton (* freeton / everscale *) + | Microton (* freeton / everscale *) + | Milliton (* freeton / everscale *) + | Ton (* freeton / everscale *) + | Kiloton (* freeton / everscale *) + | Megaton (* freeton / everscale *) + | Gigaton (* freeton / everscale *) + | Nanoever (* freeton / everscale *) + | Microever (* freeton / everscale *) + | Milliever (* freeton / everscale *) + | Ever (* freeton / everscale *) + | Kiloever (* freeton / everscale *) + | Megaever (* freeton / everscale *) + | Gigaever (* freeton / everscale *) and unary_operator = | UPlus diff --git a/src/solidity-common/solidity_printer.ml b/src/solidity-common/solidity_printer.ml index b1c2f8f..8aef3ee 100644 --- a/src/solidity-common/solidity_printer.ml +++ b/src/solidity-common/solidity_printer.ml @@ -51,28 +51,36 @@ let string_of_visibility = function | VPrivate -> "private" let string_of_number_unit = function - | Unit -> "" - | Wei -> "wei" - | Kwei -> "kwei" - | Mwei -> "mwei" - | Gwei -> "gwei" - | Twei -> "szabo" - | Pwei -> "finney" - | Ether -> "ether" - | Hours -> "hours" - | Minutes -> "minutes" - | Seconds -> "seconds" - | Days -> "days" - | Weeks -> "weeks" - | Years -> "years" - - | Nanoton -> "nanoton" - | Microton -> "microton" - | Milliton -> "milliton" - | Ton -> "ton" - | Kiloton -> "kiloton" - | Megaton -> "megaton" - | Gigaton -> "gigaton" + | Unit -> "" + | Wei -> "wei" + | Kwei -> "kwei" + | Mwei -> "mwei" + | Gwei -> "gwei" + | Twei -> "szabo" + | Pwei -> "finney" + | Ether -> "ether" + | Hours -> "hours" + | Minutes -> "minutes" + | Seconds -> "seconds" + | Days -> "days" + | Weeks -> "weeks" + | Years -> "years" + + | Nanoton -> "nanoton" + | Microton -> "microton" + | Milliton -> "milliton" + | Ton -> "ton" + | Kiloton -> "kiloton" + | Megaton -> "megaton" + | Gigaton -> "gigaton" + + | Nanoever -> "nanoever" + | Microever -> "microever" + | Milliever -> "milliever" + | Ever -> "ever" + | Kiloever -> "kiloever" + | Megaever -> "megaever" + | Gigaever -> "gigaever" let string_of_unop = function | UPlus -> "+" diff --git a/src/solidity-parser/solidity_lexer.mll b/src/solidity-parser/solidity_lexer.mll index 9da159b..a3e6db7 100644 --- a/src/solidity-parser/solidity_lexer.mll +++ b/src/solidity-parser/solidity_lexer.mll @@ -345,6 +345,28 @@ if freeton then "gigaton", NUMBERUNIT (Gigaton); "GTon", NUMBERUNIT (Gigaton); + + (* "nano", NUMBERUNIT (Ever); *) + "nanoever", NUMBERUNIT (Nanoever); + "nEver", NUMBERUNIT (Nanoever); + + "micro", NUMBERUNIT (Microever); + "microever", NUMBERUNIT (Microever); + + "milli", NUMBERUNIT (Milliever); + "milliever", NUMBERUNIT (Milliever); + + "ever", NUMBERUNIT (Ever); + "Ever", NUMBERUNIT (Ever); + + "kiloever", NUMBERUNIT (Kiloever); + "kEver", NUMBERUNIT (Kiloever); + + "megaever", NUMBERUNIT (Megaever); + "MEver", NUMBERUNIT (Megaever); + + "gigaever", NUMBERUNIT (Gigaever); + "GEver", NUMBERUNIT (Gigaever); ]; () end