Browse Source

removed byte0 keyword

cl-refactor
Liana Husikyan 10 years ago
parent
commit
2d732e8923
  1. 2
      libsolidity/Token.h
  2. 4
      libsolidity/Types.cpp
  3. 31
      test/libsolidity/SolidityEndToEndTest.cpp
  4. 3
      test/libsolidity/SolidityNameAndTypeResolution.cpp

2
libsolidity/Token.h

@ -304,8 +304,6 @@ namespace solidity
\
/* Identifiers (not keywords or future reserved words). */ \
T(Identifier, NULL, 0) \
/* Bytes0 token is used for empty string. */ \
T(Bytes0, NULL, 0) \
\
/* Keywords reserved for future. use. */ \
K(As, "as", 0) \

4
libsolidity/Types.cpp

@ -121,7 +121,7 @@ TypePointer Type::fromElementaryTypeName(Token::Value _typeToken)
{
int offset = _typeToken - Token::Int;
int bytes = offset % 33;
if (bytes == 0 && _typeToken != Token::Bytes0)
if (bytes == 0 && _typeToken != Token::Bytes1)
bytes = 32;
int modifier = offset / 33;
switch(modifier)
@ -131,7 +131,7 @@ TypePointer Type::fromElementaryTypeName(Token::Value _typeToken)
case 1:
return make_shared<IntegerType>(bytes * 8, IntegerType::Modifier::Unsigned);
case 2:
return make_shared<FixedBytesType>(bytes);
return make_shared<FixedBytesType>(bytes + 1);
default:
solAssert(false, "Unexpected modifier value. Should never happen");
return TypePointer();

31
test/libsolidity/SolidityEndToEndTest.cpp

@ -564,20 +564,6 @@ BOOST_AUTO_TEST_CASE(strings)
BOOST_CHECK(callContractFunction("pipeThrough(bytes2,bool)", string("\0\x02", 2), true) == encodeArgs(string("\0\x2", 2), true));
}
BOOST_AUTO_TEST_CASE(empty_string_on_stack)
{
char const* sourceCode = "contract test {\n"
" function run(string empty, uint8 inp) external returns(uint16 a, string b, bytes4 c) {\n"
" var x = \"abc\";\n"
" var y = \"\";\n"
" var z = inp;\n"
" a = z; b = y; c = x;"
" }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("run(bytes0,uint8)", string(), byte(0x02)) == encodeArgs(0x2, string(""), string("abc\0")));
}
BOOST_AUTO_TEST_CASE(inc_dec_operators)
{
char const* sourceCode = R"(
@ -4172,23 +4158,6 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
BOOST_CHECK(compileAndRunWthoutCheck(sourceCode, 0, "A").empty());
}
BOOST_AUTO_TEST_CASE(empty_string)
{
char const* sourceCode = R"(
contract Foo {
var sEmpty = "";
string sStateVar = "text";
function Foo()
{
var sLocal = "";
sEmpty = sLocal;
sLocal = s;
}
}
)";
compileAndRun(sourceCode, 0, "Foo");
}
BOOST_AUTO_TEST_CASE(positive_integers_to_signed)
{
char const* sourceCode = R"(

3
test/libsolidity/SolidityNameAndTypeResolution.cpp

@ -1579,7 +1579,6 @@ BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName)
BOOST_CHECK(*Type::fromElementaryTypeName(Token::UInt256) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Byte) == *make_shared<FixedBytesType>(1));
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes0) == *make_shared<FixedBytesType>(0));
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes1) == *make_shared<FixedBytesType>(1));
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes2) == *make_shared<FixedBytesType>(2));
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes3) == *make_shared<FixedBytesType>(3));
@ -1673,7 +1672,7 @@ BOOST_AUTO_TEST_CASE(bytes0_array)
bytes0[] illegalArray;
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError);
}
BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve)

Loading…
Cancel
Save