aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp49
-rw-r--r--libsolidity/ast/Types.h8
2 files changed, 54 insertions, 3 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 21353080..68b12777 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2375,7 +2375,11 @@ string FunctionType::richIdentifier() const
case Kind::ByteArrayPush: id += "bytearraypush"; break;
case Kind::ObjectCreation: id += "objectcreation"; break;
case Kind::Assert: id += "assert"; break;
- case Kind::Require: id += "require";break;
+ case Kind::Require: id += "require"; break;
+ case Kind::ABIEncode: id += "abiencode"; break;
+ case Kind::ABIEncodePacked: id += "abiencodepacked"; break;
+ case Kind::ABIEncodeWithSelector: id += "abiencodewithselector"; break;
+ case Kind::ABIEncodeWithSignature: id += "abiencodewithsignature"; break;
default: solAssert(false, "Unknown function location."); break;
}
id += "_" + stateMutabilityToString(m_stateMutability);
@@ -2996,6 +3000,8 @@ string MagicType::richIdentifier() const
return "t_magic_message";
case Kind::Transaction:
return "t_magic_transaction";
+ case Kind::ABI:
+ return "t_magic_abi";
default:
solAssert(false, "Unknown kind of magic");
}
@@ -3036,6 +3042,45 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const
{"origin", make_shared<IntegerType>(160, IntegerType::Modifier::Address)},
{"gasprice", make_shared<IntegerType>(256)}
});
+ case Kind::ABI:
+ return MemberList::MemberMap({
+ {"encode", make_shared<FunctionType>(
+ TypePointers(),
+ TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
+ strings{},
+ strings{},
+ FunctionType::Kind::ABIEncode,
+ true,
+ StateMutability::Pure
+ )},
+ {"encodePacked", make_shared<FunctionType>(
+ TypePointers(),
+ TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
+ strings{},
+ strings{},
+ FunctionType::Kind::ABIEncodePacked,
+ true,
+ StateMutability::Pure
+ )},
+ {"encodeWithSelector", make_shared<FunctionType>(
+ TypePointers{make_shared<FixedBytesType>(4)},
+ TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
+ strings{},
+ strings{},
+ FunctionType::Kind::ABIEncodeWithSelector,
+ true,
+ StateMutability::Pure
+ )},
+ {"encodeWithSignature", make_shared<FunctionType>(
+ TypePointers{make_shared<ArrayType>(DataLocation::Memory, true)},
+ TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
+ strings{},
+ strings{},
+ FunctionType::Kind::ABIEncodeWithSignature,
+ true,
+ StateMutability::Pure
+ )}
+ });
default:
solAssert(false, "Unknown kind of magic.");
}
@@ -3051,6 +3096,8 @@ string MagicType::toString(bool) const
return "msg";
case Kind::Transaction:
return "tx";
+ case Kind::ABI:
+ return "abi";
default:
solAssert(false, "Unknown kind of magic.");
}
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 05f506f1..47556c4d 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -914,6 +914,10 @@ public:
ObjectCreation, ///< array creation using new
Assert, ///< assert()
Require, ///< require()
+ ABIEncode,
+ ABIEncodePacked,
+ ABIEncodeWithSelector,
+ ABIEncodeWithSignature,
GasLeft ///< gasleft()
};
@@ -1049,7 +1053,7 @@ public:
ASTPointer<ASTString> documentation() const;
/// true iff arguments are to be padded to multiples of 32 bytes for external calls
- bool padArguments() const { return !(m_kind == Kind::SHA3 || m_kind == Kind::SHA256 || m_kind == Kind::RIPEMD160); }
+ bool padArguments() const { return !(m_kind == Kind::SHA3 || m_kind == Kind::SHA256 || m_kind == Kind::RIPEMD160 || m_kind == Kind::ABIEncodePacked); }
bool takesArbitraryParameters() const { return m_arbitraryParameters; }
bool gasSet() const { return m_gasSet; }
bool valueSet() const { return m_valueSet; }
@@ -1207,7 +1211,7 @@ private:
class MagicType: public Type
{
public:
- enum class Kind { Block, Message, Transaction };
+ enum class Kind { Block, Message, Transaction, ABI };
virtual Category category() const override { return Category::Magic; }
explicit MagicType(Kind _kind): m_kind(_kind) {}