annotate trunk/src/dil/semantic/Symbol.d @ 623:e2cd28cfc6ae

Added dil.semantic.Template.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 11 Jan 2008 01:45:24 +0100
parents a05457530ac2
children 1ae72234db26
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,
623
e2cd28cfc6ae Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 615
diff changeset
20 Template,
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
21 Variable,
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
22 Function,
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
23 // Type,
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
24 }
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
25
563
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
26 /++
c838ed7f2ac9 Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 561
diff changeset
27 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
28 +/
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
29 class Symbol
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
30 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 407
diff changeset
31 SYM sid;
568
c8861b452eb3 Added members 'node' and 'parent' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 567
diff changeset
32 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
33 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
34 /// 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
35 /// 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
36 Node node;
567
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
37
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
38 // 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
39 private template is_(char[] kind)
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
40 {
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
41 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
42 }
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
43 mixin(is_!("Module"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
44 mixin(is_!("Class"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
45 mixin(is_!("Interface"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
46 mixin(is_!("Struct"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
47 mixin(is_!("Union"));
614
8c5b1558244b Added symbol Enum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 589
diff changeset
48 mixin(is_!("Enum"));
623
e2cd28cfc6ae Added dil.semantic.Template.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 615
diff changeset
49 mixin(is_!("Template"));
567
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
50 mixin(is_!("Variable"));
ab9f5020cd02 Added 'is-methods' to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 563
diff changeset
51 mixin(is_!("Function"));
615
a05457530ac2 Added member ident to class Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 614
diff changeset
52 // mixin(is_!("Type"));
407
5431c0faf3b5 Added modules dil.Scope and dil.Symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
53 }