Inaccessible dynamic types

This commit is contained in:
chriseth
2016-06-02 12:52:25 +02:00
parent 7dab890278
commit 754a992500
4 changed files with 50 additions and 17 deletions
+7 -16
View File
@@ -2037,29 +2037,20 @@ FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound)
location = Location::DelegateCall;
}
TypePointers returnParameterTypes;
vector<string> returnParameterNames;
if (location == Location::Internal)
TypePointers returnParameterTypes = m_returnParameterTypes;
if (location != Location::Internal)
{
returnParameterNames = m_returnParameterNames;
returnParameterTypes = m_returnParameterTypes;
}
else
{
// Removes dynamic types.
for (size_t i = 0; i < m_returnParameterTypes.size(); ++i)
if (!m_returnParameterTypes[i]->isDynamicallySized())
{
returnParameterTypes.push_back(m_returnParameterTypes[i]);
returnParameterNames.push_back(m_returnParameterNames[i]);
}
// Alter dynamic types to be non-accessible.
for (auto& param: returnParameterTypes)
if (param->isDynamicallySized())
param = make_shared<InaccessibleDynamicType>();
}
return make_shared<FunctionType>(
parameterTypes,
returnParameterTypes,
m_parameterNames,
returnParameterNames,
m_returnParameterNames,
location,
m_arbitraryParameters,
m_declaration,
+22 -1
View File
@@ -137,7 +137,8 @@ public:
{
Integer, RationalNumber, StringLiteral, Bool, FixedPoint, Array,
FixedBytes, Contract, Struct, Function, Enum, Tuple,
Mapping, TypeType, Modifier, Magic, Module
Mapping, TypeType, Modifier, Magic, Module,
InaccessibleDynamic
};
/// @{
@@ -1081,5 +1082,25 @@ private:
Kind m_kind;
};
/**
* Special type that is used for dynamic types in returns from external function calls
* (The EVM currently cannot access dynamically-sized return values).
*/
class InaccessibleDynamicType: public Type
{
public:
virtual Category category() const override { return Category::InaccessibleDynamic; }
virtual bool isImplicitlyConvertibleTo(Type const&) const override { return false; }
virtual bool isExplicitlyConvertibleTo(Type const&) const override { return false; }
virtual unsigned calldataEncodedSize(bool _padded) const override { (void)_padded; return 32; }
virtual bool canBeStored() const override { return false; }
virtual bool canLiveOutsideStorage() const override { return false; }
virtual bool isValueType() const override { return true; }
virtual unsigned sizeOnStack() const override { return 1; }
virtual std::string toString(bool) const override { return "inaccessible dynamic type"; }
virtual TypePointer decodingType() const override { return std::make_shared<IntegerType>(256); }
};
}
}