Changeset e0115286


Ignore:
Timestamp:
May 10, 2019, 3:00:41 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
2a5e8a6
Parents:
1f93c2c
Message:

Fix a cyclic dependency with ptr and nodes

Location:
src/AST
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r1f93c2c re0115286  
    122122        std::vector<ptr<DeclWithType>> assertions;
    123123
    124         NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, 
     124        NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    125125                Type* b, Linkage::Spec spec = Linkage::Cforall )
    126126        : Decl( loc, name, storage, spec ), base( b ), parameters(), assertions() {}
     
    149149                Data( TypeDecl* d ) : kind( d->kind ), isComplete( d->sized ) {}
    150150                Data( Kind k, bool c ) : kind( k ), isComplete( c ) {}
    151                 Data( const Data& d1, const Data& d2 ) 
     151                Data( const Data& d1, const Data& d2 )
    152152                : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
    153153
     
    158158        };
    159159
    160         TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b, 
     160        TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
    161161                Kind k, bool s, Type* i = nullptr )
    162162        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ), init( i ) {}
     
    174174class TypedefDecl final : public NamedTypeDecl {
    175175public:
    176         TypedefDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, 
     176        TypedefDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    177177                Type* b, Linkage::Spec spec = Linkage::Cforall )
    178178        : NamedTypeDecl( loc, name, storage, b, spec ) {}
     
    275275};
    276276
     277
     278//=================================================================================================
     279/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     280/// remove only if there is a better solution
     281/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     282/// forward declarations
     283inline void increment( const class Decl * node, Node::ref_type ref ) { node->increment(ref); }
     284inline void decrement( const class Decl * node, Node::ref_type ref ) { node->decrement(ref); }
     285inline void increment( const class DeclWithType * node, Node::ref_type ref ) { node->increment(ref); }
     286inline void decrement( const class DeclWithType * node, Node::ref_type ref ) { node->decrement(ref); }
     287inline void increment( const class ObjectDecl * node, Node::ref_type ref ) { node->increment(ref); }
     288inline void decrement( const class ObjectDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     289inline void increment( const class FunctionDecl * node, Node::ref_type ref ) { node->increment(ref); }
     290inline void decrement( const class FunctionDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     291inline void increment( const class AggregateDecl * node, Node::ref_type ref ) { node->increment(ref); }
     292inline void decrement( const class AggregateDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     293inline void increment( const class StructDecl * node, Node::ref_type ref ) { node->increment(ref); }
     294inline void decrement( const class StructDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     295inline void increment( const class UnionDecl * node, Node::ref_type ref ) { node->increment(ref); }
     296inline void decrement( const class UnionDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     297inline void increment( const class EnumDecl * node, Node::ref_type ref ) { node->increment(ref); }
     298inline void decrement( const class EnumDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     299inline void increment( const class TraitDecl * node, Node::ref_type ref ) { node->increment(ref); }
     300inline void decrement( const class TraitDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     301inline void increment( const class NamedTypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     302inline void decrement( const class NamedTypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     303inline void increment( const class TypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     304inline void decrement( const class TypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     305inline void increment( const class FtypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     306inline void decrement( const class FtypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     307inline void increment( const class DtypeDecl * node, Node::ref_type ref ) { node->increment(ref); }
     308inline void decrement( const class DtypeDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     309inline void increment( const class TypedefDecl * node, Node::ref_type ref ) { node->increment(ref); }
     310inline void decrement( const class TypedefDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     311inline void increment( const class AsmDecl * node, Node::ref_type ref ) { node->increment(ref); }
     312inline void decrement( const class AsmDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     313inline void increment( const class StaticAssertDecl * node, Node::ref_type ref ) { node->increment(ref); }
     314inline void decrement( const class StaticAssertDecl * node, Node::ref_type ref ) { node->decrement(ref); }
     315
    277316}
    278317
  • src/AST/Fwd.hpp

    r1f93c2c re0115286  
    1616#pragma once
    1717
     18#include "AST/Node.hpp"
     19
    1820namespace ast {
    1921
    20 class Node;
    2122class ParseNode;
    2223
     
    137138class TypeSubstitution;
    138139
     140//=================================================================================================
     141/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     142/// remove only if there is a better solution
     143/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     144/// forward declarations
     145inline void decrement( const class Node * node, Node::ref_type ref ) { node->decrement(ref); }
     146inline void increment( const class Node * node, Node::ref_type ref ) { node->increment(ref); }
     147inline void increment( const class ParseNode *, Node::ref_type );
     148inline void decrement( const class ParseNode *, Node::ref_type );
     149inline void increment( const class Decl *, Node::ref_type );
     150inline void decrement( const class Decl *, Node::ref_type );
     151inline void increment( const class DeclWithType *, Node::ref_type );
     152inline void decrement( const class DeclWithType *, Node::ref_type );
     153inline void increment( const class ObjectDecl *, Node::ref_type );
     154inline void decrement( const class ObjectDecl *, Node::ref_type );
     155inline void increment( const class FunctionDecl *, Node::ref_type );
     156inline void decrement( const class FunctionDecl *, Node::ref_type );
     157inline void increment( const class AggregateDecl *, Node::ref_type );
     158inline void decrement( const class AggregateDecl *, Node::ref_type );
     159inline void increment( const class StructDecl *, Node::ref_type );
     160inline void decrement( const class StructDecl *, Node::ref_type );
     161inline void increment( const class UnionDecl *, Node::ref_type );
     162inline void decrement( const class UnionDecl *, Node::ref_type );
     163inline void increment( const class EnumDecl *, Node::ref_type );
     164inline void decrement( const class EnumDecl *, Node::ref_type );
     165inline void increment( const class TraitDecl *, Node::ref_type );
     166inline void decrement( const class TraitDecl *, Node::ref_type );
     167inline void increment( const class NamedTypeDecl *, Node::ref_type );
     168inline void decrement( const class NamedTypeDecl *, Node::ref_type );
     169inline void increment( const class TypeDecl *, Node::ref_type );
     170inline void decrement( const class TypeDecl *, Node::ref_type );
     171inline void increment( const class FtypeDecl *, Node::ref_type );
     172inline void decrement( const class FtypeDecl *, Node::ref_type );
     173inline void increment( const class DtypeDecl *, Node::ref_type );
     174inline void decrement( const class DtypeDecl *, Node::ref_type );
     175inline void increment( const class TypedefDecl *, Node::ref_type );
     176inline void decrement( const class TypedefDecl *, Node::ref_type );
     177inline void increment( const class AsmDecl *, Node::ref_type );
     178inline void decrement( const class AsmDecl *, Node::ref_type );
     179inline void increment( const class StaticAssertDecl *, Node::ref_type );
     180inline void decrement( const class StaticAssertDecl *, Node::ref_type );
     181inline void increment( const class Stmt *, Node::ref_type );
     182inline void decrement( const class Stmt *, Node::ref_type );
     183inline void increment( const class CompoundStmt *, Node::ref_type );
     184inline void decrement( const class CompoundStmt *, Node::ref_type );
     185inline void increment( const class ExprStmt *, Node::ref_type );
     186inline void decrement( const class ExprStmt *, Node::ref_type );
     187inline void increment( const class AsmStmt *, Node::ref_type );
     188inline void decrement( const class AsmStmt *, Node::ref_type );
     189inline void increment( const class DirectiveStmt *, Node::ref_type );
     190inline void decrement( const class DirectiveStmt *, Node::ref_type );
     191inline void increment( const class IfStmt *, Node::ref_type );
     192inline void decrement( const class IfStmt *, Node::ref_type );
     193inline void increment( const class WhileStmt *, Node::ref_type );
     194inline void decrement( const class WhileStmt *, Node::ref_type );
     195inline void increment( const class ForStmt *, Node::ref_type );
     196inline void decrement( const class ForStmt *, Node::ref_type );
     197inline void increment( const class SwitchStmt *, Node::ref_type );
     198inline void decrement( const class SwitchStmt *, Node::ref_type );
     199inline void increment( const class CaseStmt *, Node::ref_type );
     200inline void decrement( const class CaseStmt *, Node::ref_type );
     201inline void increment( const class BranchStmt *, Node::ref_type );
     202inline void decrement( const class BranchStmt *, Node::ref_type );
     203inline void increment( const class ReturnStmt *, Node::ref_type );
     204inline void decrement( const class ReturnStmt *, Node::ref_type );
     205inline void increment( const class ThrowStmt *, Node::ref_type );
     206inline void decrement( const class ThrowStmt *, Node::ref_type );
     207inline void increment( const class TryStmt *, Node::ref_type );
     208inline void decrement( const class TryStmt *, Node::ref_type );
     209inline void increment( const class CatchStmt *, Node::ref_type );
     210inline void decrement( const class CatchStmt *, Node::ref_type );
     211inline void increment( const class FinallyStmt *, Node::ref_type );
     212inline void decrement( const class FinallyStmt *, Node::ref_type );
     213inline void increment( const class WaitForStmt *, Node::ref_type );
     214inline void decrement( const class WaitForStmt *, Node::ref_type );
     215inline void increment( const class WithStmt *, Node::ref_type );
     216inline void decrement( const class WithStmt *, Node::ref_type );
     217inline void increment( const class DeclStmt *, Node::ref_type );
     218inline void decrement( const class DeclStmt *, Node::ref_type );
     219inline void increment( const class NullStmt *, Node::ref_type );
     220inline void decrement( const class NullStmt *, Node::ref_type );
     221inline void increment( const class ImplicitCtorDtorStmt *, Node::ref_type );
     222inline void decrement( const class ImplicitCtorDtorStmt *, Node::ref_type );
     223inline void increment( const class Expr *, Node::ref_type );
     224inline void decrement( const class Expr *, Node::ref_type );
     225inline void increment( const class ApplicationExpr *, Node::ref_type );
     226inline void decrement( const class ApplicationExpr *, Node::ref_type );
     227inline void increment( const class UntypedExpr *, Node::ref_type );
     228inline void decrement( const class UntypedExpr *, Node::ref_type );
     229inline void increment( const class NameExpr *, Node::ref_type );
     230inline void decrement( const class NameExpr *, Node::ref_type );
     231inline void increment( const class AddressExpr *, Node::ref_type );
     232inline void decrement( const class AddressExpr *, Node::ref_type );
     233inline void increment( const class LabelAddressExpr *, Node::ref_type );
     234inline void decrement( const class LabelAddressExpr *, Node::ref_type );
     235inline void increment( const class CastExpr *, Node::ref_type );
     236inline void decrement( const class CastExpr *, Node::ref_type );
     237inline void increment( const class KeywordCastExpr *, Node::ref_type );
     238inline void decrement( const class KeywordCastExpr *, Node::ref_type );
     239inline void increment( const class VirtualCastExpr *, Node::ref_type );
     240inline void decrement( const class VirtualCastExpr *, Node::ref_type );
     241inline void increment( const class MemberExpr *, Node::ref_type );
     242inline void decrement( const class MemberExpr *, Node::ref_type );
     243inline void increment( const class UntypedMemberExpr *, Node::ref_type );
     244inline void decrement( const class UntypedMemberExpr *, Node::ref_type );
     245inline void increment( const class VariableExpr *, Node::ref_type );
     246inline void decrement( const class VariableExpr *, Node::ref_type );
     247inline void increment( const class ConstantExpr *, Node::ref_type );
     248inline void decrement( const class ConstantExpr *, Node::ref_type );
     249inline void increment( const class SizeofExpr *, Node::ref_type );
     250inline void decrement( const class SizeofExpr *, Node::ref_type );
     251inline void increment( const class AlignofExpr *, Node::ref_type );
     252inline void decrement( const class AlignofExpr *, Node::ref_type );
     253inline void increment( const class UntypedOffsetofExpr *, Node::ref_type );
     254inline void decrement( const class UntypedOffsetofExpr *, Node::ref_type );
     255inline void increment( const class OffsetofExpr *, Node::ref_type );
     256inline void decrement( const class OffsetofExpr *, Node::ref_type );
     257inline void increment( const class OffsetPackExpr *, Node::ref_type );
     258inline void decrement( const class OffsetPackExpr *, Node::ref_type );
     259inline void increment( const class AttrExpr *, Node::ref_type );
     260inline void decrement( const class AttrExpr *, Node::ref_type );
     261inline void increment( const class LogicalExpr *, Node::ref_type );
     262inline void decrement( const class LogicalExpr *, Node::ref_type );
     263inline void increment( const class ConditionalExpr *, Node::ref_type );
     264inline void decrement( const class ConditionalExpr *, Node::ref_type );
     265inline void increment( const class CommaExpr *, Node::ref_type );
     266inline void decrement( const class CommaExpr *, Node::ref_type );
     267inline void increment( const class TypeExpr *, Node::ref_type );
     268inline void decrement( const class TypeExpr *, Node::ref_type );
     269inline void increment( const class AsmExpr *, Node::ref_type );
     270inline void decrement( const class AsmExpr *, Node::ref_type );
     271inline void increment( const class ImplicitCopyCtorExpr *, Node::ref_type );
     272inline void decrement( const class ImplicitCopyCtorExpr *, Node::ref_type );
     273inline void increment( const class ConstructorExpr *, Node::ref_type );
     274inline void decrement( const class ConstructorExpr *, Node::ref_type );
     275inline void increment( const class CompoundLiteralExpr *, Node::ref_type );
     276inline void decrement( const class CompoundLiteralExpr *, Node::ref_type );
     277inline void increment( const class UntypedValofExpr *, Node::ref_type );
     278inline void decrement( const class UntypedValofExpr *, Node::ref_type );
     279inline void increment( const class RangeExpr *, Node::ref_type );
     280inline void decrement( const class RangeExpr *, Node::ref_type );
     281inline void increment( const class UntypedTupleExpr *, Node::ref_type );
     282inline void decrement( const class UntypedTupleExpr *, Node::ref_type );
     283inline void increment( const class TupleExpr *, Node::ref_type );
     284inline void decrement( const class TupleExpr *, Node::ref_type );
     285inline void increment( const class TupleIndexExpr *, Node::ref_type );
     286inline void decrement( const class TupleIndexExpr *, Node::ref_type );
     287inline void increment( const class TupleAssignExpr *, Node::ref_type );
     288inline void decrement( const class TupleAssignExpr *, Node::ref_type );
     289inline void increment( const class StmtExpr *, Node::ref_type );
     290inline void decrement( const class StmtExpr *, Node::ref_type );
     291inline void increment( const class UniqueExpr *, Node::ref_type );
     292inline void decrement( const class UniqueExpr *, Node::ref_type );
     293inline void increment( const class UntypedInitExpr *, Node::ref_type );
     294inline void decrement( const class UntypedInitExpr *, Node::ref_type );
     295inline void increment( const class InitExpr *, Node::ref_type );
     296inline void decrement( const class InitExpr *, Node::ref_type );
     297inline void increment( const class DeletedExpr *, Node::ref_type );
     298inline void decrement( const class DeletedExpr *, Node::ref_type );
     299inline void increment( const class DefaultArgExpr *, Node::ref_type );
     300inline void decrement( const class DefaultArgExpr *, Node::ref_type );
     301inline void increment( const class GenericExpr *, Node::ref_type );
     302inline void decrement( const class GenericExpr *, Node::ref_type );
     303inline void increment( const class Type *, Node::ref_type );
     304inline void decrement( const class Type *, Node::ref_type );
     305inline void increment( const class VoidType *, Node::ref_type );
     306inline void decrement( const class VoidType *, Node::ref_type );
     307inline void increment( const class BasicType *, Node::ref_type );
     308inline void decrement( const class BasicType *, Node::ref_type );
     309inline void increment( const class PointerType *, Node::ref_type );
     310inline void decrement( const class PointerType *, Node::ref_type );
     311inline void increment( const class ArrayType *, Node::ref_type );
     312inline void decrement( const class ArrayType *, Node::ref_type );
     313inline void increment( const class ReferenceType *, Node::ref_type );
     314inline void decrement( const class ReferenceType *, Node::ref_type );
     315inline void increment( const class QualifiedType *, Node::ref_type );
     316inline void decrement( const class QualifiedType *, Node::ref_type );
     317inline void increment( const class FunctionType *, Node::ref_type );
     318inline void decrement( const class FunctionType *, Node::ref_type );
     319inline void increment( const class ReferenceToType *, Node::ref_type );
     320inline void decrement( const class ReferenceToType *, Node::ref_type );
     321inline void increment( const class StructInstType *, Node::ref_type );
     322inline void decrement( const class StructInstType *, Node::ref_type );
     323inline void increment( const class UnionInstType *, Node::ref_type );
     324inline void decrement( const class UnionInstType *, Node::ref_type );
     325inline void increment( const class EnumInstType *, Node::ref_type );
     326inline void decrement( const class EnumInstType *, Node::ref_type );
     327inline void increment( const class TraitInstType *, Node::ref_type );
     328inline void decrement( const class TraitInstType *, Node::ref_type );
     329inline void increment( const class TypeInstType *, Node::ref_type );
     330inline void decrement( const class TypeInstType *, Node::ref_type );
     331inline void increment( const class TupleType *, Node::ref_type );
     332inline void decrement( const class TupleType *, Node::ref_type );
     333inline void increment( const class TypeofType *, Node::ref_type );
     334inline void decrement( const class TypeofType *, Node::ref_type );
     335inline void increment( const class AttrType *, Node::ref_type );
     336inline void decrement( const class AttrType *, Node::ref_type );
     337inline void increment( const class VarArgsType *, Node::ref_type );
     338inline void decrement( const class VarArgsType *, Node::ref_type );
     339inline void increment( const class ZeroType *, Node::ref_type );
     340inline void decrement( const class ZeroType *, Node::ref_type );
     341inline void increment( const class OneType *, Node::ref_type );
     342inline void decrement( const class OneType *, Node::ref_type );
     343inline void increment( const class GlobalScopeType *, Node::ref_type );
     344inline void decrement( const class GlobalScopeType *, Node::ref_type );
     345inline void increment( const class Designation *, Node::ref_type );
     346inline void decrement( const class Designation *, Node::ref_type );
     347inline void increment( const class Init *, Node::ref_type );
     348inline void decrement( const class Init *, Node::ref_type );
     349inline void increment( const class SingleInit *, Node::ref_type );
     350inline void decrement( const class SingleInit *, Node::ref_type );
     351inline void increment( const class ListInit *, Node::ref_type );
     352inline void decrement( const class ListInit *, Node::ref_type );
     353inline void increment( const class ConstructorInit *, Node::ref_type );
     354inline void decrement( const class ConstructorInit *, Node::ref_type );
     355inline void increment( const class Constant *, Node::ref_type );
     356inline void decrement( const class Constant *, Node::ref_type );
     357inline void increment( const class Label *, Node::ref_type );
     358inline void decrement( const class Label *, Node::ref_type );
     359inline void increment( const class Attribute *, Node::ref_type );
     360inline void decrement( const class Attribute *, Node::ref_type );
     361inline void increment( const class TypeSubstitution *, Node::ref_type );
     362inline void decrement( const class TypeSubstitution *, Node::ref_type );
     363
    139364typedef unsigned int UniqueId;
    140365
  • src/AST/Init.hpp

    r1f93c2c re0115286  
    2828class Stmt;
    2929
    30 /// List of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an 
     30/// List of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an
    3131/// object being initialized
    3232class Designation final : public ParseNode {
     
    3434        std::vector<ptr<Expr>> designators;
    3535
    36         Designation( const CodeLocation& loc, std::vector<ptr<Expr>>&& ds = {} ) 
     36        Designation( const CodeLocation& loc, std::vector<ptr<Expr>>&& ds = {} )
    3737        : ParseNode( loc ), designators( std::move(ds) ) {}
    3838
     
    6060        ptr<Expr> value;
    6161
    62         SingleInit( const CodeLocation& loc, Expr* val, bool mc = false ) 
     62        SingleInit( const CodeLocation& loc, Expr* val, bool mc = false )
    6363        : Init( loc, mc ), value( val ) {}
    6464
     
    7777        std::vector<ptr<Designation>> designations;
    7878
    79         ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is, 
     79        ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is,
    8080                std::vector<ptr<Designation>>&& ds = {}, bool mc = false );
    81        
     81
    8282        using iterator = std::vector<ptr<Init>>::iterator;
    8383        using const_iterator = std::vector<ptr<Init>>::const_iterator;
     
    9393
    9494/// Either a constructor expression or a C-style initializer.
    95 /// Should not be necessary to create manually; instead set `maybeConstructed` true on `SingleInit` 
     95/// Should not be necessary to create manually; instead set `maybeConstructed` true on `SingleInit`
    9696/// or `ListInit` if the object should be constructed.
    9797class ConstructorInit final : public Init {
     
    9999        ptr<Stmt> ctor;
    100100        ptr<Stmt> dtor;
    101         /// C-style initializer made up of SingleInit/ListInit nodes to use as a fallback if an 
     101        /// C-style initializer made up of SingleInit/ListInit nodes to use as a fallback if an
    102102        /// appropriate constructor definition is not found by the resolver.
    103103        ptr<Init> init;
     
    111111};
    112112
     113
     114//=================================================================================================
     115/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     116/// remove only if there is a better solution
     117/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     118/// forward declarations
     119inline void increment( const class Init * node, Node::ref_type ref ) { node->increment( ref ); }
     120inline void decrement( const class Init * node, Node::ref_type ref ) { node->decrement( ref ); }
     121inline void increment( const class SingleInit * node, Node::ref_type ref ) { node->increment( ref ); }
     122inline void decrement( const class SingleInit * node, Node::ref_type ref ) { node->decrement( ref ); }
     123inline void increment( const class ListInit * node, Node::ref_type ref ) { node->increment( ref ); }
     124inline void decrement( const class ListInit * node, Node::ref_type ref ) { node->decrement( ref ); }
     125inline void increment( const class ConstructorInit * node, Node::ref_type ref ) { node->increment( ref ); }
     126inline void decrement( const class ConstructorInit * node, Node::ref_type ref ) { node->decrement( ref ); }
    113127}
    114128
  • src/AST/Label.hpp

    r1f93c2c re0115286  
    2525namespace ast {
    2626
    27         class Attribute;
     27class Attribute;
    2828
    29         /// Named labels for statements
    30         class Label {
    31         public:
    32                 CodeLocation location;
    33                 std::string name;
    34                 std::vector< ptr<Attribute> > attributes;
     29/// Named labels for statements
     30class Label {
     31public:
     32        CodeLocation location;
     33        std::string name;
     34        std::vector< ptr<Attribute> > attributes;
    3535
    36                 Label( CodeLocation loc, const std::string& name = "",
    37                         const std::vector<ptr<Attribute>>& attrs = std::vector<ptr<Attribute>>{} )
    38                 : location( loc ), name( name ), attributes( attrs ) {}
     36        Label( CodeLocation loc, const std::string& name = "",
     37                const std::vector<ptr<Attribute>>& attrs = std::vector<ptr<Attribute>>{} )
     38        : location( loc ), name( name ), attributes( attrs ) {}
    3939
    40                 operator std::string () const { return name; }
    41                 bool empty() { return name.empty(); }
    42         };
     40        operator std::string () const { return name; }
     41        bool empty() { return name.empty(); }
     42};
    4343
    44         inline bool operator== ( const Label& l1, const Label& l2 ) { return l1.name == l2.name; }
    45         inline bool operator!= ( const Label& l1, const Label& l2 ) { return !(l1 == l2); }
    46         inline bool operator<  ( const Label& l1, const Label& l2 ) { return l1.name < l2.name; }
     44inline bool operator== ( const Label& l1, const Label& l2 ) { return l1.name == l2.name; }
     45inline bool operator!= ( const Label& l1, const Label& l2 ) { return !(l1 == l2); }
     46inline bool operator<  ( const Label& l1, const Label& l2 ) { return l1.name < l2.name; }
    4747
    48         inline std::ostream& operator<< ( std::ostream& out, const Label& l ) { return out << l.name; }
     48inline std::ostream& operator<< ( std::ostream& out, const Label& l ) { return out << l.name; }
     49
     50
     51//=================================================================================================
     52/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     53/// remove only if there is a better solution
     54/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     55/// forward declarations
     56inline void increment( const class Label * node, Node::ref_type ref ) { node->increment( ref ); }
     57inline void decrement( const class Label * node, Node::ref_type ref ) { node->decrement( ref ); }
    4958
    5059}
  • src/AST/ParseNode.hpp

    r1f93c2c re0115286  
    2222namespace ast {
    2323
    24         /// AST node with an included source location
    25         class ParseNode : public Node {
    26         public:
    27                 CodeLocation location;
     24/// AST node with an included source location
     25class ParseNode : public Node {
     26public:
     27        CodeLocation location;
    2828
    29                 // Default constructor is deliberately omitted, all ParseNodes must have a location.
    30                 // Escape hatch if needed is to explicitly pass a default-constructed location, but
    31                 // this should be used sparingly.
     29        // Default constructor is deliberately omitted, all ParseNodes must have a location.
     30        // Escape hatch if needed is to explicitly pass a default-constructed location, but
     31        // this should be used sparingly.
    3232
    33                 ParseNode( const CodeLocation& loc ) : Node(), location(loc) {}
     33        ParseNode( const CodeLocation& loc ) : Node(), location(loc) {}
    3434
    35                 ParseNode( const ParseNode& o ) = default;
    36         };
     35        ParseNode( const ParseNode& o ) = default;
     36};
    3737
     38
     39//=================================================================================================
     40/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     41/// remove only if there is a better solution
     42/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     43/// forward declarations
     44inline void increment( const class ParseNode * node, Node::ref_type ref ) { node->increment( ref ); }
     45inline void decrement( const class ParseNode * node, Node::ref_type ref ) { node->decrement( ref ); }
    3846}
    3947
  • src/AST/Stmt.hpp

    r1f93c2c re0115286  
    8989
    9090
     91//=================================================================================================
     92/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     93/// remove only if there is a better solution
     94/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     95/// forward declarations
     96inline void increment( const class Stmt * node, Node::ref_type ref ) { node->increment( ref ); }
     97inline void decrement( const class Stmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     98inline void increment( const class CompoundStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     99inline void decrement( const class CompoundStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     100inline void increment( const class ExprStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     101inline void decrement( const class ExprStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     102inline void increment( const class AsmStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     103inline void decrement( const class AsmStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     104inline void increment( const class DirectiveStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     105inline void decrement( const class DirectiveStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     106inline void increment( const class IfStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     107inline void decrement( const class IfStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     108inline void increment( const class WhileStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     109inline void decrement( const class WhileStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     110inline void increment( const class ForStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     111inline void decrement( const class ForStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     112inline void increment( const class SwitchStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     113inline void decrement( const class SwitchStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     114inline void increment( const class CaseStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     115inline void decrement( const class CaseStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     116inline void increment( const class BranchStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     117inline void decrement( const class BranchStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     118inline void increment( const class ReturnStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     119inline void decrement( const class ReturnStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     120inline void increment( const class ThrowStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     121inline void decrement( const class ThrowStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     122inline void increment( const class TryStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     123inline void decrement( const class TryStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     124inline void increment( const class CatchStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     125inline void decrement( const class CatchStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     126inline void increment( const class FinallyStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     127inline void decrement( const class FinallyStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     128inline void increment( const class WaitForStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     129inline void decrement( const class WaitForStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     130inline void increment( const class WithStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     131inline void decrement( const class WithStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     132inline void increment( const class DeclStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     133inline void decrement( const class DeclStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     134inline void increment( const class NullStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     135inline void decrement( const class NullStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     136inline void increment( const class ImplicitCtorDtorStmt * node, Node::ref_type ref ) { node->increment( ref ); }
     137inline void decrement( const class ImplicitCtorDtorStmt * node, Node::ref_type ref ) { node->decrement( ref ); }
     138
    91139}
    92140
  • src/AST/Type.hpp

    r1f93c2c re0115286  
    2424};
    2525
     26
     27
     28//=================================================================================================
     29/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     30/// remove only if there is a better solution
     31/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     32/// forward declarations
     33inline void increment( const class Type * node, Node::ref_type ref ) { node->increment( ref ); }
     34inline void decrement( const class Type * node, Node::ref_type ref ) { node->decrement( ref ); }
     35inline void increment( const class VoidType * node, Node::ref_type ref ) { node->increment( ref ); }
     36inline void decrement( const class VoidType * node, Node::ref_type ref ) { node->decrement( ref ); }
     37inline void increment( const class BasicType * node, Node::ref_type ref ) { node->increment( ref ); }
     38inline void decrement( const class BasicType * node, Node::ref_type ref ) { node->decrement( ref ); }
     39inline void increment( const class PointerType * node, Node::ref_type ref ) { node->increment( ref ); }
     40inline void decrement( const class PointerType * node, Node::ref_type ref ) { node->decrement( ref ); }
     41inline void increment( const class ArrayType * node, Node::ref_type ref ) { node->increment( ref ); }
     42inline void decrement( const class ArrayType * node, Node::ref_type ref ) { node->decrement( ref ); }
     43inline void increment( const class ReferenceType * node, Node::ref_type ref ) { node->increment( ref ); }
     44inline void decrement( const class ReferenceType * node, Node::ref_type ref ) { node->decrement( ref ); }
     45inline void increment( const class QualifiedType * node, Node::ref_type ref ) { node->increment( ref ); }
     46inline void decrement( const class QualifiedType * node, Node::ref_type ref ) { node->decrement( ref ); }
     47inline void increment( const class FunctionType * node, Node::ref_type ref ) { node->increment( ref ); }
     48inline void decrement( const class FunctionType * node, Node::ref_type ref ) { node->decrement( ref ); }
     49inline void increment( const class ReferenceToType * node, Node::ref_type ref ) { node->increment( ref ); }
     50inline void decrement( const class ReferenceToType * node, Node::ref_type ref ) { node->decrement( ref ); }
     51inline void increment( const class StructInstType * node, Node::ref_type ref ) { node->increment( ref ); }
     52inline void decrement( const class StructInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
     53inline void increment( const class UnionInstType * node, Node::ref_type ref ) { node->increment( ref ); }
     54inline void decrement( const class UnionInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
     55inline void increment( const class EnumInstType * node, Node::ref_type ref ) { node->increment( ref ); }
     56inline void decrement( const class EnumInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
     57inline void increment( const class TraitInstType * node, Node::ref_type ref ) { node->increment( ref ); }
     58inline void decrement( const class TraitInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
     59inline void increment( const class TypeInstType * node, Node::ref_type ref ) { node->increment( ref ); }
     60inline void decrement( const class TypeInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
     61inline void increment( const class TupleType * node, Node::ref_type ref ) { node->increment( ref ); }
     62inline void decrement( const class TupleType * node, Node::ref_type ref ) { node->decrement( ref ); }
     63inline void increment( const class TypeofType * node, Node::ref_type ref ) { node->increment( ref ); }
     64inline void decrement( const class TypeofType * node, Node::ref_type ref ) { node->decrement( ref ); }
     65inline void increment( const class AttrType * node, Node::ref_type ref ) { node->increment( ref ); }
     66inline void decrement( const class AttrType * node, Node::ref_type ref ) { node->decrement( ref ); }
     67inline void increment( const class VarArgsType * node, Node::ref_type ref ) { node->increment( ref ); }
     68inline void decrement( const class VarArgsType * node, Node::ref_type ref ) { node->decrement( ref ); }
     69inline void increment( const class ZeroType * node, Node::ref_type ref ) { node->increment( ref ); }
     70inline void decrement( const class ZeroType * node, Node::ref_type ref ) { node->decrement( ref ); }
     71inline void increment( const class OneType * node, Node::ref_type ref ) { node->increment( ref ); }
     72inline void decrement( const class OneType * node, Node::ref_type ref ) { node->decrement( ref ); }
     73inline void increment( const class GlobalScopeType * node, Node::ref_type ref ) { node->increment( ref ); }
     74inline void decrement( const class GlobalScopeType * node, Node::ref_type ref ) { node->decrement( ref ); }
     75
    2676}
    2777
Note: See TracChangeset for help on using the changeset viewer.