Skip to content

Commit 56bee54

Browse files
committed
Rename all References to Locations
1 parent ba565d9 commit 56bee54

37 files changed

Lines changed: 201 additions & 186 deletions

src/Castle.Core/DynamicProxy/Contributors/ClassProxySerializableContributor.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class ClassProxySerializableContributor : SerializableContributor
3333
{
3434
private bool delegateToBaseGetObjectData;
3535
private ConstructorInfo serializationConstructor;
36-
private readonly IList<FieldReference> serializedFields = new List<FieldReference>();
36+
private readonly IList<FieldLocation> serializedFields = new List<FieldLocation>();
3737

3838
public ClassProxySerializableContributor(Type targetType, Type[] interfaces, string typeId)
3939
: base(targetType, interfaces, typeId)
@@ -82,15 +82,15 @@ public override void Generate(ClassEmitter @class)
8282
Constructor(@class);
8383
}
8484

85-
protected override void AddAddValueInvocation(ArgumentReference serializationInfo, MethodEmitter getObjectData,
86-
FieldReference field)
85+
protected override void AddAddValueInvocation(ArgumentLocation serializationInfo, MethodEmitter getObjectData,
86+
FieldLocation field)
8787
{
8888
serializedFields.Add(field);
8989
base.AddAddValueInvocation(serializationInfo, getObjectData, field);
9090
}
9191

92-
protected override void CustomizeGetObjectData(CodeBuilder codeBuilder, ArgumentReference serializationInfo,
93-
ArgumentReference streamingContext, ClassEmitter emitter)
92+
protected override void CustomizeGetObjectData(CodeBuilder codeBuilder, ArgumentLocation serializationInfo,
93+
ArgumentLocation streamingContext, ClassEmitter emitter)
9494
{
9595
codeBuilder.AddStatement(
9696
new MethodInvocationExpression(
@@ -108,7 +108,7 @@ protected override void CustomizeGetObjectData(CodeBuilder codeBuilder, Argument
108108
EmitCallToBaseGetObjectData(codeBuilder, serializationInfo, streamingContext);
109109
}
110110

111-
private void EmitCustomGetObjectData(CodeBuilder codeBuilder, ArgumentReference serializationInfo)
111+
private void EmitCustomGetObjectData(CodeBuilder codeBuilder, ArgumentLocation serializationInfo)
112112
{
113113
var members = codeBuilder.DeclareLocal(typeof(MemberInfo[]));
114114
var data = codeBuilder.DeclareLocal(typeof(object[]));
@@ -141,8 +141,8 @@ private void EmitCustomGetObjectData(CodeBuilder codeBuilder, ArgumentReference
141141
codeBuilder.AddStatement(addValue);
142142
}
143143

144-
private void EmitCallToBaseGetObjectData(CodeBuilder codeBuilder, ArgumentReference serializationInfo,
145-
ArgumentReference streamingContext)
144+
private void EmitCallToBaseGetObjectData(CodeBuilder codeBuilder, ArgumentLocation serializationInfo,
145+
ArgumentLocation streamingContext)
146146
{
147147
var baseGetObjectData = targetType.GetMethod("GetObjectData",
148148
new[] { typeof(SerializationInfo), typeof(StreamingContext) });
@@ -166,8 +166,8 @@ private void Constructor(ClassEmitter emitter)
166166

167167
private void GenerateSerializationConstructor(ClassEmitter emitter)
168168
{
169-
var serializationInfo = new ArgumentReference(typeof(SerializationInfo));
170-
var streamingContext = new ArgumentReference(typeof(StreamingContext));
169+
var serializationInfo = new ArgumentLocation(typeof(SerializationInfo));
170+
var streamingContext = new ArgumentLocation(typeof(StreamingContext));
171171

172172
var ctor = emitter.CreateConstructor(serializationInfo, streamingContext);
173173

src/Castle.Core/DynamicProxy/Contributors/ClassProxyTargetContributor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private IInvocationCreationContributor GetContributor(Type @delegate, MetaMethod
158158
}
159159
return new InvocationWithGenericDelegateContributor(@delegate,
160160
method,
161-
new FieldReference(InvocationMethods.ProxyObject));
161+
new FieldLocation(InvocationMethods.ProxyObject));
162162
}
163163

164164
private Type GetDelegateType(MetaMethod method, ClassEmitter @class)

src/Castle.Core/DynamicProxy/Contributors/ClassProxyWithTargetTargetContributor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private IInvocationCreationContributor GetContributor(Type @delegate, MetaMethod
109109
}
110110
return new InvocationWithGenericDelegateContributor(@delegate,
111111
method,
112-
new FieldReference(InvocationMethods.CompositionInvocationTarget));
112+
new FieldLocation(InvocationMethods.CompositionInvocationTarget));
113113
}
114114

115115
private Type GetDelegateType(MetaMethod method, ClassEmitter @class)

src/Castle.Core/DynamicProxy/Contributors/IInvocationCreationContributor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ namespace Castle.DynamicProxy.Contributors
2121

2222
internal interface IInvocationCreationContributor
2323
{
24-
ConstructorEmitter CreateConstructor(ArgumentReference[] baseCtorArguments, AbstractTypeEmitter invocation);
24+
ConstructorEmitter CreateConstructor(ArgumentLocation[] baseCtorArguments, AbstractTypeEmitter invocation);
2525

2626
MethodInfo GetCallbackMethod();
2727

2828
MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, IExpression[] args,
29-
Reference targetField, MethodEmitter invokeMethodOnTarget);
29+
Location targetField, MethodEmitter invokeMethodOnTarget);
3030

3131
IExpression[] GetConstructorInvocationArguments(IExpression[] arguments, ClassEmitter proxy);
3232
}

src/Castle.Core/DynamicProxy/Contributors/InterfaceProxySerializableContributor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public InterfaceProxySerializableContributor(Type targetType, string proxyGenera
2929
{
3030
}
3131

32-
protected override void CustomizeGetObjectData(CodeBuilder codeBuilder, ArgumentReference serializationInfo,
33-
ArgumentReference streamingContext, ClassEmitter emitter)
32+
protected override void CustomizeGetObjectData(CodeBuilder codeBuilder, ArgumentLocation serializationInfo,
33+
ArgumentLocation streamingContext, ClassEmitter emitter)
3434
{
3535
var targetField = emitter.GetField("__target");
3636

src/Castle.Core/DynamicProxy/Contributors/InvocationWithDelegateContributor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public InvocationWithDelegateContributor(Type delegateType, Type targetType, Met
4040
this.namingScope = namingScope;
4141
}
4242

43-
public ConstructorEmitter CreateConstructor(ArgumentReference[] baseCtorArguments, AbstractTypeEmitter invocation)
43+
public ConstructorEmitter CreateConstructor(ArgumentLocation[] baseCtorArguments, AbstractTypeEmitter invocation)
4444
{
4545
var arguments = GetArguments(baseCtorArguments);
4646
var constructor = invocation.CreateConstructor(arguments);
@@ -56,11 +56,11 @@ public MethodInfo GetCallbackMethod()
5656
}
5757

5858
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, IExpression[] args,
59-
Reference targetField,
59+
Location targetField,
6060
MethodEmitter invokeMethodOnTarget)
6161
{
6262
var allArgs = GetAllArgs(args, targetField);
63-
var @delegate = (Reference)invocation.GetField("delegate");
63+
var @delegate = (Location)invocation.GetField("delegate");
6464

6565
return new MethodInvocationExpression(@delegate, GetCallbackMethod(), allArgs);
6666
}
@@ -73,7 +73,7 @@ public IExpression[] GetConstructorInvocationArguments(IExpression[] arguments,
7373
return allArguments;
7474
}
7575

76-
private FieldReference BuildDelegateToken(ClassEmitter proxy)
76+
private FieldLocation BuildDelegateToken(ClassEmitter proxy)
7777
{
7878
var callback = proxy.CreateStaticField(namingScope.GetUniqueName("callback_" + method.Method.Name), delegateType);
7979
var createDelegate = new MethodInvocationExpression(
@@ -88,18 +88,18 @@ private FieldReference BuildDelegateToken(ClassEmitter proxy)
8888
return callback;
8989
}
9090

91-
private IExpression[] GetAllArgs(IExpression[] args, Reference targetField)
91+
private IExpression[] GetAllArgs(IExpression[] args, Location targetField)
9292
{
9393
var allArgs = new IExpression[args.Length + 1];
9494
args.CopyTo(allArgs, 1);
9595
allArgs[0] = new ConvertExpression(targetType, targetField);
9696
return allArgs;
9797
}
9898

99-
private ArgumentReference[] GetArguments(ArgumentReference[] baseCtorArguments)
99+
private ArgumentLocation[] GetArguments(ArgumentLocation[] baseCtorArguments)
100100
{
101-
var arguments = new ArgumentReference[baseCtorArguments.Length + 1];
102-
arguments[0] = new ArgumentReference(delegateType);
101+
var arguments = new ArgumentLocation[baseCtorArguments.Length + 1];
102+
arguments[0] = new ArgumentLocation(delegateType);
103103
baseCtorArguments.CopyTo(arguments, 1);
104104
return arguments;
105105
}

src/Castle.Core/DynamicProxy/Contributors/InvocationWithGenericDelegateContributor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public InvocationWithGenericDelegateContributor(Type delegateType, MetaMethod me
3939
this.target = target;
4040
}
4141

42-
public ConstructorEmitter CreateConstructor(ArgumentReference[] baseCtorArguments, AbstractTypeEmitter invocation)
42+
public ConstructorEmitter CreateConstructor(ArgumentLocation[] baseCtorArguments, AbstractTypeEmitter invocation)
4343
{
4444
return invocation.CreateConstructor(baseCtorArguments);
4545
}
@@ -50,7 +50,7 @@ public MethodInfo GetCallbackMethod()
5050
}
5151

5252
public MethodInvocationExpression GetCallbackMethodInvocation(AbstractTypeEmitter invocation, IExpression[] args,
53-
Reference targetField,
53+
Location targetField,
5454
MethodEmitter invokeMethodOnTarget)
5555
{
5656
var @delegate = GetDelegate(invocation, invokeMethodOnTarget);
@@ -62,7 +62,7 @@ public IExpression[] GetConstructorInvocationArguments(IExpression[] arguments,
6262
return arguments;
6363
}
6464

65-
private Reference GetDelegate(AbstractTypeEmitter invocation, MethodEmitter invokeMethodOnTarget)
65+
private Location GetDelegate(AbstractTypeEmitter invocation, MethodEmitter invokeMethodOnTarget)
6666
{
6767
var genericTypeParameters = invocation.GenericTypeParams.AsTypeArray();
6868
var closedDelegateType = delegateType.MakeGenericType(genericTypeParameters);
@@ -73,7 +73,7 @@ private Reference GetDelegate(AbstractTypeEmitter invocation, MethodEmitter invo
7373
return localReference;
7474
}
7575

76-
private AssignStatement SetDelegate(LocalReference localDelegate, IExpression target,
76+
private AssignStatement SetDelegate(LocalLocation localDelegate, IExpression target,
7777
Type closedDelegateType, MethodInfo closedMethodOnTarget)
7878
{
7979
var delegateCreateDelegate = new MethodInvocationExpression(

src/Castle.Core/DynamicProxy/Contributors/MixinContributor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class MixinContributor : CompositeTypeContributor
2828
{
2929
private readonly bool canChangeTarget;
3030
private readonly IList<Type> empty = new List<Type>();
31-
private readonly IDictionary<Type, FieldReference> fields = new SortedDictionary<Type, FieldReference>(new FieldReferenceComparer());
31+
private readonly IDictionary<Type, FieldLocation> fields = new SortedDictionary<Type, FieldLocation>(new FieldReferenceComparer());
3232
private readonly GetTargetExpressionDelegate getTarget;
3333

3434
public MixinContributor(INamingScope namingScope, bool canChangeTarget)
@@ -38,7 +38,7 @@ public MixinContributor(INamingScope namingScope, bool canChangeTarget)
3838
getTarget = BuildGetTargetExpression();
3939
}
4040

41-
public IEnumerable<FieldReference> Fields
41+
public IEnumerable<FieldLocation> Fields
4242
{
4343
get { return fields.Values; }
4444
}
@@ -118,7 +118,7 @@ private GetTargetExpressionDelegate BuildGetTargetExpression()
118118
fields[m.DeclaringType]);
119119
}
120120

121-
private FieldReference BuildTargetField(ClassEmitter @class, Type type)
121+
private FieldLocation BuildTargetField(ClassEmitter @class, Type type)
122122
{
123123
var name = "__mixin_" + type.FullName.Replace(".", "_");
124124
return @class.CreateField(namingScope.GetUniqueName(name), type);

src/Castle.Core/DynamicProxy/Contributors/ProxyTargetAccessorContributor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void Generate(ClassEmitter emitter)
5151
var dynProxySetTarget = emitter.CreateMethod(nameof(IProxyTargetAccessor.DynProxySetTarget), typeof(void), typeof(object));
5252

5353
// we can only change the target of the interface proxy
54-
if (target is FieldReference targetField)
54+
if (target is FieldLocation targetField)
5555
{
5656
dynProxySetTarget.CodeBuilder.AddStatement(
5757
new AssignStatement(targetField,

src/Castle.Core/DynamicProxy/Contributors/SerializableContributor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected void ImplementGetObjectData(ClassEmitter emitter)
9191
{
9292
getObjectData.CodeBuilder.AddStatement(
9393
new AssignStatement(
94-
new ArrayElementReference(interfacesLocal, i),
94+
new ArrayElementLocation(interfacesLocal, i),
9595
new LiteralStringExpression(interfaces[i].AssemblyQualifiedName)));
9696
}
9797

@@ -128,8 +128,8 @@ protected void ImplementGetObjectData(ClassEmitter emitter)
128128
getObjectData.CodeBuilder.AddStatement(new ReturnStatement());
129129
}
130130

131-
protected virtual void AddAddValueInvocation(ArgumentReference serializationInfo, MethodEmitter getObjectData,
132-
FieldReference field)
131+
protected virtual void AddAddValueInvocation(ArgumentLocation serializationInfo, MethodEmitter getObjectData,
132+
FieldLocation field)
133133
{
134134
getObjectData.CodeBuilder.AddStatement(
135135
new MethodInvocationExpression(
@@ -140,8 +140,8 @@ protected virtual void AddAddValueInvocation(ArgumentReference serializationInfo
140140
return;
141141
}
142142

143-
protected abstract void CustomizeGetObjectData(CodeBuilder builder, ArgumentReference serializationInfo,
144-
ArgumentReference streamingContext, ClassEmitter emitter);
143+
protected abstract void CustomizeGetObjectData(CodeBuilder builder, ArgumentLocation serializationInfo,
144+
ArgumentLocation streamingContext, ClassEmitter emitter);
145145

146146
public virtual void CollectElementsToProxy(IProxyGenerationHook hook, MetaType model)
147147
{

0 commit comments

Comments
 (0)