34 class WriteStream : 
public SerialisationStream<true> {
 
   39               summary(rwOperation.at(
"IO") == 
"stdoutprintsize") {}
 
   54         for (
const auto& current : 
relation) {
 
   70         fatal(
"attempting to print size of a write operation");
 
   73     template <
typename Tuple>
 
   80         auto&& recordInfo = 
types[
"records"][name];
 
   83         assert(!recordInfo.is_null() && 
"Missing record type information");
 
   91         auto&& recordTypes = recordInfo[
"types"];
 
   92         const size_t recordArity = recordInfo[
"arity"].long_value();
 
   99         for (
size_t i = 0; 
i < recordArity; ++
i) {
 
  104             const std::string& recordType = recordTypes[
i].string_value();
 
  107             switch (recordType[0]) {
 
  108                 case 'i': destination << recordValue; 
break;
 
  109                 case 'f': destination << ramBitCast<RamFloat>(recordValue); 
break;
 
  110                 case 'u': destination << ramBitCast<RamUnsigned>(recordValue); 
break;
 
  111                 case 's': destination << 
symbolTable.unsafeResolve(recordValue); 
break;
 
  112                 case 'r': 
outputRecord(destination, recordValue, recordType); 
break;
 
  113                 case '+': 
outputADT(destination, recordValue, recordType); 
break;
 
  114                 default: 
fatal(
"Unsupported type attribute: `%c`", recordType[0]);
 
  120     void outputADT(std::ostream& destination, 
const RamDomain value, 
const std::string& name) {
 
  121         auto&& adtInfo = 
types[
"ADTs"][name];
 
  123         assert(!adtInfo.is_null() && 
"Missing adt type information");
 
  125         const size_t numBranches = adtInfo[
"arity"].long_value();
 
  126         assert(numBranches > 0);
 
  132         bool isEnum = adtInfo[
"enum"].bool_value();
 
  142             branchId = tuplePtr[0];
 
  143             branchInfo = adtInfo[
"branches"][branchId];
 
  148                 if (branchTypes.size() > 1) {
 
  149                     return recordTable.unpack(tuplePtr[1], branchTypes.size());
 
  155             branchInfo = adtInfo[
"branches"][branchId];
 
  159         destination << 
"$" << branchInfo[
"name"].
string_value();
 
  161         if (branchTypes.size() > 0) {
 
  166         for (
size_t i = 0; 
i < branchTypes.size(); ++
i) {
 
  171             auto argType = branchTypes[
i].string_value();
 
  172             switch (argType[0]) {
 
  173                 case 'i': destination << branchArgs[
i]; 
break;
 
  174                 case 'f': destination << ramBitCast<RamFloat>(branchArgs[
i]); 
break;
 
  175                 case 'u': destination << ramBitCast<RamUnsigned>(branchArgs[
i]); 
break;
 
  176                 case 's': destination << 
symbolTable.unsafeResolve(branchArgs[
i]); 
break;
 
  177                 case 'r': 
outputRecord(destination, branchArgs[
i], argType); 
break;
 
  178                 case '+': 
outputADT(destination, branchArgs[
i], argType); 
break;
 
  179                 default: 
fatal(
"Unsupported type attribute: `%c`", argType[0]);
 
  183         if (branchTypes.size() > 0) {
 
  189 class WriteStreamFactory {
 
  191     virtual Own<WriteStream> 
getWriter(
const std::map<std::string, std::string>& rwOperation,
 
  192             const SymbolTable& symbolTable, 
const RecordTable& recordTable) = 0;
 
  194     virtual const std::string& 
getName() 
const = 0;