public XamlILNodeEmitResult Emit(IXamlAstNode node, XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { if (!(node is HandleRootObjectScopeNode)) { return(null); } var types = context.GetAvaloniaTypes(); var next = codeGen.DefineLabel(); var scopeField = context.RuntimeContext.ContextType.Fields.First(f => f.Name == AvaloniaXamlIlLanguage.ContextNameScopeFieldName); using (var local = codeGen.LocalsPool.GetLocal(types.StyledElement)) { codeGen .Isinst(types.StyledElement) .Dup() .Stloc(local.Local) .Brfalse(next) .Ldloc(local.Local) .Ldloc(context.ContextLocal) .Ldfld(scopeField) .EmitCall(types.NameScopeSetNameScope, true) .MarkLabel(next) .Ldloc(context.ContextLocal) .Ldfld(scopeField) .EmitCall(types.INameScopeComplete, true); } return(XamlILNodeEmitResult.Void(1)); }
public XamlILNodeEmitResult Emit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { codeGen.Ldstr(_color); codeGen.EmitCall(_method); return(XamlILNodeEmitResult.Type(0, Type.GetClrType())); }
public virtual XamlILNodeEmitResult Emit( XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { codeGen.Newobj(_constructor); return(XamlILNodeEmitResult.Type(0, Type.GetClrType())); }
public XamlILNodeEmitResult Emit(XamlIlEmitContext context, IXamlILEmitter codeGen) { if (!XamlIlAvaloniaPropertyHelper.Emit(context, codeGen, Property)) { throw new XamlX.XamlLoadException(Property.Name + " is not an AvaloniaProperty", this); } return(XamlILNodeEmitResult.Type(0, Type.GetClrType())); }
public XamlILNodeEmitResult Emit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { codeGen .Ldc_R8(_gridLength.Value) .Ldc_I4((int)_gridLength.GridUnitType) .Newobj(_types.GridLengthConstructorValueType); return(XamlILNodeEmitResult.Type(0, Type.GetClrType())); }
public XamlILNodeEmitResult Emit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { codeGen .Ldloc(context.ContextLocal) .Castclass(context.Configuration.TypeMappings.UriContextProvider) .EmitCall(context.Configuration.TypeMappings.UriContextProvider.FindMethod( "get_BaseUri", _types.Uri, false)) .Ldstr(_text) .Newobj(_types.FontFamilyConstructorUriName); return(XamlILNodeEmitResult.Type(0, _types.FontFamily)); }
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())); }
public XamlILNodeEmitResult Emit(IXamlAstNode node, XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { if (!(node is HandleRootObjectScopeNode)) { return(null); } var controlType = context.Configuration.TypeSystem.FindType("Robust.Client.UserInterface.Control"); var next = codeGen.DefineLabel(); var dontAbsorb = codeGen.DefineLabel(); var end = codeGen.DefineLabel(); var contextScopeField = context.RuntimeContext.ContextType.Fields.First(f => f.Name == XamlCompiler.ContextNameScopeFieldName); var controlNameScopeField = controlType.Fields.First(f => f.Name == "NameScope"); var nameScopeType = context.Configuration.TypeSystem .FindType("Robust.Client.UserInterface.XAML.NameScope"); var nameScopeCompleteMethod = nameScopeType.Methods.First(m => m.Name == "Complete"); var nameScopeAbsorbMethod = nameScopeType.Methods.First(m => m.Name == "Absorb"); using (var local = codeGen.LocalsPool.GetLocal(controlType)) { codeGen .Isinst(controlType) .Dup() .Stloc(local.Local) //store control in local field .Brfalse(next) //if control is null, move to next (this should never happen but whatev, avalonia does it) .Ldloc(context.ContextLocal) .Ldfld(contextScopeField) .Ldloc(local.Local) //load control from local field .Ldfld(controlNameScopeField) //load namescope field from control .EmitCall(nameScopeAbsorbMethod, true) .Ldloc(local.Local) //load control .Ldloc(context.ContextLocal) //load contextObject .Ldfld(contextScopeField) //load namescope field from context obj .Stfld(controlNameScopeField) //store namescope field in control .MarkLabel(next) .Ldloc(context.ContextLocal) .Ldfld(contextScopeField) .EmitCall(nameScopeCompleteMethod, true); //set the namescope as complete } return(XamlILNodeEmitResult.Void(1)); }
public XamlILNodeEmitResult Emit(XamlEmitContext <IXamlILEmitter, XamlILNodeEmitResult> context, IXamlILEmitter codeGen) { codeGen.Newobj(_constructor); codeGen .Dup() .Ldc_I4(_values.Count) .EmitCall(_listSetCapacityMethod); foreach (var value in _values) { codeGen.Dup(); context.Emit(value, codeGen, _elementType); codeGen.EmitCall(_listAddMethod); } return(XamlILNodeEmitResult.Type(0, Type.GetClrType())); }
public XamlILNodeEmitResult Emit(XamlIlEmitContext context, IXamlILEmitter codeGen) { codeGen.Ldsfld(_field); return(XamlILNodeEmitResult.Type(0, _field.FieldType)); }