@@ -279,8 +279,8 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
279
279
string funName = IRNames::internalDispatch (arity);
280
280
m_context.functionCollector ().createFunction (funName, [&]() {
281
281
Whiskers templ (R"(
282
+ <sourceLocationComment>
282
283
function <functionName>(fun<?+in>, <in></+in>) <?+out>-> <out></+out> {
283
- <sourceLocationComment>
284
284
switch fun
285
285
<#cases>
286
286
case <funID>
@@ -290,6 +290,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
290
290
</cases>
291
291
default { <panic>() }
292
292
}
293
+ <sourceLocationComment>
293
294
)" );
294
295
templ (" sourceLocationComment" , sourceLocationComment (_contract, m_context));
295
296
templ (" functionName" , funName);
@@ -336,14 +337,19 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function)
336
337
return m_context.functionCollector ().createFunction (functionName, [&]() {
337
338
m_context.resetLocalVariables ();
338
339
Whiskers t (R"(
340
+ <sourceLocationComment>
339
341
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
340
- <sourceLocationComment>
341
342
<retInit>
342
343
<body>
343
344
}
345
+ <contractSourceLocationComment>
344
346
)" );
345
347
346
348
t (" sourceLocationComment" , sourceLocationComment (_function, m_context));
349
+ t (
350
+ " contractSourceLocationComment" ,
351
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
352
+ );
347
353
348
354
t (" functionName" , functionName);
349
355
vector<string> params;
@@ -398,12 +404,13 @@ string IRGenerator::generateModifier(
398
404
return m_context.functionCollector ().createFunction (functionName, [&]() {
399
405
m_context.resetLocalVariables ();
400
406
Whiskers t (R"(
407
+ <sourceLocationComment>
401
408
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
402
- <sourceLocationComment>
403
409
<assignRetParams>
404
410
<evalArgs>
405
411
<body>
406
412
}
413
+ <contractSourceLocationComment>
407
414
)" );
408
415
t (" functionName" , functionName);
409
416
vector<string> retParamsIn;
@@ -428,6 +435,11 @@ string IRGenerator::generateModifier(
428
435
);
429
436
solAssert (modifier, " " );
430
437
t (" sourceLocationComment" , sourceLocationComment (*modifier, m_context));
438
+ t (
439
+ " contractSourceLocationComment" ,
440
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
441
+ );
442
+
431
443
switch (*_modifierInvocation.name ().annotation ().requiredLookup )
432
444
{
433
445
case VirtualLookup::Virtual:
@@ -478,13 +490,18 @@ string IRGenerator::generateFunctionWithModifierInner(FunctionDefinition const&
478
490
return m_context.functionCollector ().createFunction (functionName, [&]() {
479
491
m_context.resetLocalVariables ();
480
492
Whiskers t (R"(
493
+ <sourceLocationComment>
481
494
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
482
- <sourceLocationComment>
483
495
<assignRetParams>
484
496
<body>
485
497
}
498
+ <contractSourceLocationComment>
486
499
)" );
487
500
t (" sourceLocationComment" , sourceLocationComment (_function, m_context));
501
+ t (
502
+ " contractSourceLocationComment" ,
503
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
504
+ );
488
505
t (" functionName" , functionName);
489
506
vector<string> retParams;
490
507
vector<string> retParamsIn;
@@ -522,12 +539,17 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
522
539
solAssert (paramTypes.empty (), " " );
523
540
solUnimplementedAssert (type->sizeOnStack () == 1 , " " );
524
541
return Whiskers (R"(
542
+ <sourceLocationComment>
525
543
function <functionName>() -> rval {
526
- <sourceLocationComment>
527
544
rval := loadimmutable("<id>")
528
545
}
546
+ <contractSourceLocationComment>
529
547
)" )
530
548
(" sourceLocationComment" , sourceLocationComment (_varDecl, m_context))
549
+ (
550
+ " contractSourceLocationComment" ,
551
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
552
+ )
531
553
(" functionName" , functionName)
532
554
(" id" , to_string (_varDecl.id ()))
533
555
.render ();
@@ -536,12 +558,17 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
536
558
{
537
559
solAssert (paramTypes.empty (), " " );
538
560
return Whiskers (R"(
561
+ <sourceLocationComment>
539
562
function <functionName>() -> <ret> {
540
- <sourceLocationComment>
541
563
<ret> := <constantValueFunction>()
542
564
}
565
+ <contractSourceLocationComment>
543
566
)" )
544
567
(" sourceLocationComment" , sourceLocationComment (_varDecl, m_context))
568
+ (
569
+ " contractSourceLocationComment" ,
570
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
571
+ )
545
572
(" functionName" , functionName)
546
573
(" constantValueFunction" , IRGeneratorForStatements (m_context, m_utils).constantValueFunction (_varDecl))
547
574
(" ret" , suffixedVariableNameList (" ret_" , 0 , _varDecl.type ()->sizeOnStack ()))
@@ -653,16 +680,21 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
653
680
}
654
681
655
682
return Whiskers (R"(
683
+ <sourceLocationComment>
656
684
function <functionName>(<params>) -> <retVariables> {
657
- <sourceLocationComment>
658
685
<code>
659
686
}
687
+ <contractSourceLocationComment>
660
688
)" )
661
689
(" functionName" , functionName)
662
690
(" params" , joinHumanReadable (parameters))
663
691
(" retVariables" , joinHumanReadable (returnVariables))
664
692
(" code" , std::move (code))
665
693
(" sourceLocationComment" , sourceLocationComment (_varDecl, m_context))
694
+ (
695
+ " contractSourceLocationComment" ,
696
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
697
+ )
666
698
.render ();
667
699
});
668
700
}
@@ -769,13 +801,15 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
769
801
m_context.resetLocalVariables ();
770
802
m_context.functionCollector ().createFunction (IRNames::constructor (*contract), [&]() {
771
803
Whiskers t (R"(
804
+ <sourceLocationComment>
772
805
function <functionName>(<params><comma><baseParams>) {
773
806
<evalBaseArguments>
774
807
<sourceLocationComment>
775
808
<?hasNextConstructor> <nextConstructor>(<nextParams>) </hasNextConstructor>
776
809
<initStateVariables>
777
810
<userDefinedConstructorBody>
778
811
}
812
+ <contractSourceLocationComment>
779
813
)" );
780
814
vector<string> params;
781
815
if (contract->constructor ())
@@ -788,6 +822,10 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
788
822
contract->location (),
789
823
m_context
790
824
));
825
+ t (
826
+ " contractSourceLocationComment" ,
827
+ sourceLocationComment (m_context.mostDerivedContract (), m_context)
828
+ );
791
829
792
830
t (" params" , joinHumanReadable (params));
793
831
vector<string> baseParams = listAllParams (baseConstructorParams);
0 commit comments