diff options
author | mingchuan <mingc@skymizer.com> | 2018-05-23 12:31:20 +0800 |
---|---|---|
committer | mingchuan <mingc@skymizer.com> | 2018-05-30 18:05:55 +0800 |
commit | b7cafcbdf95c807f46fc07f4788d82981b7112b4 (patch) | |
tree | 5714a463da64eaf75a3ec56732165ec89e77d677 /libsolidity/parsing | |
parent | 9d5064d04d178474b95d67e87aaa32d0e5e03b0f (diff) | |
download | dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.gz dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.bz2 dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.lz dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.xz dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.zst dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.zip |
Allow using `calldata` keyword to specify data location
Diffstat (limited to 'libsolidity/parsing')
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 21 | ||||
-rw-r--r-- | libsolidity/parsing/Token.h | 5 |
2 files changed, 19 insertions, 7 deletions
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index e2e1eebc..aec9ebbb 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -592,11 +592,22 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration( else if (!type) parserError(string("Location specifier needs explicit type name.")); else - location = ( - token == Token::Memory ? - VariableDeclaration::Location::Memory : - VariableDeclaration::Location::Storage - ); + { + switch (token) + { + case Token::Storage: + location = VariableDeclaration::Location::Storage; + break; + case Token::Memory: + location = VariableDeclaration::Location::Memory; + break; + case Token::CallData: + location = VariableDeclaration::Location::CallData; + break; + default: + solAssert(false, "Unknown data location."); + } + } } else break; diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index 4d7a7bc6..4d456550 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -173,6 +173,7 @@ namespace solidity K(Return, "return", 0) \ K(Returns, "returns", 0) \ K(Storage, "storage", 0) \ + K(CallData, "calldata", 0) \ K(Struct, "struct", 0) \ K(Throw, "throw", 0) \ K(Using, "using", 0) \ @@ -289,7 +290,7 @@ public: static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; } static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; } - static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage; } + static bool isLocationSpecifier(Value op) { return op == Memory || op == Storage || op == CallData; } static bool isStateMutabilitySpecifier(Value op) { return op == Pure || op == Constant || op == View || op == Payable; } static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; } static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; } @@ -348,7 +349,7 @@ public: unsigned int secondNumber() const { return m_secondNumber; } Token::Value token() const { return m_token; } ///if tokValue is set to true, then returns the actual token type name, otherwise, returns full type - std::string toString(bool const& tokenValue = false) const + std::string toString(bool const& tokenValue = false) const { std::string name = Token::toString(m_token); if (tokenValue || (firstNumber() == 0 && secondNumber() == 0)) |