Example #1
0
 public override void EmitWithArguments(
     XamlEmitContextWithLocals <IXamlILEmitter, XamlILNodeEmitResult> context,
     IXamlILEmitter emitter,
     IReadOnlyList <IXamlAstValueNode> arguments)
 {
     emitter.Ldsfld(AvaloniaProperty);
     context.Emit(arguments[1], emitter, Parameters[1]);
     EmitAnchorAndBind(emitter);
 }
 protected override void DoEmit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen)
 {
     codeGen.Ldsfld(PropertyFiled);
     context.Emit(Value, codeGen, context.Configuration.WellKnownTypes.Object);
     EmitCall(context, codeGen,
              m => m.Name == "PropertyEquals" &&
              m.Parameters.Count == 3 &&
              m.Parameters[1].FullName == "Avalonia.AvaloniaProperty" &&
              m.Parameters[2].Equals(context.Configuration.WellKnownTypes.Object));
 }
Example #3
0
        public static bool Emit(XamlIlEmitContext context, IXamlILEmitter emitter, XamlAstClrProperty property)
        {
            if (property is IXamlIlAvaloniaProperty ap)
            {
                emitter.Ldsfld(ap.AvaloniaProperty);
                return(true);
            }
            var type  = property.DeclaringType;
            var name  = property.Name + "Property";
            var found = type.Fields.FirstOrDefault(f => f.IsStatic && f.Name == name);

            if (found == null)
            {
                return(false);
            }

            emitter.Ldsfld(found);
            return(true);
        }
Example #4
0
            private void EmitSetValue(IXamlILEmitter emitter)
            {
                // Ignore the instance and load one from the static field to avoid extra local variable
                var unsetValue = Types.AvaloniaProperty.Fields.First(f => f.Name == "UnsetValue");

                emitter
                .Ldsfld(AvaloniaProperty)
                .Ldsfld(unsetValue)
                .Ldc_I4(0)
                .EmitCall(Types.AvaloniaObjectSetValueMethod, true);
            }
Example #5
0
        public static bool Emit(XamlIlEmitContext context, IXamlILEmitter emitter, IXamlProperty property)
        {
            var type  = (property.Getter ?? property.Setter).DeclaringType;
            var name  = property.Name + "Property";
            var found = type.Fields.FirstOrDefault(f => f.IsStatic && f.Name == name);

            if (found == null)
            {
                return(false);
            }

            emitter.Ldsfld(found);
            return(true);
        }
Example #6
0
                public void EmitCall(IXamlILEmitter emitter)
                {
                    var method = Parent._avaloniaObject
                                 .FindMethod(m => m.IsPublic && !m.IsStatic && m.Name == "GetValue"
                                             &&
                                             m.Parameters.Count == 1 &&
                                             m.Parameters[0].Equals(Parent._avaloniaPropertyType));

                    if (method == null)
                    {
                        throw new XamlTypeSystemException(
                                  "Unable to find T GetValue<T>(AvaloniaProperty<T>) on AvaloniaObject");
                    }
                    emitter
                    .Ldsfld(Parent._field)
                    .EmitCall(method);
                    if (Parent.PropertyType.IsValueType)
                    {
                        emitter.Unbox_Any(Parent.PropertyType);
                    }
                }
 public void Emit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen)
 => codeGen
 .Ldsfld(_field)
 .EmitCall(context.GetAvaloniaTypes()
           .PropertyPathBuilder.FindMethod(m => m.Name == "Property"));
Example #8
0
 public XamlILNodeEmitResult Emit(XamlIlEmitContext context, IXamlILEmitter codeGen)
 {
     codeGen.Ldsfld(_field);
     return(XamlILNodeEmitResult.Type(0, _field.FieldType));
 }