IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
LocalBuilder.cs
Go to the documentation of this file.
1using System;
2using System.Reflection.Emit;
3
5{
6
7 internal sealed class LocalBuilder : LocalVariableInfo
8 {
9
10 readonly MethodBuilder method;
11
18 internal LocalBuilder(MethodBuilder method, Type localType, int index, bool pinned) :
19 base(index, localType, pinned)
20 {
21 this.method = method ?? throw new ArgumentNullException(nameof(method));
22 }
23
31 internal LocalBuilder(MethodBuilder method, Type localType, int index, bool pinned, CustomModifiers customModifiers) :
32 base(index, localType, pinned, customModifiers)
33 {
34 this.method = method ?? throw new ArgumentNullException(nameof(method));
35 }
36
40 internal MethodBuilder Method => method;
41
46 public void SetLocalSymInfo(string name)
47 {
48 SetLocalSymInfo(name, 0, 0);
49 }
50
57 public void SetLocalSymInfo(string name, int startOffset, int endOffset)
58 {
59 var module = method.ModuleBuilder;
60 if (method.IsTypeCreated())
61 throw new InvalidOperationException("Unable to change after type has been created.");
62
63 // generate field signature representing type
64 var signature = SignatureHelper.GetFieldSigHelper(module);
65 signature.AddArgument(LocalType);
66 var array = signature.GetSignature();
67
68 int currentActiveScopeIndex = method.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
69 if (currentActiveScopeIndex == -1)
70 {
71 method.m_localSymInfo ??= new();
72 method.m_localSymInfo.AddLocalSymInfo(name, array, LocalIndex, startOffset, endOffset);
73 return;
74 }
75
76 method.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope(name, array, LocalIndex, startOffset, endOffset);
77 }
78
79 }
80
81}
IKVM.Reflection.Type Type