34
34
#include < liblangutil/CharStream.h>
35
35
#include < liblangutil/Exceptions.h>
36
36
37
- #include < json/json.h>
38
-
39
37
#include < fstream>
40
38
#include < range/v3/algorithm/any_of.hpp>
41
39
@@ -198,9 +196,9 @@ string Assembly::assemblyString(StringMap const& _sourceCodes) const
198
196
return tmp.str ();
199
197
}
200
198
201
- Json::Value Assembly::createJsonValue (string _name, int _source, int _begin, int _end, string _value, string _jumpType)
199
+ Json Assembly::createJsonValue (string _name, int _source, int _begin, int _end, string _value, string _jumpType)
202
200
{
203
- Json::Value value;
201
+ Json value = Json::object () ;
204
202
value[" name" ] = _name;
205
203
value[" source" ] = _source;
206
204
value[" begin" ] = _begin;
@@ -219,11 +217,12 @@ string Assembly::toStringInHex(u256 _value)
219
217
return hexStr.str ();
220
218
}
221
219
222
- Json::Value Assembly::assemblyJSON (map<string, unsigned > const & _sourceIndices) const
220
+ Json Assembly::assemblyJSON (map<string, unsigned > const & _sourceIndices) const
223
221
{
224
- Json::Value root;
222
+ Json root = Json::object ();
223
+ root[" .code" ] = Json::array ();
225
224
226
- Json::Value & collection = root[" .code" ] = Json::arrayValue ;
225
+ Json& collection = root[" .code" ];
227
226
for (AssemblyItem const & i: m_items)
228
227
{
229
228
int sourceIndex = -1 ;
@@ -237,7 +236,7 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
237
236
switch (i.type ())
238
237
{
239
238
case Operation:
240
- collection.append (
239
+ collection.emplace_back (
241
240
createJsonValue (
242
241
instructionInfo (i.instruction ()).name ,
243
242
sourceIndex,
@@ -247,41 +246,41 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
247
246
);
248
247
break ;
249
248
case Push:
250
- collection.append (
249
+ collection.emplace_back (
251
250
createJsonValue (" PUSH" , sourceIndex, i.location ().start , i.location ().end , toStringInHex (i.data ()), i.getJumpTypeAsString ()));
252
251
break ;
253
252
case PushTag:
254
253
if (i.data () == 0 )
255
- collection.append (
254
+ collection.emplace_back (
256
255
createJsonValue (" PUSH [ErrorTag]" , sourceIndex, i.location ().start , i.location ().end , " " ));
257
256
else
258
- collection.append (
257
+ collection.emplace_back (
259
258
createJsonValue (" PUSH [tag]" , sourceIndex, i.location ().start , i.location ().end , toString (i.data ())));
260
259
break ;
261
260
case PushSub:
262
- collection.append (
261
+ collection.emplace_back (
263
262
createJsonValue (" PUSH [$]" , sourceIndex, i.location ().start , i.location ().end , toString (h256 (i.data ()))));
264
263
break ;
265
264
case PushSubSize:
266
- collection.append (
265
+ collection.emplace_back (
267
266
createJsonValue (" PUSH #[$]" , sourceIndex, i.location ().start , i.location ().end , toString (h256 (i.data ()))));
268
267
break ;
269
268
case PushProgramSize:
270
- collection.append (
269
+ collection.emplace_back (
271
270
createJsonValue (" PUSHSIZE" , sourceIndex, i.location ().start , i.location ().end ));
272
271
break ;
273
272
case PushLibraryAddress:
274
- collection.append (
273
+ collection.emplace_back (
275
274
createJsonValue (" PUSHLIB" , sourceIndex, i.location ().start , i.location ().end , m_libraries.at (h256 (i.data ())))
276
275
);
277
276
break ;
278
277
case PushDeployTimeAddress:
279
- collection.append (
278
+ collection.emplace_back (
280
279
createJsonValue (" PUSHDEPLOYADDRESS" , sourceIndex, i.location ().start , i.location ().end )
281
280
);
282
281
break ;
283
282
case PushImmutable:
284
- collection.append (createJsonValue (
283
+ collection.emplace_back (createJsonValue (
285
284
" PUSHIMMUTABLE" ,
286
285
sourceIndex,
287
286
i.location ().start ,
@@ -290,7 +289,7 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
290
289
));
291
290
break ;
292
291
case AssignImmutable:
293
- collection.append (createJsonValue (
292
+ collection.emplace_back (createJsonValue (
294
293
" ASSIGNIMMUTABLE" ,
295
294
sourceIndex,
296
295
i.location ().start ,
@@ -299,16 +298,16 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
299
298
));
300
299
break ;
301
300
case Tag:
302
- collection.append (
301
+ collection.emplace_back (
303
302
createJsonValue (" tag" , sourceIndex, i.location ().start , i.location ().end , toString (i.data ())));
304
- collection.append (
303
+ collection.emplace_back (
305
304
createJsonValue (" JUMPDEST" , sourceIndex, i.location ().start , i.location ().end ));
306
305
break ;
307
306
case PushData:
308
- collection.append (createJsonValue (" PUSH data" , sourceIndex, i.location ().start , i.location ().end , toStringInHex (i.data ())));
307
+ collection.emplace_back (createJsonValue (" PUSH data" , sourceIndex, i.location ().start , i.location ().end , toStringInHex (i.data ())));
309
308
break ;
310
309
case VerbatimBytecode:
311
- collection.append (createJsonValue (" VERBATIM" , sourceIndex, i.location ().start , i.location ().end , toHex (i.verbatimData ())));
310
+ collection.emplace_back (createJsonValue (" VERBATIM" , sourceIndex, i.location ().start , i.location ().end , toHex (i.verbatimData ())));
312
311
break ;
313
312
default :
314
313
assertThrow (false , InvalidOpcode, " " );
@@ -317,7 +316,8 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
317
316
318
317
if (!m_data.empty () || !m_subs.empty ())
319
318
{
320
- Json::Value& data = root[" .data" ] = Json::objectValue;
319
+ root[" .data" ] = Json::object ();
320
+ Json& data = root[" .data" ];
321
321
for (auto const & i: m_data)
322
322
if (u256 (i.first ) >= m_subs.size ())
323
323
data[toStringInHex ((u256)i.first )] = toHex (i.second );
0 commit comments