diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-09 21:35:31 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-09 21:35:31 +0800 |
commit | 148a7cb3e1bcd4648824285e4f6dc9800d3f6de3 (patch) | |
tree | 12eae61e00be2356bd278ae127ab29f050dbb509 | |
parent | 7c0ae1a82f28f3a3679ee7160d0080eac9ca5b9c (diff) | |
download | dexon-solidity-148a7cb3e1bcd4648824285e4f6dc9800d3f6de3.tar.gz dexon-solidity-148a7cb3e1bcd4648824285e4f6dc9800d3f6de3.tar.zst dexon-solidity-148a7cb3e1bcd4648824285e4f6dc9800d3f6de3.zip |
ExpressionCompiler's enums to CamelCase
-rw-r--r-- | AST.cpp | 8 | ||||
-rw-r--r-- | AST.h | 22 | ||||
-rw-r--r-- | ASTJsonConverter.cpp | 2 | ||||
-rw-r--r-- | ExpressionCompiler.cpp | 32 | ||||
-rw-r--r-- | ExpressionCompiler.h | 16 | ||||
-rw-r--r-- | Parser.cpp | 14 |
6 files changed, 47 insertions, 47 deletions
@@ -279,9 +279,9 @@ string FunctionDefinition::getCanonicalSignature() const Declaration::LValueType VariableDeclaration::getLValueType() const { if (dynamic_cast<FunctionDefinition const*>(getScope()) || dynamic_cast<ModifierDefinition const*>(getScope())) - return Declaration::LValueType::LOCAL; + return Declaration::LValueType::Local; else - return Declaration::LValueType::STORAGE; + return Declaration::LValueType::Storage; } TypePointer ModifierDefinition::getType(ContractDefinition const*) const @@ -577,7 +577,7 @@ void MemberAccess::checkTypeRequirements() BOOST_THROW_EXCEPTION(createTypeError("Member \"" + *m_memberName + "\" not found or not " "visible in " + type.toString())); //@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() @@ -589,7 +589,7 @@ void IndexAccess::checkTypeRequirements() MappingType const& type = dynamic_cast<MappingType const&>(*m_base->getType()); m_index->expectType(*type.getKeyType()); m_type = type.getValueType(); - m_lvalue = Declaration::LValueType::STORAGE; + m_lvalue = Declaration::LValueType::Storage; } void Identifier::checkTypeRequirements() @@ -132,17 +132,17 @@ private: class Declaration: public ASTNode { public: - enum class LValueType { NONE, LOCAL, STORAGE }; - enum class Visibility { DEFAULT, PUBLIC, PROTECTED, PRIVATE }; + enum class LValueType { None, Local, Storage }; + enum class Visibility { Default, Public, Protected, Private }; 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) {} /// @returns the declared name. ASTString const& getName() const { return *m_name; } - Visibility getVisibility() const { return m_visibility == Visibility::DEFAULT ? getDefaultVisibility() : m_visibility; } - bool isPublic() const { return getVisibility() == Visibility::PUBLIC; } + Visibility getVisibility() const { return m_visibility == Visibility::Default ? getDefaultVisibility() : m_visibility; } + bool isPublic() const { return getVisibility() == Visibility::Public; } /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. /// Available only after name and type resolution step. @@ -154,10 +154,10 @@ public: /// contract types. virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0; /// @returns the lvalue type of expressions referencing this declaration - virtual LValueType getLValueType() const { return LValueType::NONE; } + virtual LValueType getLValueType() const { return LValueType::None; } protected: - virtual Visibility getDefaultVisibility() const { return Visibility::PUBLIC; } + virtual Visibility getDefaultVisibility() const { return Visibility::Public; } private: ASTPointer<ASTString> m_name; @@ -414,7 +414,7 @@ public: bool isIndexed() const { return m_isIndexed; } protected: - Visibility getDefaultVisibility() const override { return Visibility::PROTECTED; } + Visibility getDefaultVisibility() const override { return Visibility::Protected; } private: ASTPointer<TypeName> m_typeName; ///< can be empty ("var") @@ -847,8 +847,8 @@ public: virtual void checkTypeRequirements() = 0; std::shared_ptr<Type const> const& getType() const { return m_type; } - bool isLValue() const { return m_lvalue != Declaration::LValueType::NONE; } - bool isLocalLValue() const { return m_lvalue == Declaration::LValueType::LOCAL; } + bool isLValue() const { return m_lvalue != Declaration::LValueType::None; } + bool isLocalLValue() const { return m_lvalue == Declaration::LValueType::Local; } /// Helper function, infer the type via @ref checkTypeRequirements and then check that it /// is implicitly convertible to @a _expectedType. If not, throw exception. @@ -865,7 +865,7 @@ protected: std::shared_ptr<Type const> m_type; //! 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() - 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. bool m_lvalueRequested = false; }; diff --git a/ASTJsonConverter.cpp b/ASTJsonConverter.cpp index d9332990..a216a59a 100644 --- a/ASTJsonConverter.cpp +++ b/ASTJsonConverter.cpp @@ -118,7 +118,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) bool ASTJsonConverter::visit(VariableDeclaration const& _node) { - bool isLocalVariable = (_node.getLValueType() == VariableDeclaration::LValueType::LOCAL); + bool isLocalVariable = (_node.getLValueType() == VariableDeclaration::LValueType::Local); addJsonNode("VariableDeclaration", { make_pair("name", _node.getName()), make_pair("local", boost::lexical_cast<std::string>(isLocalVariable))}, diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 1da309e6..cdbfde6f 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -479,7 +479,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) { StructType const& type = dynamic_cast<StructType const&>(*_memberAccess.getExpression().getType()); 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); break; } @@ -515,7 +515,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) length += CompilerUtils(m_context).storeInMemory(length); 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); return false; @@ -922,7 +922,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& m_context << eth::Instruction::DUP1 << structType->getStorageOffsetOfMember(names[i]) << 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); solAssert(types[i]->getSizeOnStack() == 1, "Returning struct elements with stack size != 1 not yet implemented."); m_context << eth::Instruction::SWAP1; @@ -934,7 +934,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& { // simple value 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); retSizeOnStack = returnType->getSizeOnStack(); } @@ -948,7 +948,7 @@ ExpressionCompiler::LValue::LValue(CompilerContext& _compilerContext, LValueType { //@todo change the type cast for arrays 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()); else m_size = unsigned(_dataType.getSizeOnStack()); @@ -958,7 +958,7 @@ void ExpressionCompiler::LValue::retrieveValue(TypePointer const& _type, Locatio { switch (m_type) { - case STACK: + case LValueType::STACK: { unsigned stackPos = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset)); 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); break; } - case STORAGE: + case LValueType::STORAGE: retrieveValueFromStorage(_type, _remove); break; - case MEMORY: + case LValueType::MEMORY: if (!_type->isValueType()) break; // no distinction between value and reference for non-value types BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_location) @@ -1007,7 +1007,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, bool { switch (m_type) { - case STACK: + case LValueType::STACK: { unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset)) - m_size + 1; if (stackDiff > 16) @@ -1020,7 +1020,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, bool retrieveValue(_expression.getType(), _expression.getLocation()); break; } - case LValue::STORAGE: + case LValueType::STORAGE: if (!_expression.getType()->isValueType()) break; // no distinction between value and reference for non-value types // 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; } break; - case LValue::MEMORY: + case LValueType::MEMORY: if (!_expression.getType()->isValueType()) break; // no distinction between value and reference for non-value types BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_sourceLocation(_expression.getLocation()) @@ -1062,7 +1062,7 @@ void ExpressionCompiler::LValue::setToZero(Expression const& _expression) const { switch (m_type) { - case STACK: + case LValueType::STACK: { unsigned stackDiff = m_context->baseToCurrentStackOffset(unsigned(m_baseStackOffset)); if (stackDiff > 16) @@ -1074,7 +1074,7 @@ void ExpressionCompiler::LValue::setToZero(Expression const& _expression) const << eth::Instruction::POP; break; } - case LValue::STORAGE: + case LValueType::STORAGE: if (m_size == 0) *m_context << eth::Instruction::POP; 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; } break; - case LValue::MEMORY: + case LValueType::MEMORY: if (!_expression.getType()->isValueType()) break; // no distinction between value and reference for non-value types 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) { - 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"); *m_context << m_context->getStorageLocationOfVariable(_varDecl); m_size = unsigned(_type->getStorageSize()); @@ -1121,7 +1121,7 @@ void ExpressionCompiler::LValue::fromIdentifier(Identifier const& _identifier, D { if (m_context->isLocalVariable(&_declaration)) { - m_type = STACK; + m_type = LValueType::STACK; m_size = _identifier.getType()->getSizeOnStack(); m_baseStackOffset = m_context->getBaseStackOffsetOfVariable(_declaration); } diff --git a/ExpressionCompiler.h b/ExpressionCompiler.h index 006858cb..ffb9ff19 100644 --- a/ExpressionCompiler.h +++ b/ExpressionCompiler.h @@ -120,7 +120,7 @@ private: class LValue { public: - enum LValueType { NONE, STACK, MEMORY, STORAGE }; + enum class LValueType { NONE, STACK, MEMORY, STORAGE }; explicit LValue(CompilerContext& _compilerContext): m_context(&_compilerContext) { reset(); } LValue(CompilerContext& _compilerContext, LValueType _type, Type const& _dataType, unsigned _baseStackOffset = 0); @@ -130,15 +130,15 @@ private: void fromIdentifier(Identifier const& _identifier, Declaration const& _declaration); /// Convenience function to set type for a state variable and retrieve the reference 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 isInOnStack() const { return m_type == STACK; } - bool isInMemory() const { return m_type == MEMORY; } - bool isInStorage() const { return m_type == STORAGE; } + bool isValid() const { return m_type != LValueType::NONE; } + bool isInOnStack() const { return m_type == LValueType::STACK; } + bool isInMemory() const { return m_type == LValueType::MEMORY; } + bool isInStorage() const { return m_type == LValueType::STORAGE; } /// @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, /// 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; CompilerContext* m_context; - LValueType m_type = NONE; + LValueType m_type = LValueType::NONE; /// If m_type is STACK, this is base stack offset (@see /// CompilerContext::getBaseStackOffsetOfVariable) of a local variable. unsigned m_baseStackOffset = 0; @@ -180,13 +180,13 @@ ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier() Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token) { - Declaration::Visibility visibility(Declaration::Visibility::DEFAULT); + Declaration::Visibility visibility(Declaration::Visibility::Default); if (_token == Token::Public) - visibility = Declaration::Visibility::PUBLIC; + visibility = Declaration::Visibility::Public; else if (_token == Token::Protected) - visibility = Declaration::Visibility::PROTECTED; + visibility = Declaration::Visibility::Protected; else if (_token == Token::Private) - visibility = Declaration::Visibility::PRIVATE; + visibility = Declaration::Visibility::Private; else solAssert(false, "Invalid visibility specifier."); m_scanner->next(); @@ -208,7 +208,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(ASTString const* name = expectIdentifierToken(); ASTPointer<ParameterList> parameters(parseParameterList()); bool isDeclaredConst = false; - Declaration::Visibility visibility(Declaration::Visibility::DEFAULT); + Declaration::Visibility visibility(Declaration::Visibility::Default); vector<ASTPointer<ModifierInvocation>> modifiers; while (true) { @@ -222,7 +222,7 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(ASTString const* modifiers.push_back(parseModifierInvocation()); else if (Token::isVisibilitySpecifier(token)) { - if (visibility != Declaration::Visibility::DEFAULT) + if (visibility != Declaration::Visibility::Default) BOOST_THROW_EXCEPTION(createParserError("Multiple visibility specifiers.")); visibility = parseVisibilitySpecifier(token); } @@ -272,7 +272,7 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(VarDeclParserOp bool isIndexed = false; ASTPointer<ASTString> identifier; Token::Value token = m_scanner->getCurrentToken(); - Declaration::Visibility visibility(Declaration::Visibility::DEFAULT); + Declaration::Visibility visibility(Declaration::Visibility::Default); if (_options.isStateVariable && Token::isVisibilitySpecifier(token)) visibility = parseVisibilitySpecifier(token); if (_options.allowIndexed && token == Token::Indexed) |