yast2-core
YSymbolEntry.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------\
2 | |
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
8 | |
9 | core system |
10 | (C) SuSE GmbH |
11 \-----------------------------------------------------------------------/
12 
13  File: SymbolEntry.h
14  symbol entry class
15 
16  Author: Stanislav Visnovsky <visnov@suse.cz>
17  Maintainer: Stanislav Visnovsky <visnov@suse.cz>
18 
19 /-*/
20 // -*- c++ -*-
21 
22 #ifndef YSymbolEntry_h
23 #define YSymbolEntry_h
24 
25 #include <y2util/Ustring.h>
26 #include <y2util/RepDef.h>
27 
28 #include <y2/SymbolEntry.h>
29 
30 #include "ycp/YCPValue.h"
31 #include "ycp/Type.h"
32 #include "ycp/StaticDeclaration.h"
33 #include "ycp/YCode.h"
34 
35 #include <stack>
36 
37 class Y2Namespace;
38 
40 
41 class YSymbolEntry : public SymbolEntry {
43 
56  union payload {
60  } m_payload;
61 
62  /*
63  * Valid for
64  * c_variable: YCode* (any value)
65  * c_reference: YCode* (YEReference*)
66  * c_function: YCode* (YFunction* to be precise)
67  */
68  YCodePtr m_code;
69 
70 public:
71  // create symbol beloging to namespace (at position) - overloaded
72  YSymbolEntry (const Y2Namespace* name_space, unsigned int position, const char *name, category_t cat, constTypePtr type, YCodePtr payload = 0);
73 
74  // create builtin symbol (category == c_builtin), name_space != 0 for symbols inside namespace
75  YSymbolEntry (const char *name, constTypePtr type, declaration_t *payload, const Y2Namespace *name_space = 0);
76 
77  // create namespace symbol (category == c_namespace)
78  YSymbolEntry (const char *name, constTypePtr type, SymbolTable *payload);
79 
80  // create declaration point symbol (category == c_filename)
81  YSymbolEntry (const char *filename);
82 
83  YSymbolEntry (bytecodeistream & str, const Y2Namespace *name_space = 0);
84 
85  // payload access for variables and functions
86  void setCode (YCodePtr code);
87  YCodePtr code () const;
88 
89  // returns true for a declared symbol which isn't defined yet.
90  virtual bool onlyDeclared () const;
91 
92  // payload access for builtins
93  void setDeclaration (declaration_t *decl);
94  declaration_t *declaration () const;
95 
96  // payload access for namespace symbols
97  void setTable (SymbolTable *table);
98  SymbolTable *table() const;
99 
100  // symbols' link to the defining namespace
101  Y2Namespace *payloadNamespace () const;
102  void setPayloadNamespace (Y2Namespace *name_space);
103 
104  virtual string toString (bool with_type = true) const;
105  std::ostream & toStream (std::ostream & str) const;
106  std::ostream & toXml (std::ostream & str, int indent ) const;
107 };
108 
109 #endif // YSymbolEntry_h
void setTable(SymbolTable *table)
Definition: YSymbolEntry.cc:328
std::ostream & toStream(std::ostream &str) const
Definition: YSymbolEntry.cc:236
Definition: SymbolEntry.h:41
DEFINE_DERIVED_POINTER(YSymbolEntry, SymbolEntry)
constTypePtr type() const
Definition: SymbolEntry.cc:192
#define str
Definition: scanner.cc:1003
unsigned int position() const
Definition: SymbolEntry.cc:90
Y2Namespace * payloadNamespace() const
Definition: YSymbolEntry.cc:306
declaration_t * declaration() const
Definition: YSymbolEntry.cc:295
Definition: SymbolTable.h:100
virtual bool onlyDeclared() const
Definition: YSymbolEntry.cc:151
YSymbolEntry(const Y2Namespace *name_space, unsigned int position, const char *name, category_t cat, constTypePtr type, YCodePtr payload=0)
Definition: YSymbolEntry.cc:40
category_t
Definition: SymbolEntry.h:54
void setDeclaration(declaration_t *decl)
Definition: YSymbolEntry.cc:283
SymbolTable * m_table
Definition: YSymbolEntry.h:59
declaration_t * m_decl
Definition: YSymbolEntry.h:58
void setCode(YCodePtr code)
Definition: YSymbolEntry.cc:128
SymbolTable * table() const
Definition: YSymbolEntry.cc:342
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YSymbolEntry.cc:266
void setPayloadNamespace(Y2Namespace *name_space)
Definition: YSymbolEntry.cc:317
Definition: StaticDeclaration.h:71
union YSymbolEntry::payload m_payload
YCodePtr code() const
Definition: YSymbolEntry.cc:140
Definition: YSymbolEntry.h:41
Y2Namespace * m_namespace
Definition: YSymbolEntry.h:57
REP_BODY(YSymbolEntry)
Definition: YSymbolEntry.h:56
Definition: Y2Namespace.h:43
const char * name() const
Definition: SymbolEntry.cc:170
An istream that remembers some data about the bytecode.
Definition: Bytecode.h:42
YCodePtr m_code
Definition: YSymbolEntry.h:68
virtual string toString(bool with_type=true) const
Definition: YSymbolEntry.cc:159

Generated on a sunny day for yast2-core by doxygen 1.8.11