@@ -44,34 +44,39 @@ class StructGenerator
44
44
45
45
// generate triples
46
46
auto const & triples = parser.GetParsedTriples ();
47
+ std::unordered_set<std::string> typeArcsCache;
47
48
for (auto const & t : triples)
48
49
{
49
- auto const & src = parser.GetParsedElement (t.m_source );
50
+ auto const & source = parser.GetParsedElement (t.m_source );
50
51
auto const & connector = parser.GetParsedElement (t.m_connector );
51
- auto const & trg = parser.GetParsedElement (t.m_target );
52
+ auto const & target = parser.GetParsedElement (t.m_target );
52
53
53
- auto const & srcAddrResult = ResolveElement (src );
54
- auto const & trgAddrResult = ResolveElement (trg );
54
+ auto const & sourceResult = ResolveElement (source );
55
+ auto const & targetResult = ResolveElement (target );
55
56
56
- if (!connector.GetType ().IsConnector ())
57
- SC_THROW_EXCEPTION (utils::ExceptionInvalidType, " Specified sc-connector in triple has incorrect type." );
57
+ ScType const & connectorType = connector.GetType ();
58
+ std::string const & connectorIdtf = connector.GetIdtf ();
59
+ if (!connectorType.IsConnector ())
60
+ SC_THROW_EXCEPTION (
61
+ utils::ExceptionInvalidType,
62
+ " Specified in triple sc-connector `" << connectorIdtf << " ` has incorrect type `"
63
+ << std::string (connectorType) << " `." );
58
64
59
- ScAddr const arcAddr = m_ctx.GenerateConnector (connector. GetType (), srcAddrResult .first , trgAddrResult .first );
60
- m_idtfCache.insert ({connector. GetIdtf () , arcAddr});
65
+ ScAddr const arcAddr = m_ctx.GenerateConnector (connectorType, sourceResult .first , targetResult .first );
66
+ m_idtfCache.insert ({connectorIdtf , arcAddr});
61
67
62
68
if (m_outputStructure.IsValid ())
63
69
{
64
- AppendToOutputStructure (srcAddrResult .first , arcAddr, trgAddrResult .first );
65
- AppendToOutputStructure (srcAddrResult .second );
66
- AppendToOutputStructure (trgAddrResult .second );
70
+ AppendToOutputStructure (sourceResult .first , arcAddr, sourceResult .first );
71
+ AppendToOutputStructure (sourceResult .second );
72
+ AppendToOutputStructure (targetResult .second );
67
73
}
68
74
}
69
75
70
76
parser.ForEachParsedElement (
71
77
[this ](scs::ParsedElement const & el)
72
78
{
73
- if (m_idtfCache.find (el.GetIdtf ()) == m_idtfCache.end () && !el.GetType ().IsConnector ()
74
- && !scs::TypeResolver::IsKeynodeType (el.GetIdtf ()))
79
+ if (m_idtfCache.find (el.GetIdtf ()) == m_idtfCache.cend () && !el.GetType ().IsConnector ())
75
80
ResolveElement (el);
76
81
});
77
82
}
@@ -167,7 +172,9 @@ class StructGenerator
167
172
resultAddr = m_ctx.GenerateNode (type);
168
173
}
169
174
else
170
- SC_THROW_EXCEPTION (utils::ExceptionInvalidState, " Incorrect element type at this state." );
175
+ SC_THROW_EXCEPTION (
176
+ utils::ExceptionInvalidState,
177
+ " Incorrect element type `" << std::string (type) << " ` for element `" << el.GetIdtf () << " `." );
171
178
172
179
// setup system identifier
173
180
if (el.GetVisibility () == scs::Visibility::System)
@@ -177,9 +184,7 @@ class StructGenerator
177
184
result = {quintuple.addr2 , quintuple.addr3 , quintuple.addr4 , quintuple.addr5 };
178
185
}
179
186
else if (el.GetVisibility () == scs::Visibility::Global)
180
- {
181
187
result = SetSCsGlobalIdtf (el.GetIdtf (), resultAddr);
182
- }
183
188
}
184
189
else
185
190
{
@@ -190,12 +195,15 @@ class StructGenerator
190
195
if (oldType.CanExtendTo (newType))
191
196
m_ctx.SetElementSubtype (resultAddr, newType);
192
197
else if (!newType.CanExtendTo (oldType))
193
- SC_THROW_EXCEPTION (utils::ExceptionInvalidType, " Duplicate element type for " + el.GetIdtf ());
198
+ SC_THROW_EXCEPTION (
199
+ utils::ExceptionInvalidType,
200
+ " Can't extend type `" << std::string (oldType) << " ` to type `" << std::string (newType)
201
+ << " ` for element `" << el.GetIdtf () << " `." );
194
202
}
195
203
}
196
204
197
205
// anyway save in cache
198
- m_idtfCache.insert (std::make_pair ( idtf, resultAddr) );
206
+ m_idtfCache.insert ({ idtf, resultAddr} );
199
207
}
200
208
201
209
return {resultAddr, result};
0 commit comments