aboutsummaryrefslogtreecommitdiffstats
path: root/libdevcore/CommonData.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-16 23:58:17 +0800
committerchriseth <chris@ethereum.org>2018-10-22 21:52:26 +0800
commit19be6cd818e4bb1a49325d8bfea7f7727d85c933 (patch)
treefae4f0c8bb4ca4c32ede677466a6a8cfc2965fee /libdevcore/CommonData.cpp
parentc13b5280c1b44f18a2a1fb61ef5556e91c5678e7 (diff)
downloaddexon-solidity-19be6cd818e4bb1a49325d8bfea7f7727d85c933.tar.gz
dexon-solidity-19be6cd818e4bb1a49325d8bfea7f7727d85c933.tar.zst
dexon-solidity-19be6cd818e4bb1a49325d8bfea7f7727d85c933.zip
Some well-formedness checks for the Yul AST.
Diffstat (limited to 'libdevcore/CommonData.cpp')
-rw-r--r--libdevcore/CommonData.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp
index 6d7c74d7..fa1a5353 100644
--- a/libdevcore/CommonData.cpp
+++ b/libdevcore/CommonData.cpp
@@ -110,3 +110,26 @@ string dev::getChecksummedAddress(string const& _addr)
}
return ret;
}
+
+bool dev::isValidHex(string const& _string)
+{
+ if (_string.substr(0, 2) != "0x")
+ return false;
+ if (_string.find_first_not_of("0123456789abcdefABCDEF", 2) != string::npos)
+ return false;
+ return true;
+}
+
+bool dev::isValidDecimal(string const& _string)
+{
+ if (_string.empty())
+ return false;
+ if (_string == "0")
+ return true;
+ // No leading zeros
+ if (_string.front() == '0')
+ return false;
+ if (_string.find_first_not_of("0123456789") != string::npos)
+ return false;
+ return true;
+}