Skip to content

Commit 55c75ee

Browse files
committed
удален устаревший класс
1 parent 109564d commit 55c75ee

4 files changed

Lines changed: 8 additions & 41 deletions

File tree

src/OneScript.Native/Compiler/ExpressionHelpers.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,12 @@ public static Expression CallOfInstanceMethod(Expression instance, string name,
595595

596596
public static Expression AccessModuleVariable(ParameterExpression thisArg, int variableIndex)
597597
{
598-
var contextProperty = PropertiesCache.GetOrAdd(
599-
typeof(NativeClassInstanceWrapper),
600-
nameof(NativeClassInstanceWrapper.Context),
601-
BindingFlags.Instance | BindingFlags.Public);
602-
603-
var contextAccess = Expression.Property(thisArg, contextProperty);
604598
var getVariableMethod = OperationsCache.GetOrAdd(
605599
typeof(IAttachableContext),
606600
nameof(IAttachableContext.GetVariable),
607601
BindingFlags.Instance | BindingFlags.Public);
608602

609-
var iVariable = Expression.Call(contextAccess, getVariableMethod, Expression.Constant(variableIndex));
603+
var iVariable = Expression.Call(thisArg, getVariableMethod, Expression.Constant(variableIndex));
610604
var valueProperty = PropertiesCache.GetOrAdd(
611605
typeof(IValueReference),
612606
nameof(IValueReference.BslValue),

src/OneScript.Native/Compiler/MethodCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void CompileFragment(BslSyntaxNode node, Action<BslSyntaxNode> visitor)
142142
private void FillParameterVariables()
143143
{
144144
_declaredParameters = _method.GetBslParameters();
145-
_thisParameter = _method.IsInstance ? Expression.Parameter(typeof(NativeClassInstanceWrapper), "$this") : null;
145+
_thisParameter = _method.IsInstance ? Expression.Parameter(typeof(IAttachableContext), "$this") : null;
146146

147147
var localScope = Symbols.GetScope(Symbols.ScopeCount-1);
148148
foreach (var parameter in _declaredParameters)

src/OneScript.Native/Runtime/CallableMethod.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class CallableMethod
2727
{
2828
private readonly BslNativeMethodInfo _method;
2929

30-
private delegate BslValue NativeCallable(NativeClassInstanceWrapper target, BslValue[] args, IBslProcess process);
30+
private delegate BslValue NativeCallable(IAttachableContext target, BslValue[] args, IBslProcess process);
3131

3232
private NativeCallable _delegate;
3333

@@ -47,23 +47,16 @@ public BslValue Invoke(IBslProcess process, object target, BslValue[] args)
4747
return _delegate.Invoke(callableWrapper, args, process);
4848
}
4949

50-
private NativeClassInstanceWrapper GetCallableWrapper(object obj)
50+
private IAttachableContext GetCallableWrapper(object obj)
5151
{
52-
NativeClassInstanceWrapper callableWrapper;
52+
IAttachableContext callableWrapper;
5353
if (_method.IsInstance)
5454
{
5555
if (obj == null)
5656
throw new InvalidOperationException($"Method {_method.Name} is not static and requires target");
57-
if (obj is NativeClassInstanceWrapper w)
57+
if (obj is IAttachableContext context)
5858
{
59-
callableWrapper = w;
60-
}
61-
else if (obj is IAttachableContext context)
62-
{
63-
callableWrapper = new NativeClassInstanceWrapper
64-
{
65-
Context = context
66-
};
59+
callableWrapper = context;
6760
}
6861
else
6962
{
@@ -86,7 +79,7 @@ private static NativeCallable CreateDelegate(BslNativeMethodInfo method)
8679
if (method.Implementation == default)
8780
throw new InvalidOperationException("Method has no implementation");
8881

89-
var targetParam = Expression.Parameter(typeof(NativeClassInstanceWrapper));
82+
var targetParam = Expression.Parameter(typeof(IAttachableContext));
9083
var arrayOfValuesParam = Expression.Parameter(typeof(BslValue[]));
9184
var processParam = Expression.Parameter(typeof(IBslProcess));
9285
var convertedAccessList = new List<Expression>();

src/OneScript.Native/Runtime/NativeClassInstanceWrapper.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)