1 #ifndef HOBBES_LANG_EXPR_HPP_INCLUDED 2 #define HOBBES_LANG_EXPR_HPP_INCLUDED 19 virtual void show(std::ostream&)
const = 0;
40 template <
typename Case>
50 }
else if (
const Case* trhs = is<Case>(&rhs)) {
51 return *
this == *trhs;
59 typedef std::vector<ExprPtr>
Exprs;
66 std::string
show(
const ExprPtr& e);
67 std::string
show(
const Definition& d);
80 virtual bool operator< (
const Primitive&)
const = 0;
89 bool operator()(
const PrimitivePtr&,
const PrimitivePtr&)
const;
93 template <
typename Case>
98 virtual bool equiv(
const Case&)
const = 0;
99 virtual bool lt(
const Case&)
const = 0;
102 if (
const Case* trhs = is<Case>(&rhs)) {
110 if (
const Case* trhs = is<Case>(&rhs)) {
111 return this->equiv(*trhs);
122 void show(std::ostream&
out)
const;
124 bool equiv(
const Unit&)
const;
125 bool lt(
const Unit&)
const;
128 static const int type_case_id = 0;
137 void show(std::ostream&
out)
const;
139 bool equiv(
const Bool&)
const;
140 bool lt(
const Bool&)
const;
143 static const int type_case_id = 1;
154 void show(std::ostream&
out)
const;
156 bool equiv(
const Char&)
const;
157 bool lt(
const Char&)
const;
160 static const int type_case_id = 2;
169 unsigned char value()
const;
170 void value(
unsigned char);
172 void show(std::ostream&
out)
const;
174 bool equiv(
const Byte&)
const;
175 bool lt(
const Byte&)
const;
178 static const int type_case_id = 3;
190 void show(std::ostream&
out)
const;
192 bool equiv(
const Short&)
const;
193 bool lt(
const Short&)
const;
196 static const int type_case_id = 4;
208 void show(std::ostream&
out)
const;
210 bool equiv(
const Int&)
const;
211 bool lt(
const Int&)
const;
214 static const int type_case_id = 5;
226 void show(std::ostream&
out)
const;
228 bool equiv(
const Long&)
const;
229 bool lt(
const Long&)
const;
232 static const int type_case_id = 6;
244 void show(std::ostream&
out)
const;
246 bool equiv(
const Float&)
const;
247 bool lt(
const Float&)
const;
250 static const int type_case_id = 7;
259 double value()
const;
262 void show(std::ostream&
out)
const;
264 bool equiv(
const Double&)
const;
265 bool lt(
const Double&)
const;
268 static const int type_case_id = 8;
273 template <
typename Case>
287 const std::string& value()
const;
288 void value(
const std::string&);
290 void show(std::ostream&
out)
const;
293 static const int type_case_id = 9;
304 const std::string&
var()
const;
305 const ExprPtr& varExpr()
const;
306 const ExprPtr& bodyExpr()
const;
308 void var(
const std::string&);
309 void varExpr(
const ExprPtr&);
310 void bodyExpr(
const ExprPtr&);
313 void show(std::ostream&
out)
const;
316 static const int type_case_id = 10;
326 typedef std::pair<std::string, ExprPtr>
Binding;
332 const Bindings& bindings()
const;
333 const ExprPtr& bodyExpr()
const;
336 Bindings& bindings();
337 void bodyExpr(
const ExprPtr&);
340 void show(std::ostream&)
const;
343 static const int type_case_id = 11;
358 const ExprPtr& body()
const;
361 void body(
const ExprPtr&);
364 void show(std::ostream&
out)
const;
367 static const int type_case_id = 12;
379 const ExprPtr&
fn()
const;
380 const Exprs& args()
const;
382 void fn(
const ExprPtr&);
386 void show(std::ostream&
out)
const;
389 static const int type_case_id = 13;
401 const ExprPtr&
left()
const;
402 const ExprPtr&
right()
const;
404 void left(
const ExprPtr&);
405 void right(
const ExprPtr&);
408 void show(std::ostream&
out)
const;
411 static const int type_case_id = 14;
423 const Exprs&
values()
const;
427 void show(std::ostream&
out)
const;
430 static const int type_case_id = 15;
441 const std::string&
label()
const;
442 const ExprPtr& value()
const;
444 void label(
const std::string&);
445 void value(
const ExprPtr&);
448 void show(std::ostream&
out)
const;
451 static const int type_case_id = 16;
466 const FieldDefs& fields()
const;
470 void show(std::ostream&
out)
const;
473 static const int type_case_id = 17;
477 bool isTuple()
const;
478 void showRecord(std::ostream&
out)
const;
479 void showRecordAnnotated(std::ostream&
out)
const;
480 void showTuple(std::ostream&
out)
const;
481 void showTupleAnnotated(std::ostream&
out)
const;
490 const ExprPtr&
array()
const;
491 const ExprPtr&
index()
const;
493 void array(
const ExprPtr&);
494 void index(
const ExprPtr&);
497 void show(std::ostream&
out)
const;
500 static const int type_case_id = 18;
511 Binding(
const std::string& selector,
const std::string& vname,
const ExprPtr& exp) : selector(selector), vname(vname), exp(exp) { }
523 const ExprPtr&
variant()
const;
524 const Bindings& bindings()
const;
525 const ExprPtr& defaultExpr()
const;
528 Bindings& bindings();
529 void defaultExpr(
const ExprPtr&);
531 bool hasBinding(
const std::string&)
const;
532 void addBinding(
const std::string& selector,
const std::string& vname,
const ExprPtr& exp);
535 void show(std::ostream&
out)
const;
538 static const int type_case_id = 19;
550 Binding(
const PrimitivePtr& value,
const ExprPtr& exp) : value(value), exp(exp) { }
561 const ExprPtr& expr()
const;
562 const Bindings& bindings()
const;
563 const ExprPtr& defaultExpr()
const;
565 void expr(
const ExprPtr&);
566 Bindings& bindings();
567 void defaultExpr(
const ExprPtr&);
570 void show(std::ostream&)
const;
573 static const int type_case_id = 20;
586 const ExprPtr& record()
const;
587 const std::string&
field()
const;
589 void record(
const ExprPtr&);
590 void field(
const std::string&);
593 void show(std::ostream&
out)
const;
596 static const int type_case_id = 21;
608 const ExprPtr& expr()
const;
611 void expr(
const ExprPtr&);
615 void show(std::ostream&
out)
const;
618 static const int type_case_id = 22;
630 const ExprPtr& expr()
const;
631 void expr(
const ExprPtr&);
634 void show(std::ostream&
out)
const;
637 static const int type_case_id = 23;
648 const std::string&
varName()
const;
649 const ExprPtr& package()
const;
650 const ExprPtr& expr()
const;
652 void varName(
const std::string&);
653 void package(
const ExprPtr&);
654 void expr(
const ExprPtr&);
657 void show(std::ostream&
out)
const;
660 static const int type_case_id = 24;
667 template <
typename Case>
673 ExprPtr
r(
new Bool(x, la));
679 ExprPtr
r(
new Byte(x, la));
685 ExprPtr
r(
new Int(x, la));
691 ExprPtr
r(
new Long(x, la));
697 ExprPtr
r(
new Long(x, la));
708 for (
const std::string& vn : vns) {
709 r.push_back(
var(vn, la));
715 ExprPtr
r(
new Var(vn, la));
725 ExprPtr
r(
new Let(vn, e, b, la));
734 for (
auto rb = bs.rbegin(); rb != bs.rend(); ++rb) {
735 r =
let(rb->first, rb->second, r, la);
742 for (
const auto& e : es) {
745 return let(bs, b, la);
749 ExprPtr
r(
new Unit(la));
755 if (fds.size() == 0) {
762 for (MkRecord::FieldDefs::const_iterator fd = fds.begin(); fd != fds.end(); ++fd) {
767 ms.push_back(
Record::Member(fd->first, fd->second->type()->monoType()));
784 ExprPtr p(
new Proj(rec, field, la));
785 p->type(
qualtype(rec->type()->constraints(), rty->
member(field)));
791 if (
const Record* rty = is<Record>(rec->type()->monoType())) {
792 return proj(rec, rty, field, la);
802 for (
const auto& f : fields) {
812 template <
typename ... Cases>
817 hbs.insert(hbs.end(), tbs.begin(), tbs.end());
821 template <
typename ... Cases>
822 ExprPtr
caseOf(
const ExprPtr& e, Cases... cs) {
828 for (Exprs::const_iterator e = es.begin(); e != es.end(); ++e) {
831 append(&r, qt->constraints());
846 ExprPtr
r(
new App(f, args, la));
862 return ExprPtr(
new Unpack(cn, c,
fncall(
proj(
var(cn, la),
".f0", la),
cons(
proj(
var(cn, la),
".f1", la), args), la), la));
865 const Exists* ety = is<Exists>(qt->monoType());
867 throw annotated_error(*c,
"Expected existential type in closure application");
880 Func* fty = is<Func>(oty);
881 if (!fty) {
throw annotated_error(la,
"Internal compiler error while eta-expanding primitive op: " + opname); }
883 ExprPtr
op =
var(opname, oty, la);
890 for (
const auto& a : atys) {
892 args.push_back(
var(vname, a, la));
893 vns.push_back(vname);
897 ExprPtr ret =
fn(vns,
fncall(op, args, la), la);
908 for (
size_t b = 0; b < v.size(); ++b) {
909 ExprPtr be(
new Byte(v[b], la));
914 ExprPtr marr(
new MkArray(cs, la));
929 for (
size_t c = 0; c < v.size(); ++c) {
930 ExprPtr ce(
new Char(v[c], la));
935 ExprPtr marr(
new MkArray(cs, la));
945 if (bs.size() == 0) {
953 if (
const Assump* ae = is<Assump>(e)) {
954 if (*ae->ty() == *t) {
961 ExprPtr
r(
new Assump(e, t, la));
978 return assume(r, r->type(), la);
997 ExprPtr
r(
new Assign(lhs, rhs, la));
998 if (lhs->type() && rhs->type()) {
1006 for (MkRecord::FieldDefs::const_iterator
m = ms.begin();
m != ms.end(); ++
m) {
1007 r.push_back(
m->second);
1014 for (Case::Bindings::const_iterator b = bs.begin(); b != bs.end(); ++b) {
1015 r.push_back(b->exp);
1024 ExprPtr
substitute(
const VarMapping& vm,
const ExprPtr& e,
bool* mapped = 0);
1031 template <
typename T>
1033 virtual T with(
const Unit* v)
const = 0;
1034 virtual T with(
const Bool* v)
const = 0;
1035 virtual T with(
const Char* v)
const = 0;
1036 virtual T with(
const Byte* v)
const = 0;
1037 virtual T with(
const Short* v)
const = 0;
1038 virtual T with(
const Int* v)
const = 0;
1039 virtual T with(
const Long* v)
const = 0;
1040 virtual T with(
const Float* v)
const = 0;
1041 virtual T with(
const Double* v)
const = 0;
1044 template <
typename T>
1046 switch (p->case_id()) {
1047 case Unit::type_case_id:
1049 case Bool::type_case_id:
1051 case Char::type_case_id:
1053 case Byte::type_case_id:
1055 case Short::type_case_id:
1057 case Int::type_case_id:
1058 return f.
with((
Int*)(p.get()));
1059 case Long::type_case_id:
1061 case Float::type_case_id:
1063 case Double::type_case_id:
1066 throw annotated_error(*p,
"Internal error, cannot switch on unknown constant: " +
show(p));
1072 template <
typename T>
1074 virtual T with(
const Unit* v)
const = 0;
1075 virtual T with(
const Bool* v)
const = 0;
1076 virtual T with(
const Char* v)
const = 0;
1077 virtual T with(
const Byte* v)
const = 0;
1078 virtual T with(
const Short* v)
const = 0;
1079 virtual T with(
const Int* v)
const = 0;
1080 virtual T with(
const Long* v)
const = 0;
1081 virtual T with(
const Float* v)
const = 0;
1082 virtual T with(
const Double* v)
const = 0;
1083 virtual T with(
const Var* v)
const = 0;
1084 virtual T with(
const Let* v)
const = 0;
1085 virtual T with(
const LetRec* v)
const = 0;
1086 virtual T with(
const Fn* v)
const = 0;
1087 virtual T with(
const App* v)
const = 0;
1088 virtual T with(
const Assign* v)
const = 0;
1089 virtual T with(
const MkArray* v)
const = 0;
1090 virtual T with(
const MkVariant* v)
const = 0;
1091 virtual T with(
const MkRecord* v)
const = 0;
1092 virtual T with(
const AIndex* v)
const = 0;
1093 virtual T with(
const Case* v)
const = 0;
1094 virtual T with(
const Switch* v)
const = 0;
1095 virtual T with(
const Proj* v)
const = 0;
1096 virtual T with(
const Assump* v)
const = 0;
1097 virtual T with(
const Pack* v)
const = 0;
1098 virtual T with(
const Unpack* v)
const = 0;
1101 template <
typename T>
1103 virtual T withConst(
const Expr* v)
const = 0;
1104 virtual T with (
const Var* v)
const = 0;
1105 virtual T with (
const Let* v)
const = 0;
1106 virtual T with (
const LetRec* v)
const = 0;
1107 virtual T with (
const Fn* v)
const = 0;
1108 virtual T with (
const App* v)
const = 0;
1109 virtual T with (
const Assign* v)
const = 0;
1110 virtual T with (
const MkArray* v)
const = 0;
1111 virtual T with (
const MkVariant* v)
const = 0;
1112 virtual T with (
const MkRecord* v)
const = 0;
1113 virtual T with (
const AIndex* v)
const = 0;
1114 virtual T with (
const Case* v)
const = 0;
1115 virtual T with (
const Switch* v)
const = 0;
1116 virtual T with (
const Proj* v)
const = 0;
1117 virtual T with (
const Assump* v)
const = 0;
1118 virtual T with (
const Pack* v)
const = 0;
1119 virtual T with (
const Unpack* v)
const = 0;
1127 T
with(
const Int* v)
const {
return withConst(v); }
1135 template <
typename T>
1137 virtual T with(
Unit* v) = 0;
1138 virtual T with(
Bool* v) = 0;
1139 virtual T with(
Char* v) = 0;
1140 virtual T with(
Byte* v) = 0;
1141 virtual T with(
Short* v) = 0;
1142 virtual T with(
Int* v) = 0;
1143 virtual T with(
Long* v) = 0;
1144 virtual T with(
Float* v) = 0;
1145 virtual T with(
Double* v) = 0;
1146 virtual T with(
Var* v) = 0;
1147 virtual T with(
Let* v) = 0;
1148 virtual T with(
LetRec* v) = 0;
1149 virtual T with(
Fn* v) = 0;
1150 virtual T with(
App* v) = 0;
1151 virtual T with(
Assign* v) = 0;
1152 virtual T with(
MkArray* v) = 0;
1155 virtual T with(
AIndex* v) = 0;
1156 virtual T with(
Case* v) = 0;
1157 virtual T with(
Switch* v) = 0;
1158 virtual T with(
Proj* v) = 0;
1159 virtual T with(
Assump* v) = 0;
1160 virtual T with(
Pack* v) = 0;
1161 virtual T with(
Unpack* v) = 0;
1165 template <
typename T,
typename F>
1168 case Unit::type_case_id:
1169 return f.with((
Unit*)&e);
1170 case Bool::type_case_id:
1171 return f.with((
Bool*)&e);
1172 case Char::type_case_id:
1173 return f.with((
Char*)&e);
1174 case Byte::type_case_id:
1175 return f.with((
Byte*)&e);
1176 case Short::type_case_id:
1177 return f.with((
Short*)&e);
1178 case Int::type_case_id:
1179 return f.with((
Int*)&e);
1180 case Long::type_case_id:
1181 return f.with((
Long*)&e);
1182 case Float::type_case_id:
1183 return f.with((
Float*)&e);
1184 case Double::type_case_id:
1185 return f.with((
Double*)&e);
1186 case Var::type_case_id:
1187 return f.with((
Var*)&e);
1188 case Let::type_case_id:
1189 return f.with((
Let*)&e);
1190 case LetRec::type_case_id:
1191 return f.with((
LetRec*)&e);
1192 case Fn::type_case_id:
1193 return f.with((
Fn*)&e);
1194 case App::type_case_id:
1195 return f.with((
App*)&e);
1196 case Assign::type_case_id:
1197 return f.with((
Assign*)&e);
1198 case MkArray::type_case_id:
1200 case MkVariant::type_case_id:
1202 case MkRecord::type_case_id:
1204 case AIndex::type_case_id:
1205 return f.with((
AIndex*)&e);
1206 case Case::type_case_id:
1207 return f.with((
Case*)&e);
1208 case Switch::type_case_id:
1209 return f.with((
Switch*)&e);
1210 case Proj::type_case_id:
1211 return f.with((
Proj*)&e);
1212 case Assump::type_case_id:
1213 return f.with((
Assump*)&e);
1214 case Pack::type_case_id:
1215 return f.with((
Pack*)&e);
1216 case Unpack::type_case_id:
1217 return f.with((
Unpack*)&e);
1219 throw annotated_error(e,
"Internal error, cannot switch on unknown expression: " +
show(e));
1223 template <
typename T>
1225 return switchOfF< T, const switchExpr<T>& >(e, f);
1228 template <
typename T>
1230 return switchOfF< T, const switchExpr<T>& >(*e, f);
1233 template <
typename T>
1235 return switchOfF< T, switchExprM<T>& >(*e,
const_cast<switchExprM<T>&
>(f));
1238 template <
typename T>
1241 for (Exprs::const_iterator e = es.begin(); e != es.end(); ++e) {
1247 template <
typename T>
1250 for (Exprs::const_iterator e = es.begin(); e != es.end(); ++e) {
1256 template <
typename K,
typename T>
1258 typedef std::pair<K, T> KT;
1259 typedef std::vector<KT> KTS;
1261 for (
typename std::vector< std::pair<K, ExprPtr> >::const_iterator ke = kes.begin(); ke != kes.end(); ++ke) {
1262 kts.push_back(KT(ke->first,
switchOf(ke->second, f)));
1267 template <
typename K,
typename T>
1269 typedef std::pair<K, T> KT;
1270 typedef std::vector<KT> KTS;
1272 for (
typename std::vector< std::pair<K, ExprPtr> >::const_iterator ke = kes.begin(); ke != kes.end(); ++ke) {
1289 ExprPtr withConst(
const Expr* v)
const;
1290 ExprPtr with (
const Var* v)
const;
1291 ExprPtr with (
const Let* v)
const;
1292 ExprPtr with (
const LetRec* v)
const;
1293 ExprPtr with (
const Fn* v)
const;
1294 ExprPtr with (
const App* v)
const;
1295 ExprPtr with (
const Assign* v)
const;
1296 ExprPtr with (
const MkArray* v)
const;
1297 ExprPtr with (
const MkVariant* v)
const;
1298 ExprPtr with (
const MkRecord* v)
const;
1299 ExprPtr with (
const AIndex* v)
const;
1300 ExprPtr with (
const Case* v)
const;
1301 ExprPtr with (
const Switch* v)
const;
1302 ExprPtr with (
const Proj* v)
const;
1303 ExprPtr with (
const Assump* v)
const;
1304 ExprPtr with (
const Pack* v)
const;
1305 ExprPtr with (
const Unpack* v)
const;
1392 void encode(
const PrimitivePtr&, std::ostream&);
1393 void decode(PrimitivePtr*, std::istream&);
1395 void encode(
const ExprPtr&, std::ostream&);
1396 void decode(ExprPtr*, std::istream&);
1398 void encode(
const ExprPtr&, std::vector<uint8_t>*);
1399 void decode(
const std::vector<uint8_t>&, ExprPtr*);
ExprPtr mkrecord(const MkRecord::FieldDefs &fds, const LexicalAnnotation &la)
Definition: expr.H:754
T with(const Unit *v) const
Definition: expr.H:1122
PrimitivePtr value
Definition: expr.H:552
ExprPtr v
Definition: expr.H:540
int case_id() const
Definition: expr.C:41
std::string varname
Definition: expr.H:1370
virtual bool operator==(const Expr &) const =0
ExprPtr closcall(const ExprPtr &c, const Exprs &args, const LexicalAnnotation &la)
Definition: expr.H:857
ExprPtr mktuple(const ExprPtr &e, const LexicalAnnotation &la)
Definition: expr.H:777
ExprPtr e
Definition: expr.H:620
std::string vn
Definition: expr.H:662
std::string vname
Definition: expr.H:514
QualTypePtr annotatedType
Definition: expr.H:28
MonoTypePtr arrayty(const MonoTypePtr &ty, size_t n)
Definition: type.H:1155
ExprPtr switchE(const ExprPtr &e, const Switch::Bindings &bs, const ExprPtr &def, const LexicalAnnotation &la)
Definition: expr.H:944
static void addBinding(imagefile *f, const std::string &vname, const MonoTypePtr &type, size_t offset)
Definition: file.C:497
ExprPtr fncall(const ExprPtr &f, const ExprPtr &a, const LexicalAnnotation &la)
Definition: expr.H:853
std::pair< std::string, ExprPtr > Definition
Definition: expr.H:61
ExprPtr field(MDFA *dfa, const std::string &vn, const std::string &fn)
Definition: dfa.C:183
float x
Definition: expr.H:252
ExprPtr def
Definition: expr.H:542
std::string fn
Definition: expr.H:599
ExprPtr proj(const ExprPtr &rec, const str::seq &fields, const LexicalAnnotation &la)
Definition: expr.H:800
ExprPtr caseOf(const ExprPtr &e, Cases... cs)
Definition: expr.H:822
Definition: terminal.H:71
PrimitiveCase(const LexicalAnnotation &)
Definition: expr.H:274
std::set< TVName > NameSet
Definition: type.H:142
Bindings bs
Definition: expr.H:345
const LexicalAnnotation & la() const
Definition: lannotation.C:98
ExprPtr b
Definition: expr.H:320
ExprPtr e
Definition: expr.H:346
T with(const Byte *v) const
Definition: expr.H:1125
ExprPtr def
Definition: expr.H:577
T with(const Bool *v) const
Definition: expr.H:1123
ExprPtr e
Definition: expr.H:319
ExprPtr varName(MDFA *dfa, const std::string &vn)
Definition: dfa.C:129
PrimitivePtr mkTimePrim(const std::string &, const LexicalAnnotation &)
Definition: expr.C:1457
MonoTypePtr primty(const char *x)
Definition: type.H:1008
ExprPtr fne
Definition: expr.H:391
ExprPtr assume(const ExprPtr &e, const MonoTypePtr &t, const LexicalAnnotation &la)
Definition: expr.H:969
long x
Definition: expr.H:234
Binding()
Definition: expr.H:510
ExprCase< Case > Base
Definition: expr.H:43
void encode(const ExprPtr &, std::vector< uint8_t > *)
Definition: expr.C:1933
ExprPtr exp
Definition: expr.H:553
T * make(const Args &... args)
Definition: hobbes.H:60
Exprs argl
Definition: expr.H:392
ExprPtr etaLift(const std::string &opname, const MonoTypePtr &oty, const LexicalAnnotation &la)
Definition: expr.H:879
ExprPtr liftTypesAsAssumptions(const ExprPtr &e)
Definition: expr.C:1247
std::pair< std::string, ExprPtr > Binding
Definition: expr.H:326
QualTypePtr qualtype(const Constraints &cs, const MonoTypePtr &p)
Definition: type.H:1016
Constraints liftConstraints(const Exprs &es)
Definition: expr.H:826
bool operator==(const PatternRow &, const PatternRow &)
Definition: pattern.C:270
const QualTypePtr & type() const
Definition: expr.C:39
Expr(int cid, const LexicalAnnotation &)
Definition: expr.C:37
NameSet tvarNames(const ExprPtr &)
Definition: expr.C:1383
ExprPtr var(const std::string &vn, const MonoTypePtr &ty, const LexicalAnnotation &la)
Definition: expr.H:720
std::vector< ExprPtr > Exprs
Definition: expr.H:59
PrimitivePtr mkDateTimePrim(const std::string &, const LexicalAnnotation &)
Definition: expr.C:1464
TVName canonicalName(int v)
Definition: type.C:2032
virtual T with(const Unit *v) const =0
bool isConst(const ExprPtr &)
Definition: expr.C:1009
ExprPtr mkFormatExpr(const std::string &fmt, const LexicalAnnotation &)
Definition: expr.C:1442
Exprs es
Definition: expr.H:432
MonoTypes parameters() const
Definition: type.C:1397
ExprPtr desugarComprehension(const ExprPtr &ex, const ComprehensionDefs &cdefs, const LexicalAnnotation &la)
Definition: expr.C:1429
FieldDefs fs
Definition: expr.H:475
ExprPtr e
Definition: expr.H:370
ExprPtr ex
Definition: expr.H:1371
void append(std::vector< T > *xs, const std::vector< T > &ys)
Definition: array.H:292
QualTypePtr t
Definition: expr.H:621
std::string id
Definition: expr.H:295
bool operator==(const Expr &rhs) const
Definition: expr.H:109
virtual Expr * clone() const =0
std::shared_ptr< Primitive > PrimitivePtr
Definition: expr.H:86
int index(const std::vector< T > &xs, T x)
Definition: array.H:63
MonoType::ptr MonoTypePtr
Definition: type.H:71
ExprPtr e
Definition: expr.H:639
MonoTypePtr maybety(const MonoTypePtr &t)
Definition: type.H:1087
ExprPtr assign(const ExprPtr &lhs, const ExprPtr &rhs, const LexicalAnnotation &la)
Definition: expr.H:996
std::map< std::string, ExprPtr > VarMapping
Definition: expr.H:1023
Case::Bindings caseOfBindings(const char *ctor, const char *vname, const ExprPtr &e, Cases... cs)
Definition: expr.H:813
std::vector< Binding > Bindings
Definition: expr.H:555
VarSet freeVars(const Expr &)
Definition: expr.C:1327
std::vector< ComprehensionDef > ComprehensionDefs
Definition: expr.H:1374
ExprPtr mkTimeExpr(const std::string &, const LexicalAnnotation &)
Definition: expr.C:1460
ExprPtr pkg
Definition: expr.H:663
Exprs exprs(const Case::Bindings &bs)
Definition: expr.H:1012
PrimitivePtr mkTimespanPrim(const str::seq &, const LexicalAnnotation &)
Definition: expr.C:1450
str::seq varNames(unsigned int n)
Definition: pattern.C:527
std::string lbl
Definition: expr.H:453
T with(const Int *v) const
Definition: expr.H:1127
double x
Definition: expr.H:270
const ExprPtr & stripAssumpHead(const ExprPtr &)
Definition: expr.C:1261
MonoTypePtr fnresult(const MonoTypePtr &fty)
Definition: type.H:1233
Binding(const std::string &selector, const std::string &vname, const ExprPtr &exp)
Definition: expr.H:511
std::string id
Definition: expr.H:318
std::vector< T > cons(T h, std::vector< T > t)
Definition: array.H:286
ExprPtr substitute(const MonoTypeSubst &s, const ExprPtr &e)
Definition: expr.C:985
PrimitiveCase< Case > Base
Definition: expr.H:96
Bindings bs
Definition: expr.H:541
std::vector< ConstraintPtr > Constraints
Definition: type.H:35
bool operator==(const Expr &rhs) const
Definition: expr.H:47
unsigned char x
Definition: expr.H:180
ExprPtr lhs
Definition: expr.H:413
int tgenSize(const ExprPtr &)
Definition: expr.C:2152
int x
Definition: expr.H:216
Expr * mkarray(const std::string &v, const LexicalAnnotation &la)
Definition: expr.H:923
std::shared_ptr< Expr > ExprPtr
Definition: expr.H:58
ExprPtr nothingE(const MonoTypePtr &jt, const LexicalAnnotation &la)
Definition: expr.H:990
ExprPtr stripExplicitAssumptions(const ExprPtr &)
Definition: expr.C:1257
ExprPtr justE(const ExprPtr &e, const LexicalAnnotation &la)
Definition: expr.H:974
ExprPtr body
Definition: expr.H:664
std::vector< T > list()
Definition: array.H:25
T with(const Long *v) const
Definition: expr.H:1128
Definition: lannotation.H:36
short x
Definition: expr.H:198
size_t r(const reader::MetaData &md, size_t o, T *t)
Definition: storage.H:1730
bool hasSingularType(const ExprPtr &)
Definition: expr.C:2047
Definition: lannotation.H:60
Definition: lannotation.H:22
std::vector< std::string > seq
Definition: str.H:19
MonoTypePtr freshTypeVar()
Definition: type.C:1612
Binding(const PrimitivePtr &value, const ExprPtr &exp)
Definition: expr.H:550
void decode(const std::vector< uint8_t > &, ExprPtr *)
Definition: expr.C:1938
ExprPtr mktunit(const LexicalAnnotation &la)
Definition: expr.H:748
virtual ~Expr()
Definition: expr.C:38
ExprPtr mkTimespanExpr(const str::seq &, const LexicalAnnotation &)
Definition: expr.C:1453
#define out
Definition: netio.H:19
std::vector< FieldDef > FieldDefs
Definition: expr.H:461
std::vector< Definition > Definitions
Definition: expr.H:62
std::set< PrimitivePtr, PrimPtrLT > PrimitiveSet
Definition: expr.H:91
Definition: terminal.H:71
const MonoTypePtr & member(const std::string &mn) const
Definition: type.C:1316
ExprPtr e
Definition: expr.H:454
Definition: variant.H:103
MonoTypePtr clone(const MonoTypePtr &)
Definition: type.C:1530
ExprPtr let(const Exprs &es, const ExprPtr &b, const LexicalAnnotation &la)
Definition: expr.H:740
ExprPtr constant(size_t x, const LexicalAnnotation &la)
Definition: expr.H:696
uint32_t result
Definition: regex.C:376
VarNames vs
Definition: expr.H:369
Bindings bs
Definition: expr.H:576
std::vector< Member > Members
Definition: type.H:435
std::set< std::string > VarSet
Definition: expr.H:1356
MonoTypePtr unpackedType(const Exists *e)
Definition: type.C:2274
ExprPtr i
Definition: expr.H:503
std::pair< std::string, ExprPtr > FieldDef
Definition: expr.H:460
bool isfilter
Definition: expr.H:1369
std::string showAnnotated(const Definition &d)
Definition: expr.C:858
MonoTypePtr sumtype(const MonoTypePtr &t0, const MonoTypePtr &t1)
Definition: type.H:1080
T with(const Short *v) const
Definition: expr.H:1126
std::vector< V > values(const std::map< K, V > &m)
Definition: array.H:218
std::vector< std::string > strings
Definition: data.H:69
T with(const Float *v) const
Definition: expr.H:1129
ExprPtr r
Definition: expr.H:598
char x
Definition: expr.H:162
std::vector< MonoTypePtr > MonoTypes
Definition: type.H:72
T switchOfF(const Expr &e, F f)
Definition: expr.H:1166
ExprPtr v
Definition: expr.H:575
std::shared_ptr< QualType > QualTypePtr
Definition: type.H:28
MonoTypes requireMonotype(const Exprs &)
Definition: expr.C:1239
std::vector< Binding > Bindings
Definition: expr.H:327
T with(const Char *v) const
Definition: expr.H:1124
ExprPtr fn(const std::string &vn, const ExprPtr &b, const LexicalAnnotation &la)
Definition: expr.H:841
LexicalAnnotation m(const YYLTYPE &p)
Definition: hexpr.parse.C:127
std::vector< std::string > VarNames
Definition: expr.H:352
Case::Bindings switchOf(const Case::Bindings &bs, const switchExpr< ExprPtr > &f)
Definition: expr.C:1023
std::map< TVName, MonoTypePtr > MonoTypeSubst
Definition: type.H:143
Binding()
Definition: expr.H:549
ExprPtr rhs
Definition: expr.H:414
ExprPtr arr
Definition: expr.H:502
std::string show(const Definition &d)
Definition: expr.C:27
bool x
Definition: expr.H:145
bool operator<(const Primitive &rhs) const
Definition: expr.H:101
virtual void showAnnotated(std::ostream &) const =0
std::string selector
Definition: expr.H:513
ExprPtr mkDateTimeExpr(const std::string &, const LexicalAnnotation &)
Definition: expr.C:1467
Exprs vars(const std::vector< std::string > &vns, const LexicalAnnotation &la)
Definition: expr.H:706
virtual void show(std::ostream &) const =0
unsigned char UnitV
Definition: array.H:17
int cid
Definition: expr.H:36
TVName freshName()
Definition: type.C:1600
std::vector< Binding > Bindings
Definition: expr.H:517
Constraints mergeConstraints(const Constraints &lhs, const Constraints &rhs)
Definition: type.C:1581
T with(const Double *v) const
Definition: expr.H:1130
ExprPtr exp
Definition: expr.H:515