annotate sema/Scope.d @ 129:ed815b31479b

Added a Symbol
author Anders Halager <halager@gmail.com>
date Sat, 21 Jun 2008 20:41:18 +0200
parents 189c049cbfcc
children a14ac9e5c858
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92
771ac63898e2 A few better parser errors plus renaming most of the sema classes to match that they do now. Some have changes a lot.
Anders Johnsen <skabet@gmail.com>
parents: 82
diff changeset
1 module sema.Scope;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
2
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
3 import tango.io.Stdout;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
4
26
b4dc2b2c0e38 Added a DType class
Anders Halager <halager@gmail.com>
parents: 24
diff changeset
5 import lexer.Token,
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 93
diff changeset
6 ast.Module,
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
7 ast.Decl,
27
9031487e97d7 Various changes related to DType
Anders Halager <halager@gmail.com>
parents: 26
diff changeset
8 ast.Exp;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
9
93
621cedba53ea Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents: 92
diff changeset
10 public
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
11 import sema.DType,
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
12 sema.Symbol;
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 27
diff changeset
13
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
14 class Scope
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
15 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
16 this() {}
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
17 this(Scope enclosing)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
18 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
19 this.enclosing = enclosing;
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
20 this.func = enclosing.func;
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 93
diff changeset
21 this.inModule = enclosing.inModule;
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
22 this.mHandle = enclosing.mHandle;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
23 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
24
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
25 Scope enclosing;
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
26 ModuleHandler mHandle;
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 93
diff changeset
27 Module inModule;
107
189c049cbfcc Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents: 101
diff changeset
28 Scope[] imported;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
29
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
30 ImportDecl[] imports;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
31
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
32 void put(Identifier id, Decl d)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
33 {
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
34 symbols[id] = d;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
35 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
36
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
37 Decl find(Identifier id)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
38 {
107
189c049cbfcc Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents: 101
diff changeset
39 if(id is null)
82
06dda301ea61 Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
40 return null;
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
41 else if (auto sym = id in symbols)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
42 return *sym;
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
43 else if (enclosing !is null)
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
44 {
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
45 auto res = enclosing.find(id);
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
46 if (res is null)
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
47 return mHandle.find(getImports, id);
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
48 return res;
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
49 }
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
50 return null;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
52
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
53 ImportDecl[] getImports()
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
54 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
55 if(enclosing)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
56 return enclosing.getImports ~ imports;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
57 return imports;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
58 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
59
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 27
diff changeset
60 DType findType(Identifier id)
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
61 {
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 27
diff changeset
62 if (auto type = id.get in types)
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
63 return *type;
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
64 if (enclosing !is null)
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
65 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
66 auto type = enclosing.findType(id);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
67 if(type is null)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
68 return mHandle.findType(getImports, id);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
69 return type;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
70 }
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
71 return null;
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
72 }
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
73
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
74 /*
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
75 char[][] names()
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
76 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
77 char[][] res;
59
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
78 if (parentFunction() !is null)
1d6f4ad38a91 Make most of the tests pass again
Anders Halager <halager@gmail.com>
parents: 56
diff changeset
79 res ~= "pf: " ~ parentFunction().identifier.get;
24
2d28b21faad6 New codegen!
Anders Halager <halager@gmail.com>
parents: 22
diff changeset
80 if (enclosing)
2d28b21faad6 New codegen!
Anders Halager <halager@gmail.com>
parents: 22
diff changeset
81 res = enclosing.names;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
82 foreach (id, sym; symbols)
93
621cedba53ea Removed the Symbol from semantics - it was not needed anymore. From now on you set the type by doing a setType on an Identifier.
Anders Johnsen <skabet@gmail.com>
parents: 92
diff changeset
83 res ~= sym.name ~ " : " ~ (sym.type is null? "?" : sym.type.name);
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
84 return res;
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
85 }
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
86 */
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
87
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
88 FuncDecl parentFunction()
2
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
89 {
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
90 if (func !is null)
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
91 return func;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
92 else if (enclosing !is null)
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
93 return enclosing.parentFunction();
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
94 else
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
95 return null;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
96 }
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
97
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
98 int stmtIndex()
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
99 {
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
100 if (currentStmtIndex != -1)
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
101 return currentStmtIndex;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
102 else if (enclosing !is null)
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
103 return enclosing.stmtIndex();
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
104 else
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
105 return -1;
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
106 }
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
107
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
108 int opEquals(Object o)
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
109 {
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
110 return this is o;
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
111 }
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
112
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
113 char[] toString()
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
114 {
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
115 if (func)
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
116 return Stdout.layout.convert("{}: {}", func.identifier.get, symbols.length);
53
da551f90e03f Added struct decl and forward ref. A note on structs: they need to make a new scope when declared. Otherwise you could access struct members as globals
Anders Johnsen <skabet@gmail.com>
parents: 28
diff changeset
117 return Stdout.layout.convert("root: {}", symbols.length);
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
118 }
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
119
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
120 FuncDecl parentFunction(FuncDecl f)
2
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
121 {
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
122 func = f;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
123 return f;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
124 }
28
69464d465284 Now supporting structs - both read and write. Still a few errors though, so watch out.
Anders Johnsen <skabet@gmail.com>
parents: 27
diff changeset
125 DType[char[]] types;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
126 int currentStmtIndex = -1;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
127 private:
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
128 Decl[Identifier] symbols;
56
4ae365eff712 Now return types works for structs... Also, simplyfing in AST have been startet - but still messy. This update is a little messy...
Anders Johnsen <skabet@gmail.com>
parents: 53
diff changeset
129 FuncDecl func;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
130 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
131
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
132 class ModuleHandler
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
133 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
134 void add(Module m)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
135 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
136 modules[m.moduleName] = m;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
137 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
138 void add(Module m, char[] file)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
139 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
140 fileToModule[file] = m.moduleName;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
141 add(m);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
142 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
143
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
144 DType findType(ImportDecl[] imports, Identifier type)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
145 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
146 foreach(i ; imports)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
147 if(i.get in modules)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
148 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
149 auto t = modules[i.get].env.findType(type);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
150 if(t !is null)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
151 return t;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
152 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
153 return null;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
154 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
155
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
156 Decl find(ImportDecl[] imports, Identifier id)
101
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
157 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
158 foreach(i ; imports)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
159 if(i.get in modules)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
160 {
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
161 auto t = modules[i.get].env.find(id);
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
162 if(t !is null)
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
163 return t;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
164 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
165 return null;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
166 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
167
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
168 char[][char[]] fileToModule;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
169 Module[char[]] modules;
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
170 }
fea8d61a2451 First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
Anders Johnsen <skabet@gmail.com>
parents: 99
diff changeset
171