mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +00:00
Make plugmanager not throw exceptions when plug targets are not found.
This commit is contained in:
parent
00658f9923
commit
3bfaf7f670
4 changed files with 20 additions and 7 deletions
|
|
@ -236,6 +236,7 @@ namespace Cosmos.IL2CPU
|
||||||
using (var xScanner = new ILScanner(xAsm))
|
using (var xScanner = new ILScanner(xAsm))
|
||||||
{
|
{
|
||||||
xScanner.LogException = LogException;
|
xScanner.LogException = LogException;
|
||||||
|
xScanner.LogWarning = LogWarning;
|
||||||
CompilerHelpers.DebugEvent += LogMessage;
|
CompilerHelpers.DebugEvent += LogMessage;
|
||||||
if (EnableLogging)
|
if (EnableLogging)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ namespace Cosmos.IL2CPU
|
||||||
public class ILScanner : IDisposable
|
public class ILScanner : IDisposable
|
||||||
{
|
{
|
||||||
public LogExceptionDelegate LogException = null;
|
public LogExceptionDelegate LogException = null;
|
||||||
|
public Action<string> LogWarning = null;
|
||||||
|
|
||||||
protected ILReader mReader;
|
protected ILReader mReader;
|
||||||
protected AppAssembler mAsmblr;
|
protected AppAssembler mAsmblr;
|
||||||
|
|
@ -71,7 +72,7 @@ namespace Cosmos.IL2CPU
|
||||||
mAsmblr = aAsmblr;
|
mAsmblr = aAsmblr;
|
||||||
mReader = new ILReader();
|
mReader = new ILReader();
|
||||||
|
|
||||||
mPlugManager = new PlugManager(LogException);
|
mPlugManager = new PlugManager(LogException, LogWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnableLogging(string aPathname)
|
public bool EnableLogging(string aPathname)
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,10 @@ namespace Cosmos.IL2CPU
|
||||||
return LabelName.GenerateFullName(m);
|
return LabelName.GenerateFullName(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlugManager(LogExceptionDelegate aLogException)
|
public PlugManager(LogExceptionDelegate aLogException, Action<string> aLogWarning)
|
||||||
{
|
{
|
||||||
LogException = aLogException;
|
LogException = aLogException;
|
||||||
|
LogWarning = aLogWarning;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FindPlugImpls()
|
public void FindPlugImpls()
|
||||||
|
|
@ -321,7 +322,10 @@ namespace Cosmos.IL2CPU
|
||||||
if (xAttrib == null
|
if (xAttrib == null
|
||||||
|| xAttrib.IsOptional)
|
|| xAttrib.IsOptional)
|
||||||
{
|
{
|
||||||
throw new Exception("Invalid plug method! Target method not found. : " + xMethod.GetFullName());
|
if (LogWarning != null)
|
||||||
|
{
|
||||||
|
LogWarning("Invalid plug method! Target method not found. : " + xMethod.GetFullName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -330,7 +334,10 @@ namespace Cosmos.IL2CPU
|
||||||
if (xAttrib.IsWildcard
|
if (xAttrib.IsWildcard
|
||||||
&& xAttrib.Assembler == null)
|
&& xAttrib.Assembler == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Wildcard PlugMethods need to use an assembler for now.");
|
if (LogWarning != null)
|
||||||
|
{
|
||||||
|
LogWarning("Wildcard PlugMethods need to use an assembler for now.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -355,6 +362,8 @@ namespace Cosmos.IL2CPU
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action<string> LogWarning;
|
||||||
|
|
||||||
private MethodBase ResolvePlug(Type aTargetType, List<Type> aImpls, MethodBase aMethod, Type[] aParamTypes)
|
private MethodBase ResolvePlug(Type aTargetType, List<Type> aImpls, MethodBase aMethod, Type[] aParamTypes)
|
||||||
{
|
{
|
||||||
//TODO: This method is "reversed" from old - remember that when porting
|
//TODO: This method is "reversed" from old - remember that when porting
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ namespace PlugsInspector
|
||||||
|
|
||||||
plugManager = new PlugManager((Exception ex) => {
|
plugManager = new PlugManager((Exception ex) => {
|
||||||
AddExceptionEntry(ex.Message);
|
AddExceptionEntry(ex.Message);
|
||||||
});
|
}, warning =>
|
||||||
|
{
|
||||||
|
});
|
||||||
plugManager.ThrowExceptions = false;
|
plugManager.ThrowExceptions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue