From 51b3593cbfb33c1d7b4b588f3841c3c405e3a215 Mon Sep 17 00:00:00 2001 From: Gert van Valkenhoef Date: Mon, 7 Nov 2011 22:42:04 +0000 Subject: [PATCH] Fold toString() --- fold.cc | 13 ++++++++++--- fold.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fold.cc b/fold.cc index 5cdbbb4..b416401 100644 --- a/fold.cc +++ b/fold.cc @@ -53,14 +53,21 @@ void Fold::internalize(Reader &reader) { // rd.ReadXInt(xint); fold.collapsed := xint = 0; reader.readSInt(); // 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_hidden->toString() + std::string(" }"); +} + } // namespace odc diff --git a/fold.h b/fold.h index ad56642..78eaa4e 100644 --- a/fold.h +++ b/fold.h @@ -25,12 +25,17 @@ namespace odc { static const std::string TYPENAME; static const TypeProxy PROXY; + Store *d_hidden; + SHORTCHAR *d_label; + public: Fold(INTEGER id); static const std::string &getType(); static const std::string *getSuper(); virtual const std::string &getTypeName() const; virtual void internalize(Reader &reader); + + virtual std::string toString(); }; } -- 2.29.2