mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ExpressionCompiler's enums to CamelCase
This commit is contained in:
parent
7c0ae1a82f
commit
148a7cb3e1
8
AST.cpp
8
AST.cpp
@ -279,9 +279,9 @@ string FunctionDefinition::getCanonicalSignature() const
|
|||||||
Declaration::LValueType VariableDeclaration::getLValueType() const
|
Declaration::LValueType VariableDeclaration::getLValueType() const
|
||||||
{
|
{
|
||||||
if (dynamic_cast<FunctionDefinition const*>(getScope()) || dynamic_cast<ModifierDefinition const*>(getScope()))
|
if (dynamic_cast<FunctionDefinition const*>(getScope()) || dynamic_cast<ModifierDefinition const*>(getScope()))
|
||||||
return Declaration::LValueType::LOCAL;
|
return Declaration::LValueType::Local;
|
||||||
else
|
else
|
||||||
return Declaration::LValueType::STORAGE;
|
return Declaration::LValueType::Storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypePointer ModifierDefinition::getType(ContractDefinition const*) const
|
TypePointer ModifierDefinition::getType(ContractDefinition const*) const
|
||||||
@ -577,7 +577,7 @@ void MemberAccess::checkTypeRequirements()
|
|||||||
BOOST_THROW_EXCEPTION(createTypeError("Member \"" + *m_memberName + "\" not found or not "
|
BOOST_THROW_EXCEPTION(createTypeError("Member \"" + *m_memberName + "\" not found or not "
|
||||||
"visible in " + type.toString()));
|
"visible in " + type.toString()));
|
||||||
//@todo later, this will not always be STORAGE
|
//@todo later, this will not always be STORAGE
|
||||||
m_lvalue = type.getCategory() == Type::Category::Struct ? Declaration::LValueType::STORAGE : Declaration::LValueType::NONE;
|
m_lvalue = type.getCategory() == Type::Category::Struct ? Declaration::LValueType::Storage : Declaration::LValueType::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexAccess::checkTypeRequirements()
|
void IndexAccess::checkTypeRequirements()
|
||||||
@ -589,7 +589,7 @@ void IndexAccess::checkTypeRequirements()
|
|||||||
MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType());
|
MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType());
|
||||||
m_index->expectType(*type.getKeyType());
|
m_index->expectType(*type.getKeyType());
|
||||||
m_type = type.getValueType();
|
m_type = type.getValueType();
|
||||||
m_lvalue = Declaration::LValueType::STORAGE;
|
m_lvalue = Declaration::LValueType::Storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Identifier::checkTypeRequirements()
|
void Identifier::checkTypeRequirements()
|
||||||
|
22
AST.h
22
AST.h
@ -132,17 +132,17 @@ private:
|
|||||||
class Declaration: public ASTNode
|
class Declaration: public ASTNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class LValueType { NONE, LOCAL, STORAGE };
|
enum class LValueType { None, Local, Storage };
|
||||||
enum class Visibility { DEFAULT, PUBLIC, PROTECTED, PRIVATE };
|
enum class Visibility { Default, Public, Protected, Private };
|
||||||
|
|
||||||
Declaration(Location const& _location, ASTPointer<ASTString> const& _name,
|
Declaration(Location const& _location, ASTPointer<ASTString> const& _name,
|
||||||
Visibility _visibility = Visibility::DEFAULT):
|
Visibility _visibility = Visibility::Default):
|
||||||
ASTNode(_location), m_name(_name), m_visibility(_visibility), m_scope(nullptr) {}
|
ASTNode(_location), m_name(_name), m_visibility(_visibility), m_scope(nullptr) {}
|
||||||
|
|
||||||
/// @returns the declared name.
|
/// @returns the declared name.
|
||||||
ASTString const& getName() const { return *m_name; }
|
ASTString const& getName() const { return *m_name; }
|
||||||
Visibility getVisibility() const { return m_visibility == Visibility::DEFAULT ? getDefaultVisibility() : m_visibility; }
|
Visibility getVisibility() const { return m_visibility == Visibility::Default ? getDefaultVisibility() : m_visibility; }
|
||||||
bool isPublic() const { return getVisibility() == Visibility::PUBLIC; }
|
bool isPublic() const { return getVisibility() == Visibility::Public; }
|
||||||
|
|
||||||
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
|
/// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
|
||||||
/// Available only after name and type resolution step.
|
/// Available only after name and type resolution step.
|
||||||
@ -154,10 +154,10 @@ public:
|
|||||||
/// contract types.
|
/// contract types.
|
||||||
virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0;
|
virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0;
|
||||||
/// @returns the lvalue type of expressions referencing this declaration
|
/// @returns the lvalue type of expressions referencing this declaration
|
||||||
virtual LValueType getLValueType() const { return LValueType::NONE; }
|
virtual LValueType getLValueType() const { return LValueType::None; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Visibility getDefaultVisibility() const { return Visibility::PUBLIC; }
|
virtual Visibility getDefaultVisibility() const { return Visibility::Public; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<ASTString> m_name;
|
ASTPointer<ASTString> m_name;
|
||||||
@ -414,7 +414,7 @@ public:
|
|||||||
bool isIndexed() const { return m_isIndexed; }
|
bool isIndexed() const { return m_isIndexed; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Visibility getDefaultVisibility() const override { return Visibility::PROTECTED; }
|
Visibility getDefaultVisibility() const override { return Visibility::Protected; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
|
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
|
||||||
@ -847,8 +847,8 @@ public:
|
|||||||
virtual void checkTypeRequirements() = 0;
|
virtual void checkTypeRequirements() = 0;
|
||||||
|
|
||||||
std::shared_ptr<Type const> const& getType() const { return m_type; }
|
std::shared_ptr<Type const> const& getType() const { return m_type; }
|
||||||
bool isLValue() const { return m_lvalue != Declaration::LValueType::NONE; }
|
bool isLValue() const { return m_lvalue != Declaration::LValueType::None; }
|
||||||
bool isLocalLValue() const { return m_lvalue == Declaration::LValueType::LOCAL; }
|
bool isLocalLValue() const { return m_lvalue == Declaration::LValueType::Local; }
|
||||||
|
|
||||||
/// Helper function, infer the type via @ref checkTypeRequirements and then check that it
|
/// Helper function, infer the type via @ref checkTypeRequirements and then check that it
|
||||||
/// is implicitly convertible to @a _expectedType. If not, throw exception.
|
/// is implicitly convertible to @a _expectedType. If not, throw exception.
|
||||||
@ -865,7 +865,7 @@ protected:
|
|||||||
std::shared_ptr<Type const> m_type;
|
std::shared_ptr<Type const> m_type;
|
||||||
//! If this expression is an lvalue (i.e. something that can be assigned to) and is stored
|
//! If this expression is an lvalue (i.e. something that can be assigned to) and is stored
|
||||||
//! locally or in storage. This is set during calls to @a checkTypeRequirements()
|
//! locally or in storage. This is set during calls to @a checkTypeRequirements()
|
||||||
Declaration::LValueType m_lvalue = Declaration::LValueType::NONE;
|
Declaration::LValueType m_lvalue = Declaration::LValueType::None;
|
||||||
//! Whether the outer expression requested the address (true) or the value (false) of this expression.
|
//! Whether the outer expression requested the address (true) or the value (false) of this expression.
|
||||||
bool m_lvalueRequested = false;
|
bool m_lvalueRequested = false;
|
||||||
};
|
};
|
||||||
|
@ -118,7 +118,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
|
|||||||
|
|
||||||
bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
||||||
{
|
{
|
||||||
bool isLocalVariable = (_node.getLValueType() == VariableDeclaration::LValueType::LOCAL);
|
bool isLocalVariable = (_node.getLValueType() == VariableDeclaration::LValueType::Local);
|
||||||
addJsonNode("VariableDeclaration",
|
addJsonNode("VariableDeclaration",
|
||||||
{ make_pair("name", _node.getName()),
|
{ make_pair("name", _node.getName()),
|
||||||
make_pair("local", boost::lexical_cast<std::string>(isLocalVariable))},
|
make_pair("local", boost::lexical_cast<std::string>(isLocalVariable))},
|
||||||
|
@ -479,7 +479,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
|
|||||||
{
|
{
|
||||||
StructType const& type = dynamic_cast<StructType const&>(*_memberAccess.getExpression().getType());
|
StructType const& type = dynamic_cast<StructType const&>(*_memberAccess.getExpression().getType());
|
||||||
m_context << type.getStorageOffsetOfMember(member) << eth::Instruction::ADD;
|
m_context << type.getStorageOffsetOfMember(member) << eth::Instruction::ADD;
|
||||||
m_currentLValue = LValue(m_context, LValue::STORAGE, *_memberAccess.getType());
|
m_currentLValue = LValue(m_context, LValue::LValueType::STORAGE, *_memberAccess.getType());
|
||||||
m_currentLValue.retrieveValueIfLValueNotRequested(_memberAccess);
|
m_currentLValue.retrieveValueIfLValueNotRequested(_memberAccess);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
|
|||||||
length += CompilerUtils(m_context).storeInMemory(length);
|
length += CompilerUtils(m_context).storeInMemory(length);
|
||||||
m_context << u256(length) << u256(0) << eth::Instruction::SHA3;
|
m_context << u256(length) << u256(0) << eth::Instruction::SHA3;
|
||||||
|
|
||||||
m_currentLValue = LValue(m_context, LValue::STORAGE, *_indexAccess.getType());
|
m_currentLValue = LValue(m_context, LValue::LValueType::STORAGE, *_indexAccess.getType());
|
||||||
m_currentLValue.retrieveValueIfLValueNotRequested(_indexAccess);
|
m_currentLValue.retrieveValueIfLValueNotRequested(_indexAccess);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -922,7 +922,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
|
|||||||
m_context << eth::Instruction::DUP1
|
m_context << eth::Instruction::DUP1
|
||||||
<< structType->getStorageOffsetOfMember(names[i])
|
<< structType->getStorageOffsetOfMember(names[i])
|
||||||
<< eth::Instruction::ADD;
|
<< eth::Instruction::ADD;
|
||||||
m_currentLValue = LValue(m_context, LValue::STORAGE, *types[i]);
|
m_currentLValue = LValue(m_context, LValue::LValueType::STORAGE, *types[i]);
|
||||||
m_currentLValue.retrieveValue(types[i], Location(), true);
|
m_currentLValue.retrieveValue(types[i], Location(), true);
|
||||||
solAssert(types[i]->getSizeOnStack() == 1, "Returning struct elements with stack size != 1 not yet implemented.");
|
solAssert(types[i]->getSizeOnStack() == 1, "Returning struct elements with stack size != 1 not yet implemented.");
|
||||||
m_context << eth::Instruction::SWAP1;
|
m_context << eth::Instruction::SWAP1;
|
||||||
@ -934,7 +934,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
|
|||||||
{
|
{
|
||||||
// simple value
|
// simple value
|
||||||
solAssert(accessorType.getReturnParameterTypes().size() == 1, "");
|
solAssert(accessorType.getReturnParameterTypes().size() == 1, "");
|
||||||
m_currentLValue = LValue(m_context, LValue::STORAGE, *returnType);
|
m_currentLValue = LValue(m_context, LValue::LValueType::STORAGE, *returnType);
|
||||||
m_currentLValue.retrieveValue(returnType, Location(), true);
|
m_currentLValue.retrieveValue(returnType, Location(), true);
|
||||||
retSizeOnStack = returnType->getSizeOnStack();
|
retSizeOnStack = returnType->getSizeOnStack();
|
||||||
}
|
}
|
||||||
@ -948,7 +948,7 @@ ExpressionCompiler::LValue::LValue(CompilerContext& _compilerContext, LValueType
|
|||||||
{
|
{
|
||||||
//@todo change the type cast for arrays
|
//@todo change the type cast for arrays
|
||||||
solAssert(_dataType.getStorageSize() <= numeric_limits<unsigned>::max(), "The storage size of " +_dataType.toString() + " should fit in unsigned");
|
solAssert(_dataType.getStorageSize() <= numeric_limits<unsigned>::max(), "The storage size of " +_dataType.toString() + " should fit in unsigned");
|
||||||
if (m_type == STORAGE)
|
if (m_type == LValueType::STORAGE)
|
||||||
m_size = unsigned(_dataType.getStorageSize());
|
m_size = unsigned(_dataType.getStorageSize());
|
||||||
else
|
else
|
||||||
m_size = unsigned(_dataType.getSizeOnStack());
|
m_size = unsigned(_dataType.getSizeOnStack());
|
||||||
@ -958,7 +958,7 @@ void ExpressionCompiler::LValue::retrieveValue(TypePointer const& _type, Locatio
|
|||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case STACK:
|
case LValueType::STACK:
|
||||||
{
|
{
|
||||||
unsigned stackPos = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset));
|
unsigned stackPos = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset));
|
||||||
if (stackPos >= 15) //@todo correct this by fetching earlier or moving to memory
|
if (stackPos >= 15) //@todo correct this by fetching earlier or moving to memory
|
||||||
@ -968,10 +968,10 @@ void ExpressionCompiler::LValue::retrieveValue(TypePointer const& _type, Locatio
|
|||||||
*m_context << eth::dupInstruction(stackPos + 1);
|
*m_context << eth::dupInstruction(stackPos + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STORAGE:
|
case LValueType::STORAGE:
|
||||||
retrieveValueFromStorage(_type, _remove);
|
retrieveValueFromStorage(_type, _remove);
|
||||||
break;
|
break;
|
||||||
case MEMORY:
|
case LValueType::MEMORY:
|
||||||
if (!_type->isValueType())
|
if (!_type->isValueType())
|
||||||
break; // no distinction between value and reference for non-value types
|
break; // no distinction between value and reference for non-value types
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_location)
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_location)
|
||||||
@ -1007,7 +1007,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, bool
|
|||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case STACK:
|
case LValueType::STACK:
|
||||||
{
|
{
|
||||||
unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset)) - m_size + 1;
|
unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset)) - m_size + 1;
|
||||||
if (stackDiff > 16)
|
if (stackDiff > 16)
|
||||||
@ -1020,7 +1020,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, bool
|
|||||||
retrieveValue(_expression.getType(), _expression.getLocation());
|
retrieveValue(_expression.getType(), _expression.getLocation());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LValue::STORAGE:
|
case LValueType::STORAGE:
|
||||||
if (!_expression.getType()->isValueType())
|
if (!_expression.getType()->isValueType())
|
||||||
break; // no distinction between value and reference for non-value types
|
break; // no distinction between value and reference for non-value types
|
||||||
// stack layout: value value ... value ref
|
// stack layout: value value ... value ref
|
||||||
@ -1045,7 +1045,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, bool
|
|||||||
<< u256(1) << eth::Instruction::SWAP1 << eth::Instruction::SUB;
|
<< u256(1) << eth::Instruction::SWAP1 << eth::Instruction::SUB;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LValue::MEMORY:
|
case LValueType::MEMORY:
|
||||||
if (!_expression.getType()->isValueType())
|
if (!_expression.getType()->isValueType())
|
||||||
break; // no distinction between value and reference for non-value types
|
break; // no distinction between value and reference for non-value types
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_expression.getLocation())
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_expression.getLocation())
|
||||||
@ -1062,7 +1062,7 @@ void ExpressionCompiler::LValue::setToZero(Expression const& _expression) const
|
|||||||
{
|
{
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case STACK:
|
case LValueType::STACK:
|
||||||
{
|
{
|
||||||
unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset));
|
unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset));
|
||||||
if (stackDiff > 16)
|
if (stackDiff > 16)
|
||||||
@ -1074,7 +1074,7 @@ void ExpressionCompiler::LValue::setToZero(Expression const& _expression) const
|
|||||||
<< eth::Instruction::POP;
|
<< eth::Instruction::POP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LValue::STORAGE:
|
case LValueType::STORAGE:
|
||||||
if (m_size == 0)
|
if (m_size == 0)
|
||||||
*m_context << eth::Instruction::POP;
|
*m_context << eth::Instruction::POP;
|
||||||
for (unsigned i = 0; i < m_size; ++i)
|
for (unsigned i = 0; i < m_size; ++i)
|
||||||
@ -1086,7 +1086,7 @@ void ExpressionCompiler::LValue::setToZero(Expression const& _expression) const
|
|||||||
<< u256(1) << eth::Instruction::ADD;
|
<< u256(1) << eth::Instruction::ADD;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LValue::MEMORY:
|
case LValueType::MEMORY:
|
||||||
if (!_expression.getType()->isValueType())
|
if (!_expression.getType()->isValueType())
|
||||||
break; // no distinction between value and reference for non-value types
|
break; // no distinction between value and reference for non-value types
|
||||||
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_expression.getLocation())
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_expression.getLocation())
|
||||||
@ -1111,7 +1111,7 @@ void ExpressionCompiler::LValue::retrieveValueIfLValueNotRequested(Expression co
|
|||||||
|
|
||||||
void ExpressionCompiler::LValue::fromStateVariable(Declaration const& _varDecl, TypePointer const& _type)
|
void ExpressionCompiler::LValue::fromStateVariable(Declaration const& _varDecl, TypePointer const& _type)
|
||||||
{
|
{
|
||||||
m_type = STORAGE;
|
m_type = LValueType::STORAGE;
|
||||||
solAssert(_type->getStorageSize() <= numeric_limits<unsigned>::max(), "The storage size of " + _type->toString() + " should fit in an unsigned");
|
solAssert(_type->getStorageSize() <= numeric_limits<unsigned>::max(), "The storage size of " + _type->toString() + " should fit in an unsigned");
|
||||||
*m_context << m_context->getStorageLocationOfVariable(_varDecl);
|
*m_context << m_context->getStorageLocationOfVariable(_varDecl);
|
||||||
m_size = unsigned(_type->getStorageSize());
|
m_size = unsigned(_type->getStorageSize());
|
||||||
@ -1121,7 +1121,7 @@ void ExpressionCompiler::LValue::fromIdentifier(Identifier const& _identifier, D
|
|||||||
{
|
{
|
||||||
if (m_context->isLocalVariable(&_declaration))
|
if (m_context->isLocalVariable(&_declaration))
|
||||||
{
|
{
|
||||||
m_type = STACK;
|
m_type = LValueType::STACK;
|
||||||
m_size = _identifier.getType()->getSizeOnStack();
|
m_size = _identifier.getType()->getSizeOnStack();
|
||||||
m_baseStackOffset = m_context->getBaseStackOffsetOfVariable(_declaration);
|
m_baseStackOffset = m_context->getBaseStackOffsetOfVariable(_declaration);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ private:
|
|||||||
class LValue
|
class LValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum LValueType { NONE, STACK, MEMORY, STORAGE };
|
enum class LValueType { NONE, STACK, MEMORY, STORAGE };
|
||||||
|
|
||||||
explicit LValue(CompilerContext& _compilerContext): m_context(&_compilerContext) { reset(); }
|
explicit LValue(CompilerContext& _compilerContext): m_context(&_compilerContext) { reset(); }
|
||||||
LValue(CompilerContext& _compilerContext, LValueType _type, Type const& _dataType, unsigned _baseStackOffset = 0);
|
LValue(CompilerContext& _compilerContext, LValueType _type, Type const& _dataType, unsigned _baseStackOffset = 0);
|
||||||
@ -130,15 +130,15 @@ private:
|
|||||||
void fromIdentifier(Identifier const& _identifier, Declaration const& _declaration);
|
void fromIdentifier(Identifier const& _identifier, Declaration const& _declaration);
|
||||||
/// Convenience function to set type for a state variable and retrieve the reference
|
/// Convenience function to set type for a state variable and retrieve the reference
|
||||||
void fromStateVariable(Declaration const& _varDecl, TypePointer const& _type);
|
void fromStateVariable(Declaration const& _varDecl, TypePointer const& _type);
|
||||||
void reset() { m_type = NONE; m_baseStackOffset = 0; m_size = 0; }
|
void reset() { m_type = LValueType::NONE; m_baseStackOffset = 0; m_size = 0; }
|
||||||
|
|
||||||
bool isValid() const { return m_type != NONE; }
|
bool isValid() const { return m_type != LValueType::NONE; }
|
||||||
bool isInOnStack() const { return m_type == STACK; }
|
bool isInOnStack() const { return m_type == LValueType::STACK; }
|
||||||
bool isInMemory() const { return m_type == MEMORY; }
|
bool isInMemory() const { return m_type == LValueType::MEMORY; }
|
||||||
bool isInStorage() const { return m_type == STORAGE; }
|
bool isInStorage() const { return m_type == LValueType::STORAGE; }
|
||||||
|
|
||||||
/// @returns true if this lvalue reference type occupies a slot on the stack.
|
/// @returns true if this lvalue reference type occupies a slot on the stack.
|
||||||
bool storesReferenceOnStack() const { return m_type == STORAGE || m_type == MEMORY; }
|
bool storesReferenceOnStack() const { return m_type == LValueType::STORAGE || m_type == LValueType::MEMORY; }
|
||||||
|
|
||||||
/// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true,
|
/// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true,
|
||||||
/// also removes the reference from the stack (note that is does not reset the type to @a NONE).
|
/// also removes the reference from the stack (note that is does not reset the type to @a NONE).
|
||||||
@ -162,7 +162,7 @@ private:
|
|||||||
void retrieveValueFromStorage(TypePointer const& _type, bool _remove = false) const;
|
void retrieveValueFromStorage(TypePointer const& _type, bool _remove = false) const;
|
||||||
|
|
||||||
CompilerContext* m_context;
|
CompilerContext* m_context;
|
||||||
LValueType m_type = NONE;
|
LValueType m_type = LValueType::NONE;
|
||||||
/// If m_type is STACK, this is base stack offset (@see
|
/// If m_type is STACK, this is base stack offset (@see
|
||||||
/// CompilerContext::getBaseStackOffsetOfVariable) of a local variable.
|
/// CompilerContext::getBaseStackOffsetOfVariable) of a local variable.
|
||||||
unsigned m_baseStackOffset = 0;
|
unsigned m_baseStackOffset = 0;
|
||||||
|
14
Parser.cpp
14
Parser.cpp
@ -180,13 +180,13 @@ ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier()
|
|||||||
|
|
||||||
Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token)
|
Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token)
|
||||||
{
|
{
|
||||||
Declaration::Visibility visibility(Declaration::Visibility::DEFAULT);
|
Declaration::Visibility visibility(Declaration::Visibility::Default);
|
||||||
if (_token == Token::Public)
|
if (_token == Token::Public)
|
||||||
visibility = Declaration::Visibility::PUBLIC;
|
visibility = Declaration::Visibility::Public;
|
||||||
else if (_token == Token::Protected)
|
else if (_token == Token::Protected)
|
||||||
visibility = Declaration::Visibility::PROTECTED;
|
visibility = Declaration::Visibility::Protected;
|
||||||
else if (_token == Token::Private)
|
else if (_token == Token::Private)
|
||||||
visibility = Declaration::Visibility::PRIVATE;
|
visibility = Declaration::Visibility::Private;
|
||||||
else
|
else
|
||||||
solAssert(false, "Invalid visibility specifier.");
|
solAssert(false, "Invalid visibility specifier.");
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
@ -208,7 +208,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(ASTString const*
|
|||||||
name = expectIdentifierToken();
|
name = expectIdentifierToken();
|
||||||
ASTPointer<ParameterList> parameters(parseParameterList());
|
ASTPointer<ParameterList> parameters(parseParameterList());
|
||||||
bool isDeclaredConst = false;
|
bool isDeclaredConst = false;
|
||||||
Declaration::Visibility visibility(Declaration::Visibility::DEFAULT);
|
Declaration::Visibility visibility(Declaration::Visibility::Default);
|
||||||
vector<ASTPointer<ModifierInvocation>> modifiers;
|
vector<ASTPointer<ModifierInvocation>> modifiers;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -222,7 +222,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(ASTString const*
|
|||||||
modifiers.push_back(parseModifierInvocation());
|
modifiers.push_back(parseModifierInvocation());
|
||||||
else if (Token::isVisibilitySpecifier(token))
|
else if (Token::isVisibilitySpecifier(token))
|
||||||
{
|
{
|
||||||
if (visibility != Declaration::Visibility::DEFAULT)
|
if (visibility != Declaration::Visibility::Default)
|
||||||
BOOST_THROW_EXCEPTION(createParserError("Multiple visibility specifiers."));
|
BOOST_THROW_EXCEPTION(createParserError("Multiple visibility specifiers."));
|
||||||
visibility = parseVisibilitySpecifier(token);
|
visibility = parseVisibilitySpecifier(token);
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(VarDeclParserOp
|
|||||||
bool isIndexed = false;
|
bool isIndexed = false;
|
||||||
ASTPointer<ASTString> identifier;
|
ASTPointer<ASTString> identifier;
|
||||||
Token::Value token = m_scanner->getCurrentToken();
|
Token::Value token = m_scanner->getCurrentToken();
|
||||||
Declaration::Visibility visibility(Declaration::Visibility::DEFAULT);
|
Declaration::Visibility visibility(Declaration::Visibility::Default);
|
||||||
if (_options.isStateVariable && Token::isVisibilitySpecifier(token))
|
if (_options.isStateVariable && Token::isVisibilitySpecifier(token))
|
||||||
visibility = parseVisibilitySpecifier(token);
|
visibility = parseVisibilitySpecifier(token);
|
||||||
if (_options.allowIndexed && token == Token::Indexed)
|
if (_options.allowIndexed && token == Token::Indexed)
|
||||||
|
Loading…
Reference in New Issue
Block a user