@@ -329,19 +329,27 @@ bool ASTJsonExporter::visit(UsingForDirective const& _node)
329
329
vector<pair<string, Json::Value>> attributes = {
330
330
make_pair (" typeName" , _node.typeName () ? toJson (*_node.typeName ()) : Json::nullValue)
331
331
};
332
+
332
333
if (_node.usesBraces ())
333
334
{
334
335
Json::Value functionList;
335
- for (auto const & function: _node.functionsOrLibrary ())
336
+ for (auto && [ function, op] : _node.functionsAndOperators ())
336
337
{
337
338
Json::Value functionNode;
338
339
functionNode[" function" ] = toJson (*function);
340
+ if (op.has_value ())
341
+ functionNode[" operator" ] = string (TokenTraits::toString (*op));
339
342
functionList.append (std::move (functionNode));
340
343
}
341
344
attributes.emplace_back (" functionList" , std::move (functionList));
342
345
}
343
346
else
344
- attributes.emplace_back (" libraryName" , toJson (*_node.functionsOrLibrary ().front ()));
347
+ {
348
+ auto const & functionAndOperators = _node.functionsAndOperators ();
349
+ solAssert (_node.functionsAndOperators ().size () == 1 );
350
+ solAssert (!functionAndOperators.front ().second .has_value ());
351
+ attributes.emplace_back (" libraryName" , toJson (*(functionAndOperators.front ().first )));
352
+ }
345
353
attributes.emplace_back (" global" , _node.global ());
346
354
347
355
setJsonNode (_node, " UsingForDirective" , std::move (attributes));
@@ -829,6 +837,9 @@ bool ASTJsonExporter::visit(UnaryOperation const& _node)
829
837
make_pair (" operator" , TokenTraits::toString (_node.getOperator ())),
830
838
make_pair (" subExpression" , toJson (_node.subExpression ()))
831
839
};
840
+ // NOTE: This annotation is guaranteed to be set but only if we didn't stop at the parsing stage.
841
+ if (_node.annotation ().userDefinedFunction .set () && *_node.annotation ().userDefinedFunction != nullptr )
842
+ attributes.emplace_back (" function" , nodeId (**_node.annotation ().userDefinedFunction ));
832
843
appendExpressionAttributes (attributes, _node.annotation ());
833
844
setJsonNode (_node, " UnaryOperation" , std::move (attributes));
834
845
return false ;
@@ -842,6 +853,9 @@ bool ASTJsonExporter::visit(BinaryOperation const& _node)
842
853
make_pair (" rightExpression" , toJson (_node.rightExpression ())),
843
854
make_pair (" commonType" , typePointerToJson (_node.annotation ().commonType )),
844
855
};
856
+ // NOTE: This annotation is guaranteed to be set but only if we didn't stop at the parsing stage.
857
+ if (_node.annotation ().userDefinedFunction .set () && *_node.annotation ().userDefinedFunction != nullptr )
858
+ attributes.emplace_back (" function" , nodeId (**_node.annotation ().userDefinedFunction ));
845
859
appendExpressionAttributes (attributes, _node.annotation ());
846
860
setJsonNode (_node, " BinaryOperation" , std::move (attributes));
847
861
return false ;
0 commit comments