ig.BeginFinallyBlock ();
}
- public void BeginScope ()
+ public void BeginScope (int scopeIndex)
{
if ((flags & Options.OmitDebugInfo) != 0)
return;
- methodSymbols.StartBlock (CodeBlockEntry.Type.Lexical, ig.ILOffset);
+ methodSymbols.StartBlock (CodeBlockEntry.Type.Lexical, ig.ILOffset, scopeIndex);
}
- public void BeginCompilerScope ()
+ public void BeginCompilerScope (int scopeIndex)
{
if ((flags & Options.OmitDebugInfo) != 0)
return;
- methodSymbols.StartBlock (CodeBlockEntry.Type.CompilerGenerated, ig.ILOffset);
+ methodSymbols.StartBlock (CodeBlockEntry.Type.CompilerGenerated, ig.ILOffset, scopeIndex);
}
public void EndExceptionBlock ()
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
+ if (pinned) {
+ //
+ // This is for .net compatibility. I am not sure why pinned
+ // pointer temps are converted to & even if they are pointers to
+ // pointers.
+ //
+ var pt = type as PointerContainer;
+ if (pt != null) {
+ type = pt.Element;
+ if (type.Kind == MemberKind.Void)
+ type = Module.Compiler.BuiltinTypes.IntPtr;
+
+ return ig.DeclareLocal (type.GetMetaInfo ().MakeByRefType (), true);
+ }
+ }
+
return ig.DeclareLocal (type.GetMetaInfo (), pinned);
}
if (conditionalAccess) {
if (!ec.ConditionalAccess.Statement) {
- if (ec.ConditionalAccess.Type.IsNullableType)
- Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
- else
+ var t = ec.ConditionalAccess.Type;
+ if (t.IsNullableType)
+ Nullable.LiftedNull.Create (t, Location.Null).Emit (ec);
+ else {
ec.EmitNull ();
+
+ if (t.IsGenericParameter)
+ ec.Emit (OpCodes.Unbox_Any, t);
+ }
}
ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
instance_address.AddressOf (ec, AddressOp.Load);
} else if (unwrap != null) {
unwrap.Emit (ec);
- var tmp = ec.GetTemporaryLocal (unwrap.Type);
- ec.Emit (OpCodes.Stloc, tmp);
- ec.Emit (OpCodes.Ldloca, tmp);
- ec.FreeTemporaryLocal (tmp, unwrap.Type);
+ if (addressRequired) {
+ var tmp = ec.GetTemporaryLocal (unwrap.Type);
+ ec.Emit (OpCodes.Stloc, tmp);
+ ec.Emit (OpCodes.Ldloca, tmp);
+ ec.FreeTemporaryLocal (tmp, unwrap.Type);
+ }
} else if (!conditional_access_dup) {
instance.Emit (ec);
}