This commit is contained in:
parent
151e046aa5
commit
740ea078ca
|
|
@ -918,7 +918,7 @@ namespace PascalABCCompiler.NETGenerator {
|
|||
return TypeFactory.IEnumerableType.GetMethod("GetEnumerator", Type.EmptyTypes);
|
||||
}
|
||||
|
||||
public void SetAsProcessing(ICommonTypeNode type)
|
||||
public void SetAsProcessing(ICommonTypeNode type)
|
||||
{
|
||||
processing_types[type] = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11620,11 +11620,14 @@ namespace PascalABCCompiler.NETGenerator
|
|||
//il.Emit(OpCodes.Leave, leave_label);
|
||||
il.BeginFinallyBlock();
|
||||
//il.MarkLabel(br_lbl);
|
||||
if (lb.LocalType.IsValueType)
|
||||
il.Emit(OpCodes.Ldloca, lb);
|
||||
else
|
||||
il.Emit(OpCodes.Ldloc, lb);
|
||||
il.Emit(OpCodes.Callvirt, TypeFactory.IDisposableType.GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public));
|
||||
if (lb.LocalType.GetInterface("System.IDisposable") != null)
|
||||
{
|
||||
if (lb.LocalType.IsValueType)
|
||||
il.Emit(OpCodes.Ldloca, lb);
|
||||
else
|
||||
il.Emit(OpCodes.Ldloc, lb);
|
||||
il.Emit(OpCodes.Callvirt, TypeFactory.IDisposableType.GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public));
|
||||
}
|
||||
|
||||
il.EndExceptionBlock();
|
||||
il.MarkLabel(leave_label);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,23 @@ type
|
|||
|
||||
end;
|
||||
|
||||
t2<T> = class(IEnumerable<T>, IEnumerator<T>)
|
||||
|
||||
public function GetEnumerator: IEnumerator<T> := self;
|
||||
function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator := self;
|
||||
|
||||
public function MoveNext := false;
|
||||
|
||||
public property Current: byte read 0;
|
||||
property System.Collections.IEnumerator.Current: object read 0;
|
||||
property System.Collections.Generic.IEnumerator<T>.Current: T read default(T);
|
||||
|
||||
public procedure Reset := exit;
|
||||
|
||||
public procedure Dispose := c += 1;
|
||||
|
||||
end;
|
||||
|
||||
function f1: sequence of byte;
|
||||
begin
|
||||
yield sequence new t1;
|
||||
|
|
@ -27,5 +44,7 @@ end;
|
|||
|
||||
begin
|
||||
foreach var x in new t1 do ;
|
||||
Assert(c = 1);
|
||||
foreach var x in new t2<byte> do ;
|
||||
//foreach var x in f1 do ;
|
||||
Assert(c = 2);
|
||||
end.
|
||||
Loading…
Reference in a new issue