Mercurial > projects > dil
comparison trunk/src/dil/semantic/Scope.d @ 798:c24be8d4f6ab
Added documentation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 02:53:06 +0100 |
parents | d33895f679eb |
children |
comparison
equal
deleted
inserted
replaced
797:cf2ad5df025c | 798:c24be8d4f6ab |
---|---|
7 import dil.semantic.Symbol; | 7 import dil.semantic.Symbol; |
8 import dil.semantic.Symbols; | 8 import dil.semantic.Symbols; |
9 import dil.lexer.Identifier; | 9 import dil.lexer.Identifier; |
10 import common; | 10 import common; |
11 | 11 |
12 /// Builds a hierarchy of environments. | |
12 class Scope | 13 class Scope |
13 { | 14 { |
14 Scope parent; /// The surrounding scope, or null if this is the root scope. | 15 Scope parent; /// The surrounding scope, or null if this is the root scope. |
15 | 16 |
16 ScopeSymbol symbol; /// The current symbol with the symbol table. | 17 ScopeSymbol symbol; /// The current symbol with the symbol table. |
19 { | 20 { |
20 this.parent = parent; | 21 this.parent = parent; |
21 this.symbol = symbol; | 22 this.symbol = symbol; |
22 } | 23 } |
23 | 24 |
24 /++ | 25 /// Find a symbol in this scope. |
25 Find a symbol in this scope. | 26 /// Params: |
26 Params: | 27 /// name = the name of the symbol. |
27 name = the name of the symbol. | |
28 +/ | |
29 Symbol lookup(Identifier* name) | 28 Symbol lookup(Identifier* name) |
30 { | 29 { |
31 return symbol.lookup(name); | 30 return symbol.lookup(name); |
32 } | 31 } |
33 | 32 |
34 /++ | 33 /// Create a new inner scope and return that. |
35 Create a new inner scope and return that. | |
36 +/ | |
37 Scope enter(ScopeSymbol symbol) | 34 Scope enter(ScopeSymbol symbol) |
38 { | 35 { |
39 return new Scope(this, symbol); | 36 return new Scope(this, symbol); |
40 } | 37 } |
41 | 38 |
42 /++ | 39 /// Destroy this scope and return the outer scope. |
43 Destroy this scope and return the outer scope. | |
44 +/ | |
45 Scope exit() | 40 Scope exit() |
46 { | 41 { |
47 auto sc = parent; | 42 auto sc = parent; |
48 // delete this; | 43 // delete this; |
49 return sc; | 44 return sc; |