@@ -20,7 +20,7 @@ public class Scope
20
20
private readonly IDictionary < string , PEvent > events = new Dictionary < string , PEvent > ( ) ;
21
21
private readonly IDictionary < string , NamedEventSet > eventSets = new Dictionary < string , NamedEventSet > ( ) ;
22
22
private readonly IDictionary < string , Function > functions = new Dictionary < string , Function > ( ) ;
23
- private readonly ITranslationErrorHandler handler ;
23
+ private readonly ICompilerConfiguration config ;
24
24
private readonly IDictionary < string , Implementation > implementations = new Dictionary < string , Implementation > ( ) ;
25
25
private readonly IDictionary < string , Interface > interfaces = new Dictionary < string , Interface > ( ) ;
26
26
private readonly IDictionary < string , Machine > machines = new Dictionary < string , Machine > ( ) ;
@@ -32,9 +32,9 @@ public class Scope
32
32
private readonly IDictionary < string , TypeDef > typedefs = new Dictionary < string , TypeDef > ( ) ;
33
33
private readonly IDictionary < string , Variable > variables = new Dictionary < string , Variable > ( ) ;
34
34
35
- private Scope ( ITranslationErrorHandler handler , Scope parent = null )
35
+ private Scope ( ICompilerConfiguration config , Scope parent = null )
36
36
{
37
- this . handler = handler ;
37
+ this . config = config ;
38
38
parent ? . children . Remove ( this ) ;
39
39
Parent = parent ;
40
40
parent ? . children . Add ( this ) ;
@@ -80,14 +80,14 @@ private Scope(ITranslationErrorHandler handler, Scope parent = null)
80
80
public IEnumerable < Implementation > Implementations => implementations . Values ;
81
81
public IEnumerable < NamedModule > NamedModules => namedModules . Values ;
82
82
83
- public static Scope CreateGlobalScope ( ITranslationErrorHandler handler )
83
+ public static Scope CreateGlobalScope ( ICompilerConfiguration config )
84
84
{
85
- return new Scope ( handler ) ;
85
+ return new Scope ( config ) ;
86
86
}
87
87
88
88
public Scope MakeChildScope ( )
89
89
{
90
- return new Scope ( handler , this ) ;
90
+ return new Scope ( config , this ) ;
91
91
}
92
92
93
93
public IEnumerable < Function > GetAllMethods ( )
@@ -599,6 +599,16 @@ public Implementation Put(string name, PParser.ImplementationDeclContext tree)
599
599
600
600
public SafetyTest Put ( string name , PParser . SafetyTestDeclContext tree )
601
601
{
602
+ // check if test is from an imported project, if so, return null
603
+ string filePath = config . LocationResolver . GetLocation ( tree ) . File . FullName ;
604
+ foreach ( var dependencyPath in config . ProjectDependencies )
605
+ {
606
+ if ( filePath . StartsWith ( dependencyPath ) )
607
+ {
608
+ return null ;
609
+ }
610
+ }
611
+
602
612
var safetyTest = new SafetyTest ( tree , name ) ;
603
613
CheckConflicts ( safetyTest ,
604
614
Namespace ( implementations ) ,
@@ -631,7 +641,7 @@ private void CheckConflicts(IPDecl decl, params TableReader[] namespaces)
631
641
IPDecl existingDecl = null ;
632
642
if ( namespaces . Any ( table => table ( decl . Name , out existingDecl ) ) )
633
643
{
634
- throw handler . DuplicateDeclaration ( decl . SourceLocation , decl , existingDecl ) ;
644
+ throw config . Handler . DuplicateDeclaration ( decl . SourceLocation , decl , existingDecl ) ;
635
645
}
636
646
}
637
647
0 commit comments