hobbes
a language, embedded compiler, and runtime for efficient dynamic expression evaluation, data storage and analysis
hobbes.H
Go to the documentation of this file.
1 
2 #ifndef HOBBES_MAIN_HPP_INCLUDED
3 #define HOBBES_MAIN_HPP_INCLUDED
4 
5 #include <hobbes/eval/cc.H>
6 #include <hobbes/eval/cmodule.H>
7 #include <hobbes/lang/tylift.H>
8 #include <hobbes/read/parser.H>
9 #include <hobbes/events/events.H>
10 #include <hobbes/ipc/prepl.H>
11 #include <hobbes/util/region.H>
12 #include <hobbes/util/variant.H>
13 
14 namespace hobbes {
15 
16 // type aliases for common types
17 extern const char timespanTNV[];
19 
20 extern const char timeTNV[];
22 
23 extern const char datetimeTNV[];
25 
26 // allocate some memory in the calling thread's memory pool
27 char* memalloc(long n);
28 
29 // string representations, I/O
30 const array<char>* makeString(const std::string& x);
31 std::string makeStdString(const array<char>* x);
32 
33 const array<char>* makeString(region& m, const char* s);
34 const array<char>* makeString(region& m, const std::string& s);
35 const array<char>* makeString(region& m, const char* s, size_t len);
36 const array<char>* makeString(const char* s, size_t len);
37 
38 inline std::ostream& operator<<(std::ostream& out, const array<char>* x) {
39  out.write(x->data, x->size);
40  return out;
41 }
42 
43 // allocate an array at some type, with some length
44 template <typename T>
45  array<T>* makeArray(region& m, long n) {
46  array<T>* r = (array<T>*)m.malloc(sizeof(long) + (sizeof(T) * n));
47  r->size = n;
48  return r;
49  }
50 
51 template <typename T>
52  array<T>* makeArray(long n) {
53  array<T>* r = (array<T>*)memalloc(sizeof(long) + (sizeof(T) * n));
54  r->size = n;
55  return r;
56  }
57 
58 // allocate ... something
59 template <typename T, typename ... Args>
60  T* make(const Args& ... args) {
61  return new (memalloc(sizeof(T))) T(args...);
62  }
63 
64 // resets the thread-local memory pool for expressions
65 // (subsequent allocations will reuse previously-used memory)
66 void resetMemoryPool();
67 
68 // reset the thread-local memory pool when this object goes out of scope
70 public:
72 };
73 
74 // shows a description of all active memory regions
75 std::string showMemoryPool();
76 
77 // control the set of regions used for dynamic allocation
78 size_t addThreadRegion(const std::string&, region*);
79 size_t findThreadRegion(const std::string&);
80 void removeThreadRegion(size_t);
81 size_t setThreadRegion(size_t);
82 
83 }
84 
85 #endif
size_t addThreadRegion(const std::string &, region *)
Definition: funcdefs.C:42
typeAlias< datetimeTNV, int64_t > datetimeT
Definition: hobbes.H:24
array< T > * makeArray(region &m, long n)
Definition: hobbes.H:45
const array< char > * makeString(const std::string &x)
Definition: funcdefs.C:191
typeAlias< timeTNV, int64_t > timeT
Definition: hobbes.H:21
~scoped_pool_reset()
Definition: funcdefs.C:168
typeAlias< timespanTNV, int64_t > timespanT
Definition: hobbes.H:18
T * make(const Args &... args)
Definition: hobbes.H:60
void removeThreadRegion(size_t)
Definition: funcdefs.C:58
Definition: boot.H:7
long size
Definition: tylift.H:84
char * memalloc(long n)
Definition: funcdefs.C:84
std::string makeStdString(const array< char > *x)
Definition: funcdefs.C:195
std::string showMemoryPool()
Definition: funcdefs.C:126
Definition: tylift.H:63
const char datetimeTNV[]
Definition: funcdefs.C:319
const char timespanTNV[]
Definition: funcdefs.C:307
const char timeTNV[]
Definition: funcdefs.C:313
Definition: tylift.H:81
size_t r(const reader::MetaData &md, size_t o, T *t)
Definition: storage.H:1730
#define out
Definition: netio.H:19
size_t setThreadRegion(size_t)
Definition: funcdefs.C:67
void resetMemoryPool()
Definition: funcdefs.C:156
std::map< std::string, llvm::Value * > Args
Definition: dfa.C:1276
void * malloc(unsigned int sz)
Definition: region.C:28
size_t findThreadRegion(const std::string &)
Definition: funcdefs.C:48
LexicalAnnotation m(const YYLTYPE &p)
Definition: hexpr.parse.C:127
Definition: region.H:16
Definition: hobbes.H:69