aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-03-07 23:55:53 +0800
committerchriseth <c@ethdev.com>2016-03-12 00:49:32 +0800
commite5514becb89c945f59fd440696d0bb3122edbe99 (patch)
tree6358ae151c50802b3cb0c158f7b8b06c53669fd4 /libsolidity/ast
parent60a21c6487743578af6fd4e1540a36a2b80fcac7 (diff)
downloaddexon-solidity-e5514becb89c945f59fd440696d0bb3122edbe99.tar.gz
dexon-solidity-e5514becb89c945f59fd440696d0bb3122edbe99.tar.zst
dexon-solidity-e5514becb89c945f59fd440696d0bb3122edbe99.zip
BREAKING: Implement delegatecall and make default for library calls.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp47
-rw-r--r--libsolidity/ast/Types.h4
2 files changed, 27 insertions, 24 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index bca83d59..0696b908 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -333,6 +333,7 @@ MemberList::MemberMap IntegerType::nativeMembers(ContractDefinition const*) cons
{"balance", make_shared<IntegerType >(256)},
{"call", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Location::Bare, true)},
{"callcode", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Location::BareCallCode, true)},
+ {"delegatecall", make_shared<FunctionType>(strings(), strings{"bool"}, FunctionType::Location::BareDelegateCall, true)},
{"send", make_shared<FunctionType>(strings{"uint"}, strings{"bool"}, FunctionType::Location::Send)}
};
else
@@ -1561,9 +1562,9 @@ unsigned FunctionType::sizeOnStack() const
}
unsigned size = 0;
- if (location == Location::External || location == Location::CallCode)
+ if (location == Location::External || location == Location::CallCode || location == Location::DelegateCall)
size = 2;
- else if (location == Location::Bare || location == Location::BareCallCode)
+ else if (location == Location::Bare || location == Location::BareCallCode || location == Location::BareDelegateCall)
size = 1;
else if (location == Location::Internal)
size = 1;
@@ -1619,9 +1620,11 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
case Location::RIPEMD160:
case Location::Bare:
case Location::BareCallCode:
+ case Location::BareDelegateCall:
{
- MemberList::MemberMap members{
- {
+ MemberList::MemberMap members;
+ if (m_location != Location::BareDelegateCall)
+ members.push_back(MemberList::Member(
"value",
make_shared<FunctionType>(
parseElementaryTypeVector({"uint"}),
@@ -1634,25 +1637,22 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
m_gasSet,
m_valueSet
)
- }
- };
+ ));
if (m_location != Location::Creation)
- members.push_back(
- MemberList::Member(
- "gas",
- make_shared<FunctionType>(
- parseElementaryTypeVector({"uint"}),
- TypePointers{copyAndSetGasOrValue(true, false)},
- strings(),
- strings(),
- Location::SetGas,
- false,
- nullptr,
- m_gasSet,
- m_valueSet
- )
+ members.push_back(MemberList::Member(
+ "gas",
+ make_shared<FunctionType>(
+ parseElementaryTypeVector({"uint"}),
+ TypePointers{copyAndSetGasOrValue(true, false)},
+ strings(),
+ strings(),
+ Location::SetGas,
+ false,
+ nullptr,
+ m_gasSet,
+ m_valueSet
)
- );
+ ));
return members;
}
default:
@@ -1700,6 +1700,7 @@ bool FunctionType::isBareCall() const
{
case Location::Bare:
case Location::BareCallCode:
+ case Location::BareDelegateCall:
case Location::ECRecover:
case Location::SHA256:
case Location::RIPEMD160:
@@ -1785,7 +1786,7 @@ FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound)
returnParameterTypes,
m_parameterNames,
returnParameterNames,
- _inLibrary ? Location::CallCode : m_location,
+ _inLibrary ? Location::DelegateCall : m_location,
m_arbitraryParameters,
m_declaration,
m_gasSet,
@@ -1884,7 +1885,7 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current
for (auto const& it: contract.interfaceFunctions())
members.push_back(MemberList::Member(
it.second->declaration().name(),
- it.second->asMemberFunction(true), // use callcode
+ it.second->asMemberFunction(true),
&it.second->declaration()
));
if (isBase)
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index b4a2d573..189dd10a 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -732,8 +732,10 @@ public:
Internal, ///< stack-call using plain JUMP
External, ///< external call using CALL
CallCode, ///< extercnal call using CALLCODE, i.e. not exchanging the storage
+ DelegateCall, ///< extercnal call using DELEGATECALL, i.e. not exchanging the storage
Bare, ///< CALL without function hash
BareCallCode, ///< CALLCODE without function hash
+ BareDelegateCall, ///< DELEGATECALL without function hash
Creation, ///< external call using CREATE
Send, ///< CALL, but without data and gas
SHA3, ///< SHA3
@@ -869,7 +871,7 @@ public:
/// removed and the location of reference types is changed from CallData to Memory.
/// This is needed if external functions are called on other contracts, as they cannot return
/// dynamic values.
- /// @param _inLibrary if true, uses CallCode as location.
+ /// @param _inLibrary if true, uses DelegateCall as location.
/// @param _bound if true, the argumenst are placed as `arg1.functionName(arg2, ..., argn)`.
FunctionTypePointer asMemberFunction(bool _inLibrary, bool _bound = false) const;