| 1 |
// Copyright (c) 1999-2009 by Digital Mars |
|---|
| 2 |
// All Rights Reserved |
|---|
| 3 |
// written by Walter Bright |
|---|
| 4 |
// http://www.digitalmars.com |
|---|
| 5 |
// License for redistribution is by either the Artistic License |
|---|
| 6 |
// in artistic.txt, or the GNU General Public License in gnu.txt. |
|---|
| 7 |
// See the included readme.txt for details. |
|---|
| 8 |
|
|---|
| 9 |
#ifndef DMD_SCOPE_H |
|---|
| 10 |
#define DMD_SCOPE_H |
|---|
| 11 |
|
|---|
| 12 |
#ifdef __DMC__ |
|---|
| 13 |
#pragma once |
|---|
| 14 |
#endif |
|---|
| 15 |
|
|---|
| 16 |
struct Dsymbol; |
|---|
| 17 |
struct ScopeDsymbol; |
|---|
| 18 |
struct Array; |
|---|
| 19 |
struct Identifier; |
|---|
| 20 |
struct Module; |
|---|
| 21 |
struct Statement; |
|---|
| 22 |
struct SwitchStatement; |
|---|
| 23 |
struct TryFinallyStatement; |
|---|
| 24 |
struct LabelStatement; |
|---|
| 25 |
struct ForeachStatement; |
|---|
| 26 |
struct ClassDeclaration; |
|---|
| 27 |
struct AggregateDeclaration; |
|---|
| 28 |
struct AnonymousAggregateDeclaration; |
|---|
| 29 |
struct FuncDeclaration; |
|---|
| 30 |
struct DocComment; |
|---|
| 31 |
struct TemplateInstance; |
|---|
| 32 |
|
|---|
| 33 |
#if __GNUC__ |
|---|
| 34 |
// Requires a full definition for PROT and LINK |
|---|
| 35 |
#include "dsymbol.h" // PROT |
|---|
| 36 |
#include "mars.h" // LINK |
|---|
| 37 |
#else |
|---|
| 38 |
enum LINK; |
|---|
| 39 |
enum PROT; |
|---|
| 40 |
#endif |
|---|
| 41 |
|
|---|
| 42 |
struct Scope |
|---|
| 43 |
{ |
|---|
| 44 |
Scope *enclosing; // enclosing Scope |
|---|
| 45 |
|
|---|
| 46 |
Module *module; // Root module |
|---|
| 47 |
ScopeDsymbol *scopesym; // current symbol |
|---|
| 48 |
ScopeDsymbol *sd; // if in static if, and declaring new symbols, |
|---|
| 49 |
// sd gets the addMember() |
|---|
| 50 |
FuncDeclaration *func; // function we are in |
|---|
| 51 |
Dsymbol *parent; // parent to use |
|---|
| 52 |
LabelStatement *slabel; // enclosing labelled statement |
|---|
| 53 |
SwitchStatement *sw; // enclosing switch statement |
|---|
| 54 |
TryFinallyStatement *tf; // enclosing try finally statement |
|---|
| 55 |
TemplateInstance *tinst; // enclosing template instance |
|---|
| 56 |
Statement *sbreak; // enclosing statement that supports "break" |
|---|
| 57 |
Statement *scontinue; // enclosing statement that supports "continue" |
|---|
| 58 |
ForeachStatement *fes; // if nested function for ForeachStatement, this is it |
|---|
| 59 |
unsigned offset; // next offset to use in aggregate |
|---|
| 60 |
int inunion; // we're processing members of a union |
|---|
| 61 |
int incontract; // we're inside contract code |
|---|
| 62 |
int nofree; // set if shouldn't free it |
|---|
| 63 |
int noctor; // set if constructor calls aren't allowed |
|---|
| 64 |
int intypeof; // in typeof(exp) |
|---|
| 65 |
int parameterSpecialization; // if in template parameter specialization |
|---|
| 66 |
int noaccesscheck; // don't do access checks |
|---|
| 67 |
int mustsemantic; // cannot defer semantic() |
|---|
| 68 |
|
|---|
| 69 |
unsigned callSuper; // primitive flow analysis for constructors |
|---|
| 70 |
#define CSXthis_ctor 1 // called this() |
|---|
| 71 |
#define CSXsuper_ctor 2 // called super() |
|---|
| 72 |
#define CSXthis 4 // referenced this |
|---|
| 73 |
#define CSXsuper 8 // referenced super |
|---|
| 74 |
#define CSXlabel 0x10 // seen a label |
|---|
| 75 |
#define CSXreturn 0x20 // seen a return statement |
|---|
| 76 |
#define CSXany_ctor 0x40 // either this() or super() was called |
|---|
| 77 |
|
|---|
| 78 |
unsigned structalign; // alignment for struct members |
|---|
| 79 |
enum LINK linkage; // linkage for external functions |
|---|
| 80 |
|
|---|
| 81 |
enum PROT protection; // protection for class members |
|---|
| 82 |
int explicitProtection; // set if in an explicit protection attribute |
|---|
| 83 |
|
|---|
| 84 |
StorageClass stc; // storage class |
|---|
| 85 |
|
|---|
| 86 |
unsigned flags; |
|---|
| 87 |
#define SCOPEctor 1 // constructor type |
|---|
| 88 |
#define SCOPEstaticif 2 // inside static if |
|---|
| 89 |
#define SCOPEfree 4 // is on free list |
|---|
| 90 |
|
|---|
| 91 |
AnonymousAggregateDeclaration *anonAgg; // for temporary analysis |
|---|
| 92 |
|
|---|
| 93 |
DocComment *lastdc; // documentation comment for last symbol at this scope |
|---|
| 94 |
unsigned lastoffset; // offset in docbuf of where to insert next dec |
|---|
| 95 |
OutBuffer *docbuf; // buffer for documentation output |
|---|
| 96 |
|
|---|
| 97 |
static Scope *freelist; |
|---|
| 98 |
static void *operator new(size_t sz); |
|---|
| 99 |
static Scope *createGlobal(Module *module); |
|---|
| 100 |
|
|---|
| 101 |
Scope(); |
|---|
| 102 |
Scope(Module *module); |
|---|
| 103 |
Scope(Scope *enclosing); |
|---|
| 104 |
|
|---|
| 105 |
Scope *push(); |
|---|
| 106 |
Scope *push(ScopeDsymbol *ss); |
|---|
| 107 |
Scope *pop(); |
|---|
| 108 |
|
|---|
| 109 |
void mergeCallSuper(Loc loc, unsigned cs); |
|---|
| 110 |
|
|---|
| 111 |
Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym); |
|---|
| 112 |
Dsymbol *search_correct(Identifier *ident); |
|---|
| 113 |
Dsymbol *insert(Dsymbol *s); |
|---|
| 114 |
|
|---|
| 115 |
ClassDeclaration *getClassScope(); |
|---|
| 116 |
AggregateDeclaration *getStructClassScope(); |
|---|
| 117 |
void setNoFree(); |
|---|
| 118 |
}; |
|---|
| 119 |
|
|---|
| 120 |
#endif /* DMD_SCOPE_H */ |
|---|