예제 #1
0
 /// <summary>
 /// Adds a binder for the given assembly to this multi-binder,
 /// if it hasn't been added yet.
 /// </summary>
 /// <param name="Assembly">The assembly to create a binder from.</param>
 public bool AddAssembly(IAssembly Assembly)
 {
     if (registeredAsms.Add(Assembly))
     {
         AddBinder(Assembly.CreateBinder());
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Infers an assembly's entry point, which is any function that matches the following pattern:
 /// `static void main(string[] Args)`.
 /// </summary>
 /// <param name="Assembly"></param>
 /// <returns></returns>
 private static IMethod InferEntryPoint(IAssembly Assembly)
 {
     foreach (var type in Assembly.CreateBinder().GetTypes())
     {
         foreach (var method in type.GetMethods())
         {
             // Basically match anything that looks like `static void main(...)`
             if (method.IsStatic && method.Name.Equals("main", StringComparison.OrdinalIgnoreCase) && method.ReturnType.Equals(PrimitiveTypes.Void))
             {
                 return method;
             }
         }
     }
     return null;
 }