libwreport
2.9
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
wreport
opcode.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
*
17
* Author: Enrico Zini <enrico@enricozini.com>
18
*/
19
20
#ifndef WREPORT_OPCODE_H
21
#define WREPORT_OPCODE_H
22
29
#include <
wreport/varinfo.h
>
30
#include <vector>
31
#include <cstdio>
32
33
namespace
wreport {
34
35
namespace
opcode {
36
struct
Visitor;
37
}
38
39
struct
Vartable;
40
struct
DTable;
41
50
struct
Opcodes
51
{
53
const
std::vector<Varcode>&
vals
;
55
unsigned
begin
;
57
unsigned
end
;
58
60
Opcodes
(
const
std::vector<Varcode>&
vals
) : vals(vals),
begin
(0),
end
(vals.
size
()) {}
62
Opcodes
(
const
std::vector<Varcode>&
vals
,
unsigned
begin
,
unsigned
end
)
63
: vals(vals), begin(begin), end(end) {}
65
Opcodes
(
const
Opcodes
& o) :
vals
(o.
vals
),
begin
(o.
begin
),
end
(o.
end
) {}
66
72
Opcodes
&
operator=
(
const
Opcodes
& o)
73
{
74
begin
= o.
begin
;
75
end
= o.
end
;
76
return
*
this
;
77
}
78
80
Varcode
operator[]
(
unsigned
i)
const
81
{
82
if
(
begin
+ i >
end
)
83
return
0;
84
else
85
return
vals
[
begin
+ i];
86
}
87
89
unsigned
size
()
const
{
return
end
-
begin
; }
90
92
bool
empty
()
const
{
return
begin
==
end
; }
93
95
Varcode
head
()
const
96
{
97
if
(
begin
==
end
)
98
return
0;
99
return
vals
[
begin
];
100
}
101
107
Opcodes
next
()
const
108
{
109
if
(
begin
==
end
)
110
return
*
this
;
111
else
112
return
Opcodes
(
vals
,
begin
+1,
end
);
113
}
114
116
Opcodes
sub
(
unsigned
skip)
const
117
{
118
if
(
begin
+ skip >
end
)
119
return
Opcodes
(
vals
,
end
,
end
);
120
else
121
return
Opcodes
(
vals
,
begin
+ skip,
end
);
122
}
123
125
Opcodes
sub
(
unsigned
skip,
unsigned
len)
const
126
{
127
if
(
begin
+ skip >
end
)
128
return
Opcodes
(
vals
,
end
,
end
);
129
else
if
(
begin
+ skip + len >
end
)
130
return
Opcodes
(
vals
,
begin
+ skip,
end
);
131
else
132
return
Opcodes
(
vals
,
begin
+ skip,
begin
+ skip + len);
133
}
134
140
void
visit
(
opcode::Visitor
& e,
const
DTable
& dtable)
const
;
141
147
void
visit
(
opcode::Visitor
& e)
const
;
148
150
void
print
(FILE* out)
const
;
151
};
152
153
namespace
opcode
154
{
155
167
struct
Visitor
168
{
174
const
DTable
*
dtable
;
175
176
Visitor
();
177
virtual
~
Visitor
();
178
185
virtual
void
b_variable
(
Varcode
code);
186
196
virtual
void
c_modifier
(
Varcode
code);
197
206
virtual
void
c_change_data_width
(
Varcode
code,
int
change);
207
216
virtual
void
c_change_data_scale
(
Varcode
code,
int
change);
217
229
virtual
void
c_associated_field
(
Varcode
code,
Varcode
sig_code,
unsigned
nbits);
230
237
virtual
void
c_char_data
(
Varcode
code);
238
247
virtual
void
c_char_data_override
(
Varcode
code,
unsigned
new_length);
248
255
virtual
void
c_quality_information_bitmap
(
Varcode
code);
256
263
virtual
void
c_substituted_value_bitmap
(
Varcode
code);
264
271
virtual
void
c_substituted_value
(
Varcode
code);
272
283
virtual
void
c_local_descriptor
(
Varcode
code,
Varcode
desc_code,
unsigned
nbits);
284
296
virtual
void
r_replication
(
Varcode
code,
Varcode
delayed_code,
const
Opcodes
& ops);
297
304
virtual
void
d_group_begin
(
Varcode
code);
305
312
virtual
void
d_group_end
(
Varcode
code);
313
322
virtual
void
c_increase_scale_ref_width
(
Varcode
code,
int
change);
323
};
324
329
class
Printer
:
public
Visitor
330
{
331
protected
:
338
void
print_lead
(
Varcode
code);
339
340
public
:
346
FILE*
out
;
347
354
const
Vartable
*
btable
;
355
362
unsigned
indent
;
363
365
unsigned
indent_step
;
366
367
Printer
();
368
virtual
void
b_variable
(
Varcode
code);
369
virtual
void
c_modifier
(
Varcode
code);
370
virtual
void
c_change_data_width
(
Varcode
code,
int
change);
371
virtual
void
c_change_data_scale
(
Varcode
code,
int
change);
372
virtual
void
c_associated_field
(
Varcode
code,
Varcode
sig_code,
unsigned
nbits);
373
virtual
void
c_char_data
(
Varcode
code);
374
virtual
void
c_char_data_override
(
Varcode
code,
unsigned
new_length);
375
virtual
void
c_quality_information_bitmap
(
Varcode
code);
376
virtual
void
c_substituted_value_bitmap
(
Varcode
code);
377
virtual
void
c_substituted_value
(
Varcode
code);
378
virtual
void
c_local_descriptor
(
Varcode
code,
Varcode
desc_code,
unsigned
nbits);
379
virtual
void
r_replication
(
Varcode
code,
Varcode
delayed_code,
const
Opcodes
& ops);
380
virtual
void
d_group_begin
(
Varcode
code);
381
virtual
void
d_group_end
(
Varcode
code);
382
};
383
384
}
385
386
}
387
388
#endif
Generated on Wed Oct 23 2013 08:51:49 for libwreport by
1.8.4