public override MethodVisitor VisitMethod(AccessFlags access, string name, string descriptor , string signature, string[] exceptions) { MethodVisitor methodVisitor; if ("<clinit>".Equals(name)) { var newAccess = AccessFlags.Private + (int)AccessFlags.Static; var newName = renamedClinitMethodPrefix + numClinitMethods++; methodVisitor = base.VisitMethod(newAccess, newName, descriptor, signature, exceptions ); if (mergedClinitVisitor == null) { mergedClinitVisitor = base.VisitMethod(newAccess, name, descriptor, null, null); } mergedClinitVisitor.VisitMethodInsn(OpcodesConstants.Invokestatic, owner, newName , descriptor, false); } else { methodVisitor = base.VisitMethod(access, name, descriptor, signature, exceptions); } return(methodVisitor); }
public GetFieldBinder(string name, RuntimeTypeHandle classContext, RuntimeTypeHandle returnType, AccessFlags access) { _name = name; _returnType = Type.GetTypeFromHandle(returnType); // should correspond to AccessFlags _classContext = Type.GetTypeFromHandle(classContext); _access = access & AccessFlags.ReadMask; }
/// <summary>Initializes a new instance of the <see cref="AccessRightInfo"/> struct.</summary> /// <param name="mask">The access mask.</param> /// <param name="name">The display name.</param> /// <param name="flags">The access flags.</param> public AccessRightInfo(uint mask, string name, AccessFlags flags) { guidObjectType = NativeMethods.EmptyGuidPtr; Mask = mask; Name = name; Flags = flags; }
public SubpassDependency2 ( StructureType sType = StructureType.SubpassDependency2, void *pNext = default, uint srcSubpass = default, uint dstSubpass = default, PipelineStageFlags srcStageMask = default, PipelineStageFlags dstStageMask = default, AccessFlags srcAccessMask = default, AccessFlags dstAccessMask = default, DependencyFlags dependencyFlags = default, int viewOffset = default ) { SType = sType; PNext = pNext; SrcSubpass = srcSubpass; DstSubpass = dstSubpass; SrcStageMask = srcStageMask; DstStageMask = dstStageMask; SrcAccessMask = srcAccessMask; DstAccessMask = dstAccessMask; DependencyFlags = dependencyFlags; ViewOffset = viewOffset; }
/* Methods */ #region Data Binding /// <summary> /// The bind data. /// </summary> private void BindData() { if (Request.QueryString.GetFirstOrDefault("i") != null) { // load access mask using (DataTable dt = DB.accessmask_list(PageContext.PageBoardID, Request.QueryString.GetFirstOrDefault("i"))) { // we need just one DataRow row = dt.Rows[0]; // get access mask properties this.Name.Text = (string)row["Name"]; this.SortOrder.Text = row["SortOrder"].ToString(); // get flags var flags = new AccessFlags(row["Flags"]); this.ReadAccess.Checked = flags.ReadAccess; this.PostAccess.Checked = flags.PostAccess; this.ReplyAccess.Checked = flags.ReplyAccess; this.PriorityAccess.Checked = flags.PriorityAccess; this.PollAccess.Checked = flags.PollAccess; this.VoteAccess.Checked = flags.VoteAccess; this.ModeratorAccess.Checked = flags.ModeratorAccess; this.EditAccess.Checked = flags.EditAccess; this.DeleteAccess.Checked = flags.DeleteAccess; this.UploadAccess.Checked = flags.UploadAccess; this.DownloadAccess.Checked = flags.DownloadAccess; } } DataBind(); }
protected void Page_Load( object sender, System.EventArgs e ) { if ( !IsPostBack ) { PageLinks.AddLink( PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink( YAF.Classes.Utils.ForumPages.forum ) ); PageLinks.AddLink( "Administration", YAF.Classes.Utils.YafBuildLink.GetLink( YAF.Classes.Utils.ForumPages.admin_admin ) ); PageLinks.AddLink( "Access Masks", "" ); BindData(); if ( Request.QueryString ["i"] != null ) { using (DataTable dt = YAF.Classes.Data.DB.accessmask_list(PageContext.PageBoardID, Request.QueryString["i"])) { DataRow row = dt.Rows[0]; AccessFlags flags = new AccessFlags(row["Flags"]); Name.Text = (string)row["Name"]; ReadAccess.Checked = flags.ReadAccess; PostAccess.Checked = flags.PostAccess; ReplyAccess.Checked = flags.ReplyAccess; PriorityAccess.Checked = flags.PriorityAccess; PollAccess.Checked = flags.PollAccess; VoteAccess.Checked = flags.VoteAccess; ModeratorAccess.Checked = flags.ModeratorAccess; EditAccess.Checked = flags.EditAccess; DeleteAccess.Checked = flags.DeleteAccess; UploadAccess.Checked = flags.UploadAccess; DownloadAccess.Checked = flags.DownloadAccess; } } } }
public override ModuleVisitor VisitModule(string name, AccessFlags flags, string version) { var moduleVisitor = base.VisitModule(remapper.MapModuleName(name), flags , version); return(moduleVisitor == null ? null : CreateModuleRemapper(moduleVisitor)); }
private unsafe void Transition( CommandBuffer commandBuffer, Image image, AccessFlags srcAccess, AccessFlags dstAccess, ImageLayout srcLayout, ImageLayout dstLayout) { var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, 1, 0, 1); var barrier = new ImageMemoryBarrier() { SType = StructureType.ImageMemoryBarrier, SrcAccessMask = srcAccess, DstAccessMask = dstAccess, OldLayout = srcLayout, NewLayout = dstLayout, SrcQueueFamilyIndex = Vk.QueueFamilyIgnored, DstQueueFamilyIndex = Vk.QueueFamilyIgnored, Image = image, SubresourceRange = subresourceRange }; _gd.Api.CmdPipelineBarrier( commandBuffer, PipelineStageFlags.PipelineStageTopOfPipeBit, PipelineStageFlags.PipelineStageAllCommandsBit, 0, 0, null, 0, null, 1, barrier); }
/// <summary> /// Constructs a new /// <see cref="TraceSignatureVisitor" /> /// . /// </summary> /// <param name="accessFlags"> /// for class type signatures, the access flags of the class. /// </param> public TraceSignatureVisitor(AccessFlags accessFlags) : base(VisitorAsmApiVersion.Asm7) { /* latest api = */ isInterface = accessFlags.HasFlagFast(AccessFlags.Interface); declaration = new StringBuilder(); }
private void SetupProperties(MetadataJavaMethod meta) { _metaFlags = (AccessFlags)meta.AccessFlags; _metaName = meta.Name; _metaType = Type.GetType(meta.ReturnType); _metaParams = meta.Parameters.Select(c => c.ToDataClass()).ToArray(); }
public override FieldVisitor VisitField(AccessFlags access, string name, string desc, string signature, object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSvuid) { if ("serialVersionUID".Equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSvuid = false; hasSvuid = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if (access.HasNotFlagFast(AccessFlags.Private) || (access & (AccessFlags.Static | AccessFlags.Transient)) == 0) { var mods = access & (AccessFlags.Public | AccessFlags.Private | AccessFlags.Protected | AccessFlags.Static | AccessFlags .Final | AccessFlags.Volatile | AccessFlags.Transient); svuidFields.Add(new Item(name, mods, desc)); } } return(base.VisitField(access, name, desc, signature, value)); }
protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum)); PageLinks.AddLink("Administration", YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.admin_admin)); PageLinks.AddLink("Access Masks", ""); BindData(); if (Request.QueryString ["i"] != null) { using (DataTable dt = YAF.Classes.Data.DB.accessmask_list(PageContext.PageBoardID, Request.QueryString["i"])) { DataRow row = dt.Rows[0]; AccessFlags flags = new AccessFlags(row["Flags"]); Name.Text = (string)row["Name"]; ReadAccess.Checked = flags.ReadAccess; PostAccess.Checked = flags.PostAccess; ReplyAccess.Checked = flags.ReplyAccess; PriorityAccess.Checked = flags.PriorityAccess; PollAccess.Checked = flags.PollAccess; VoteAccess.Checked = flags.VoteAccess; ModeratorAccess.Checked = flags.ModeratorAccess; EditAccess.Checked = flags.EditAccess; DeleteAccess.Checked = flags.DeleteAccess; UploadAccess.Checked = flags.UploadAccess; DownloadAccess.Checked = flags.DownloadAccess; } } } }
public static unsafe void InsertBufferBarrier( VulkanRenderer gd, CommandBuffer commandBuffer, VkBuffer buffer, AccessFlags srcAccessMask, AccessFlags dstAccessMask, PipelineStageFlags srcStageMask, PipelineStageFlags dstStageMask, int offset, int size) { BufferMemoryBarrier memoryBarrier = new BufferMemoryBarrier() { SType = StructureType.BufferMemoryBarrier, SrcAccessMask = srcAccessMask, DstAccessMask = dstAccessMask, SrcQueueFamilyIndex = Vk.QueueFamilyIgnored, DstQueueFamilyIndex = Vk.QueueFamilyIgnored, Buffer = buffer, Offset = (ulong)offset, Size = (ulong)size }; gd.Api.CmdPipelineBarrier( commandBuffer, srcStageMask, dstStageMask, 0, 0, null, 1, memoryBarrier, 0, null); }
/// <summary> /// 根据枚举获取访问级别 /// </summary> /// <param name="enumAccess">访问级别枚举</param> /// <returns></returns> public static string GetAccess(AccessFlags enumAccess) { switch (enumAccess) { case AccessFlags.Public: return("public "); case AccessFlags.Private: return("private "); case AccessFlags.Protected: return("protected "); case AccessFlags.Internal: return("internal "); case AccessFlags.InternalAndProtected: return("internal protected "); default: return("internal "); } }
public ImageMemoryBarrier ( StructureType sType = StructureType.ImageMemoryBarrier, void *pNext = default, AccessFlags srcAccessMask = default, AccessFlags dstAccessMask = default, ImageLayout oldLayout = default, ImageLayout newLayout = default, uint srcQueueFamilyIndex = default, uint dstQueueFamilyIndex = default, Image image = default, ImageSubresourceRange subresourceRange = default ) { SType = sType; PNext = pNext; SrcAccessMask = srcAccessMask; DstAccessMask = dstAccessMask; OldLayout = oldLayout; NewLayout = newLayout; SrcQueueFamilyIndex = srcQueueFamilyIndex; DstQueueFamilyIndex = dstQueueFamilyIndex; Image = image; SubresourceRange = subresourceRange; }
/// <summary> /// Returns the total size in bytes of all the attributes that correspond to the given field, /// method or class access flags and signature. /// </summary> /// <remarks> /// Returns the total size in bytes of all the attributes that correspond to the given field, /// method or class access flags and signature. This size includes the 6 header bytes /// (attribute_name_index and attribute_length) per attribute. Also adds the attribute type names /// to the constant pool. /// </remarks> /// <param name="symbolTable"> /// where the constants used in the attributes must be stored. /// </param> /// <param name="accessFlags">some field, method or class access flags.</param> /// <param name="signatureIndex"> /// the constant pool index of a field, method of class signature. /// </param> /// <returns> /// the size of all the attributes in bytes. This size includes the size of the attribute /// headers. /// </returns> internal static int ComputeAttributesSize(SymbolTable symbolTable, AccessFlags accessFlags , int signatureIndex) { var size = 0; // Before Java 1.5, synthetic fields are represented with a Synthetic attribute. if (accessFlags.HasFlagFast(AccessFlags.Synthetic) && symbolTable.GetMajorVersion () < OpcodesConstants.V1_5) { // Synthetic attributes always use 6 bytes. symbolTable.AddConstantUtf8(Constants.Synthetic); size += 6; } if (signatureIndex != 0) { // Signature attributes always use 8 bytes. symbolTable.AddConstantUtf8(Constants.Signature); size += 8; } // ACC_DEPRECATED is ASM specific, the ClassFile format uses a Deprecated attribute instead. if (accessFlags.HasFlagFast(AccessFlags.Deprecated)) { // Deprecated attributes always use 6 bytes. symbolTable.AddConstantUtf8(Constants.Deprecated); size += 6; } return(size); }
/// <summary>Visit an open package of the current module.</summary> /// <param name="packaze">the internal name of the opened package.</param> /// <param name="access"> /// the access flag of the opened package, valid values are among /// <c>ACC_SYNTHETIC</c> /// and /// <c>ACC_MANDATED</c> /// . /// </param> /// <param name="modules"> /// the fully qualified names (using dots) of the modules that can use deep /// reflection to the classes of the open package, or /// <literal>null</literal> /// . /// </param> public virtual void VisitOpen(string packaze, AccessFlags access, params string[] modules) { if (mv != null) { mv.VisitOpen(packaze, access, modules); } }
public GetFieldBinder(string name, RuntimeTypeHandle classContext, RuntimeTypeHandle returnType, AccessFlags access) { _name = name; _returnType = Type.GetTypeFromHandle(returnType); // should correspond to AccessFlags _classContext = Type.GetTypeFromHandle(classContext); _access = access; }
public override ModuleVisitor VisitModule(string name, AccessFlags flags, string version) { var modulePrinter = p.VisitModule(name, flags, version); return(new TraceModuleVisitor(base.VisitModule(name, flags, version), modulePrinter )); }
/// <summary>Visits a dependence of the current module.</summary> /// <param name="module">the fully qualified name (using dots) of the dependence.</param> /// <param name="access"> /// the access flag of the dependence among /// <c>ACC_TRANSITIVE</c> /// , /// <c>ACC_STATIC_PHASE</c> /// , /// <c>ACC_SYNTHETIC</c> /// and /// <c>ACC_MANDATED</c> /// . /// </param> /// <param name="version"> /// the module version at compile time, or /// <literal>null</literal> /// . /// </param> public virtual void VisitRequire(string module, AccessFlags access, string version) { if (mv != null) { mv.VisitRequire(module, access, version); } }
/// <summary> /// Create an android InnerClass annotation and attach it to the given provider. /// </summary> public static void AddInnerClassAnnotation(this IAnnotationProvider provider, string simpleName, AccessFlags accessFlags) { var annotation = new Annotation { Type = new ClassReference("dalvik/annotation/InnerClass"), Visibility = AnnotationVisibility.System }; annotation.Arguments.Add(new AnnotationArgument("name", simpleName)); annotation.Arguments.Add(new AnnotationArgument("accessFlags", (int)accessFlags)); provider.Annotations.Add(annotation); }
/* Methods */ /// <summary> /// Binds the data. /// </summary> private void BindData() { if (this.Request.QueryString.GetFirstOrDefault("i") != null) { // load access mask using (DataTable dataTable = this.GetRepository <AccessMask>().List(this.Request.QueryString.GetFirstOrDefaultAs <int>("i"))) { // we need just one DataRow row = dataTable.Rows[0]; // get access mask properties this.Name.Text = (string)row["Name"]; this.SortOrder.Text = row["SortOrder"].ToString(); // get flags var flags = new AccessFlags(row["Flags"]); this.ReadAccess.Checked = flags.ReadAccess; this.PostAccess.Checked = flags.PostAccess; this.ReplyAccess.Checked = flags.ReplyAccess; this.PriorityAccess.Checked = flags.PriorityAccess; this.PollAccess.Checked = flags.PollAccess; this.VoteAccess.Checked = flags.VoteAccess; this.ModeratorAccess.Checked = flags.ModeratorAccess; this.EditAccess.Checked = flags.EditAccess; this.DeleteAccess.Checked = flags.DeleteAccess; this.UploadAccess.Checked = flags.UploadAccess; this.DownloadAccess.Checked = flags.DownloadAccess; } } this.DataBind(); }
public override MethodVisitor VisitMethod(AccessFlags access, string name, string descriptor , string signature, string[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSvuid) { if (Clinit.Equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. var mods = access & (AccessFlags.Public | AccessFlags.Private | AccessFlags.Protected | AccessFlags.Static | AccessFlags .Final | AccessFlags.Synchronized | AccessFlags.Native | AccessFlags .Abstract | AccessFlags.Strict); if (access.HasNotFlagFast(AccessFlags.Private)) { if ("<init>".Equals(name)) { svuidConstructors.Add(new Item(name, mods, descriptor)); } else if (!Clinit.Equals(name)) { svuidMethods.Add(new Item(name, mods, descriptor)); } } } return(base.VisitMethod(access, name, descriptor, signature, exceptions)); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { if (this.Request.QueryString.GetFirstOrDefault("i") != null) { var accessMask = this.GetRepository <AccessMask>() .ListTyped(this.Request.QueryString.GetFirstOrDefaultAs <int>("i")) .FirstOrDefault(); // get access mask properties this.Name.Text = accessMask.Name; this.SortOrder.Text = accessMask.SortOrder.ToString(); // get flags var flags = new AccessFlags(accessMask.Flags); this.ReadAccess.Checked = flags.ReadAccess; this.PostAccess.Checked = flags.PostAccess; this.ReplyAccess.Checked = flags.ReplyAccess; this.PriorityAccess.Checked = flags.PriorityAccess; this.PollAccess.Checked = flags.PollAccess; this.VoteAccess.Checked = flags.VoteAccess; this.ModeratorAccess.Checked = flags.ModeratorAccess; this.EditAccess.Checked = flags.EditAccess; this.DeleteAccess.Checked = flags.DeleteAccess; this.UploadAccess.Checked = flags.UploadAccess; this.DownloadAccess.Checked = flags.DownloadAccess; } this.DataBind(); }
/// <summary> /// Insert a memory dependency. /// </summary> /// <param name="sourceStageMask"> /// </param> /// <param name="destinationStageMask"> /// </param> /// <param name="sourceAccessMask"> /// </param> /// <param name="destinationAccessMask"> /// </param> /// <param name="oldLayout"> /// </param> /// <param name="newLayout"> /// </param> /// <param name="sourceQueueFamilyIndex"> /// </param> /// <param name="destinationQueueFamilyIndex"> /// </param> /// <param name="image"> /// </param> /// <param name="subresourceRange"> /// </param> /// <param name="dependencyFlags"> /// </param> public unsafe void PipelineBarrier(PipelineStageFlags sourceStageMask, PipelineStageFlags destinationStageMask, AccessFlags sourceAccessMask, AccessFlags destinationAccessMask, ImageLayout oldLayout, ImageLayout newLayout, uint sourceQueueFamilyIndex, uint destinationQueueFamilyIndex, Image image, ImageSubresourceRange subresourceRange, DependencyFlags dependencyFlags = DependencyFlags.None) { try { Interop.ImageMemoryBarrier marshalledImageMemoryBarrier = default; marshalledImageMemoryBarrier.SType = StructureType.ImageMemoryBarrier; marshalledImageMemoryBarrier.Next = null; marshalledImageMemoryBarrier.SourceAccessMask = sourceAccessMask; marshalledImageMemoryBarrier.DestinationAccessMask = destinationAccessMask; marshalledImageMemoryBarrier.OldLayout = oldLayout; marshalledImageMemoryBarrier.NewLayout = newLayout; marshalledImageMemoryBarrier.SourceQueueFamilyIndex = sourceQueueFamilyIndex; marshalledImageMemoryBarrier.DestinationQueueFamilyIndex = destinationQueueFamilyIndex; marshalledImageMemoryBarrier.Image = image.handle; marshalledImageMemoryBarrier.SubresourceRange = subresourceRange; Interop.VkCommandBufferPipelineBarrierDelegate commandDelegate = commandCache.GetCommandDelegate <Interop.VkCommandBufferPipelineBarrierDelegate>("vkCmdPipelineBarrier", ""); commandDelegate(this.handle, sourceStageMask, destinationStageMask, dependencyFlags, 0, null, 0, null, 1, &marshalledImageMemoryBarrier); } finally { Interop.HeapUtil.FreeAll(); } }
public override FieldVisitor VisitField(AccessFlags access, string name, string descriptor , string signature, object value) { var fieldPrinter = p.VisitField(access, name, descriptor, signature, value); return(new TraceFieldVisitor(base.VisitField(access, name, descriptor, signature, value), fieldPrinter)); }
/// <summary> /// Constructs a new /// <see cref="AdviceAdapter" /> /// . /// </summary> /// <param name="api"> /// the ASM API version implemented by this visitor. Must be one of /// <see cref="Opcodes.Asm4" /> /// , /// <see cref="Opcodes.Asm5" /> /// , /// <see cref="Opcodes.Asm6" /> /// or /// <see cref="Opcodes.Asm7" /> /// . /// </param> /// <param name="methodVisitor"> /// the method visitor to which this adapter delegates calls. /// </param> /// <param name="access"> /// the method's access flags (see /// <see cref="Opcodes" /> /// ). /// </param> /// <param name="name">the method's name.</param> /// <param name="descriptor"> /// the method's descriptor (see /// <see cref="Org.Objectweb.Asm.Type">Type</see> /// ). /// </param> protected internal AdviceAdapter(VisitorAsmApiVersion api, MethodVisitor methodVisitor, AccessFlags access , string name, string descriptor) : base(api, methodVisitor, access, name, descriptor) { methodAccess = access; methodDesc = descriptor; isConstructor = "<init>".Equals(name); }
/// <summary>Visits the header of the class.</summary> /// <param name="version"> /// the class version. The minor version is stored in the 16 most significant bits, /// and the major version in the 16 least significant bits. /// </param> /// <param name="access"> /// the class's access flags (see /// <see cref="Opcodes" /> /// ). This parameter also indicates if /// the class is deprecated. /// </param> /// <param name="name"> /// the internal name of the class (see /// <see cref="Type.GetInternalName()" /> /// ). /// </param> /// <param name="signature"> /// the signature of this class. May be /// <literal>null</literal> /// if the class is not a /// generic one, and does not extend or implement generic classes or interfaces. /// </param> /// <param name="superName"> /// the internal of name of the super class (see /// <see cref="Type.GetInternalName()" /> /// ). /// For interfaces, the super class is /// <see cref="object" /> /// . May be /// <literal>null</literal> /// , but only for the /// <see cref="object" /> /// class. /// </param> /// <param name="interfaces"> /// the internal names of the class's interfaces (see /// <see cref="Type.GetInternalName()" /> /// ). May be /// <literal>null</literal> /// . /// </param> public virtual void Visit(int version, AccessFlags access, string name, string signature, string superName, string[] interfaces) { if (cv != null) { cv.Visit(version, access, name, signature, superName, interfaces); } }
/// <summary>Visits information about an inner class.</summary> /// <remarks> /// Visits information about an inner class. This inner class is not necessarily a member of the /// class being visited. /// </remarks> /// <param name="name"> /// the internal name of an inner class (see /// <see cref="Type.GetInternalName()" /> /// ). /// </param> /// <param name="outerName"> /// the internal name of the class to which the inner class belongs (see /// <see cref="Type.GetInternalName()" /> /// ). May be /// <literal>null</literal> /// for not member classes. /// </param> /// <param name="innerName"> /// the (simple) name of the inner class inside its enclosing class. May be /// <literal>null</literal> /// for anonymous inner classes. /// </param> /// <param name="access"> /// the access flags of the inner class as originally declared in the enclosing /// class. /// </param> public virtual void VisitInnerClass(string name, string outerName, string innerName , AccessFlags access) { if (cv != null) { cv.VisitInnerClass(name, outerName, innerName, access); } }
/// <summary> /// Initializes a new instance of the <see cref="AccessRightInfo"/> struct. /// </summary> /// <param name="mask">The access mask.</param> /// <param name="name">The display name.</param> /// <param name="flags">The access flags.</param> public AccessRightInfo(uint mask, string name, AccessFlags flags) { this.guidObjectType = Helper.EmptyGuidPtr; this.Mask = mask; this.Name = name; this.Flags = flags; }
/// <summary> /// Create new access flags by including or excluding the given delta. /// </summary> internal static AccessFlags Set(this AccessFlags original, bool set, AccessFlags delta) { if (set) { return original | delta; } return original & ~delta; }
/// <summary> /// Create new access flags by including or excluding the given delta. /// </summary> internal static AccessFlags Set(this AccessFlags original, bool set, AccessFlags delta) { if (set) { return(original | delta); } return(original & ~delta); }
/// <summary> /// Constructs a new /// <see cref="InnerClassNode" /> /// . /// </summary> /// <param name="name"> /// the internal name of an inner class (see /// <see cref="Type.GetInternalName()" /> /// ). /// </param> /// <param name="outerName"> /// the internal name of the class to which the inner class belongs (see /// <see cref="Type.GetInternalName()" /> /// ). May be /// <literal>null</literal> /// . /// </param> /// <param name="innerName"> /// the (simple) name of the inner class inside its enclosing class. May be /// <literal>null</literal> /// for anonymous inner classes. /// </param> /// <param name="access"> /// the access flags of the inner class as originally declared in the enclosing /// class. /// </param> public InnerClassNode(string name, string outerName, string innerName, AccessFlags access ) { this.name = name; this.outerName = outerName; this.innerName = innerName; this.access = access; }
public override void VisitRequire(string module, AccessFlags access, string version) { if (requires == null) { requires = new List <ModuleRequireNode>(5); } requires.Add(new ModuleRequireNode(module, access, version)); }
public BufferMemoryBarrier(Buffer buffer, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, uint sourceQueueFamilyIndex, uint destinationQueueFamilyIndex, ulong offset = 0, ulong size = Vulkan.WholeSize) { StructureType = StructureType.BufferMemoryBarrier; Next = IntPtr.Zero; Buffer = buffer; Offset = offset; Size = size; SourceAccessMask = sourceAccesMask; DestinationAccessMask = destinationAccessMask; SourceQueueFamilyIndex = sourceQueueFamilyIndex; DestinationQueueFamilyIndex = destinationQueueFamilyIndex; }
public ImageMemoryBarrier(Image image, ImageLayout oldLayout, ImageLayout newLayout, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, uint sourceQueueFamilyIndex, uint destinationQueueFamilyIndex, ImageSubresourceRange subresourceRange) { StructureType = StructureType.ImageMemoryBarrier; Next = IntPtr.Zero; Image = image; SubresourceRange = subresourceRange; OldLayout = oldLayout; NewLayout = newLayout; SourceAccessMask = sourceAccesMask; DestinationAccessMask = destinationAccessMask; SourceQueueFamilyIndex = sourceQueueFamilyIndex; DestinationQueueFamilyIndex = destinationQueueFamilyIndex; }
private string AccessFlagsAsString(AccessFlags accessFlags) { string result = accessFlags.HasFlag(AccessFlags.Public) ? "public " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Private) ? "private " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Protected) ? "protected " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Static) ? "static " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Final) ? "final " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Volatile) ? "volatile " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Transient) ? "transient " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Synthetic) ? "synthetic " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Enum) ? "enum " : string.Empty; return result.Trim(); }
private string AccessFlagsAsString(AccessFlags accessFlags) { string result = accessFlags.HasFlag(AccessFlags.Public) ? "public " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Private) ? "private " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Protected) ? "protected " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Static) ? "static " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Final) ? "final " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Interface) ? "interface " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Abstract) ? "abstract " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Synthetic) ? "synthetic " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Annotation) ? "annotation " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Enum) ? "enum " : string.Empty; return result.Trim(); }
public AuthorizationService(IConfig config, Scene scene) { m_Scene = scene; m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); m_GridService = scene.GridService; if (config != null) { string accessStr = config.GetString("Region_" + scene.RegionInfo.RegionName.Replace(' ', '_'), String.Empty); if (accessStr != string.Empty) { try { m_accessValue = (AccessFlags)Enum.Parse(typeof(AccessFlags), accessStr); } catch (ArgumentException) { m_log.WarnFormat("[AuthorizationService]: {0} is not a valid access flag", accessStr); } } m_log.DebugFormat("[AuthorizationService]: Region {0} access restrictions: {1}", m_Scene.RegionInfo.RegionName, m_accessValue); } }
public ImageMemoryBarrier(Image image, ImageLayout oldLayout, ImageLayout newLayout, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, ImageSubresourceRange subresourceRange) : this(image, oldLayout, newLayout, sourceAccesMask, destinationAccessMask, Vulkan.QueueFamilyIgnored, Vulkan.QueueFamilyIgnored, subresourceRange) { }
public static IEnumerable<ENUM_SERVICE_STATUS_PROCESS> GetServices( string machineName, string databaseName, AccessFlags accessFlags, // From OpenSCManager ServiceEnumType infoLevel, ServiceType serviceType, ServiceStateRequest serviceStateRequest // From EnumServicesStatusEx ) { List<ENUM_SERVICE_STATUS_PROCESS> results = new List<ENUM_SERVICE_STATUS_PROCESS>(); IntPtr handle = OpenSCManager(machineName, databaseName, accessFlags); if (handle == IntPtr.Zero) { return null; } IntPtr serviceStatusBuffer = IntPtr.Zero; try { uint bytesNeeded = 0; uint servicesReturned = 0; uint resumeHandle = 0; if (!EnumServicesStatusEx(handle, infoLevel, serviceType, serviceStateRequest, IntPtr.Zero, 0, out bytesNeeded, out servicesReturned, ref resumeHandle, null)) { // allocate our memory to receive the data for all the services (including the names) serviceStatusBuffer = Marshal.AllocHGlobal((int)bytesNeeded); if (!EnumServicesStatusEx(handle, infoLevel, serviceType, serviceStateRequest, serviceStatusBuffer, bytesNeeded, out bytesNeeded, out servicesReturned, ref resumeHandle, null)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } ENUM_SERVICE_STATUS_PROCESS serviceStatus; // check if 64 bit system which has different pack sizes if (IntPtr.Size == 8) { long pointer = serviceStatusBuffer.ToInt64(); for (int i = 0; i < (int)servicesReturned; i++) { serviceStatus = (ENUM_SERVICE_STATUS_PROCESS)Marshal.PtrToStructure(new IntPtr(pointer), typeof(ENUM_SERVICE_STATUS_PROCESS)); results.Add(serviceStatus); // incremement by sizeof(ENUM_SERVICE_STATUS_PROCESS) allow Packing of 8 pointer += ENUM_SERVICE_STATUS_PROCESS.SizePack8; } } else { int pointer = serviceStatusBuffer.ToInt32(); for (int i = 0; i < (int)servicesReturned; i++) { serviceStatus = (ENUM_SERVICE_STATUS_PROCESS)Marshal.PtrToStructure(new IntPtr(pointer), typeof(ENUM_SERVICE_STATUS_PROCESS)); results.Add(serviceStatus); // incremement by sizeof(ENUM_SERVICE_STATUS_PROCESS) allow Packing of 4 pointer += ENUM_SERVICE_STATUS_PROCESS.SizePack4; } } } } catch (Exception /*e*/) { ; } finally { if (handle != IntPtr.Zero) { CloseServiceHandle(handle); } if (serviceStatusBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(serviceStatusBuffer); } } return results; }
internal Access( int mask, String name, AccessFlags flags) { this.Guid = IntPtr.Zero; this.Mask = mask; this.Name = name; this.Flags = flags; }
internal static string GetModifiersSourceCode(AccessFlags flags) { AccessFlags modifiers = GetModifiers(flags); StringBuilder resultBuilder = new StringBuilder(); foreach (AccessFlags value in Enum.GetValues(typeof(AccessFlags))) { if (0 != (value & modifiers)) { resultBuilder.Append(JavaSourceModifierByAccessFlag[value] + " "); } } return resultBuilder.ToString(); }
static extern bool OpenThreadToken( IntPtr ThreadHandle, AccessFlags DesiredAccess, bool OpenAsSelf, out IntPtr TokenHandle);
/// <summary> /// Explicitly recreate buffer with given data. Usually called after a <see cref="GraphicsDevice"/> reset. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dataPointer"></param> public unsafe void Recreate(IntPtr dataPointer) { var createInfo = new BufferCreateInfo { StructureType = StructureType.BufferCreateInfo, Size = (ulong)bufferDescription.SizeInBytes, Flags = BufferCreateFlags.None, }; createInfo.Usage |= BufferUsageFlags.TransferSource; // We always fill using transfer //if (bufferDescription.Usage != GraphicsResourceUsage.Immutable) createInfo.Usage |= BufferUsageFlags.TransferDestination; if ((ViewFlags & BufferFlags.VertexBuffer) != 0) { createInfo.Usage |= BufferUsageFlags.VertexBuffer; NativeAccessMask |= AccessFlags.VertexAttributeRead; NativePipelineStageMask |= PipelineStageFlags.VertexInput; } if ((ViewFlags & BufferFlags.IndexBuffer) != 0) { createInfo.Usage |= BufferUsageFlags.IndexBuffer; NativeAccessMask |= AccessFlags.IndexRead; NativePipelineStageMask |= PipelineStageFlags.VertexInput; } if ((ViewFlags & BufferFlags.ConstantBuffer) != 0) { createInfo.Usage |= BufferUsageFlags.UniformBuffer; NativeAccessMask |= AccessFlags.UniformRead; NativePipelineStageMask |= PipelineStageFlags.VertexShader | PipelineStageFlags.FragmentShader; } if ((ViewFlags & BufferFlags.ShaderResource) != 0) { createInfo.Usage |= BufferUsageFlags.UniformTexelBuffer; NativeAccessMask |= AccessFlags.ShaderRead; NativePipelineStageMask |= PipelineStageFlags.VertexShader | PipelineStageFlags.FragmentShader; if ((ViewFlags & BufferFlags.UnorderedAccess) != 0) { createInfo.Usage |= BufferUsageFlags.StorageTexelBuffer; NativeAccessMask |= AccessFlags.ShaderWrite; } } // Create buffer NativeBuffer = GraphicsDevice.NativeDevice.CreateBuffer(ref createInfo); // Allocate memory var memoryProperties = MemoryPropertyFlags.DeviceLocal; if (bufferDescription.Usage == GraphicsResourceUsage.Staging) { throw new NotImplementedException(); } else if (Usage == GraphicsResourceUsage.Dynamic) { memoryProperties = MemoryPropertyFlags.HostVisible | MemoryPropertyFlags.HostCoherent; } MemoryRequirements memoryRequirements; GraphicsDevice.NativeDevice.GetBufferMemoryRequirements(NativeBuffer, out memoryRequirements); AllocateMemory(memoryProperties, memoryRequirements); if (NativeMemory != DeviceMemory.Null) { GraphicsDevice.NativeDevice.BindBufferMemory(NativeBuffer, NativeMemory, 0); } if (SizeInBytes > 0) { // Begin copy command buffer var commandBufferAllocateInfo = new CommandBufferAllocateInfo { StructureType = StructureType.CommandBufferAllocateInfo, CommandPool = GraphicsDevice.NativeCopyCommandPool, CommandBufferCount = 1, Level = CommandBufferLevel.Primary }; CommandBuffer commandBuffer; GraphicsDevice.NativeDevice.AllocateCommandBuffers(ref commandBufferAllocateInfo, &commandBuffer); var beginInfo = new CommandBufferBeginInfo { StructureType = StructureType.CommandBufferBeginInfo, Flags = CommandBufferUsageFlags.OneTimeSubmit }; commandBuffer.Begin(ref beginInfo); // Copy to upload buffer if (dataPointer != IntPtr.Zero) { if (Usage == GraphicsResourceUsage.Dynamic) { var uploadMemory = GraphicsDevice.NativeDevice.MapMemory(NativeMemory, 0, (ulong)SizeInBytes, MemoryMapFlags.None); Utilities.CopyMemory(uploadMemory, dataPointer, SizeInBytes); GraphicsDevice.NativeDevice.UnmapMemory(NativeMemory); } else { var sizeInBytes = bufferDescription.SizeInBytes; SharpVulkan.Buffer uploadResource; int uploadOffset; var uploadMemory = GraphicsDevice.AllocateUploadBuffer(sizeInBytes, out uploadResource, out uploadOffset); Utilities.CopyMemory(uploadMemory, dataPointer, sizeInBytes); // Barrier var memoryBarrier = new BufferMemoryBarrier(uploadResource, AccessFlags.HostWrite, AccessFlags.TransferRead, (ulong)uploadOffset, (ulong)sizeInBytes); commandBuffer.PipelineBarrier(PipelineStageFlags.Host, PipelineStageFlags.Transfer, DependencyFlags.None, 0, null, 1, &memoryBarrier, 0, null); // Copy var bufferCopy = new BufferCopy { SourceOffset = (uint)uploadOffset, DestinationOffset = 0, Size = (uint)sizeInBytes }; commandBuffer.CopyBuffer(uploadResource, NativeBuffer, 1, &bufferCopy); } } else { commandBuffer.FillBuffer(NativeBuffer, 0, (uint)bufferDescription.SizeInBytes, 0); } // Barrier var bufferMemoryBarrier = new BufferMemoryBarrier(NativeBuffer, AccessFlags.TransferWrite, NativeAccessMask); commandBuffer.PipelineBarrier(PipelineStageFlags.Transfer, PipelineStageFlags.AllCommands, DependencyFlags.None, 0, null, 1, &bufferMemoryBarrier, 0, null); // Close and submit commandBuffer.End(); var submitInfo = new SubmitInfo { StructureType = StructureType.SubmitInfo, CommandBufferCount = 1, CommandBuffers = new IntPtr(&commandBuffer), }; lock (GraphicsDevice.QueueLock) { GraphicsDevice.NativeCommandQueue.Submit(1, &submitInfo, Fence.Null); GraphicsDevice.NativeCommandQueue.WaitIdle(); //commandBuffer.Reset(CommandBufferResetFlags.None); GraphicsDevice.NativeDevice.FreeCommandBuffers(GraphicsDevice.NativeCopyCommandPool, 1, &commandBuffer); } InitializeViews(); } }
private string AccessFlagsAsString(AccessFlags accessFlags) { string result = accessFlags.HasFlag(AccessFlags.Public) ? "public " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Private) ? "private " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Protected) ? "protected " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Static) ? "static " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Final) ? "final " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Synchronized) ? "synchronized " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Bridge) ? "bridge " : string.Empty; result += accessFlags.HasFlag(AccessFlags.VarArgs) ? "varargs " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Native) ? "native " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Abstract) ? "abstract " : string.Empty; result += accessFlags.HasFlag(AccessFlags.StrictFp) ? "strictfp " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Synthetic) ? "synthetic " : string.Empty; result += accessFlags.HasFlag(AccessFlags.Constructor) ? "constructor " : string.Empty; result += accessFlags.HasFlag(AccessFlags.DeclaredSynchronized) ? "synchronized " : string.Empty; return result.Trim(); }
public bool Open() { if (File.Exists(FClassFileName)) { try { // read the .class file systematically FileStream fs = new FileStream(FClassFileName, FileMode.Open, FileAccess.Read); FReader = new BinaryReader(fs); // read header FMagic = Common.ReadDWord(FReader); if (FMagic != 0x0CAFEBABE) return false; FMinorVersion = Common.ReadWord(FReader); FMajorVersion = Common.ReadWord(FReader); // read constant pool // this also reads the "FConstantPoolCount" // so instead use FConstantPool.MaxItems or somesuch FConstantPool = new TConstantPool(FReader); // more constants FAccessFlags = (AccessFlags)Common.ReadWord(FReader); FThisClass = Common.ReadWord(FReader); FThisClass--; FSuperClass = Common.ReadWord(FReader); FSuperClass--; FThisClassName = ((ConstantClassInfo)FConstantPool.Item(FThisClass)).Name; (FConstantPool.Item(FThisClass)).References++; FSuperClassName = ((ConstantClassInfo)FConstantPool.Item(FSuperClass)).Name; (FConstantPool.Item(FSuperClass)).References++; FInterfaces = new TInterfaces(FReader, FConstantPool); FFields = new TFields(FReader, FConstantPool); FMethods = new TMethods(FReader, FConstantPool); FAttributes = new TAttributes(FReader, FConstantPool); //FHasBeenOpened = true; fs.Close(); return true; } catch (Exception e) { // catch any unhandled exceptions here // and exit gracefully. // garbage collection does the rest ;D return false; } } return false; }
private void InitializeFromImpl(DataBox[] dataBoxes = null) { NativeFormat = VulkanConvertExtensions.ConvertPixelFormat(ViewFormat); HasStencil = IsStencilFormat(ViewFormat); NativeImageAspect = IsDepthStencil ? ImageAspectFlags.Depth : ImageAspectFlags.Color; if (HasStencil) NativeImageAspect |= ImageAspectFlags.Stencil; // For depth-stencil formats, automatically fall back to a supported one if (IsDepthStencil && HasStencil) { NativeFormat = GetFallbackDepthStencilFormat(GraphicsDevice, NativeFormat); } if (Usage == GraphicsResourceUsage.Staging) { if (NativeImage != SharpVulkan.Image.Null) throw new InvalidOperationException(); if (isNotOwningResources) throw new InvalidOperationException(); if (ParentTexture != null) { // Create only a view NativeBuffer = ParentTexture.NativeBuffer; NativeMemory = ParentTexture.NativeMemory; } else { CreateBuffer(); if (dataBoxes != null) throw new InvalidOperationException(); } } else { if (NativeImage != SharpVulkan.Image.Null) throw new InvalidOperationException(); NativeLayout = IsRenderTarget ? ImageLayout.ColorAttachmentOptimal : IsDepthStencil ? ImageLayout.DepthStencilAttachmentOptimal : IsShaderResource ? ImageLayout.ShaderReadOnlyOptimal : ImageLayout.General; if (NativeLayout == ImageLayout.TransferDestinationOptimal) NativeAccessMask = AccessFlags.TransferRead; if (NativeLayout == ImageLayout.ColorAttachmentOptimal) NativeAccessMask = AccessFlags.ColorAttachmentWrite; if (NativeLayout == ImageLayout.DepthStencilAttachmentOptimal) NativeAccessMask = AccessFlags.DepthStencilAttachmentWrite; if (NativeLayout == ImageLayout.ShaderReadOnlyOptimal) NativeAccessMask = AccessFlags.ShaderRead | AccessFlags.InputAttachmentRead; NativePipelineStageMask = IsRenderTarget ? PipelineStageFlags.ColorAttachmentOutput : IsDepthStencil ? PipelineStageFlags.ColorAttachmentOutput | PipelineStageFlags.EarlyFragmentTests | PipelineStageFlags.LateFragmentTests : IsShaderResource ? PipelineStageFlags.VertexInput | PipelineStageFlags.FragmentShader : PipelineStageFlags.None; if (ParentTexture != null) { // Create only a view NativeImage = ParentTexture.NativeImage; NativeMemory = ParentTexture.NativeMemory; } else { if (!isNotOwningResources) { CreateImage(); InitializeImage(dataBoxes); } } if (!isNotOwningResources) { NativeImageView = GetImageView(ViewType, ArraySlice, MipLevel); NativeColorAttachmentView = GetColorAttachmentView(ViewType, ArraySlice, MipLevel); NativeDepthStencilView = GetDepthStencilView(); } } }
public SetFieldBinder(string name, RuntimeTypeHandle classContext, AccessFlags access) { _name = name; _classContext = Type.GetTypeFromHandle(classContext); _access = access; }
internal static AccessFlags GetInterfaceModifiers(AccessFlags candidate) { return (AccessFlags)(candidate & ClassModifiersMask & ~(AccessFlags.Final)); }
private static AccessFlags GetModifiers(AccessFlags candidate) { bool isInterface = (0 != (candidate & AccessFlags.Interface)); return (AccessFlags)(candidate & ClassModifiersMask & ~(isInterface ? AccessFlags.Final : 0)); }
private static extern IntPtr OpenSCManager(string machineName, string databaseName, AccessFlags dwAccess);
public static extern int libmsiecf_file_open_wide(IndexDatHandle fileHandle, string filename, AccessFlags flags, IntPtr error);
public QStatus AddProperty(string name, string signature, AccessFlags access) { return alljoyn_interfacedescription_addproperty(_interfaceDescription, name, signature, (byte)access); }
public BufferMemoryBarrier(Buffer buffer, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, ulong offset = 0, ulong size = Vulkan.WholeSize) : this(buffer, sourceAccesMask, destinationAccessMask, Vulkan.QueueFamilyIgnored, Vulkan.QueueFamilyIgnored, offset, size) { }
public static Expression BindField(PhpTypeInfo type, Type classCtx, Expression target, string field, Expression ctx, AccessFlags access, Expression rvalue) { if (access.Write() != (rvalue != null)) { throw new ArgumentException(); } // lookup a declared field for (var t = type; t != null; t = t.BaseType) { var expr = t.DeclaredFields.Bind(field, classCtx, target, ctx, (target != null) ? TypeFields.FieldKind.InstanceField : TypeFields.FieldKind.StaticField); if (expr != null) { return BindAccess(expr, ctx, access, rvalue); } } // lookup __get, __set, ... TypeMethods.MagicMethods magic; if (access.Write()) magic = TypeMethods.MagicMethods.__set; else if (access.Unset()) magic = TypeMethods.MagicMethods.__unset; else if (access.Isset()) magic = TypeMethods.MagicMethods.__isset; else magic = TypeMethods.MagicMethods.__get; for (var t = type; t != null; t = t.BaseType) { var m = (PhpMethodInfo)t.DeclaredMethods[magic]; if (m != null) { if (m.Methods.Length == 1 && m.Methods[0].IsVisible(classCtx)) { switch (magic) { case TypeMethods.MagicMethods.__set: // __set(name, value) return OverloadBinder.BindOverloadCall(rvalue.Type, target, m.Methods, ctx, new Expression[] { Expression.Constant(field), rvalue }); default: // __get(name), __unset(name), __isset(name) return OverloadBinder.BindOverloadCall(m.Methods[0].ReturnType, target, m.Methods, ctx, new Expression[] { Expression.Constant(field) }); } } break; } } // runtime fields var __runtimeflds = type.RuntimeFieldsHolder; if (__runtimeflds != null) { var __runtimeflds_field = Expression.Field(target, __runtimeflds); var key = Expression.Constant(new IntStringKey(field)); return BindArrayAccess(__runtimeflds_field, key, ctx, access, rvalue); } // TODO: dynamic // return null; }
static Expression BindArrayAccess(Expression arr, Expression key, Expression ctx, AccessFlags access, Expression rvalue) { Debug.Assert(key.Type == typeof(IntStringKey)); if (access.EnsureObject()) { // (arr ?? arr = []).EnsureItemObject(key) return Expression.Call( EnsureNotNullPhpArray(arr), Cache.Operators.PhpArray_EnsureItemObject, key); } else if (access.EnsureArray()) { // (arr ?? arr = []).EnsureItemArray(key) return Expression.Call( EnsureNotNullPhpArray(arr), Cache.Operators.PhpArray_EnsureItemArray, key); } else if (access.EnsureAlias()) { // (arr ?? arr = []).EnsureItemAlias(key) return Expression.Call( EnsureNotNullPhpArray(arr), Cache.Operators.PhpArray_EnsureItemAlias, key); } else if (access.WriteAlias()) { Debug.Assert(rvalue.Type == typeof(PhpAlias)); rvalue = ConvertExpression.Bind(rvalue, typeof(PhpAlias), ctx); // (arr ?? arr = []).SetItemAlias(key, value) return Expression.Call( EnsureNotNullPhpArray(arr), Cache.Operators.PhpArray_SetItemAlias, key, rvalue); } else if (access.Unset()) { Debug.Assert(rvalue == null); // remove key // arr.RemoveKey(name) // TODO: if (arr != null) return Expression.Call(arr, Cache.Operators.PhpArray_RemoveKey, key); } else if (access.Write()) { rvalue = ConvertExpression.Bind(rvalue, typeof(PhpValue), ctx); return Expression.Call( EnsureNotNullPhpArray(arr), Cache.Operators.PhpArray_SetItemValue, key, rvalue); } else { // read // TODO: (arr != null) ? arr[key] : (quiet ? void : ERROR) return Expression.Call(arr, Cache.Operators.PhpArray_GetItemValue, key); } }
static Expression BindAccess(Expression expr, Expression ctx, AccessFlags access, Expression rvalue) { if (access.EnsureObject()) { if (expr.Type == typeof(PhpAlias)) { // ((PhpAlias)fld).EnsureObject(ctx) expr = Expression.Call(expr, Cache.Operators.PhpAlias_EnsureObject_Context); } else if (expr.Type == typeof(PhpValue)) { // ((PhpValue)fld).EnsureObject(ctx) expr = Expression.Call(expr, Cache.Operators.PhpValue_EnsureObject_Context); } else { // getter // TODO: ensure it is not null } } else if (access.EnsureArray()) { if (expr.Type == typeof(PhpAlias)) { // ((PhpAlias)fld).EnsureArray() expr = Expression.Call(expr, Cache.Operators.PhpAlias_EnsureArray); } else if (expr.Type == typeof(PhpValue)) { // ((PhpValue)fld).EnsureArray() expr = Expression.Call(expr, Cache.Operators.PhpValue_EnsureArray); } else if (expr.Type == typeof(PhpArray)) { // (PhpArray)fld // TODO: ensure it is not null } else { // getter } } else if (access.EnsureAlias()) { if (expr.Type == typeof(PhpAlias)) { // (PhpAlias)getter } else if (expr.Type == typeof(PhpValue)) { // ((PhpValue)fld).EnsureAlias() expr = Expression.Call(expr, Cache.Operators.PhpValue_EnsureAlias); } else { // getter // cannot read as reference } } else if (access.WriteAlias()) { // write alias Debug.Assert(rvalue.Type == typeof(PhpAlias)); rvalue = ConvertExpression.Bind(rvalue, typeof(PhpAlias), ctx); if (expr.Type == typeof(PhpAlias)) { // ok } else if (expr.Type == typeof(PhpValue)) { // fld = PhpValue.Create(alias) rvalue = Expression.Call(typeof(PhpValue).GetMethod("Create", Cache.Types.PhpAlias), rvalue); } else { // fld is not aliasable Debug.Assert(false, "Cannot assign aliased value to field of type " + expr.Type.ToString()); rvalue = ConvertExpression.Bind(rvalue, expr.Type, ctx); } expr = Expression.Assign(expr, rvalue); } else if (access.Unset()) { Debug.Assert(rvalue == null); expr = Expression.Assign(expr, ConvertExpression.BindDefault(expr.Type)); } else if (access.Write()) { // write by value if (expr.Type == typeof(PhpAlias)) { // Template: fld.Value = (PhpValue)value expr = Expression.Assign(Expression.PropertyOrField(expr, "Value"), ConvertExpression.Bind(rvalue, typeof(PhpValue), ctx)); } else if (expr.Type == typeof(PhpValue)) { // Template: Operators.SetValue(ref fld, (PhpValue)value) expr = Expression.Call(Cache.Operators.SetValue_PhpValueRef_PhpValue, expr, ConvertExpression.Bind(rvalue, typeof(PhpValue), ctx)); } else { // Template: fld = value // default behaviour by value to value expr = Expression.Assign(expr, ConvertExpression.Bind(rvalue, expr.Type, ctx)); } } // return expr; }
private void SetAccessFlags(AccessFlags flags, bool value) { if (value) { AccessFlags |= flags; } else { AccessFlags &= ~flags; } }
static extern bool DuplicateTokenEx( IntPtr hExistingToken, AccessFlags dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, out IntPtr phNewToken);