committed by
GitHub
26 changed files with 296 additions and 55 deletions
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="System.Reactive" Version="4.4.1" /> |
<PackageReference Include="System.Reactive" Version="5.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,54 @@ |
|||||
|
using Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers; |
||||
|
using XamlX; |
||||
|
using XamlX.Ast; |
||||
|
using XamlX.Emit; |
||||
|
using XamlX.IL; |
||||
|
using XamlX.TypeSystem; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AstNodes |
||||
|
{ |
||||
|
class AvaloniaXamlIlVectorLikeConstantAstNode : XamlAstNode, IXamlAstValueNode, IXamlAstILEmitableNode |
||||
|
{ |
||||
|
private readonly IXamlConstructor _constructor; |
||||
|
private readonly double[] _values; |
||||
|
|
||||
|
public AvaloniaXamlIlVectorLikeConstantAstNode(IXamlLineInfo lineInfo, AvaloniaXamlIlWellKnownTypes types, IXamlType type, IXamlConstructor constructor, double[] values) : base(lineInfo) |
||||
|
{ |
||||
|
var parameters = constructor.Parameters; |
||||
|
|
||||
|
if (parameters.Count != values.Length) |
||||
|
{ |
||||
|
throw new XamlTypeSystemException($"Constructor that takes {values.Length} parameters is expected, got {parameters.Count} instead."); |
||||
|
} |
||||
|
|
||||
|
var elementType = types.XamlIlTypes.Double; |
||||
|
|
||||
|
foreach (var parameter in parameters) |
||||
|
{ |
||||
|
if (parameter != elementType) |
||||
|
{ |
||||
|
throw new XamlTypeSystemException($"Expected parameter of type {elementType}, got {parameter} instead."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
_constructor = constructor; |
||||
|
_values = values; |
||||
|
|
||||
|
Type = new XamlAstClrTypeReference(lineInfo, type, false); |
||||
|
} |
||||
|
|
||||
|
public IXamlAstTypeReference Type { get; } |
||||
|
|
||||
|
public XamlILNodeEmitResult Emit(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) |
||||
|
{ |
||||
|
foreach (var value in _values) |
||||
|
{ |
||||
|
codeGen.Ldc_R8(value); |
||||
|
} |
||||
|
|
||||
|
codeGen.Newobj(_constructor); |
||||
|
|
||||
|
return XamlILNodeEmitResult.Type(0, Type.GetClrType()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1 +1 @@ |
|||||
Subproject commit 5420df861ce6f2be5ead9efa078fe7242ce88f18 |
Subproject commit ea80a607c5e9d8f000160dbbb48c27ed4cfafbc9 |
||||
Loading…
Reference in new issue