Browse Source

Merge pull request #1107 from chriseth/sol_inheritableIsInternal

Replaced "inheritable" by "internal".
cl-refactor
Gav Wood 10 years ago
parent
commit
e1274524d4
  1. 6
      libsolidity/AST.h
  2. 4
      libsolidity/Parser.cpp
  3. 4
      libsolidity/Token.h
  4. 12
      test/SolidityNameAndTypeResolution.cpp
  5. 6
      test/SolidityParser.cpp

6
libsolidity/AST.h

@ -133,7 +133,7 @@ class Declaration: public ASTNode
{ {
public: public:
/// Visibility ordered from restricted to unrestricted. /// Visibility ordered from restricted to unrestricted.
enum class Visibility { Default, Private, Inheritable, Public, External }; enum class Visibility { Default, Private, Internal, Public, External };
Declaration(Location const& _location, ASTPointer<ASTString> const& _name, Declaration(Location const& _location, ASTPointer<ASTString> const& _name,
Visibility _visibility = Visibility::Default): Visibility _visibility = Visibility::Default):
@ -144,7 +144,7 @@ public:
Visibility getVisibility() const { return m_visibility == Visibility::Default ? getDefaultVisibility() : m_visibility; } Visibility getVisibility() const { return m_visibility == Visibility::Default ? getDefaultVisibility() : m_visibility; }
bool isPublic() const { return getVisibility() >= Visibility::Public; } bool isPublic() const { return getVisibility() >= Visibility::Public; }
bool isVisibleInContract() const { return getVisibility() != Visibility::External; } bool isVisibleInContract() const { return getVisibility() != Visibility::External; }
bool isVisibleInDerivedContracts() const { return isVisibleInContract() && getVisibility() >= Visibility::Inheritable; } bool isVisibleInDerivedContracts() const { return isVisibleInContract() && getVisibility() >= Visibility::Internal; }
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
/// Available only after name and type resolution step. /// Available only after name and type resolution step.
@ -459,7 +459,7 @@ public:
bool isIndexed() const { return m_isIndexed; } bool isIndexed() const { return m_isIndexed; }
protected: protected:
Visibility getDefaultVisibility() const override { return Visibility::Inheritable; } Visibility getDefaultVisibility() const override { return Visibility::Internal; }
private: private:
ASTPointer<TypeName> m_typeName; ///< can be empty ("var") ASTPointer<TypeName> m_typeName; ///< can be empty ("var")

4
libsolidity/Parser.cpp

@ -187,8 +187,8 @@ Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token)
Declaration::Visibility visibility(Declaration::Visibility::Default); Declaration::Visibility visibility(Declaration::Visibility::Default);
if (_token == Token::Public) if (_token == Token::Public)
visibility = Declaration::Visibility::Public; visibility = Declaration::Visibility::Public;
else if (_token == Token::Inheritable) else if (_token == Token::Internal)
visibility = Declaration::Visibility::Inheritable; visibility = Declaration::Visibility::Internal;
else if (_token == Token::Private) else if (_token == Token::Private)
visibility = Declaration::Visibility::Private; visibility = Declaration::Visibility::Private;
else if (_token == Token::External) else if (_token == Token::External)

4
libsolidity/Token.h

@ -162,7 +162,7 @@ namespace solidity
K(New, "new", 0) \ K(New, "new", 0) \
K(Public, "public", 0) \ K(Public, "public", 0) \
K(Private, "private", 0) \ K(Private, "private", 0) \
K(Inheritable, "inheritable", 0) \ K(Internal, "internal", 0) \
K(Return, "return", 0) \ K(Return, "return", 0) \
K(Returns, "returns", 0) \ K(Returns, "returns", 0) \
K(Struct, "struct", 0) \ K(Struct, "struct", 0) \
@ -380,7 +380,7 @@ public:
static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isCountOp(Value op) { return op == Inc || op == Dec; }
static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); }
static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; } static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; }
static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Inheritable; } static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; }
static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; }
// Returns a string corresponding to the JS token string // Returns a string corresponding to the JS token string

12
test/SolidityNameAndTypeResolution.cpp

@ -470,7 +470,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_indirect)
BOOST_AUTO_TEST_CASE(illegal_override_visibility) BOOST_AUTO_TEST_CASE(illegal_override_visibility)
{ {
char const* text = R"( char const* text = R"(
contract B { function f() inheritable {} } contract B { function f() internal {} }
contract C is B { function f() public {} } contract C is B { function f() public {} }
)"; )";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
@ -706,7 +706,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
" uint64(2);\n" " uint64(2);\n"
" }\n" " }\n"
"uint256 private foo;\n" "uint256 private foo;\n"
"uint256 inheritable bar;\n" "uint256 internal bar;\n"
"}\n"; "}\n";
ASTPointer<SourceUnit> source; ASTPointer<SourceUnit> source;
@ -717,7 +717,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
function = retrieveFunctionBySignature(contract, "foo()"); function = retrieveFunctionBySignature(contract, "foo()");
BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist"); BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist");
function = retrieveFunctionBySignature(contract, "bar()"); function = retrieveFunctionBySignature(contract, "bar()");
BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of an inheritable variable should not exist"); BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of an internal variable should not exist");
} }
BOOST_AUTO_TEST_CASE(fallback_function) BOOST_AUTO_TEST_CASE(fallback_function)
@ -832,11 +832,11 @@ BOOST_AUTO_TEST_CASE(access_to_default_function_visibility)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
} }
BOOST_AUTO_TEST_CASE(access_to_inheritable_function) BOOST_AUTO_TEST_CASE(access_to_internal_function)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
function f() inheritable {} function f() internal {}
} }
contract d { contract d {
function g() { c(0).f(); } function g() { c(0).f(); }
@ -856,7 +856,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
} }
BOOST_AUTO_TEST_CASE(access_to_inheritable_state_variable) BOOST_AUTO_TEST_CASE(access_to_internal_state_variable)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {

6
test/SolidityParser.cpp

@ -651,13 +651,13 @@ BOOST_AUTO_TEST_CASE(visibility_specifiers)
char const* text = R"( char const* text = R"(
contract c { contract c {
uint private a; uint private a;
uint inheritable b; uint internal b;
uint public c; uint public c;
uint d; uint d;
function f() {} function f() {}
function f_priv() private {} function f_priv() private {}
function f_public() public {} function f_public() public {}
function f_inheritable() inheritable {} function f_internal() internal {}
})"; })";
BOOST_CHECK_NO_THROW(parseText(text)); BOOST_CHECK_NO_THROW(parseText(text));
} }
@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
{ {
char const* text = R"( char const* text = R"(
contract c { contract c {
uint private inheritable a; uint private internal a;
})"; })";
BOOST_CHECK_THROW(parseText(text), ParserError); BOOST_CHECK_THROW(parseText(text), ParserError);
} }

Loading…
Cancel
Save