@@ -234,7 +234,6 @@ internal static int ColumnVarDeref()
234234
235235 internal static readonly Var CompilerContextVar = Var . create ( null ) . setDynamic ( ) ;
236236 internal static readonly Var CompilerActiveVar = Var . create ( false ) . setDynamic ( ) ;
237- internal static readonly Var DirectLinkingMapVar = Var . create ( null ) . setDynamic ( ) ;
238237
239238 public static Var CompilerOptionsVar ;
240239
@@ -516,9 +515,17 @@ static Compiler()
516515
517516 #region Symbol/namespace resolving
518517
519- // TODO: we have duplicate code below.
518+ // Registry of Var -> Type
519+ // Where the key is a Var that has been def'd to a Type that was generated by compilation.
520520
521- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Style" , "IDE1006:Naming Styles" , Justification = "ClojureJVM name match" ) ]
521+ static Dictionary < Var , Type > _directLinkingMap = new Dictionary < Var , Type > ( ) ;
522+
523+ public static void RegisterDirectLink ( Var var , Type type ) => _directLinkingMap [ var ] = type ;
524+ public static bool TryGetDirectLink ( Var var , out Type t ) => _directLinkingMap . TryGetValue ( var , out t ) ;
525+
526+ // TODO: we have duplicate code below.
527+
528+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Style" , "IDE1006:Naming Styles" , Justification = "ClojureJVM name match" ) ]
522529 public static Symbol resolveSymbol ( Symbol sym )
523530 {
524531 //already qualified or classname?
@@ -1739,8 +1746,7 @@ public static object Compile(GenContext context,TextReader rdr, string sourceDir
17391746 RT . WarnOnReflectionVar , RT . WarnOnReflectionVar . deref ( ) ,
17401747 RT . DataReadersVar , RT . DataReadersVar . deref ( ) ,
17411748 CompilerContextVar , context ,
1742- CompilerActiveVar , true ,
1743- DirectLinkingMapVar , new Dictionary < Var , Type > ( )
1749+ CompilerActiveVar , true
17441750 ) ) ;
17451751
17461752 try
@@ -1828,7 +1834,7 @@ private static void Compile1(TypeBuilder tb, CljILGen ilg, ObjExpr objx, object
18281834
18291835 if ( expr is DefExpr dex && dex . Init is FnExpr fnx )
18301836 {
1831- ( ( Dictionary < Var , Type > ) DirectLinkingMapVar . deref ( ) ) [ dex . Var ] = fnx . CompiledType ;
1837+ RegisterDirectLink ( dex . Var , fnx . CompiledType ) ;
18321838 }
18331839
18341840#if NET9_0_OR_GREATER
@@ -1863,8 +1869,7 @@ private static void DoSeparateEval(ParserContext evPC, Object form)
18631869 //RT.WarnOnReflectionVar, RT.WarnOnReflectionVar.deref(),
18641870 //RT.DataReadersVar, RT.DataReadersVar.deref(),
18651871 CompilerContextVar , null ,
1866- CompilerActiveVar , false ,
1867- DirectLinkingMapVar , null // we do not want to have the evaluated version try to direct link to functions in the compile assembly
1872+ CompilerActiveVar , false
18681873 ) ) ;
18691874 try
18701875 {
0 commit comments