Home | History | Annotate | Line # | Download | only in dmd
scope.h revision 1.1.1.3
      1      1.1  mrg 
      2      1.1  mrg /* Compiler implementation of the D programming language
      3  1.1.1.3  mrg  * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
      4      1.1  mrg  * written by Walter Bright
      5  1.1.1.3  mrg  * https://www.digitalmars.com
      6      1.1  mrg  * Distributed under the Boost Software License, Version 1.0.
      7  1.1.1.3  mrg  * https://www.boost.org/LICENSE_1_0.txt
      8      1.1  mrg  * https://github.com/dlang/dmd/blob/master/src/dmd/scope.h
      9      1.1  mrg  */
     10      1.1  mrg 
     11      1.1  mrg #pragma once
     12      1.1  mrg 
     13      1.1  mrg class Identifier;
     14      1.1  mrg class Module;
     15      1.1  mrg class Statement;
     16      1.1  mrg class SwitchStatement;
     17      1.1  mrg class TryFinallyStatement;
     18      1.1  mrg class LabelStatement;
     19      1.1  mrg class ForeachStatement;
     20      1.1  mrg class ClassDeclaration;
     21      1.1  mrg class AggregateDeclaration;
     22      1.1  mrg class FuncDeclaration;
     23      1.1  mrg class UserAttributeDeclaration;
     24      1.1  mrg struct DocComment;
     25      1.1  mrg struct AA;
     26      1.1  mrg class TemplateInstance;
     27  1.1.1.3  mrg class CPPNamespaceDeclaration;
     28      1.1  mrg 
     29      1.1  mrg #include "dsymbol.h"
     30      1.1  mrg 
     31  1.1.1.3  mrg enum
     32  1.1.1.3  mrg {
     33  1.1.1.3  mrg     CSXthis_ctor  = 1,      // called this()
     34  1.1.1.3  mrg     CSXsuper_ctor = 2,      // called super()
     35  1.1.1.3  mrg     CSXthis       = 4,      // referenced this
     36  1.1.1.3  mrg     CSXsuper      = 8,      // referenced super
     37  1.1.1.3  mrg     CSXlabel      = 0x10,   // seen a label
     38  1.1.1.3  mrg     CSXreturn     = 0x20,   // seen a return statement
     39  1.1.1.3  mrg     CSXany_ctor   = 0x40,   // either this() or super() was called
     40  1.1.1.3  mrg     CSXhalt       = 0x80,   // assert(0)
     41  1.1.1.3  mrg };
     42  1.1.1.3  mrg 
     43  1.1.1.3  mrg enum
     44  1.1.1.3  mrg {
     45  1.1.1.3  mrg     // Flags that would not be inherited beyond scope nesting
     46  1.1.1.3  mrg     SCOPEctor          = 0x0001,  // constructor type
     47  1.1.1.3  mrg     SCOPEcondition     = 0x0004,  // inside static if/assert condition
     48  1.1.1.3  mrg     SCOPEdebug         = 0x0008,  // inside debug conditional
     49  1.1.1.3  mrg 
     50  1.1.1.3  mrg     // Flags that would be inherited beyond scope nesting
     51  1.1.1.3  mrg     SCOPEnoaccesscheck = 0x0002,  // don't do access checks
     52  1.1.1.3  mrg     SCOPEconstraint    = 0x0010,  // inside template constraint
     53  1.1.1.3  mrg     SCOPEinvariant     = 0x0020,  // inside invariant code
     54  1.1.1.3  mrg     SCOPErequire       = 0x0040,  // inside in contract code
     55  1.1.1.3  mrg     SCOPEensure        = 0x0060,  // inside out contract code
     56  1.1.1.3  mrg     SCOPEcontract      = 0x0060,  // [mask] we're inside contract code
     57  1.1.1.3  mrg     SCOPEctfe          = 0x0080,  // inside a ctfe-only expression
     58  1.1.1.3  mrg     SCOPEcompile       = 0x0100,  // inside __traits(compile)
     59  1.1.1.3  mrg     SCOPEignoresymbolvisibility = 0x0200,  // ignore symbol visibility (Bugzilla 15907)
     60  1.1.1.3  mrg 
     61  1.1.1.3  mrg     SCOPEfree          = 0x8000,  // is on free list
     62  1.1.1.3  mrg     SCOPEfullinst      = 0x10000, // fully instantiate templates
     63  1.1.1.3  mrg     SCOPEalias         = 0x20000, // inside alias declaration
     64  1.1.1.3  mrg 
     65  1.1.1.3  mrg     // The following are mutually exclusive
     66  1.1.1.3  mrg     SCOPEprintf        = 0x40000, // printf-style function
     67  1.1.1.3  mrg     SCOPEscanf         = 0x80000, // scanf-style function
     68  1.1.1.3  mrg };
     69      1.1  mrg 
     70      1.1  mrg struct Scope
     71      1.1  mrg {
     72      1.1  mrg     Scope *enclosing;           // enclosing Scope
     73      1.1  mrg 
     74      1.1  mrg     Module *_module;            // Root module
     75      1.1  mrg     ScopeDsymbol *scopesym;     // current symbol
     76      1.1  mrg     FuncDeclaration *func;      // function we are in
     77      1.1  mrg     Dsymbol *parent;            // parent to use
     78      1.1  mrg     LabelStatement *slabel;     // enclosing labelled statement
     79      1.1  mrg     SwitchStatement *sw;        // enclosing switch statement
     80  1.1.1.3  mrg     Statement *tryBody;         // enclosing _body of TryCatchStatement or TryFinallyStatement
     81      1.1  mrg     TryFinallyStatement *tf;    // enclosing try finally statement
     82  1.1.1.3  mrg     ScopeGuardStatement *os;       // enclosing scope(xxx) statement
     83      1.1  mrg     Statement *sbreak;          // enclosing statement that supports "break"
     84      1.1  mrg     Statement *scontinue;       // enclosing statement that supports "continue"
     85      1.1  mrg     ForeachStatement *fes;      // if nested function for ForeachStatement, this is it
     86      1.1  mrg     Scope *callsc;              // used for __FUNCTION__, __PRETTY_FUNCTION__ and __MODULE__
     87  1.1.1.3  mrg     Dsymbol *inunion;           // !=null if processing members of a union
     88  1.1.1.3  mrg     bool nofree;                // true if shouldn't free it
     89  1.1.1.3  mrg     bool inLoop;                // true if inside a loop (where constructor calls aren't allowed)
     90      1.1  mrg     int intypeof;               // in typeof(exp)
     91      1.1  mrg     VarDeclaration *lastVar;    // Previous symbol used to prevent goto-skips-init
     92      1.1  mrg 
     93      1.1  mrg     /* If  minst && !tinst, it's in definitely non-speculative scope (eg. module member scope).
     94      1.1  mrg      * If !minst && !tinst, it's in definitely speculative scope (eg. template constraint).
     95      1.1  mrg      * If  minst &&  tinst, it's in instantiated code scope without speculation.
     96      1.1  mrg      * If !minst &&  tinst, it's in instantiated code scope with speculation.
     97      1.1  mrg      */
     98      1.1  mrg     Module *minst;              // root module where the instantiated templates should belong to
     99      1.1  mrg     TemplateInstance *tinst;    // enclosing template instance
    100      1.1  mrg 
    101  1.1.1.3  mrg     unsigned char callSuper;    // primitive flow analysis for constructors
    102  1.1.1.3  mrg     unsigned char *fieldinit;
    103      1.1  mrg     size_t fieldinit_dim;
    104      1.1  mrg 
    105      1.1  mrg     AlignDeclaration *aligndecl;    // alignment for struct members
    106      1.1  mrg 
    107  1.1.1.3  mrg     /// C++ namespace this symbol belongs to
    108  1.1.1.3  mrg     CPPNamespaceDeclaration *namespace_;
    109  1.1.1.3  mrg 
    110      1.1  mrg     LINK linkage;               // linkage for external functions
    111      1.1  mrg     CPPMANGLE cppmangle;        // C++ mangle type
    112  1.1.1.3  mrg     PragmaDeclaration *inlining; // inlining strategy for functions
    113      1.1  mrg 
    114  1.1.1.3  mrg     Visibility visibility;            // visibility for class members
    115  1.1.1.3  mrg     int explicitVisibility;     // set if in an explicit visibility attribute
    116      1.1  mrg 
    117      1.1  mrg     StorageClass stc;           // storage class
    118      1.1  mrg 
    119      1.1  mrg     DeprecatedDeclaration *depdecl; // customized deprecation message
    120      1.1  mrg 
    121      1.1  mrg     unsigned flags;
    122      1.1  mrg 
    123      1.1  mrg     UserAttributeDeclaration *userAttribDecl;   // user defined attributes
    124      1.1  mrg 
    125      1.1  mrg     DocComment *lastdc;         // documentation comment for last symbol at this scope
    126      1.1  mrg     AA *anchorCounts;           // lookup duplicate anchor name count
    127      1.1  mrg     Identifier *prevAnchor;     // qualified symbol name of last doc anchor
    128      1.1  mrg 
    129  1.1.1.3  mrg     AliasDeclaration *aliasAsg; // if set, then aliasAsg is being assigned a new value,
    130  1.1.1.3  mrg                                 // do not set wasRead for it
    131      1.1  mrg     Scope();
    132      1.1  mrg 
    133      1.1  mrg     Scope *copy();
    134      1.1  mrg 
    135      1.1  mrg     Scope *push();
    136      1.1  mrg     Scope *push(ScopeDsymbol *ss);
    137      1.1  mrg     Scope *pop();
    138      1.1  mrg 
    139      1.1  mrg     Scope *startCTFE();
    140      1.1  mrg     Scope *endCTFE();
    141      1.1  mrg 
    142  1.1.1.3  mrg     Dsymbol *search(const Loc &loc, Identifier *ident, Dsymbol **pscopesym, int flags = IgnoreNone);
    143      1.1  mrg 
    144      1.1  mrg     ClassDeclaration *getClassScope();
    145      1.1  mrg     AggregateDeclaration *getStructClassScope();
    146      1.1  mrg 
    147      1.1  mrg     structalign_t alignment();
    148  1.1.1.3  mrg 
    149  1.1.1.3  mrg     bool isDeprecated() const;
    150      1.1  mrg };
    151