@@ -41,20 +41,15 @@ void irep_serializationt::write_irep(
41
41
out.put (0 ); // terminator
42
42
}
43
43
44
- void irep_serializationt::reference_convert (
45
- std::istream &in,
46
- irept &irep)
44
+ const irept &irep_serializationt::reference_convert (std::istream &in)
47
45
{
48
46
std::size_t id=read_gb_word (in);
49
47
50
- if (id<ireps_container.ireps_on_read .size () &&
51
- ireps_container.ireps_on_read [id].first )
52
- {
53
- irep=ireps_container.ireps_on_read [id].second ;
54
- }
55
- else
48
+ if (
49
+ id >= ireps_container.ireps_on_read .size () ||
50
+ !ireps_container.ireps_on_read [id].first )
56
51
{
57
- read_irep (in, irep );
52
+ irept irep = read_irep (in);
58
53
59
54
if (id >= ireps_container.ireps_on_read .size ())
60
55
ireps_container.ireps_on_read .resize (1 + id * 2 , {false , get_nil_irep ()});
@@ -63,42 +58,57 @@ void irep_serializationt::reference_convert(
63
58
if (ireps_container.ireps_on_read [id].first )
64
59
throw deserialization_exceptiont (" irep id read twice." );
65
60
66
- ireps_container.ireps_on_read [id] = {true , irep};
61
+ ireps_container.ireps_on_read [id] = {true , std::move ( irep) };
67
62
}
63
+
64
+ return ireps_container.ireps_on_read [id].second ;
68
65
}
69
66
70
- void irep_serializationt::read_irep (
71
- std::istream &in,
72
- irept &irep)
67
+ irept irep_serializationt::read_irep (std::istream &in)
73
68
{
74
- irep.clear ();
75
- irep.id (read_string_ref (in));
69
+ irep_idt id = read_string_ref (in);
70
+ irept::subt sub;
71
+ irept::named_subt named_sub;
76
72
77
73
while (in.peek ()==' S' )
78
74
{
79
75
in.get ();
80
- irep.get_sub ().push_back (irept ());
81
- reference_convert (in, irep.get_sub ().back ());
76
+ sub.push_back (reference_convert (in));
82
77
}
83
78
79
+ #ifdef NAMED_SUB_IS_FORWARD_LIST
80
+ irept::named_subt::iterator before = named_sub.before_begin ();
81
+ #endif
84
82
while (in.peek ()==' N' )
85
83
{
86
84
in.get ();
87
- irept &r=irep.add (read_string_ref (in));
88
- reference_convert (in, r);
85
+ irep_idt id = read_string_ref (in);
86
+ #ifdef NAMED_SUB_IS_FORWARD_LIST
87
+ named_sub.emplace_after (before, id, reference_convert (in));
88
+ ++before;
89
+ #else
90
+ named_sub.emplace (id, reference_convert (in));
91
+ #endif
89
92
}
90
93
91
94
while (in.peek ()==' C' )
92
95
{
93
96
in.get ();
94
- irept &r=irep.add (read_string_ref (in));
95
- reference_convert (in, r);
97
+ irep_idt id = read_string_ref (in);
98
+ #ifdef NAMED_SUB_IS_FORWARD_LIST
99
+ named_sub.emplace_after (before, id, reference_convert (in));
100
+ ++before;
101
+ #else
102
+ named_sub.emplace (id, reference_convert (in));
103
+ #endif
96
104
}
97
105
98
106
if (in.get ()!=0 )
99
107
{
100
108
throw deserialization_exceptiont (" irep not terminated" );
101
109
}
110
+
111
+ return irept (std::move (id), std::move (named_sub), std::move (sub));
102
112
}
103
113
104
114
// / Serialize an irept
0 commit comments