Created
January 7, 2020 16:22
-
-
Save atifaziz/86718fa842552a739f6863602ba26764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using SharpLab.Runtime; | |
static class X | |
{ | |
public static bool HasFlag(this FileAttributes self, FileAttributes flag) => | |
(self & flag) == flag; | |
[JitGeneric(typeof(FileAttributes))] | |
public static bool HasFlag<T>(this T self, T flag) where T : Enum, IConvertible => | |
(self.ToInt32(null) & flag.ToInt32(null)) == flag.ToInt32(null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Core CLR v4.700.19.46205 (coreclr.dll) on x86. | |
X.HasFlag(System.IO.FileAttributes, System.IO.FileAttributes) | |
L0000: and ecx, edx | |
L0002: cmp ecx, edx | |
L0004: setz al | |
L0007: movzx eax, al | |
L000a: ret | |
X.HasFlag[[System.IO.FileAttributes, System.Runtime]](System.IO.FileAttributes, System.IO.FileAttributes) | |
L0000: push ebp | |
L0001: mov ebp, esp | |
L0003: push edi | |
L0004: push esi | |
L0005: push ebx | |
L0006: push eax | |
L0007: mov edi, ecx | |
L0009: mov esi, edx | |
L000b: mov ecx, 0x111b15a0 | |
L0010: call 0x31c30cc | |
L0015: mov ebx, eax | |
L0017: mov [ebx+0x4], edi | |
L001a: mov ecx, 0x111b15a0 | |
L001f: call 0x31c30cc | |
L0024: mov edi, eax | |
L0026: mov ecx, ebx | |
L0028: xor edx, edx | |
L002a: call dword [0x33309d4] | |
L0030: mov ebx, eax | |
L0032: mov [edi+0x4], esi | |
L0035: mov ecx, 0x111b15a0 | |
L003a: call 0x31c30cc | |
L003f: mov [ebp-0x10], eax | |
L0042: mov ecx, edi | |
L0044: xor edx, edx | |
L0046: call dword [0x33309d4] | |
L004c: and ebx, eax | |
L004e: mov edi, [ebp-0x10] | |
L0051: mov [edi+0x4], esi | |
L0054: mov ecx, edi | |
L0056: xor edx, edx | |
L0058: call dword [0x33309d4] | |
L005e: cmp eax, ebx | |
L0060: setz al | |
L0063: movzx eax, al | |
L0066: pop ecx | |
L0067: pop ebx | |
L0068: pop esi | |
L0069: pop edi | |
L006a: pop ebp | |
L006b: ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": 1, | |
"target": "JIT ASM", | |
"mode": "Release", | |
"branch": "features-local-function-attributes" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment