00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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/YSymbolEntry.h"
00030 #include "ycp/Import.h"
00031
00032 class YBlock;
00033
00034
00035
00036 DEFINE_DERIVED_POINTER(YStatement, YCode);
00037 DEFINE_DERIVED_POINTER(YSExpression, YCode);
00038 DEFINE_DERIVED_POINTER(YSBlock, YCode);
00039 DEFINE_DERIVED_POINTER(YSReturn, YCode);
00040 DEFINE_DERIVED_POINTER(YSTypedef, YCode);
00041 DEFINE_DERIVED_POINTER(YSFunction, YCode);
00042 DEFINE_DERIVED_POINTER(YSAssign, YCode);
00043 DEFINE_DERIVED_POINTER(YSBracket, YCode);
00044 DEFINE_DERIVED_POINTER(YSIf, YCode);
00045 DEFINE_DERIVED_POINTER(YSWhile, YCode);
00046 DEFINE_DERIVED_POINTER(YSRepeat, YCode);
00047 DEFINE_DERIVED_POINTER(YSDo, YCode);
00048 DEFINE_DERIVED_POINTER(YSTextdomain, YCode);
00049 DEFINE_DERIVED_POINTER(YSInclude, YCode);
00050 DEFINE_DERIVED_POINTER(YSImport, YCode);
00051 DEFINE_DERIVED_POINTER(YSFilename, YCode);
00052
00053
00058 class YStatement : public YCode
00059 {
00060 REP_BODY(YStatement);
00061 int m_line;
00062 public:
00063 YStatement (ykind kind, int line = 0);
00064 YStatement (ykind kind, bytecodeistream & str);
00065 ~YStatement () {};
00066 virtual string toString () const;
00067 std::ostream & toStream (std::ostream & str) const;
00068 int line () const { return m_line; };
00069 virtual YCPValue evaluate (bool cse = false);
00070 constTypePtr type () const { return Type::Void; };
00071 };
00072
00073
00074
00079 class YSExpression : public YStatement
00080 {
00081 REP_BODY(YSExpression);
00082 YCodePtr m_expr;
00083 public:
00084 YSExpression (YCodePtr expr, int line = 0);
00085 YSExpression (bytecodeistream & str);
00086 ~YSExpression ();
00087 string toString () const;
00088 std::ostream & toStream (std::ostream & str) const;
00089 YCPValue evaluate (bool cse = false);
00090 constTypePtr type () const { return Type::Void; };
00091 };
00092
00093
00094
00099 class YSBlock : public YStatement
00100 {
00101 REP_BODY(YSBlock);
00102 YBlockPtr m_block;
00103 public:
00104 YSBlock (YBlockPtr block, int line = 0);
00105 YSBlock (bytecodeistream & str);
00106 ~YSBlock ();
00107 string toString () const;
00108 std::ostream & toStream (std::ostream & str) const;
00109 YCPValue evaluate (bool cse = false);
00110 constTypePtr type () const { return Type::Void; };
00111 };
00112
00113
00114
00119 class YSReturn : public YStatement
00120 {
00121 REP_BODY(YSReturn);
00122 YCodePtr m_value;
00123 public:
00124 YSReturn (YCodePtr value, int line = 0);
00125 YSReturn (bytecodeistream & str);
00126 ~YSReturn ();
00127 void propagate (constTypePtr from, constTypePtr to);
00128 YCodePtr value () const;
00129 void clearValue ();
00130 string toString () const;
00131 std::ostream & toStream (std::ostream & str) const;
00132 YCPValue evaluate (bool cse = false);
00133 constTypePtr type () const { return Type::Void; };
00134 };
00135
00136
00137
00142 class YSTypedef : public YStatement
00143 {
00144 REP_BODY(YSTypedef);
00145 Ustring m_name;
00146 constTypePtr m_type;
00147 public:
00148 YSTypedef (const string &name, constTypePtr type, int line = 0);
00149 YSTypedef (bytecodeistream & str);
00150 ~YSTypedef () {};
00151 string toString() const;
00152 std::ostream & toStream (std::ostream & str) const;
00153 YCPValue evaluate (bool cse = false);
00154 constTypePtr type () const { return Type::Void; };
00155 };
00156
00157
00158
00163 class YSFunction : public YStatement
00164 {
00165 REP_BODY(YSFunction);
00166
00167 YSymbolEntryPtr m_entry;
00168
00169 public:
00170 YSFunction (YSymbolEntryPtr entry, int line = 0);
00171 YSFunction (bytecodeistream & str);
00172 ~YSFunction ();
00173
00174
00175 SymbolEntryPtr entry () const;
00176
00177
00178 YFunctionPtr function () const;
00179
00180 string toString () const;
00181 std::ostream & toStream (std::ostream & str) const;
00182 YCPValue evaluate (bool cse = false);
00183 constTypePtr type () const { return Type::Void; };
00184 };
00185
00186
00187
00193 class YSAssign : public YStatement
00194 {
00195 REP_BODY(YSAssign);
00196 SymbolEntryPtr m_entry;
00197 YCodePtr m_code;
00198 public:
00199 YSAssign (bool definition, SymbolEntryPtr entry, YCodePtr code, int line = 0);
00200 YSAssign (bool definition, bytecodeistream & str);
00201 ~YSAssign ();
00202 string toString () const;
00203 std::ostream & toStream (std::ostream & str) const;
00204 YCPValue evaluate (bool cse = false);
00205 constTypePtr type () const { return Type::Void; };
00206 };
00207
00208
00209
00215 class YSBracket : public YStatement
00216 {
00217 REP_BODY(YSBracket);
00218 SymbolEntryPtr m_entry;
00219 YCodePtr m_arg;
00220 YCodePtr m_code;
00221 public:
00222 YSBracket (SymbolEntryPtr entry, YCodePtr arg, YCodePtr code, int line = 0);
00223 YSBracket (bytecodeistream & str);
00224 ~YSBracket ();
00225 string toString () const;
00226 std::ostream & toStream (std::ostream & str) const;
00227
00228
00229 YCPValue commit (YCPValue current, int idx, YCPList arg, YCPValue value);
00230 YCPValue evaluate (bool cse = false);
00231 constTypePtr type () const { return Type::Void; };
00232 };
00233
00234
00235
00240 class YSIf : public YStatement
00241 {
00242 REP_BODY(YSIf);
00243 YCodePtr m_condition;
00244 YCodePtr m_true;
00245 YCodePtr m_false;
00246 public:
00247 YSIf (YCodePtr a_expr, YCodePtr a_true, YCodePtr a_false, int line = 0);
00248 YSIf (bytecodeistream & str);
00249 ~YSIf ();
00250 string toString () const;
00251 std::ostream & toStream (std::ostream & str) const;
00252 YCPValue evaluate (bool cse = false);
00253 constTypePtr type () const { return Type::Void; };
00254 };
00255
00256
00257
00262 class YSWhile : public YStatement
00263 {
00264 REP_BODY(YSWhile);
00265 YCodePtr m_condition;
00266 YCodePtr m_loop;
00267
00268 public:
00269 YSWhile (YCodePtr expr, YCodePtr loop, int line = 0);
00270 YSWhile (bytecodeistream & str);
00271 ~YSWhile ();
00272 string toString () const;
00273 std::ostream & toStream (std::ostream & str) const;
00274 YCPValue evaluate (bool cse = false);
00275 constTypePtr type () const { return Type::Void; };
00276 };
00277
00278
00279
00284 class YSRepeat : public YStatement
00285 {
00286 REP_BODY(YSRepeat);
00287 YCodePtr m_loop;
00288 YCodePtr m_condition;
00289
00290 public:
00291 YSRepeat (YCodePtr loop, YCodePtr expr, int line = 0);
00292 YSRepeat (bytecodeistream & str);
00293 ~YSRepeat ();
00294 string toString () const;
00295 std::ostream & toStream (std::ostream & str) const;
00296 YCPValue evaluate (bool cse = false);
00297 constTypePtr type () const { return Type::Void; };
00298 };
00299
00300
00301
00306 class YSDo : public YStatement
00307 {
00308 REP_BODY(YSDo);
00309 YCodePtr m_loop;
00310 YCodePtr m_condition;
00311
00312 public:
00313 YSDo (YCodePtr loop, YCodePtr expr, int line = 0);
00314 YSDo (bytecodeistream & str);
00315 ~YSDo ();
00316 string toString () const;
00317 std::ostream & toStream (std::ostream & str) const;
00318 YCPValue evaluate (bool cse = false);
00319 constTypePtr type () const { return Type::Void; };
00320 };
00321
00322
00323
00328 class YSTextdomain : public YStatement
00329 {
00330 REP_BODY(YSTextdomain);
00331 Ustring m_domain;
00332 public:
00333 YSTextdomain (const string &textdomain, int line = 0);
00334 YSTextdomain (bytecodeistream & str);
00335 ~YSTextdomain ();
00336 string toString () const;
00337 std::ostream & toStream (std::ostream & str) const;
00338 YCPValue evaluate (bool cse = false);
00339 constTypePtr type () const { return Type::Void; };
00340 const char *domain () const { return m_domain->c_str(); };
00341 private:
00342 void bind ();
00343 };
00344
00345
00346
00351 class YSInclude : public YStatement
00352 {
00353 REP_BODY(YSInclude);
00354 Ustring m_filename;
00355 bool m_skipped;
00356 public:
00357 YSInclude (const string &filename, int line = 0, bool skipped = false);
00358 YSInclude (bytecodeistream & str);
00359 ~YSInclude ();
00360 string toString () const;
00361 std::ostream & toStream (std::ostream & str) const;
00362 YCPValue evaluate (bool cse = false);
00363 constTypePtr type () const { return Type::Void; };
00364 string filename () const { return m_filename; };
00365 };
00366
00367
00368
00373 class YSImport : public YStatement, public Import
00374 {
00375 REP_BODY(YSImport);
00376 public:
00377 YSImport (const string &name, int line = 0);
00378 YSImport (const string &name, Y2Namespace *name_space);
00379 YSImport (bytecodeistream & str);
00380 ~YSImport ();
00381 string name () const;
00382 string toString () const;
00383 std::ostream & toStream (std::ostream & str) const;
00384 YCPValue evaluate (bool cse = false);
00385 constTypePtr type () const { return Type::Void; };
00386 };
00387
00388
00389
00394 class YSFilename : public YStatement
00395 {
00396 REP_BODY(YSFilename);
00397 Ustring m_filename;
00398 public:
00399 YSFilename (const string &filename, int line = 0);
00400 YSFilename (bytecodeistream & str);
00401 ~YSFilename ();
00402 string toString () const;
00403 std::ostream & toStream (std::ostream & str) const;
00404 YCPValue evaluate (bool cse = false);
00405 constTypePtr type () const { return Type::Void; };
00406 };
00407
00408 #endif // YStatement_h