Mailinglist Archive: yast-commit (747 mails)

< Previous Next >
[yast-commit] r39369 - in /trunk/core/libycp/src: YExpression.cc YStatement.cc
  • From: kkaempf@xxxxxxxxxxxxxxxx
  • Date: Thu, 12 Jul 2007 14:26:19 -0000
  • Message-id: <20070712142619.C5C63B245E@xxxxxxxxxxxxxxxx>
Author: kkaempf
Date: Thu Jul 12 16:26:19 2007
New Revision: 39369

URL: http://svn.opensuse.org/viewcvs/yast?rev=39369&view=rev
Log:
first attempt on expressions with symbols, like maplist, foreach, etc.

Modified:
    trunk/core/libycp/src/YExpression.cc
    trunk/core/libycp/src/YStatement.cc

Modified: trunk/core/libycp/src/YExpression.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YExpression.cc?rev=39369&r1=39368&r2=39369&view=diff
==============================================================================
--- trunk/core/libycp/src/YExpression.cc (original)
+++ trunk/core/libycp/src/YExpression.cc Thu Jul 12 16:26:19 2007
@@ -959,8 +959,16 @@
 std::ostream &
 YEMap::toXml( std::ostream & str, int indent ) const
 {
-    str << "<map>";
     mapval_t *mapp = m_first;
+    u_int32_t count = 0;
+    while( mapp )
+    {
+       count++;
+       mapp = mapp->next;
+    }
+    str << "<map size=\"" << count << "\">";
+
+    mapp = m_first;
     while (mapp)
     {
        str << "<element>";
@@ -1183,7 +1191,7 @@
 std::ostream &
 YEPropagate::toXml (std::ostream & str, int indent ) const
 {
-    str << "<yepropagate from=\"" << m_from->toString() << "\" to=\"" << m_to->toString() << "\">";
+    str << "<yepropagate from=\"" << Xmlcode::xmlify( m_from->toString() ) << "\" to=\"" << Xmlcode::xmlify( m_to->toString() ) << "\">";
     m_value->toXml( str, 0 );
     return str << "</yepropagate>";
 }
@@ -1933,18 +1941,49 @@
 std::ostream &
 YEBuiltin::toXml( std::ostream & str, int indent ) const
 {
-    str << "<call builtin=\"1\" name=\"" << m_decl->name << "\">";
+    str << "<builtin name=\"" << m_decl->name << "\"";
+
+    // list: find, filter, maplist, listmap, sort, foreach
+    // map: mapmap, maplist, filter, foreach
 
     if (m_parameterblock != 0)
     {
        Xmlcode::pushNamespace( m_parameterblock->nameSpace() );
     }
+
+    if (m_decl->flags & DECL_SYMBOL)
+    {
+       ycodelist_t *sym1 = NULL;
+       ycodelist_t *sym2 = NULL;
+       ycodelist_t *value = NULL;
+       ycodelist_t *block = NULL;
+
+       // symbols are also in YBlockPtr *m_parameterblock
+       ycodelist_t *p = m_parameters;
+       while (p) {
+           switch (p->code->kind()) {
+               case ycEntry:
+                   if (sym1 != NULL)
+                       sym2 = p;
+                   else
+                       sym1 = p;
+               break;
+               case yeBlock: block = p; break;
+               default: value = p; break;
+           }
+           p = p->next;
+       }
+       if (sym1 == NULL) cerr << "No symbol for " << m_decl->name << endl;
+       if (value == NULL) cerr << "No value for " << m_decl->name << endl;
+       if (block == NULL) cerr << "No block for " << m_decl->name << endl;
+    }
+    str << ">";
     Xmlcode::writeYCodelist( str, m_parameters );
     if (m_parameterblock != 0)
     {
        Xmlcode::popNamespace( m_parameterblock->nameSpace() );
     }
-    return str << "</call>";
+    return str << "</builtin>";
 }
 
 
@@ -2925,7 +2964,11 @@
 std::ostream &
 YECall::toXml (std::ostream & str, int indent ) const
 {
-    str << "<yecall ns=\"" << m_sentry->nameSpace()->name() << "\" name=\"" << m_sentry->name() << "\">";
+    str << "<call";
+    if (!m_sentry->nameSpace()->name().empty()) {
+       str << " ns=\"" << m_sentry->nameSpace()->name() << "\"";
+    }
+    str << " name=\"" << m_sentry->name() << "\">";
     if (m_next_param_id > 0) {
        str << "<args>";
 
@@ -2935,7 +2978,7 @@
        }
        str << "</args>";
     }
-    return str << "</yecall>";
+    return str << "</call>";
 }
 
 

Modified: trunk/core/libycp/src/YStatement.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YStatement.cc?rev=39369&r1=39368&r2=39369&view=diff
==============================================================================
--- trunk/core/libycp/src/YStatement.cc (original)
+++ trunk/core/libycp/src/YStatement.cc Thu Jul 12 16:26:19 2007
@@ -637,12 +637,9 @@
 std::ostream &
 YSAssign::toXml( std::ostream & str, int indent ) const
 {
-    str << "<assign>";
-    str << "<lhs>";
-    str << m_entry->toString (false /*definition*/);
-    str << "</lhs><rhs>";
+    str << "<assign name=\"" << m_entry->toString (false /*definition*/) << "\">";
     m_code->toXml( str, 0 );
-    return str << "</rhs></assign>";
+    return str << "</assign>";
 }
 
 
@@ -1139,7 +1136,7 @@
 YSWhile::toXml (std::ostream & str, int indent ) const
 {
     str << "<while>\n";
-    str << Xmlcode::spaces( indent+2 ) << "<cond>"; str << m_condition->toXml(str, 0 ); str << "</cond>\n";
+    str << Xmlcode::spaces( indent+2 ) << "<cond>"; m_condition->toXml(str, 0 ); str << "</cond>\n";
     if (m_loop) {
        str << Xmlcode::spaces( indent+2 ) << "<do>";
        m_loop->toXml(str, indent );

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages