mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
renamed fromIdentifier to fromStateVariable
This commit is contained in:
parent
858acaa193
commit
d0c36795a0
@ -69,7 +69,7 @@ void ExpressionCompiler::appendStateVariableInitialization(CompilerContext& _con
|
|||||||
void ExpressionCompiler::appendStateVariableInitialization(VariableDeclaration const& _varDecl)
|
void ExpressionCompiler::appendStateVariableInitialization(VariableDeclaration const& _varDecl)
|
||||||
{
|
{
|
||||||
LValue lvalue = LValue(m_context);
|
LValue lvalue = LValue(m_context);
|
||||||
lvalue.fromVariableDeclaration(_varDecl);
|
lvalue.fromDeclaration(_varDecl, _varDecl.getValue()->getLocation());
|
||||||
lvalue.storeValue(*_varDecl.getType(), _varDecl.getLocation());
|
lvalue.storeValue(*_varDecl.getType(), _varDecl.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier)
|
|||||||
m_context << m_context.getVirtualFunctionEntryLabel(*functionDef).pushTag();
|
m_context << m_context.getVirtualFunctionEntryLabel(*functionDef).pushTag();
|
||||||
else if (dynamic_cast<VariableDeclaration const*>(declaration))
|
else if (dynamic_cast<VariableDeclaration const*>(declaration))
|
||||||
{
|
{
|
||||||
m_currentLValue.fromIdentifier(_identifier, *declaration);
|
m_currentLValue.fromDeclaration(*declaration, _identifier.getLocation());
|
||||||
m_currentLValue.retrieveValueIfLValueNotRequested(_identifier);
|
m_currentLValue.retrieveValueIfLValueNotRequested(_identifier);
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<ContractDefinition const*>(declaration))
|
else if (dynamic_cast<ContractDefinition const*>(declaration))
|
||||||
@ -1018,32 +1018,29 @@ ExpressionCompiler::LValue::LValue(CompilerContext& _compilerContext, LValueType
|
|||||||
m_size = unsigned(m_dataType->getSizeOnStack());
|
m_size = unsigned(m_dataType->getSizeOnStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionCompiler::LValue::fromIdentifier(Identifier const& _identifier, Declaration const& _declaration)
|
void ExpressionCompiler::LValue::fromDeclaration(Declaration const& _declaration, Location const& _location)
|
||||||
{
|
{
|
||||||
if (m_context->isLocalVariable(&_declaration))
|
if (m_context->isLocalVariable(&_declaration))
|
||||||
{
|
{
|
||||||
m_type = LValueType::Stack;
|
m_type = LValueType::Stack;
|
||||||
m_dataType = _identifier.getType();
|
m_dataType = _declaration.getType();
|
||||||
m_size = m_dataType->getSizeOnStack();
|
m_size = m_dataType->getSizeOnStack();
|
||||||
m_baseStackOffset = m_context->getBaseStackOffsetOfVariable(_declaration);
|
m_baseStackOffset = m_context->getBaseStackOffsetOfVariable(_declaration);
|
||||||
}
|
}
|
||||||
else if (m_context->isStateVariable(&_declaration))
|
else if (m_context->isStateVariable(&_declaration))
|
||||||
fromVariableDeclaration(_declaration);
|
{
|
||||||
|
*m_context << m_context->getStorageLocationOfVariable(_declaration);
|
||||||
|
m_type = LValueType::Storage;
|
||||||
|
m_dataType = _declaration.getType();
|
||||||
|
solAssert(m_dataType->getStorageSize() <= numeric_limits<unsigned>::max(),
|
||||||
|
"The storage size of " + m_dataType->toString() + " should fit in an unsigned");
|
||||||
|
m_size = unsigned(m_dataType->getStorageSize());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_identifier.getLocation())
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_location)
|
||||||
<< errinfo_comment("Identifier type not supported or identifier not found."));
|
<< errinfo_comment("Identifier type not supported or identifier not found."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionCompiler::LValue::fromVariableDeclaration(Declaration const& _declaration)
|
|
||||||
{
|
|
||||||
*m_context << m_context->getStorageLocationOfVariable(_declaration);
|
|
||||||
m_type = LValueType::Storage;
|
|
||||||
m_dataType = _declaration.getType();
|
|
||||||
solAssert(m_dataType->getStorageSize() <= numeric_limits<unsigned>::max(),
|
|
||||||
"The storage size of " + m_dataType->toString() + " should fit in an unsigned");
|
|
||||||
m_size = unsigned(m_dataType->getStorageSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExpressionCompiler::LValue::retrieveValue(Location const& _location, bool _remove) const
|
void ExpressionCompiler::LValue::retrieveValue(Location const& _location, bool _remove) const
|
||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
|
@ -132,12 +132,8 @@ private:
|
|||||||
std::shared_ptr<Type const> const& _dataType, unsigned _baseStackOffset = 0);
|
std::shared_ptr<Type const> const& _dataType, unsigned _baseStackOffset = 0);
|
||||||
|
|
||||||
/// Set type according to the declaration and retrieve the reference.
|
/// Set type according to the declaration and retrieve the reference.
|
||||||
/// @a _identifier is the current identifier
|
/// @a _location is the current location
|
||||||
void fromIdentifier(Identifier const& _identifier, Declaration const& _declaration);
|
void fromDeclaration(Declaration const& _declaration, Location const& _location);
|
||||||
|
|
||||||
/// Set type according to the declaration and retrieve the reference.
|
|
||||||
/// @a _declaration is the variable declaration
|
|
||||||
void fromVariableDeclaration(const Declaration &_declaration);
|
|
||||||
|
|
||||||
void reset() { m_type = LValueType::None; m_dataType.reset(); m_baseStackOffset = 0; m_size = 0; }
|
void reset() { m_type = LValueType::None; m_dataType.reset(); m_baseStackOffset = 0; m_size = 0; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user