annotate trunk/src/dil/Symbols.d @ 561:302e50e71ec2

Added Interface symbol.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 26 Dec 2007 23:38:16 +0100
parents 709e223a8eb9
children b0533550d64c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
1 /++
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
2 Author: Aziz Köksal
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
3 License: GPL3
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
4 +/
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
5 module dil.Symbols;
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
6
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
7 import dil.Symbol;
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
8 import dil.SymbolTable;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
9 import dil.SyntaxTree;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
10 import dil.Enums;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
11 import dil.TypeSystem;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
12 import dil.Identifier;
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
13 import common;
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
14
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
15 /// A symbol that has its own scope with a symbol table.
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
16 class ScopeSymbol : Symbol
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
17 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
18 SymbolTable symbolTable; /// The symbol table.
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
19
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
20 this()
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
21 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
22 symbolTable = new SymbolTable;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
23 }
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
24 }
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
25
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
26 /// Aggregates have function and field members.
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
27 class Aggregate : ScopeSymbol
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
28 {
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
29 Function[] funcs;
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
30 Variable[] fields;
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
31 }
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
32
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
33 class Class : Aggregate
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
34 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
35 this()
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
36 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
37 this.sid = SYM.Class;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
38 }
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
39 }
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
40
561
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
41 class Interface : Aggregate
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
42 {
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
43 this()
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
44 {
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
45 this.sid = SYM.Interface;
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
46 }
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
47 }
302e50e71ec2 Added Interface symbol.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 560
diff changeset
48
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
49 class Union : Aggregate
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
50 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
51 this()
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
52 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
53 this.sid = SYM.Union;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
54 }
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
55 }
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
56
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
57 class Struct : Aggregate
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
58 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
59 this()
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
60 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
61 this.sid = SYM.Struct;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
62 }
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
63 }
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
64
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
65 class Function : ScopeSymbol
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
66 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
67 StorageClass stc;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
68 LinkageType linkType;
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
69
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
70 Type returnType;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
71 Identifier* ident;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
72 Variable[] params;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
73
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
74 this()
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
75 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
76 this.sid = SYM.Function;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
77 }
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
78 }
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
79
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
80 class Variable : Symbol
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
81 {
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
82 StorageClass stc;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
83 LinkageType linkType;
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
84
560
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
85 Type type;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
86 Identifier* ident;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
87 Node varDecl; /// The VariableDeclaration or Parameter node - for source code location.
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
88
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
89 this(StorageClass stc, LinkageType linkType,
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
90 Type type, Identifier* ident, Node varDecl)
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
91 {
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
92 this.sid = SYM.Variable;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
93
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
94 this.stc = stc;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
95 this.linkType = linkType;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
96 this.type = type;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
97 this.ident = ident;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
98 this.varDecl = varDecl;
709e223a8eb9 Added code related to symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 517
diff changeset
99 }
517
b465c669d70c Added module dil.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
100 }