annotate sema/Scope.d @ 168:7982eb63c0eb

Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
author Anders Johnsen <skabet@gmail.com>
date Thu, 24 Jul 2008 12:06:48 +0200
parents 6c5a3c0bb4fb
children
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,
147
060b6eb16db9 Parsing for-loops to some extend.
Anders Johnsen <skabet@gmail.com>
parents: 145
diff changeset
7 ast.Decl;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
8
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
9 public
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
10 import sema.DType,
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
11 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
12
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
13 class Scope
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
14 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
15 this() {}
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
16 this(Scope enclosing)
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
17 {
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
18 this.enclosing = enclosing;
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
19 this.func = enclosing.func;
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 93
diff changeset
20 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
21 this.mHandle = enclosing.mHandle;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
22 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
23
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
24 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
25 ModuleHandler mHandle;
99
857f0d530789 Imports and improved module statement
Anders Halager <halager@gmail.com>
parents: 93
diff changeset
26 Module inModule;
107
189c049cbfcc Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents: 101
diff changeset
27 Scope[] imported;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
28
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
29 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
30
145
a14ac9e5c858 Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents: 129
diff changeset
31 void put(char[] id, Decl d)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
32 {
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
33 symbols[id] ~= d;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
34 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
35
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
36 Decl[] find(char[] id)
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
37 {
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
38 if(id is "")
82
06dda301ea61 Can declare outside functions and call c-functions
Anders Johnsen <skabet@gmail.com>
parents: 59
diff changeset
39 return null;
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
40 else if (auto sym = id in symbols)
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
41 {
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
42 return *sym;
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
43 }
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
44 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
45 {
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
46 auto res = enclosing.find(id) ~ mHandle.find(getImports, id);
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
47 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
48 }
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
49 return [];
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
50 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
51
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
52 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
53 {
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 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
55 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
56 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
57 }
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
145
a14ac9e5c858 Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents: 129
diff changeset
59 DType findType(char[] id)
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
60 {
145
a14ac9e5c858 Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents: 129
diff changeset
61 if (auto type = id in types)
129
ed815b31479b Added a Symbol
Anders Halager <halager@gmail.com>
parents: 107
diff changeset
62 return *type;
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
63 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
64 {
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 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
66 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
67 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
68 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
69 }
22
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
70 return null;
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
71 }
e331e4e816e4 now handling structs to some extend
johnsen@johnsen-laptop
parents: 14
diff changeset
72
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
73 FuncDecl parentFunction()
2
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
74 {
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
75 if (func !is null)
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
76 return func;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
77 else if (enclosing !is null)
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
78 return enclosing.parentFunction();
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
79 else
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
80 return null;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
81 }
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
82
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
83 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
84 {
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
85 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
86 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
87 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
88 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
89 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
90 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
91 }
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
92
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
93 int opEquals(Object o)
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
94 {
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
95 return this is o;
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
96 }
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
97
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
98 char[] toString()
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
99 {
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
100 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
101 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
102 return Stdout.layout.convert("root: {}", symbols.length);
14
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
103 }
a51bdf15a33d Better scopes.
Anders Halager <halager@gmail.com>
parents: 2
diff changeset
104
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
105 FuncDecl parentFunction(FuncDecl f)
2
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
106 {
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
107 func = f;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
108 return f;
ae5bbe4e7fd6 Lots of stuff, here are the git comments:
Anders Halager <halager@gmail.com>
parents: 1
diff changeset
109 }
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
110 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
111 int currentStmtIndex = -1;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
112 private:
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
113 Decl[][char[]] 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
114 FuncDecl func;
1
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
115 }
2168f4cb73f1 First push
johnsen@johnsen-desktop
parents:
diff changeset
116
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
117 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
118 {
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
119 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
120 {
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
121 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
122 }
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
123 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
124 {
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
125 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
126 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
127 }
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
128
145
a14ac9e5c858 Changes Scope to use char[]'s insted of Identifiers for lookup.
Anders Johnsen <skabet@gmail.com>
parents: 129
diff changeset
129 DType findType(ImportDecl[] imports, char[] type)
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
130 {
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
131 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
132 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
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 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
135 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
136 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
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 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
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
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
141 Decl[] find(ImportDecl[] imports, char[] 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
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 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
144 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
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 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
147 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
148 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
149 }
168
7982eb63c0eb Some changes to get function overloading to work. Also class inherit works now - to some extend. needs vtables and all the complex stuff of it.
Anders Johnsen <skabet@gmail.com>
parents: 150
diff changeset
150 return [];
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
151 }
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 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
154 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
155 }
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
156