-
Notifications
You must be signed in to change notification settings - Fork 3
/
Linker.cpp
64 lines (50 loc) · 974 Bytes
/
Linker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "Linker.hpp"
#include "String.hpp"
namespace SoftWire
{
Linker::External *Linker::externals;
Linker::Linker()
{
}
Linker::~Linker()
{
clearExternals();
}
void *Linker::resolveExternal(const char *name)
{
const External *external = externals;
while(external)
{
if(external->name && strcmp(external->name, name) == 0)
{
return external->pointer;
}
external = external->next();
}
return 0;
}
void Linker::defineExternal(void *pointer, const char *name)
{
if(!externals)
{
externals = new External();
}
External *external = externals;
do
{
if(external->name && strcmp(external->name, name) == 0)
{
external->pointer = pointer;
return;
}
external = external->next();
}
while(external);
externals->append(Identifier(pointer, name));
}
void Linker::clearExternals()
{
delete externals;
externals = 0;
}
}