X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=fold.cc;h=37e0fd667756bff233d05d0a9f911d6257b373b8;hb=c71568094a35bbda781ac2070e50a59a3b5ac9f7;hp=5cdbbb46ec12e89c40c4d1be530c937f5505e7e8;hpb=519462238ad20b1aca242075e3fe8c0d0719b3d4;p=odcread.git diff --git a/fold.cc b/fold.cc index 5cdbbb4..37e0fd6 100644 --- a/fold.cc +++ b/fold.cc @@ -51,16 +51,33 @@ void Fold::internalize(Reader &reader) { // rd.ReadXInt(xint);fold.leftSide := xint = 0; reader.readSInt(); // rd.ReadXInt(xint); fold.collapsed := xint = 0; - reader.readSInt(); + SHORTINT c = reader.readSInt(); + d_collapsed = (c == 0); // rd.ReadXString(fold.label); - SHORTCHAR label[32]; - reader.readSString(label); // the label + d_label = new SHORTCHAR[32]; + reader.readSString(d_label); // the label // rd.ReadStore(store); - reader.readStore(); // the hidden part + d_hidden = reader.readStore(); // the hidden part // IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold) // ELSE fold.hidden := NIL // END; // fold.leftSide := store # NIL } +std::string Fold::toString() { + if (d_hidden == 0) { + return std::string("Fold(right)"); + } + return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string(" }"); +} + +void Fold::accept(Visitor &visitor) const { + if (d_hidden == 0) { // right part + visitor.foldRight(); + } else { // left part + visitor.foldLeft(d_collapsed); + d_hidden->accept(visitor); + } +} + } // namespace odc