2using System.Reflection.Emit;
7 internal sealed class LocalBuilder : LocalVariableInfo
10 readonly MethodBuilder method;
18 internal LocalBuilder(MethodBuilder method,
Type localType,
int index,
bool pinned) :
19 base(index, localType, pinned)
21 this.method = method ??
throw new ArgumentNullException(nameof(method));
31 internal LocalBuilder(MethodBuilder method,
Type localType,
int index,
bool pinned, CustomModifiers customModifiers) :
32 base(index, localType, pinned, customModifiers)
34 this.method = method ??
throw new ArgumentNullException(nameof(method));
40 internal MethodBuilder Method => method;
46 public void SetLocalSymInfo(
string name)
48 SetLocalSymInfo(name, 0, 0);
57 public void SetLocalSymInfo(
string name,
int startOffset,
int endOffset)
59 var module = method.ModuleBuilder;
60 if (method.IsTypeCreated())
61 throw new InvalidOperationException(
"Unable to change after type has been created.");
64 var signature = SignatureHelper.GetFieldSigHelper(module);
65 signature.AddArgument(LocalType);
66 var array = signature.GetSignature();
68 int currentActiveScopeIndex = method.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
69 if (currentActiveScopeIndex == -1)
71 method.m_localSymInfo ??=
new();
72 method.m_localSymInfo.AddLocalSymInfo(name, array, LocalIndex, startOffset, endOffset);
76 method.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope(name, array, LocalIndex, startOffset, endOffset);
IKVM.Reflection.Type Type