diff options
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/AST.h | 11 | ||||
-rw-r--r-- | libsolidity/ast/ASTAnnotations.h | 3 | ||||
-rw-r--r-- | libsolidity/ast/AST_accept.h | 4 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 6 |
4 files changed, 13 insertions, 11 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 69186cb7..e2ed1853 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1216,23 +1216,24 @@ private: }; /** - * Expression that creates a new contract, e.g. the "new SomeContract" part in "new SomeContract(1, 2)". + * Expression that creates a new contract or memory-array, + * e.g. the "new SomeContract" part in "new SomeContract(1, 2)". */ class NewExpression: public Expression { public: NewExpression( SourceLocation const& _location, - ASTPointer<Identifier> const& _contractName + ASTPointer<TypeName> const& _typeName ): - Expression(_location), m_contractName(_contractName) {} + Expression(_location), m_typeName(_typeName) {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; - Identifier const& contractName() const { return *m_contractName; } + TypeName const& typeName() const { return *m_typeName; } private: - ASTPointer<Identifier> m_contractName; + ASTPointer<TypeName> m_typeName; }; /** diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index bb59ceae..b9667302 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -111,6 +111,9 @@ struct UserDefinedTypeNameAnnotation: TypeNameAnnotation { /// Referenced declaration, set during reference resolution stage. Declaration const* referencedDeclaration = nullptr; + /// Stores a reference to the current contract. + /// This is needed because types of base contracts change depending on the context. + ContractDefinition const* contractScope = nullptr; }; struct VariableDeclarationStatementAnnotation: StatementAnnotation diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index 12a26ea7..99d1bf6a 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -634,14 +634,14 @@ void FunctionCall::accept(ASTConstVisitor& _visitor) const void NewExpression::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - m_contractName->accept(_visitor); + m_typeName->accept(_visitor); _visitor.endVisit(*this); } void NewExpression::accept(ASTConstVisitor& _visitor) const { if (_visitor.visit(*this)) - m_contractName->accept(_visitor); + m_typeName->accept(_visitor); _visitor.endVisit(*this); } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index f5aefa25..63207a51 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -141,9 +141,6 @@ public: /// Factory functions that convert an AST @ref TypeName to a Type. static TypePointer fromElementaryTypeName(Token::Value _typeToken); static TypePointer fromElementaryTypeName(std::string const& _name); - static TypePointer fromUserDefinedTypeName(UserDefinedTypeName const& _typeName); - static TypePointer fromMapping(ElementaryTypeName& _keyType, TypeName& _valueType); - static TypePointer fromArrayTypeName(TypeName& _baseTypeName, Expression* _length); /// @} /// Auto-detect the proper type for a literal. @returns an empty pointer if the literal does @@ -751,7 +748,8 @@ public: AddMod, ///< ADDMOD MulMod, ///< MULMOD ArrayPush, ///< .push() to a dynamically sized array in storage - ByteArrayPush ///< .push() to a dynamically sized byte array in storage + ByteArrayPush, ///< .push() to a dynamically sized byte array in storage + ObjectCreation ///< array creation using new }; virtual Category category() const override { return Category::Function; } |