Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Examples

YStatement.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------*- c++ -*---\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:        YStatement.h
00014 
00015    Author:      Klaus Kaempf <kkaempf@suse.de>
00016    Maintainer:  Klaus Kaempf <kkaempf@suse.de>
00017 
00018 /-*/
00019 // -*- c++ -*-
00020 
00021 #ifndef YStatement_h
00022 #define YStatement_h
00023 
00024 #include <string>
00025 using std::string;
00026 
00027 #include "ycp/YCode.h"
00028 #include "ycp/SymbolTable.h"
00029 #include "ycp/Import.h"
00030 
00031 class YBlock;           // forward declaration for YDo, YRepeat
00032 
00033 //-------------------------------------------------------------------
00034 
00035 DEFINE_DERIVED_POINTER(YStatement, YCode);
00036 DEFINE_DERIVED_POINTER(YSExpression, YCode);
00037 DEFINE_DERIVED_POINTER(YSBlock, YCode);
00038 DEFINE_DERIVED_POINTER(YSReturn, YCode);
00039 DEFINE_DERIVED_POINTER(YSTypedef, YCode);
00040 DEFINE_DERIVED_POINTER(YSFunction, YCode);
00041 DEFINE_DERIVED_POINTER(YSAssign, YCode);
00042 DEFINE_DERIVED_POINTER(YSBracket, YCode);
00043 DEFINE_DERIVED_POINTER(YSIf, YCode);
00044 DEFINE_DERIVED_POINTER(YSWhile, YCode);
00045 DEFINE_DERIVED_POINTER(YSRepeat, YCode);
00046 DEFINE_DERIVED_POINTER(YSDo, YCode);
00047 DEFINE_DERIVED_POINTER(YSTextdomain, YCode);
00048 DEFINE_DERIVED_POINTER(YSInclude, YCode);
00049 DEFINE_DERIVED_POINTER(YSImport, YCode);
00050 DEFINE_DERIVED_POINTER(YSFilename, YCode);
00051 
00052 //-------------------------------------------------------------------
00057 class YStatement : public YCode
00058 {
00059     REP_BODY(YStatement);
00060     int m_line;                                 // line number
00061 public:
00062     YStatement (ykind kind, int line = 0);
00063     YStatement (ykind kind, std::istream & str);
00064     ~YStatement () {};
00065     virtual string toString () const;
00066     std::ostream & toStream (std::ostream & str) const;
00067     int line () const { return m_line; };
00068     virtual YCPValue evaluate (bool cse = false);
00069     constTypePtr type () const { return Type::Void; };
00070 };
00071 
00072 
00073 //-------------------------------------------------------------------
00078 class YSExpression : public YStatement
00079 {
00080     REP_BODY(YSExpression);
00081     YCodePtr m_expr;
00082 public:
00083     YSExpression (YCodePtr expr, int line = 0);         // statement
00084     YSExpression (std::istream & str);
00085     ~YSExpression ();
00086     string toString () const;
00087     std::ostream & toStream (std::ostream & str) const;
00088     YCPValue evaluate (bool cse = false);
00089     constTypePtr type () const { return Type::Void; };
00090 };
00091 
00092 
00093 //-------------------------------------------------------------------
00098 class YSBlock : public YStatement
00099 {
00100     REP_BODY(YSBlock);
00101     YBlockPtr m_block;
00102 public:
00103     YSBlock (YBlockPtr block, int line = 0);
00104     YSBlock (std::istream & str);
00105     ~YSBlock ();
00106     string toString () const;
00107     std::ostream & toStream (std::ostream & str) const;
00108     YCPValue evaluate (bool cse = false);
00109     constTypePtr type () const { return Type::Void; };
00110 };
00111 
00112 
00113 //-------------------------------------------------------------------
00118 class YSReturn : public YStatement
00119 {
00120     REP_BODY(YSReturn);
00121     YCodePtr m_value;
00122 public:
00123     YSReturn (YCodePtr value, int line = 0);
00124     YSReturn (std::istream & str);
00125     ~YSReturn ();
00126     void propagate (constTypePtr from, constTypePtr to);
00127     YCodePtr value () const;    // needed in YBlock::justReturn
00128     void clearValue ();         // needed if justReturn triggers
00129     string toString () const;
00130     std::ostream & toStream (std::ostream & str) const;
00131     YCPValue evaluate (bool cse = false);
00132     constTypePtr type () const { return Type::Void; };
00133 };
00134 
00135 
00136 //-------------------------------------------------------------------
00141 class YSTypedef : public YStatement
00142 {
00143     REP_BODY(YSTypedef);
00144     Ustring m_name;             // name
00145     constTypePtr m_type;        // type
00146 public:
00147     YSTypedef (const string &name, constTypePtr type, int line = 0);    // Typedef
00148     YSTypedef (std::istream & str);
00149     ~YSTypedef () {};
00150     string toString() const;
00151     std::ostream & toStream (std::ostream & str) const;
00152     YCPValue evaluate (bool cse = false);
00153     constTypePtr type () const { return Type::Void; };
00154 };
00155 
00156 
00157 //-------------------------------------------------------------------
00162 class YSFunction : public YStatement
00163 {
00164     REP_BODY(YSFunction);
00165     // the functions' symbol, it's code is this YSFunction !
00166     SymbolEntryPtr m_entry;
00167 
00168 public:
00169     YSFunction (SymbolEntryPtr entry, int line = 0);
00170     YSFunction (std::istream & str);
00171     ~YSFunction ();
00172 
00173     // symbol entry of function itself
00174     SymbolEntryPtr entry () const;
00175 
00176     // access to function definition
00177     YFunctionPtr function () const;
00178 
00179     string toString () const;
00180     std::ostream & toStream (std::ostream & str) const;
00181     YCPValue evaluate (bool cse = false);
00182     constTypePtr type () const { return Type::Void; };
00183 };
00184 
00185 
00186 //-------------------------------------------------------------------
00192 class YSAssign : public YStatement
00193 {
00194     REP_BODY(YSAssign);
00195     SymbolEntryPtr m_entry;
00196     YCodePtr m_code;
00197 public:
00198     YSAssign (bool definition, SymbolEntryPtr entry, YCodePtr code, int line = 0);
00199     YSAssign (bool definition, std::istream & str);
00200     ~YSAssign ();
00201     string toString () const;
00202     std::ostream & toStream (std::ostream & str) const;
00203     YCPValue evaluate (bool cse = false);
00204     constTypePtr type () const { return Type::Void; };
00205 };
00206 
00207 
00208 //-------------------------------------------------------------------
00214 class YSBracket : public YStatement
00215 {
00216     REP_BODY(YSBracket);
00217     SymbolEntryPtr m_entry;
00218     YCodePtr m_arg;
00219     YCodePtr m_code;
00220 public:
00221     YSBracket (SymbolEntryPtr entry, YCodePtr arg, YCodePtr code, int line = 0);
00222     YSBracket (std::istream & str);
00223     ~YSBracket ();
00224     string toString () const;
00225     std::ostream & toStream (std::ostream & str) const;
00226     // recursively extract list arg at idx, get value from current at idx
00227     // and replace with value. re-generating the list/map/term during unwind
00228     YCPValue commit (YCPValue current, int idx, YCPList arg, YCPValue value);
00229     YCPValue evaluate (bool cse = false);
00230     constTypePtr type () const { return Type::Void; };
00231 };
00232 
00233 
00234 //-------------------------------------------------------------------
00239 class YSIf : public YStatement
00240 {
00241     REP_BODY(YSIf);
00242     YCodePtr m_condition;               // bool expr
00243     YCodePtr m_true;            // true statement/block
00244     YCodePtr m_false;           // false statement/block
00245 public:
00246     YSIf (YCodePtr a_expr, YCodePtr a_true, YCodePtr a_false, int line = 0);
00247     YSIf (std::istream & str);
00248     ~YSIf ();
00249     string toString () const;
00250     std::ostream & toStream (std::ostream & str) const;
00251     YCPValue evaluate (bool cse = false);
00252     constTypePtr type () const { return Type::Void; };
00253 };
00254 
00255 
00256 //-------------------------------------------------------------------
00261 class YSWhile : public YStatement
00262 {
00263     REP_BODY(YSWhile);
00264     YCodePtr m_condition;               // bool expr
00265     YCodePtr m_loop;            // loop statement
00266 
00267 public:
00268     YSWhile (YCodePtr expr, YCodePtr loop, int line = 0);
00269     YSWhile (std::istream & str);
00270     ~YSWhile ();
00271     string toString () const;
00272     std::ostream & toStream (std::ostream & str) const;
00273     YCPValue evaluate (bool cse = false);
00274     constTypePtr type () const { return Type::Void; };
00275 };
00276 
00277 
00278 //-------------------------------------------------------------------
00283 class YSRepeat : public YStatement
00284 {
00285     REP_BODY(YSRepeat);
00286     YCodePtr m_loop;            // loop statement
00287     YCodePtr m_condition;               // bool expr
00288 
00289 public:
00290     YSRepeat (YCodePtr loop, YCodePtr expr, int line = 0);
00291     YSRepeat (std::istream & str);
00292     ~YSRepeat ();
00293     string toString () const;
00294     std::ostream & toStream (std::ostream & str) const;
00295     YCPValue evaluate (bool cse = false);
00296     constTypePtr type () const { return Type::Void; };
00297 };
00298 
00299 
00300 //-------------------------------------------------------------------
00305 class YSDo : public YStatement
00306 {
00307     REP_BODY(YSDo);
00308     YCodePtr m_loop;            // loop statement
00309     YCodePtr m_condition;               // bool expr
00310 
00311 public:
00312     YSDo (YCodePtr loop, YCodePtr expr, int line = 0);
00313     YSDo (std::istream & str);
00314     ~YSDo ();
00315     string toString () const;
00316     std::ostream & toStream (std::ostream & str) const;
00317     YCPValue evaluate (bool cse = false);
00318     constTypePtr type () const { return Type::Void; };
00319 };
00320 
00321 
00322 //-------------------------------------------------------------------
00327 class YSTextdomain : public YStatement
00328 {
00329     REP_BODY(YSTextdomain);
00330     Ustring m_domain;
00331 public:
00332     YSTextdomain (const string &textdomain, int line = 0);
00333     YSTextdomain (std::istream & str);
00334     ~YSTextdomain ();
00335     string toString () const;
00336     std::ostream & toStream (std::ostream & str) const;
00337     YCPValue evaluate (bool cse = false);
00338     constTypePtr type () const { return Type::Void; };
00339     const char *domain () const { return m_domain->c_str(); };
00340 private:
00341     void bind ();
00342 };
00343 
00344 
00345 //-------------------------------------------------------------------
00350 class YSInclude : public YStatement
00351 {
00352     REP_BODY(YSInclude);
00353     Ustring m_filename;
00354     bool m_skipped;
00355 public:
00356     YSInclude (const string &filename, int line = 0, bool skipped = false);
00357     YSInclude (std::istream & str);
00358     ~YSInclude ();
00359     string toString () const;
00360     std::ostream & toStream (std::ostream & str) const;
00361     YCPValue evaluate (bool cse = false);
00362     constTypePtr type () const { return Type::Void; };
00363     string filename () const { return m_filename; };
00364 };
00365 
00366 
00367 //-------------------------------------------------------------------
00372 class YSImport : public YStatement, public Import
00373 {
00374     REP_BODY(YSImport);
00375 public:
00376     YSImport (const string &name, int line = 0);
00377     YSImport (const string &name, Y2Namespace *name_space);
00378     YSImport (std::istream & str);
00379     ~YSImport ();
00380     string name () const;
00381     string toString () const;
00382     std::ostream & toStream (std::ostream & str) const;
00383     YCPValue evaluate (bool cse = false);
00384     constTypePtr type () const { return Type::Void; };
00385 };
00386 
00387 
00388 //-------------------------------------------------------------------
00393 class YSFilename : public YStatement
00394 {
00395     REP_BODY(YSFilename);
00396     Ustring m_filename;
00397 public:
00398     YSFilename (const string &filename, int line = 0);
00399     YSFilename (std::istream & str);
00400     ~YSFilename ();
00401     string toString () const;
00402     std::ostream & toStream (std::ostream & str) const;
00403     YCPValue evaluate (bool cse = false);
00404     constTypePtr type () const { return Type::Void; };
00405 };
00406 
00407 #endif   // YStatement_h

Generated on Fri Nov 9 18:15:23 2007 for yast2-core by doxygen 1.3.6