11// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22#pragma once
33
4+ #include " soll/AST/ASTBase.h"
45#include " soll/AST/ASTForward.h"
56#include " soll/AST/DeclVisitor.h"
67#include " soll/AST/Expr.h"
@@ -14,11 +15,13 @@ namespace soll {
1415
1516class ASTContext ;
1617
17- class Decl {
18+ class Decl : public ASTNode {
1819public:
1920 enum class Visibility { Default, Private, Internal, Public, External };
2021 virtual ~Decl () noexcept {}
2122
23+ ASTNodeType getASTType () override { return ASTNode::ASTNodeType::DECL; }
24+
2225private:
2326 SourceRange Location;
2427 std::string Name;
@@ -31,8 +34,11 @@ class Decl {
3134protected:
3235 Decl (SourceRange L,
3336 llvm::StringRef Name = llvm::StringRef::withNullAsEmpty(nullptr ),
34- Visibility vis = Visibility::Default)
35- : Location(L), Name(Name.str()), Vis(vis), UniqueName(Name.str()) {}
37+ Visibility Vis = Visibility::Default)
38+ : Location(L), Name(Name.str()), Vis(Vis), UniqueName(Name.str()) {}
39+
40+ Decl (SourceRange L, std::string Name, Visibility Vis = Visibility::Default)
41+ : Location(L), Name(Name), Vis(Vis), UniqueName(Name) {}
3642
3743public:
3844 virtual void accept (DeclVisitor &visitor) = 0;
@@ -44,6 +50,29 @@ class Decl {
4450 Visibility getVisibility () const { return Vis; }
4551};
4652
53+ /* *
54+ * Pseudo AST node that is used as declaration for "this", "msg", "tx", "block"
55+ * and the global functions when such an identifier is encountered. Will never
56+ * have a valid location in the source code
57+ */
58+ class MagicVariableDecl : public Decl {
59+ public:
60+ MagicVariableDecl (int Id, std::string MagicName, TypePtr Type)
61+ : Decl(SourceRange(), MagicName), Type(Type) {}
62+
63+ virtual void accept (DeclVisitor &visitor) override {
64+ assert (false && " MagicVariable should used inside real AST" );
65+ };
66+ virtual void accept (ConstDeclVisitor &visitor) const override {
67+ assert (false && " MagicVariable should used inside real AST" );
68+ };
69+
70+ TypePtr getType () { return Type; }
71+
72+ private:
73+ TypePtr Type;
74+ };
75+
4776class SourceUnit : public Decl {
4877 std::vector<DeclPtr> Nodes;
4978
@@ -373,10 +402,11 @@ class StructDecl : public Decl {
373402 Token Tok;
374403 TypePtr Ty;
375404 TypePtr ConstructorTy;
405+ std::vector<VarDeclBasePtr> Members;
376406
377407public:
378408 StructDecl (Token NameTok, SourceRange L, llvm::StringRef Name,
379- std::vector<TypePtr > &&ET, std::vector<std::string> &&EN );
409+ std::vector<VarDeclBasePtr > &&Members );
380410
381411 void accept (DeclVisitor &Visitor) override ;
382412 void accept (ConstDeclVisitor &Visitor) const override ;
0 commit comments