toMap method
Convert this expression to a Map, requires that this expression constructs a datatype.
Implementation
Map<String, Expr> toMap() {
final app = this;
if (app is App) {
final sort = getSort(this);
if (sort is DatatypeSort) {
final info = getDatatypeInfo(sort);
for (var i = 0; i < info.constructors.length; i++) {
final constructor = info.constructors[i];
if (currentContext.funcDeclsEqual(
app.decl,
constructor.constructor,
)) {
final result = <String, Expr>{};
for (var j = 0; j < constructor.accessors.length; j++) {
final accessor = constructor.accessors[j];
result[(accessor.name as StringSym).value] = app.args[j];
}
return result;
}
}
}
}
throw ArgumentError('cant be converted to Map: $this');
}