This commit is contained in:
vis2k 2021-08-21 13:43:59 +08:00
parent 9cf66b511d
commit cf42e303ef

View File

@ -46,7 +46,6 @@ internal void Register(TypeReference dataType, MethodReference methodReference)
void RegisterReadFunc(TypeReference typeReference, MethodDefinition newReaderFunc) void RegisterReadFunc(TypeReference typeReference, MethodDefinition newReaderFunc)
{ {
Register(typeReference, newReaderFunc); Register(typeReference, newReaderFunc);
GeneratedCodeClass.Methods.Add(newReaderFunc); GeneratedCodeClass.Methods.Add(newReaderFunc);
} }
@ -54,15 +53,11 @@ void RegisterReadFunc(TypeReference typeReference, MethodDefinition newReaderFun
public MethodReference GetReadFunc(TypeReference variable, ref bool WeavingFailed) public MethodReference GetReadFunc(TypeReference variable, ref bool WeavingFailed)
{ {
if (readFuncs.TryGetValue(variable, out MethodReference foundFunc)) if (readFuncs.TryGetValue(variable, out MethodReference foundFunc))
{
return foundFunc; return foundFunc;
}
else
{
TypeReference importedVariable = assembly.MainModule.ImportReference(variable); TypeReference importedVariable = assembly.MainModule.ImportReference(variable);
return GenerateReader(importedVariable, ref WeavingFailed); return GenerateReader(importedVariable, ref WeavingFailed);
} }
}
MethodReference GenerateReader(TypeReference variableReference, ref bool WeavingFailed) MethodReference GenerateReader(TypeReference variableReference, ref bool WeavingFailed)
{ {