-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSymbolProvider.h
More file actions
51 lines (38 loc) · 1.35 KB
/
SymbolProvider.h
File metadata and controls
51 lines (38 loc) · 1.35 KB
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
#ifndef _SYMBOLPROVIDER_H_
#define _SYMBOLPROVIDER_H_
#include <string>
#include <map>
#include "Egg.h"
#include "Utils/egg_string.h"
#include "GCedRef.h"
namespace Egg {
class Runtime;
class SymbolProvider {
public:
virtual ~SymbolProvider() = default;
virtual Object* symbolFor_(const Egg::string& name) = 0;
virtual Object* existingSymbolFor_(const Egg::string& name) = 0;
};
class Bootstrapper;
class BootstrapSymbolProvider : public SymbolProvider {
Bootstrapper* _bootstrapper;
std::map<Egg::string, Object*> _symbols;
public:
BootstrapSymbolProvider(Bootstrapper* bootstrapper) : _bootstrapper(bootstrapper) {}
Object* symbolFor_(const Egg::string& name) override;
Object* existingSymbolFor_(const Egg::string& name) override;
std::map<Egg::string, Object*>& symbols() { return _symbols; }
};
class DynamicSymbolProvider : public SymbolProvider {
Runtime* _runtime;
GCedRef* _symbolTable;
std::map<Egg::string, GCedRef*> _cache;
public:
DynamicSymbolProvider(Runtime* runtime, HeapObject* symbolTable);
Object* symbolFor_(const Egg::string& name) override;
Object* existingSymbolFor_(const Egg::string& name) override;
void symbolTable_(HeapObject* table) { _symbolTable->set_((Object*)table); }
std::map<Egg::string, GCedRef*>& cache() { return _cache; }
};
}
#endif // _SYMBOLPROVIDER_H_