00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: YCPCode.h 00014 00015 Author: Klaus Kaempf <kkaempf@suse.de> 00016 Maintainer: Klaus Kaempf <kkaempf@suse.de> 00017 00018 Wrappers for YCode data as YCPValue 00019 00020 /-*/ 00021 // -*- c++ -*- 00022 00023 #ifndef YCPCode_h 00024 #define YCPCode_h 00025 00026 00027 #include "ycp/YCPValue.h" 00028 #include "ycp/YCode.h" 00029 #include "y2/SymbolEntry.h" 00030 00031 //--------------------------------------------------------------------------- 00032 // YCPCode 00033 00034 class YCPBreak; 00035 class YCPReturn; 00036 00040 class YCPCodeRep : public YCPValueRep 00041 { 00042 YCodePtr m_code; 00043 00044 protected: 00045 friend class YCPCode; 00046 00050 YCPCodeRep(); 00051 YCPCodeRep (YCodePtr c); 00052 00056 ~YCPCodeRep(); 00057 00058 public: 00059 YCodePtr code() const; 00060 00065 YCPOrder compare (const YCPCode &v) const; 00066 00070 string toString() const; 00071 00075 std::ostream & toStream (std::ostream & str) const; 00076 00080 YCPValueType valuetype() const; 00081 00085 YCPValue evaluate (bool cse = false) const; 00086 }; 00087 00088 00095 class YCPCode : public YCPValue 00096 { 00097 DEF_COMMON(Code, Value); 00098 public: 00099 YCPCode() : YCPValue (new YCPCodeRep ()) {} 00100 YCPCode (YCodePtr code) : YCPValue (new YCPCodeRep (code)) {} 00101 YCPCode (bytecodeistream & str); 00102 }; 00103 00104 00105 //--------------------------------------------------------------------------- 00106 // YCPBreak 00107 00108 00117 class YCPBreakRep : public YCPValueRep 00118 { 00119 protected: 00120 friend class YCPBreak; 00121 00125 YCPBreakRep () {}; 00126 00130 ~YCPBreakRep() {} 00131 00132 public: 00137 YCPOrder compare (const YCPBreak &v) const { return YO_EQUAL; } 00138 00143 string toString() const { return "nil"; } 00144 00148 std::ostream & toStream (std::ostream & str) const { return str; }; 00149 00153 YCPValueType valuetype() const { return YT_BREAK; } 00154 00155 }; 00156 00163 class YCPBreak : public YCPValue 00164 { 00165 DEF_COMMON(Break, Value); 00166 public: 00167 YCPBreak() : YCPValue (new YCPBreakRep ()) {} 00168 YCPBreak (bytecodeistream & str) : YCPValue (new YCPBreakRep ()) {} 00169 }; 00170 00171 00172 //--------------------------------------------------------------------------- 00173 // YCPReturn 00174 00185 class YCPReturnRep : public YCPValueRep 00186 { 00187 protected: 00188 friend class YCPReturn; 00189 00193 YCPReturnRep() {} 00194 00198 ~YCPReturnRep() {} 00199 00200 public: 00205 YCPOrder compare (const YCPReturn &v) const { return YO_EQUAL; } 00206 00210 string toString() const { return "nil"; } 00211 00215 std::ostream & toStream (std::ostream & str) const { return str; }; 00216 00220 YCPValueType valuetype() const { return YT_RETURN; } 00221 00222 }; 00223 00230 class YCPReturn : public YCPValue 00231 { 00232 DEF_COMMON(Return, Value); 00233 public: 00234 YCPReturn() : YCPValue (new YCPReturnRep ()) {} 00235 YCPReturn(bytecodeistream & str) : YCPValue (new YCPReturnRep ()) {} 00236 }; 00237 00238 00239 //--------------------------------------------------------------------------- 00240 // YCPEntry 00241 00242 00246 class YCPEntryRep : public YCPValueRep 00247 { 00248 SymbolEntryPtr m_entry; 00249 00250 protected: 00251 friend class YCPEntry; 00252 00256 YCPEntryRep (); 00257 YCPEntryRep (SymbolEntryPtr entry); 00258 00262 ~YCPEntryRep() {} 00263 00264 public: 00265 SymbolEntryPtr entry() const; 00266 00271 YCPOrder compare (const YCPEntry &v) const; 00272 00276 string toString() const; 00277 00281 std::ostream & toStream (std::ostream & str) const; 00282 00286 YCPValueType valuetype() const; 00287 00291 YCPValue evaluate (bool cse = false) const; 00292 }; 00293 00294 00301 class YCPEntry : public YCPValue 00302 { 00303 DEF_COMMON(Entry, Value); 00304 public: 00305 YCPEntry (SymbolEntryPtr entry) : YCPValue (new YCPEntryRep (entry)) {} 00306 YCPEntry (bytecodeistream & str); 00307 }; 00308 00309 00310 //--------------------------------------------------------------------------- 00311 // YCPReference 00312 00313 00317 class YCPReferenceRep : public YCPValueRep 00318 { 00319 SymbolEntryPtr m_entry; 00320 00321 protected: 00322 friend class YCPReference; 00323 00327 YCPReferenceRep (); 00328 YCPReferenceRep (SymbolEntryPtr entry); 00329 00333 ~YCPReferenceRep() {} 00334 00335 public: 00336 SymbolEntryPtr entry() const; 00337 00342 YCPOrder compare (const YCPReference &v) const; 00343 00347 string toString() const; 00348 00352 std::ostream & toStream (std::ostream & str) const; 00353 00357 YCPValueType valuetype() const; 00358 00362 YCPValue evaluate (bool cse = false) const; 00363 }; 00364 00365 00372 class YCPReference : public YCPValue 00373 { 00374 DEF_COMMON(Reference, Value); 00375 public: 00376 YCPReference (SymbolEntryPtr entry) : YCPValue (new YCPReferenceRep (entry)) {} 00377 }; 00378 00379 #endif // YCPCode_h