hobbes
a language, embedded compiler, and runtime for efficient dynamic expression evaluation, data storage and analysis
Classes | Namespaces | Macros | Typedefs | Functions
type.C File Reference
#include <hobbes/lang/type.H>
#include <hobbes/lang/expr.H>
#include <hobbes/lang/tylift.H>
#include <hobbes/lang/typepreds.H>
#include <hobbes/lang/constraints.H>
#include <hobbes/util/array.H>
#include <hobbes/util/codec.H>
#include <hobbes/util/str.H>
#include <hobbes/util/perf.H>
#include <sstream>
#include <stdexcept>
#include <string.h>
#include <unordered_map>
#include <atomic>
Include dependency graph for type.C:

Classes

struct  hobbes::cloneF
 
struct  hobbes::tgenVarsF
 
class  hobbes::instantiateF
 
class  hobbes::substituteF
 
class  hobbes::sizeOfF
 
struct  hobbes::readF< T >
 
struct  hobbes::readF< bool >
 
struct  hobbes::readF< std::string >
 
struct  hobbes::readF< std::vector< T > >
 
class  hobbes::encodeMonoTypeF
 
struct  hobbes::unaliasPrimTypesF
 

Namespaces

 hobbes
 

Macros

#define ntdbthrow(x, ti)   throw std::runtime_error("Internal compiler error, " x " on null type db for '" + str::demangle((ti).name()) + "'.")
 
#define TCODE_PRIM   ((char)0)
 
#define TCODE_OPAQUEPTR   ((char)1)
 
#define TCODE_TGEN   ((char)2)
 
#define TCODE_TVAR   ((char)3)
 
#define TCODE_FIXEDARR   ((char)4)
 
#define TCODE_ARR   ((char)5)
 
#define TCODE_VARIANT   ((char)6)
 
#define TCODE_RECORD   ((char)7)
 
#define TCODE_FUNC   ((char)8)
 
#define TCODE_EXISTS   ((char)9)
 
#define TCODE_TSTRING   ((char)10)
 
#define TCODE_TLONG   ((char)11)
 

Typedefs

typedef unique_refc_map< const Prim, std::string, MonoTypePtr > hobbes::PrimMem
 
typedef unique_refc_map< const OpaquePtr, std::string, unsigned int, bool > hobbes::OpaquePtrMem
 
typedef unique_refc_map< const TVar, std::string > hobbes::TVarMem
 
typedef unique_refc_map< const TGen, int > hobbes::TGenMem
 
typedef unique_refc_map< const TAbs, str::seq, MonoTypePtr > hobbes::TAbsMem
 
typedef unique_refc_map< const TApp, MonoTypePtr, MonoTypes > hobbes::TAppMem
 
typedef unique_refc_map< const FixedArray, MonoTypePtr, MonoTypePtr > hobbes::FixedArrayMem
 
typedef unique_refc_map< const Array, MonoTypePtr > hobbes::ArrayMem
 
typedef unique_refc_map< const Variant, Variant::Members > hobbes::VariantMem
 
typedef unique_refc_map< const Record, Record::Members > hobbes::RecordMem
 
typedef unique_refc_map< const Func, MonoTypePtr, MonoTypePtr > hobbes::FuncMem
 
typedef unique_refc_map< const Exists, std::string, MonoTypePtr > hobbes::ExistsMem
 
typedef unique_refc_map< const Recursive, std::string, MonoTypePtr > hobbes::RecursiveMem
 
typedef unique_refc_map< const TString, std::string > hobbes::TStringMem
 
typedef unique_refc_map< const TLong, long > hobbes::TLongMem
 
typedef unique_refc_map< const TExpr, std::string > hobbes::TExprMem
 
typedef unique_refc_maps< PrimMem, OpaquePtrMem, TVarMem, TGenMem, TAbsMem, TAppMem, FixedArrayMem, ArrayMem, VariantMem, RecordMem, FuncMem, ExistsMem, RecursiveMem, TStringMem, TLongMem, TExprMem > hobbes::MTypeCtorMaps
 

Functions

template<typename T >
std::string hobbes::showT (const T &t)
 
std::string hobbes::show (const PolyType &e)
 
std::string hobbes::show (const QualType &e)
 
std::string hobbes::show (const Constraint &e)
 
std::string hobbes::show (const MonoType &e)
 
std::string hobbes::show (const PolyType *e)
 
std::string hobbes::show (const PolyTypePtr &e)
 
std::string hobbes::show (const QualType *e)
 
std::string hobbes::show (const QualTypePtr &e)
 
std::string hobbes::show (const Constraint *e)
 
std::string hobbes::show (const ConstraintPtr &e)
 
std::string hobbes::show (const MonoType *e)
 
std::string hobbes::show (const MonoTypePtr &e)
 
template<typename T >
std::string hobbes::show (const std::set< T > &ts)
 
std::string hobbes::showNoSimpl (const PolyType &e)
 
std::string hobbes::showNoSimpl (const QualType &e)
 
std::string hobbes::showNoSimpl (const Constraint &e)
 
std::string hobbes::showNoSimpl (const MonoType &e)
 
std::string hobbes::showNoSimpl (const PolyType *e)
 
std::string hobbes::showNoSimpl (const PolyTypePtr &e)
 
std::string hobbes::showNoSimpl (const QualType *e)
 
std::string hobbes::showNoSimpl (const QualTypePtr &e)
 
std::string hobbes::showNoSimpl (const Constraint *e)
 
std::string hobbes::showNoSimpl (const ConstraintPtr &e)
 
std::string hobbes::showNoSimpl (const MonoType *e)
 
std::string hobbes::showNoSimpl (const MonoTypePtr &e)
 
str::seq hobbes::showNoSimpl (const MonoTypes &)
 
str::seq hobbes::showNoSimpl (const Constraints &)
 
TEnvPtr hobbes::fnFrame (const TEnvPtr &, const str::seq &, const MonoTypes &)
 
TEnvPtr hobbes::bindFrame (const TEnvPtr &, const std::string &, const MonoTypePtr &)
 
TEnvPtr hobbes::bindFrame (const TEnvPtr &, const std::string &, const QualTypePtr &)
 
bool hobbes::satisfied (const UnqualifierPtr &uq, const TEnvPtr &tenv, const ConstraintPtr &c, Definitions *ds)
 
bool hobbes::satisfied (const TEnvPtr &tenv, const ConstraintPtr &c, Definitions *ds)
 
bool hobbes::satisfied (const TEnvPtr &tenv, const Constraints &cs, Definitions *ds)
 
bool hobbes::satisfiable (const UnqualifierPtr &uq, const TEnvPtr &tenv, const ConstraintPtr &c, Definitions *ds)
 
bool hobbes::satisfiable (const TEnvPtr &tenv, const ConstraintPtr &c, Definitions *ds)
 
bool hobbes::satisfiable (const TEnvPtr &tenv, const Constraints &cs, Definitions *ds)
 
bool hobbes::isFileRef (const MonoTypePtr &mt)
 
unsigned int hobbes::alignment (const MonoTypePtr &)
 
MTypeCtorMaps * hobbes::tctorMaps ()
 
void hobbes::compactMTypeMemory ()
 
MonoTypePtr hobbes::normIfOpaquePtr (const MonoTypePtr &ty)
 
bool hobbes::showFileRef (const MonoTypePtr &f, const MonoTypes &targs, std::ostream &out)
 
static void hobbes::resetCtorIDs (Variant::Members *ms)
 
int hobbes::findHiddenMember (int i, const std::string &lbl, const Variant::Members &ms)
 
Variant::Members hobbes::consMember (const std::string &lbl, const MonoTypePtr &hty, const Variant::Members &tty)
 
static bool hobbes::hiddenCtor (const Variant::Member &m)
 
static void hobbes::normalizeSumFields (Variant::Members *ms)
 
size_t hobbes::nextVisibleMember (size_t i, const Variant::Members &ms)
 
void hobbes::showFullVarPayloadSuffix (const MonoTypePtr &t, std::ostream &out)
 
void hobbes::showFull (const Variant::Members &ms, std::ostream &out)
 
void hobbes::showSum (const Variant::Members &ms, std::ostream &out)
 
bool hobbes::looksLikeSum (const Variant::Members &ms)
 
Variant::Members hobbes::tailMembers (const Variant::Members &ms)
 
Record::Member hobbes::addoffset (const Record::Member &m, int o)
 
unsigned int hobbes::nextVisibleMember (unsigned int i, const Record::Members &ms)
 
static void hobbes::resetFieldOffsets (Record::Members *ms)
 
static void hobbes::normalizeTupleFields (Record::Members *ms)
 
Record::Members hobbes::tailMembers (bool tup, const Record::Members &ms)
 
unsigned int hobbes::maxFieldAlignmentF (const Record::Members &ms)
 
bool hobbes::isTupleDesc (const Record::Members &ms)
 
void hobbes::showAsTuple (std::ostream &out, const Record::Members &ms)
 
void hobbes::showAsRecord (std::ostream &out, const Record::Members &ms)
 
MonoTypePtr hobbes::clone (const MonoTypePtr &)
 
MonoTypePtr hobbes::clone (const MonoType *)
 
MonoTypePtr hobbes::clone (const MonoType &)
 
QualTypePtr hobbes::cloneP (const QualTypePtr &p)
 
MonoTypePtr hobbes::cloneP (const MonoTypePtr &p)
 
QualTypePtr hobbes::lookupFieldType (const QualTypePtr &qt, const std::string &fieldName)
 
MonoTypePtr hobbes::lookupFieldType (const MonoTypePtr &mt, const std::string &fieldName)
 
Constraints hobbes::mergeConstraints (const Constraints &lhs, const Constraints &rhs)
 
void hobbes::mergeConstraints (const Constraints &fcs, Constraints *tcs)
 
static std::atomic< std::size_t > hobbes::uidCtr (0)
 
TVName hobbes::freshName ()
 
Names hobbes::freshNames (int vs)
 
MonoTypePtr hobbes::freshTypeVar ()
 
MonoTypes hobbes::freshTypeVars (int vs)
 
MonoTypes hobbes::freshen (const MonoTypes &)
 
ConstraintPtr hobbes::freshen (const ConstraintPtr &)
 
Constraints hobbes::freshen (const Constraints &cs)
 
MonoTypes hobbes::typeVars (const Names &ns)
 
MonoTypes hobbes::tgens (int vs)
 
bool hobbes::isMonoSingular (const MonoType &)
 
bool hobbes::isMonoSingular (const MonoType *)
 
bool hobbes::isMonoSingular (const MonoTypePtr &)
 
bool hobbes::isMonoSingular (const QualTypePtr &)
 
int hobbes::tgenSize (const MonoTypePtr &mt)
 
int hobbes::tgenSize (const MonoTypes &mts)
 
int hobbes::tgenSize (const Constraints &cs)
 
int hobbes::tgenSize (const QualTypePtr &qt)
 
TGenVarSet hobbes::tgenVars (const MonoTypePtr &)
 
QualTypePtr hobbes::instantiate (int vs, const QualTypePtr &scheme)
 
Constraints hobbes::instantiate (int vs, const Constraints &cs)
 
ConstraintPtr hobbes::instantiate (int vs, const ConstraintPtr &c)
 
MonoTypePtr hobbes::instantiate (int vs, const MonoTypePtr &mt)
 
MonoTypes hobbes::instantiate (int vs, const MonoTypes &ts)
 
QualTypePtr hobbes::instantiate (const MonoTypes &ts, const QualTypePtr &scheme)
 
Constraints hobbes::instantiate (const MonoTypes &ts, const Constraints &cs)
 
ConstraintPtr hobbes::instantiate (const MonoTypes &ts, const ConstraintPtr &c)
 
MonoTypePtr hobbes::instantiate (const MonoTypes &ts, const MonoTypePtr &mt)
 
MonoTypes hobbes::instantiate (const MonoTypes &ts, const MonoTypes &sts)
 
QualTypePtr hobbes::instantiate (const Names &ns, const QualTypePtr &scheme)
 
Constraints hobbes::instantiate (const Names &ns, const Constraints &cs)
 
ConstraintPtr hobbes::instantiate (const Names &ns, const ConstraintPtr &c)
 
MonoTypePtr hobbes::instantiate (const Names &ns, const MonoTypePtr &mt)
 
MonoTypes hobbes::instantiate (const Names &ns, const MonoTypes &ts)
 
NameSet hobbes::tvarNames (const QualTypePtr &qt)
 
NameSet hobbes::tvarNames (const Constraints &cs)
 
NameSet hobbes::tvarNames (const ConstraintPtr &c)
 
NameSet hobbes::tvarNames (const MonoTypePtr &mt)
 
NameSet hobbes::tvarNames (const MonoType &mt)
 
NameSet hobbes::tvarNames (const MonoTypes &mts)
 
void hobbes::tvarNames (const QualTypePtr &qt, NameSet *out)
 
void hobbes::tvarNames (const Constraints &cs, NameSet *out)
 
void hobbes::tvarNames (const ConstraintPtr &c, NameSet *out)
 
void hobbes::tvarNames (const MonoTypePtr &mt, NameSet *out)
 
void hobbes::tvarNames (const MonoType &mt, NameSet *out)
 
void hobbes::tvarNames (const MonoTypes &mts, NameSet *out)
 
bool hobbes::isFreeVarNameIn (const TVName &, const MonoTypePtr &)
 
bool hobbes::isFreeVarNameIn (const TVName &, const MonoTypes &)
 
bool hobbes::hasFreeVariables (const QualTypePtr &)
 
bool hobbes::hasFreeVariables (const Constraints &)
 
bool hobbes::hasFreeVariables (const ConstraintPtr &)
 
bool hobbes::hasFreeVariables (const MonoTypePtr &)
 
bool hobbes::hasFreeVariables (const MonoTypes &)
 
std::string hobbes::show (const MonoTypeSubst &s)
 
void hobbes::show (const MonoTypeSubst &s, std::ostream &out)
 
QualTypePtr hobbes::substitute (const MonoTypeSubst &s, const QualTypePtr &qt)
 
bool hobbes::in (const ConstraintPtr &c, const Constraints &cs)
 
Constraints hobbes::substitute (const MonoTypeSubst &s, const Constraints &cs)
 
ConstraintPtr hobbes::substitute (const MonoTypeSubst &s, const ConstraintPtr &p)
 
MonoTypePtr hobbes::substituteStep (const MonoTypeSubst &s, const MonoTypePtr &mt)
 
MonoTypePtr hobbes::substitute (const MonoTypeSubst &s, const MonoTypePtr &mt)
 
MonoTypePtr hobbes::substitute (const MonoTypeSubst &s, const MonoType &mt)
 
MonoTypes hobbes::substitute (const MonoTypeSubst &s, const MonoTypes &ts)
 
PolyTypePtr hobbes::generalize (const QualTypePtr &qt)
 
TVName hobbes::canonicalName (int v)
 
MonoTypeSubst hobbes::canonicalNameSubst (const NameSet &ns)
 
QualTypePtr hobbes::simplifyVarNames (const PolyType &)
 
QualTypePtr hobbes::simplifyVarNames (const PolyTypePtr &)
 
ConstraintPtr hobbes::simplifyVarNames (const Constraint &)
 
ConstraintPtr hobbes::simplifyVarNames (const ConstraintPtr &)
 
QualTypePtr hobbes::simplifyVarNames (const QualType &)
 
QualTypePtr hobbes::simplifyVarNames (const QualTypePtr &)
 
MonoTypePtr hobbes::simplifyVarNames (const MonoType &)
 
MonoTypePtr hobbes::simplifyVarNames (const MonoTypePtr &)
 
MonoTypes hobbes::simplifyVarNames (const MonoTypes &mts)
 
nat hobbes::nadd (nat lhs, nat rhs)
 
nat hobbes::nmax (nat lhs, nat rhs)
 
unsigned int hobbes::sizeOf (const MonoTypePtr &mt)
 
bool hobbes::isPrimName (const std::string &tn)
 
MonoTypePtr hobbes::unroll (const MonoTypePtr &)
 
bool hobbes::isMonotype (const QualTypePtr &qt)
 
bool hobbes::isMonotype (const PolyTypePtr &pt)
 
MonoTypePtr hobbes::requireMonotype (const QualTypePtr &qt)
 
MonoTypePtr hobbes::requireMonotype (const PolyTypePtr &pt)
 
MonoTypes hobbes::requireMonotype (const PolyTypes &pts)
 
MonoTypePtr hobbes::unpackedType (const Exists *e)
 
MonoTypePtr hobbes::unpackedType (const MonoTypePtr &mty)
 
QualTypePtr hobbes::unpackedType (const QualTypePtr &qty)
 
void hobbes::write (bool b, bytes *out)
 
void hobbes::write (char c, bytes *out)
 
void hobbes::write (unsigned char c, bytes *out)
 
void hobbes::write (int x, bytes *out)
 
void hobbes::write (long x, bytes *out)
 
void hobbes::write (size_t x, bytes *out)
 
void hobbes::write (unsigned int x, bytes *out)
 
void hobbes::write (const std::string &s, bytes *out)
 
template<typename T >
void hobbes::write (const std::vector< T > &xs, bytes *out)
 
template<typename T >
hobbes::read (const bytes &in, unsigned int *n)
 
void hobbes::encode (const MonoTypePtr &, std::vector< unsigned char > *)
 
void hobbes::encode (const QualTypePtr &, std::vector< unsigned char > *)
 
MonoTypePtr hobbes::decodeFrom (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodePrim (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeOpaquePtr (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTGen (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTAbs (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTApp (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTVar (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeFixedArr (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeArr (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeVariant (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeRecord (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeFunc (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeExists (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeRecursive (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTString (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTLong (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decodeTExpr (const bytes &in, unsigned int *n)
 
MonoTypePtr hobbes::decode (const std::vector< unsigned char > &in)
 
MonoTypePtr hobbes::decode (const unsigned char *b, const unsigned char *e)
 
void hobbes::encode (const QualTypePtr &, std::ostream &)
 
void hobbes::encode (const MonoTypePtr &, std::ostream &)
 
void hobbes::decode (QualTypePtr *, std::istream &)
 
void hobbes::decode (MonoTypePtr *, std::istream &)
 
MonoTypePtr hobbes::unalias (const MonoTypePtr &)
 
MonoTypePtr hobbes::makeFileRef (const MonoTypePtr &ty, const MonoTypePtr &f)
 

Macro Definition Documentation

◆ ntdbthrow

#define ntdbthrow (   x,
  ti 
)    throw std::runtime_error("Internal compiler error, " x " on null type db for '" + str::demangle((ti).name()) + "'.")

◆ TCODE_ARR

#define TCODE_ARR   ((char)5)

◆ TCODE_EXISTS

#define TCODE_EXISTS   ((char)9)

◆ TCODE_FIXEDARR

#define TCODE_FIXEDARR   ((char)4)

◆ TCODE_FUNC

#define TCODE_FUNC   ((char)8)

◆ TCODE_OPAQUEPTR

#define TCODE_OPAQUEPTR   ((char)1)

◆ TCODE_PRIM

#define TCODE_PRIM   ((char)0)

◆ TCODE_RECORD

#define TCODE_RECORD   ((char)7)

◆ TCODE_TGEN

#define TCODE_TGEN   ((char)2)

◆ TCODE_TLONG

#define TCODE_TLONG   ((char)11)

◆ TCODE_TSTRING

#define TCODE_TSTRING   ((char)10)

◆ TCODE_TVAR

#define TCODE_TVAR   ((char)3)

◆ TCODE_VARIANT

#define TCODE_VARIANT   ((char)6)