hobbes
a language, embedded compiler, and runtime for efficient dynamic expression evaluation, data storage and analysis
func.H
Go to the documentation of this file.
1 
2 #ifndef HOBBES_EVAL_FUNC_HPP_INCLUDED
3 #define HOBBES_EVAL_FUNC_HPP_INCLUDED
4 
5 #include <hobbes/lang/type.H>
6 #include <hobbes/lang/tylift.H>
7 #include <hobbes/lang/expr.H>
8 #include <hobbes/util/llvm.H>
9 
10 namespace hobbes {
11 
12 // low-level representation decisions ...
13 inline bool hasPointerRep(const MonoTypePtr& t) {
14  if (const Prim* pt = is<Prim>(t)) {
15  if (pt->representation()) {
16  return hasPointerRep(pt->representation());
17  }
18  }
19  if (const OpaquePtr* op = is<OpaquePtr>(t)) {
20  return !op->storedContiguously();
21  }
22  return is<Record>(t) || is<FixedArray>(t) || is<Array>(t) || is<Variant>(t) || is<Recursive>(t);
23 }
24 
25 inline bool hasPointerRep(const PolyTypePtr& t) {
26  if (t->typeVariables() > 0 || t->instantiate()->constraints().size() > 0) {
27  return false;
28  } else {
29  return hasPointerRep(requireMonotype(t));
30  }
31 }
32 
33 inline bool isLargeType(const MonoTypePtr& mty) {
34  if (const Prim* pt = is<Prim>(mty)) {
35  if (pt->representation()) {
36  return isLargeType(pt->representation());
37  }
38  }
39 
40  if (const OpaquePtr* p = is<OpaquePtr>(mty)) {
41  return p->storedContiguously();
42  } else {
43  return is<Record>(mty) || is<FixedArray>(mty) || is<Variant>(mty);
44  }
45 }
46 
47 // bind standard operators
48 class cc;
49 void initDefOperators(cc*);
50 
51 }
52 
53 #endif
std::shared_ptr< PolyType > PolyTypePtr
Definition: type.H:23
Definition: type.H:279
Definition: boot.H:7
MonoType::ptr MonoTypePtr
Definition: type.H:71
Definition: cc.H:64
void initDefOperators(cc *)
Definition: func.C:979
bool isLargeType(const MonoTypePtr &mty)
Definition: func.H:33
Definition: type.H:260
Definition: jitcc.H:21
bool hasPointerRep(const MonoTypePtr &t)
Definition: func.H:13
const MonoTypePtr & requireMonotype(const ExprPtr &)
Definition: expr.C:1221