aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface/CompilerStack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/interface/CompilerStack.cpp')
-rw-r--r--libsolidity/interface/CompilerStack.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 02983a82..70bebfa5 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -632,6 +632,17 @@ string CompilerStack::absolutePath(string const& _path, string const& _reference
return result.generic_string();
}
+namespace
+{
+bool onlySafeExperimentalFeaturesActivated(set<ExperimentalFeature> const& features)
+{
+ for (auto const feature: features)
+ if (!ExperimentalFeatureOnlyAnalysis.count(feature))
+ return false;
+ return true;
+}
+}
+
void CompilerStack::compileContract(
ContractDefinition const& _contract,
map<ContractDefinition const*, eth::Assembly const*>& _compiledContracts
@@ -639,7 +650,7 @@ void CompilerStack::compileContract(
{
if (
_compiledContracts.count(&_contract) ||
- !_contract.annotation().isFullyImplemented ||
+ !_contract.annotation().unimplementedFunctions.empty() ||
!_contract.constructorIsPublic()
)
return;
@@ -649,10 +660,23 @@ void CompilerStack::compileContract(
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_optimize, m_optimizeRuns);
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
string metadata = createMetadata(compiledContract);
- bytes cborEncodedMetadata =
- // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)}
- bytes{0xa1, 0x65, 'b', 'z', 'z', 'r', '0', 0x58, 0x20} +
- dev::swarmHash(metadata).asBytes();
+ bytes cborEncodedHash =
+ // CBOR-encoding of the key "bzzr0"
+ bytes{0x65, 'b', 'z', 'z', 'r', '0'}+
+ // CBOR-encoding of the hash
+ bytes{0x58, 0x20} + dev::swarmHash(metadata).asBytes();
+ bytes cborEncodedMetadata;
+ if (onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures))
+ cborEncodedMetadata =
+ // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata)}
+ bytes{0xa1} +
+ cborEncodedHash;
+ else
+ cborEncodedMetadata =
+ // CBOR-encoding of {"bzzr0": dev::swarmHash(metadata), "experimental": true}
+ bytes{0xa2} +
+ cborEncodedHash +
+ bytes{0x6c, 'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l', 0xf5};
solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
// 16-bit big endian length
cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
@@ -935,7 +959,7 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const
for (auto const& it: contract.definedFunctions())
{
/// Exclude externally visible functions, constructor and the fallback function
- if (it->isPartOfExternalInterface() || it->isConstructor() || it->name().empty())
+ if (it->isPartOfExternalInterface() || it->isConstructor() || it->isFallback())
continue;
size_t entry = functionEntryPoint(_contractName, *it);
@@ -943,12 +967,14 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const
if (entry > 0)
gas = GasEstimator::functionalEstimation(*items, entry, *it);
+ /// TODO: This could move into a method shared with externalSignature()
FunctionType type(*it);
string sig = it->name() + "(";
auto paramTypes = type.parameterTypes();
for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
sig += (*it)->toString() + (it + 1 == paramTypes.end() ? "" : ",");
sig += ")";
+
internalFunctions[sig] = gasToJson(gas);
}