diff options
author | Christian <c@ethdev.com> | 2014-11-05 18:38:26 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-06 09:40:39 +0800 |
commit | b5e77678c9257f97be89139cf1d12bfa178147ef (patch) | |
tree | 786dbb9a1efb03b4284412fe85e5959b7195f1fa | |
parent | 95d2edfbac4dff62ac987a9fe0fc58fbce76e5b7 (diff) | |
download | dexon-solidity-b5e77678c9257f97be89139cf1d12bfa178147ef.tar.gz dexon-solidity-b5e77678c9257f97be89139cf1d12bfa178147ef.tar.zst dexon-solidity-b5e77678c9257f97be89139cf1d12bfa178147ef.zip |
Keywords for all integer types.
-rw-r--r-- | Scanner.cpp | 84 | ||||
-rw-r--r-- | Token.h | 84 | ||||
-rw-r--r-- | Types.cpp | 18 |
3 files changed, 176 insertions, 10 deletions
diff --git a/Scanner.cpp b/Scanner.cpp index c3682031..63deba49 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -556,17 +556,73 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("function", Token::FUNCTION) \ KEYWORD_GROUP('h') \ KEYWORD("hash", Token::HASH) \ + KEYWORD("hash8", Token::HASH8) \ + KEYWORD("hash16", Token::HASH16) \ + KEYWORD("hash24", Token::HASH24) \ KEYWORD("hash32", Token::HASH32) \ + KEYWORD("hash40", Token::HASH40) \ + KEYWORD("hash48", Token::HASH48) \ + KEYWORD("hash56", Token::HASH56) \ KEYWORD("hash64", Token::HASH64) \ + KEYWORD("hash72", Token::HASH72) \ + KEYWORD("hash80", Token::HASH80) \ + KEYWORD("hash88", Token::HASH88) \ + KEYWORD("hash96", Token::HASH96) \ + KEYWORD("hash104", Token::HASH104) \ + KEYWORD("hash112", Token::HASH112) \ + KEYWORD("hash120", Token::HASH120) \ KEYWORD("hash128", Token::HASH128) \ + KEYWORD("hash136", Token::HASH136) \ + KEYWORD("hash144", Token::HASH144) \ + KEYWORD("hash152", Token::HASH152) \ + KEYWORD("hash160", Token::HASH160) \ + KEYWORD("hash168", Token::HASH168) \ + KEYWORD("hash178", Token::HASH176) \ + KEYWORD("hash184", Token::HASH184) \ + KEYWORD("hash192", Token::HASH192) \ + KEYWORD("hash200", Token::HASH200) \ + KEYWORD("hash208", Token::HASH208) \ + KEYWORD("hash216", Token::HASH216) \ + KEYWORD("hash224", Token::HASH224) \ + KEYWORD("hash232", Token::HASH232) \ + KEYWORD("hash240", Token::HASH240) \ + KEYWORD("hash248", Token::HASH248) \ KEYWORD("hash256", Token::HASH256) \ KEYWORD_GROUP('i') \ KEYWORD("if", Token::IF) \ KEYWORD("in", Token::IN) \ KEYWORD("int", Token::INT) \ + KEYWORD("int8", Token::INT8) \ + KEYWORD("int16", Token::INT16) \ + KEYWORD("int24", Token::INT24) \ KEYWORD("int32", Token::INT32) \ + KEYWORD("int40", Token::INT40) \ + KEYWORD("int48", Token::INT48) \ + KEYWORD("int56", Token::INT56) \ KEYWORD("int64", Token::INT64) \ + KEYWORD("int72", Token::INT72) \ + KEYWORD("int80", Token::INT80) \ + KEYWORD("int88", Token::INT88) \ + KEYWORD("int96", Token::INT96) \ + KEYWORD("int104", Token::INT104) \ + KEYWORD("int112", Token::INT112) \ + KEYWORD("int120", Token::INT120) \ KEYWORD("int128", Token::INT128) \ + KEYWORD("int136", Token::INT136) \ + KEYWORD("int144", Token::INT144) \ + KEYWORD("int152", Token::INT152) \ + KEYWORD("int160", Token::INT160) \ + KEYWORD("int168", Token::INT168) \ + KEYWORD("int178", Token::INT176) \ + KEYWORD("int184", Token::INT184) \ + KEYWORD("int192", Token::INT192) \ + KEYWORD("int200", Token::INT200) \ + KEYWORD("int208", Token::INT208) \ + KEYWORD("int216", Token::INT216) \ + KEYWORD("int224", Token::INT224) \ + KEYWORD("int232", Token::INT232) \ + KEYWORD("int240", Token::INT240) \ + KEYWORD("int248", Token::INT248) \ KEYWORD("int256", Token::INT256) \ KEYWORD_GROUP('l') \ KEYWORD_GROUP('m') \ @@ -591,9 +647,37 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("true", Token::TRUE_LITERAL) \ KEYWORD_GROUP('u') \ KEYWORD("uint", Token::UINT) \ + KEYWORD("uint8", Token::UINT8) \ + KEYWORD("uint16", Token::UINT16) \ + KEYWORD("uint24", Token::UINT24) \ KEYWORD("uint32", Token::UINT32) \ + KEYWORD("uint40", Token::UINT40) \ + KEYWORD("uint48", Token::UINT48) \ + KEYWORD("uint56", Token::UINT56) \ KEYWORD("uint64", Token::UINT64) \ + KEYWORD("uint72", Token::UINT72) \ + KEYWORD("uint80", Token::UINT80) \ + KEYWORD("uint88", Token::UINT88) \ + KEYWORD("uint96", Token::UINT96) \ + KEYWORD("uint104", Token::UINT104) \ + KEYWORD("uint112", Token::UINT112) \ + KEYWORD("uint120", Token::UINT120) \ KEYWORD("uint128", Token::UINT128) \ + KEYWORD("uint136", Token::UINT136) \ + KEYWORD("uint144", Token::UINT144) \ + KEYWORD("uint152", Token::UINT152) \ + KEYWORD("uint160", Token::UINT160) \ + KEYWORD("uint168", Token::UINT168) \ + KEYWORD("uint178", Token::UINT176) \ + KEYWORD("uint184", Token::UINT184) \ + KEYWORD("uint192", Token::UINT192) \ + KEYWORD("uint200", Token::UINT200) \ + KEYWORD("uint208", Token::UINT208) \ + KEYWORD("uint216", Token::UINT216) \ + KEYWORD("uint224", Token::UINT224) \ + KEYWORD("uint232", Token::UINT232) \ + KEYWORD("uint240", Token::UINT240) \ + KEYWORD("uint248", Token::UINT248) \ KEYWORD("uint256", Token::UINT256) \ KEYWORD("ureal", Token::UREAL) \ KEYWORD_GROUP('v') \ @@ -169,19 +169,103 @@ namespace solidity * the implementation in Types.cpp has to be synced to this here * TODO more to be added */ \ K(INT, "int", 0) \ + K(INT8, "int8", 0) \ + K(INT16, "int16", 0) \ + K(INT24, "int24", 0) \ K(INT32, "int32", 0) \ + K(INT40, "int40", 0) \ + K(INT48, "int48", 0) \ + K(INT56, "int56", 0) \ K(INT64, "int64", 0) \ + K(INT72, "int72", 0) \ + K(INT80, "int80", 0) \ + K(INT88, "int88", 0) \ + K(INT96, "int96", 0) \ + K(INT104, "int104", 0) \ + K(INT112, "int112", 0) \ + K(INT120, "int120", 0) \ K(INT128, "int128", 0) \ + K(INT136, "int136", 0) \ + K(INT144, "int144", 0) \ + K(INT152, "int152", 0) \ + K(INT160, "int160", 0) \ + K(INT168, "int168", 0) \ + K(INT176, "int178", 0) \ + K(INT184, "int184", 0) \ + K(INT192, "int192", 0) \ + K(INT200, "int200", 0) \ + K(INT208, "int208", 0) \ + K(INT216, "int216", 0) \ + K(INT224, "int224", 0) \ + K(INT232, "int232", 0) \ + K(INT240, "int240", 0) \ + K(INT248, "int248", 0) \ K(INT256, "int256", 0) \ K(UINT, "uint", 0) \ + K(UINT8, "uint8", 0) \ + K(UINT16, "uint16", 0) \ + K(UINT24, "uint24", 0) \ K(UINT32, "uint32", 0) \ + K(UINT40, "uint40", 0) \ + K(UINT48, "uint48", 0) \ + K(UINT56, "uint56", 0) \ K(UINT64, "uint64", 0) \ + K(UINT72, "uint72", 0) \ + K(UINT80, "uint80", 0) \ + K(UINT88, "uint88", 0) \ + K(UINT96, "uint96", 0) \ + K(UINT104, "uint104", 0) \ + K(UINT112, "uint112", 0) \ + K(UINT120, "uint120", 0) \ K(UINT128, "uint128", 0) \ + K(UINT136, "uint136", 0) \ + K(UINT144, "uint144", 0) \ + K(UINT152, "uint152", 0) \ + K(UINT160, "uint160", 0) \ + K(UINT168, "uint168", 0) \ + K(UINT176, "uint178", 0) \ + K(UINT184, "uint184", 0) \ + K(UINT192, "uint192", 0) \ + K(UINT200, "uint200", 0) \ + K(UINT208, "uint208", 0) \ + K(UINT216, "uint216", 0) \ + K(UINT224, "uint224", 0) \ + K(UINT232, "uint232", 0) \ + K(UINT240, "uint240", 0) \ + K(UINT248, "uint248", 0) \ K(UINT256, "uint256", 0) \ K(HASH, "hash", 0) \ + K(HASH8, "hash8", 0) \ + K(HASH16, "hash16", 0) \ + K(HASH24, "hash24", 0) \ K(HASH32, "hash32", 0) \ + K(HASH40, "hash40", 0) \ + K(HASH48, "hash48", 0) \ + K(HASH56, "hash56", 0) \ K(HASH64, "hash64", 0) \ + K(HASH72, "hash72", 0) \ + K(HASH80, "hash80", 0) \ + K(HASH88, "hash88", 0) \ + K(HASH96, "hash96", 0) \ + K(HASH104, "hash104", 0) \ + K(HASH112, "hash112", 0) \ + K(HASH120, "hash120", 0) \ K(HASH128, "hash128", 0) \ + K(HASH136, "hash136", 0) \ + K(HASH144, "hash144", 0) \ + K(HASH152, "hash152", 0) \ + K(HASH160, "hash160", 0) \ + K(HASH168, "hash168", 0) \ + K(HASH176, "hash178", 0) \ + K(HASH184, "hash184", 0) \ + K(HASH192, "hash192", 0) \ + K(HASH200, "hash200", 0) \ + K(HASH208, "hash208", 0) \ + K(HASH216, "hash216", 0) \ + K(HASH224, "hash224", 0) \ + K(HASH232, "hash232", 0) \ + K(HASH240, "hash240", 0) \ + K(HASH248, "hash248", 0) \ K(HASH256, "hash256", 0) \ K(ADDRESS, "address", 0) \ K(BOOL, "bool", 0) \ @@ -40,16 +40,14 @@ shared_ptr<Type> Type::fromElementaryTypeName(Token::Value _typeToken) if (Token::INT <= _typeToken && _typeToken <= Token::HASH256) { int offset = _typeToken - Token::INT; - int bits = offset % 5; - if (bits == 0) - bits = 256; - else - bits = (1 << (bits - 1)) * 32; - int modifier = offset / 5; - return make_shared<IntegerType>(bits, - modifier == 0 ? IntegerType::Modifier::SIGNED : - modifier == 1 ? IntegerType::Modifier::UNSIGNED : - IntegerType::Modifier::HASH); + int bytes = offset % 33; + if (bytes == 0) + bytes = 32; + int modifier = offset / 33; + return make_shared<IntegerType>(bytes * 8, + modifier == 0 ? IntegerType::Modifier::SIGNED : + modifier == 1 ? IntegerType::Modifier::UNSIGNED : + IntegerType::Modifier::HASH); } else if (_typeToken == Token::ADDRESS) return make_shared<IntegerType>(0, IntegerType::Modifier::ADDRESS); |