yast2-core
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
liby2
src
include
y2
Y2Namespace.h
Go to the documentation of this file.
1
/*------------------------------------------------------------*- c++ -*-\
2
| |
3
| __ __ ____ _____ ____ |
4
| \ \ / /_ _/ ___|_ _|___ \ |
5
| \ V / _` \___ \ | | __) | |
6
| | | (_| |___) || | / __/ |
7
| |_|\__,_|____/ |_| |_____| |
8
| |
9
| core system |
10
| (C) SuSE GmbH |
11
\-----------------------------------------------------------------------/
12
13
File: Y2Namespace.h
14
a generic interface for accessing a namespace from YCP interpreter
15
16
Author: Stanislav Visnovsky <visnov@suse.cz>
17
Maintainer: Stanislav Visnovsky <visnov@suse.cz>
18
19
/-*/
20
21
#ifndef Y2Namespace_h
22
#define Y2Namespace_h
23
24
#include <string>
25
using
std::string;
26
27
#include "
ycp/YCPValue.h
"
28
#include "
ycp/Type.h
"
29
30
#include "
SymbolEntry.h
"
31
32
class
SymbolTable
;
33
class
Point
;
34
class
Y2Function
;
35
class
StaticDeclaration
;
36
class
SymbolTable
;
37
class
Debugger
;
38
43
class
Y2Namespace
{
44
protected
:
45
typedef
vector<SymbolEntryPtr>
symbols_t
;
46
47
SymbolTable
*
m_table
;
48
unsigned
int
m_symbolcount
;
49
symbols_t
m_symbols
;
50
51
friend
class
SymbolTable
;
52
friend
class
Debugger
;
53
54
// add symbol to namespace, it now belongs here
55
// returns the index into m_symbols
56
//
57
// this is used for blocks with a local environment but no table
58
unsigned
int
addSymbol
(SymbolEntryPtr sentry);
59
60
// add symbol _and_ enter into table for lookup
61
//
62
// this is used for namespaces with a global environment and a table
63
void
enterSymbol
(SymbolEntryPtr sentry,
Point
*point = 0);
64
65
// lookup symbol by name in m_symbols
66
SymbolEntryPtr
lookupSymbol
(
const
char
*
name
)
const
;
67
68
// find symbol by pointer
69
// return index if found, -1 if not found
70
// int findSymbol (const SymbolEntryPtr sentry) const;
71
72
// release symbol from m_symbols
73
// it's no longer owned by this block but by a ysFunction()
74
void
releaseSymbol
(
unsigned
int
position);
75
// void releaseSymbol (SymbolEntryPtr sentry);
76
77
bool
m_initialized
;
78
79
public
:
80
81
Y2Namespace
();
82
83
virtual
~Y2Namespace
();
84
85
// end of symbols, finish and clean up m_symbols
86
void
finish
();
87
89
virtual
const
string
name
()
const
;
91
virtual
const
string
filename
()
const
= 0;
92
94
// e.g. needed for function declarations which keep their symbolic
95
// parameters in a Y2Namespace
96
virtual
unsigned
int
symbolCount
()
const
;
97
99
// bytecode uses unsigneds
100
virtual
SymbolEntryPtr
symbolEntry
(
unsigned
int
position)
const
;
101
103
virtual
string
toString
()
const
;
104
105
// just m_symbols, for debugging and YBlock::toString
106
string
symbolsToString
()
const
;
107
109
// constructor is handled separately
110
virtual
YCPValue
evaluate
(
bool
cse =
false
) = 0;
111
113
virtual
SymbolTable
*
table
()
const
;
114
115
// this will ensure existence of the table.
116
// after calling this function @ref table will always return a valid pointer
117
void
createTable
();
118
128
virtual
Y2Function
*
createFunctionCall
(
const
string
name
, constFunctionTypePtr type) = 0;
129
130
// push all local variables to stack, uses SymbolEntry::push()
131
void
pushToStack
();
132
133
// pop all local variables from stack, uses SymbolEntry::pop()
134
void
popFromStack
();
135
136
// ensure that the namespace is initialized
137
virtual
void
initialize
();
138
139
};
140
141
142
#endif // Y2Namespace_h
Generated on a sunny day for yast2-core by
1.8.2