Merge pull request #2112 from chfast/refactor_move_override

Pessimising moves and missing overrides
This commit is contained in:
Gav Wood 2015-06-09 23:18:10 +09:00
commit 99fed1aba7
5 changed files with 11 additions and 11 deletions

2
AST.h
View File

@ -503,7 +503,7 @@ public:
/// Returns the declared or inferred type. Can be an empty pointer if no type was explicitly /// Returns the declared or inferred type. Can be an empty pointer if no type was explicitly
/// declared and there is no assignment to the variable that fixes the type. /// declared and there is no assignment to the variable that fixes the type.
TypePointer getType(ContractDefinition const* = nullptr) const { return m_type; } TypePointer getType(ContractDefinition const* = nullptr) const override { return m_type; }
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; } void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; }
virtual bool isLValue() const override; virtual bool isLValue() const override;

View File

@ -133,7 +133,7 @@ set<Declaration const*> CompilerContext::getFunctionsWithoutCode()
for (auto const& it: m_functionEntryLabels) for (auto const& it: m_functionEntryLabels)
if (m_functionsWithCode.count(it.first) == 0) if (m_functionsWithCode.count(it.first) == 0)
functions.insert(it.first); functions.insert(it.first);
return move(functions); return functions;
} }
ModifierDefinition const& CompilerContext::getFunctionModifier(string const& _name) const ModifierDefinition const& CompilerContext::getFunctionModifier(string const& _name) const

View File

@ -109,7 +109,7 @@ public:
StorageItem(CompilerContext& _compilerContext, Declaration const& _declaration); StorageItem(CompilerContext& _compilerContext, Declaration const& _declaration);
/// Constructs the LValue and assumes that the storage reference is already on the stack. /// Constructs the LValue and assumes that the storage reference is already on the stack.
StorageItem(CompilerContext& _compilerContext, Type const& _type); StorageItem(CompilerContext& _compilerContext, Type const& _type);
virtual unsigned sizeOnStack() const { return 2; } virtual unsigned sizeOnStack() const override { return 2; }
virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override;
virtual void storeValue( virtual void storeValue(
Type const& _sourceType, Type const& _sourceType,

View File

@ -1459,29 +1459,29 @@ MagicType::MagicType(MagicType::Kind _kind):
switch (m_kind) switch (m_kind)
{ {
case Kind::Block: case Kind::Block:
m_members = move(MemberList({ m_members = MemberList({
{"coinbase", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, {"coinbase", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"timestamp", make_shared<IntegerType>(256)}, {"timestamp", make_shared<IntegerType>(256)},
{"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"bytes32"}, FunctionType::Location::BlockHash)}, {"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"bytes32"}, FunctionType::Location::BlockHash)},
{"difficulty", make_shared<IntegerType>(256)}, {"difficulty", make_shared<IntegerType>(256)},
{"number", make_shared<IntegerType>(256)}, {"number", make_shared<IntegerType>(256)},
{"gaslimit", make_shared<IntegerType>(256)} {"gaslimit", make_shared<IntegerType>(256)}
})); });
break; break;
case Kind::Message: case Kind::Message:
m_members = move(MemberList({ m_members = MemberList({
{"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, {"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"gas", make_shared<IntegerType>(256)}, {"gas", make_shared<IntegerType>(256)},
{"value", make_shared<IntegerType>(256)}, {"value", make_shared<IntegerType>(256)},
{"data", make_shared<ArrayType>(ReferenceType::Location::CallData)}, {"data", make_shared<ArrayType>(ReferenceType::Location::CallData)},
{"sig", make_shared<FixedBytesType>(4)} {"sig", make_shared<FixedBytesType>(4)}
})); });
break; break;
case Kind::Transaction: case Kind::Transaction:
m_members = move(MemberList({ m_members = MemberList({
{"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, {"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)},
{"gasprice", make_shared<IntegerType>(256)} {"gasprice", make_shared<IntegerType>(256)}
})); });
break; break;
default: default:
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic."));

View File

@ -407,7 +407,7 @@ public:
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override; virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual bool operator==(const Type& _other) const override; virtual bool operator==(const Type& _other) const override;
virtual unsigned getCalldataEncodedSize(bool _padded) const override; virtual unsigned getCalldataEncodedSize(bool _padded) const override;
virtual bool isDynamicallySized() const { return m_hasDynamicLength; } virtual bool isDynamicallySized() const override { return m_hasDynamicLength; }
virtual u256 getStorageSize() const override; virtual u256 getStorageSize() const override;
virtual unsigned getSizeOnStack() const override; virtual unsigned getSizeOnStack() const override;
virtual std::string toString() const override; virtual std::string toString() const override;
@ -820,7 +820,7 @@ public:
return TypePointer(); return TypePointer();
} }
virtual bool operator==(Type const& _other) const; virtual bool operator==(Type const& _other) const override;
virtual bool canBeStored() const override { return false; } virtual bool canBeStored() const override { return false; }
virtual bool canLiveOutsideStorage() const override { return true; } virtual bool canLiveOutsideStorage() const override { return true; }
virtual unsigned getSizeOnStack() const override { return 0; } virtual unsigned getSizeOnStack() const override { return 0; }