yast2-core
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
liby2
src
include
y2
SymbolEntry.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: Klaus Kaempf <kkaempf@suse.de>
17
Stanislav Visnovsky <visnov@suse.cz>
18
Maintainer: Klaus Kaempf <kkaempf@suse.de>
19
20
/-*/
21
// -*- c++ -*-
22
23
#ifndef SymbolEntry_h
24
#define SymbolEntry_h
25
26
#include <
y2util/Ustring.h
>
27
#include <
y2util/RepDef.h
>
28
29
#include "
ycp/YCPValue.h
"
30
#include "
ycp/Type.h
"
31
32
#include <stack>
33
34
class
Y2Namespace
;
35
36
DEFINE_BASE_POINTER
(
SymbolEntry
);
37
41
class
SymbolEntry
:
public
Rep
42
#ifdef D_MEMUSAGE
43
,
public
MemUsage
44
#endif
45
{
46
REP_BODY
(
SymbolEntry
);
47
48
public
:
49
// hash for unique strings
50
static
UstringHash
*
_nameHash
;
51
static
Ustring
emptyUstring
;
52
53
public
:
54
typedef
enum
{
55
c_unspec
= 0,
// 0 unspecified local symbol (sets m_global = false)
56
c_global
,
// 1 unspecified global symbol (translates to c_unspec, sets m_global = true)
57
c_module
,
// 2 a module identifier
58
c_variable
,
// 3 a variable
59
c_reference
,
// 4 a reference to a variable
60
c_function
,
// 5 a defined function
61
c_builtin
,
// 6 a builtin function
62
c_typedef
,
// 7 a type
63
c_const
,
// 8 a constant (a read-only c_variable)
64
c_namespace
,
// 9 a namespace identifier
65
c_self
,
// 10 the current namespace (namespace prefix used in namespace definition)
66
c_predefined
,
// 11 a predefined namespace identifier
67
c_filename
// 12 a filename (used in conjunction with TableEntry to store definition locations)
68
}
category_t
;
69
70
protected
:
71
/*
72
* if it's global
73
*/
74
bool
m_global
;
75
76
/*
77
* the namespace this entry belongs to
78
*/
79
const
Y2Namespace
*
m_namespace
;
80
81
/*
82
* position in the namespace
83
*/
84
unsigned
int
m_position
;
85
86
/*
87
* the name of the entry
88
*/
89
Ustring
m_name
;
90
91
/*
92
* the category of the entry
93
*/
94
category_t
m_category
;
95
96
/*
97
* the type (string) of the entry
98
*/
99
constTypePtr
m_type
;
100
101
/* the current (actual) value of the entry c_const */
102
YCPValue
m_value
;
103
104
typedef
std::stack<YCPValue>
valuestack_t
;
105
valuestack_t
*
m_recurse_stack
;
106
107
public
:
108
// create symbol beloging to namespace (at position)
109
SymbolEntry
(
const
Y2Namespace
* name_space,
unsigned
int
position
,
const
char
*
name
,
category_t
cat, constTypePtr
type
);
110
111
virtual
~SymbolEntry
();
112
113
// symbols' link to the defining namespace
114
const
Y2Namespace
*
nameSpace
()
const
;
115
void
setNamespace
(
const
Y2Namespace
*name_space);
116
117
// payload access
118
119
// returns true for a declared symbol which isn't defined yet.
120
virtual
bool
onlyDeclared
()
const
{
return
false
; }
121
122
// this is the position of the entry in the namespace (>= 0)
123
// or in the xref table (< 0), see YSImport()
124
unsigned
int
position
()
const
;
125
void
setPosition
(
unsigned
int
position
);
126
127
bool
isGlobal
()
const
;
128
void
setGlobal
(
bool
global);
129
130
bool
isModule
()
const
{
return
m_category
==
c_module
; }
131
bool
isVariable
()
const
{
return
m_category
==
c_variable
; }
132
bool
isReference
()
const
{
return
m_category
==
c_reference
; }
133
bool
isFunction
()
const
{
return
m_category
==
c_function
; }
134
bool
isBuiltin
()
const
{
return
m_category
==
c_builtin
; }
135
bool
isNamespace
()
const
{
return
m_category
==
c_namespace
; }
136
bool
isSelf
()
const
{
return
m_category
==
c_self
; }
137
bool
isFilename
()
const
{
return
m_category
==
c_filename
; }
138
bool
isPredefined
()
const
{
return
m_category
==
c_predefined
; }
139
140
bool
likeNamespace
()
const
{
return
isModule
() ||
isNamespace
() ||
isSelf
(); }
141
142
const
char
*
name
()
const
;
143
category_t
category
()
const
;
144
void
setCategory
(
category_t
cat);
145
constTypePtr
type
()
const
;
146
string
catString
()
const
;
147
void
setType
(constTypePtr
type
);
148
YCPValue
setValue
(
YCPValue
value
);
149
YCPValue
value
()
const
;
150
151
void
push
();
152
void
pop
();
153
154
virtual
string
toString
(
bool
with_type =
true
)
const
;
155
};
156
157
#endif // SymbolEntry_h
Generated on a sunny day for yast2-core by
1.8.2