Co-authored-by: Xin Shi <xinshi@microsoft.com>
This commit is contained in:
Matthew Jin 2022-09-29 13:52:26 -07:00 коммит произвёл GitHub
Родитель 6e38e78a91
Коммит 598d9b6cc9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -703,6 +703,7 @@ namespace Cilsil.Cil.Parsers
out Call methodCall,
bool isConstructorCall = false)
{
ProcedureName procName;
callArgs = new List<Call.CallArg>();
returnType = calledMethod.ReturnType;
var paramCount = calledMethod.Parameters.Count;
@ -715,10 +716,33 @@ namespace Cilsil.Cil.Parsers
callArgs.Add(new Call.CallArg(thisExpr, thisType));
paramCount--;
}
var funcExp = new ConstExpression(new ProcedureName(calledMethod));
callArgs.AddRange(state.PopMany(paramCount)
.Select(p => new Call.CallArg(p.Item1, p.Item2))
.ToList());
var x = calledMethod.GetCompatibleFullName();
// When objects are handled using C#'s using construct, the compiler invokes the
// System.IDisposable method for dispose. This is problematic when applied to
// user-defined types with custom dispose, as then we will not apply the spec computed
// for the user-defined dispose.
if (calledMethod.GetCompatibleFullName().Contains("System.IDisposable::Dispose") &&
callArgs.First().Type is Tptr objectPtr &&
objectPtr.Type is Tstruct disposeType)
{
procName = new ProcedureName(
calledMethod.Name,
calledMethod.Parameters.Select(
p => p.ParameterType.GetCompatibleFullName()).ToList(),
disposeType.StructName,
calledMethod.ReturnType.GetCompatibleFullName(),
!calledMethod.HasThis);
isVirtual = false;
}
else
{
procName = new ProcedureName(calledMethod);
}
var funcExp = new ConstExpression(procName);
var callFlags = new Call.CallFlags(isVirtual, false, false);
returnVariable = state.GetIdentifier(Identifier.IdentKind.Normal);
methodCall = new Call(returnId: returnVariable,