annotate trunk/src/dil/semantic/Symbol.d @ 615:a05457530ac2

Added member ident to class Symbol. Commented out inheritance of dil.semantic.Symbol by class dil.semantic.Type.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 08 Jan 2008 22:15:59 +0100
parents 8c5b1558244b
children e2cd28cfc6ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
1 /++
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
2 Author: Aziz Köksal
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
3 License: GPL3
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
4 +/
589
de365ddcfbd4 Moved dil.Symbol to dil.semantic.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 580
diff changeset
5 module dil.semantic.Symbol;
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
6
580
fa6d3c52757d Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 568
diff changeset
7 import dil.ast.Node;
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
8 import dil.lexer.Identifier;
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
9 import common;
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
10
563
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
11 /// Symbol IDs.
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
12 enum SYM
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
13 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
14 Module,
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
15 Class,
561
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
16 Interface,
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
17 Struct,
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
18 Union,
614
8c5b1558244b Added symbol Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 589
diff changeset
19 Enum,
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
20 Variable,
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
21 Function,
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
22 // Type,
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
23 }
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
24
563
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
25 /++
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
26 A symbol represents an object with semantic code information.
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
27 +/
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
28 class Symbol
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
29 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
30 SYM sid;
568
c8861b452eb3 Added members 'node' and 'parent' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 567
diff changeset
31 Symbol parent; /// The parent this symbol belongs to.
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
32 Identifier* ident; /// The name of this symbol.
568
c8861b452eb3 Added members 'node' and 'parent' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 567
diff changeset
33 /// The AST node that produced this symbol.
c8861b452eb3 Added members 'node' and 'parent' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 567
diff changeset
34 /// Useful for source code location info and retrieval of doc comments.
c8861b452eb3 Added members 'node' and 'parent' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 567
diff changeset
35 Node node;
567
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
36
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
37 // A template macro for building isXYZ() methods.
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
38 private template is_(char[] kind)
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
39 {
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
40 const char[] is_ = `bool is`~kind~`(){ return sid == SYM.`~kind~`; }`;
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
41 }
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
42 mixin(is_!("Module"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
43 mixin(is_!("Class"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
44 mixin(is_!("Interface"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
45 mixin(is_!("Struct"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
46 mixin(is_!("Union"));
614
8c5b1558244b Added symbol Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 589
diff changeset
47 mixin(is_!("Enum"));
567
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
48 mixin(is_!("Variable"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
49 mixin(is_!("Function"));
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
50 // mixin(is_!("Type"));
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
51 }