code
stringlengths
3
10M
language
stringclasses
31 values
module mordor.common.streams.nil; public import mordor.common.streams.stream; class NilStream : Stream { private: this() {} public: static this() { _singleton = new NilStream; } static NilStream get() { return _singleton; } bool supportsRead() { return true; } bool supportsWrite() { return true; } bool supportsSeek() { return true; } bool supportsSize() { return true; } bool supportsTruncate() { return true; } size_t read(Buffer b, size_t len) { return 0; } size_t write(Buffer b, size_t len) { return len; } size_t write(void[] b) { return b.length; } long seek(long offset, Anchor anchor) { return 0; } long size() { return 0; } void truncate(long size) {} void flush() {} private: static NilStream _singleton; }
D
/++ + IRC user masks. +/ module virc.usermask; import std.algorithm : findSplit; import std.range; import std.typecons : Nullable; /++ + IRC user masks are generally in the form nick!ident@hostname. This struct + exists for easy separation and manipulation of each piece of the mask. This + also accepts cases where the ident and host are not present. +/ struct UserMask { /// string nickname; /// Nullable!string ident; /// Nullable!string host; /// this(string maskString) @safe pure nothrow @nogc { auto split = maskString.findSplit("!"); nickname = split[0]; if ((split[1] == "!") && (split[2].length > 0)) { auto split2 = split[2].findSplit("@"); ident = split2[0]; if (split2[1] == "@") { host = split2[2]; } } else { auto split2 = maskString.findSplit("@"); nickname = split2[0]; if (split2[1] == "@") { host = split2[2]; } } } void toString(T)(T sink) const if (isOutputRange!(T, const(char))) { put(sink, nickname); if (!ident.isNull) { put(sink, '!'); put(sink, ident.get); assert(!host.isNull); } if (!host.isNull) { put(sink, '@'); put(sink, host.get); } } auto toHash() const { auto hash = nickname.hashOf(); if (!ident.isNull) { hash = ident.get.hashOf(hash); } if (!host.isNull) { hash = host.get.hashOf(hash); } return hash; } } @safe pure nothrow @nogc unittest { with (UserMask("localhost")) { assert(nickname == "localhost"); assert(ident.isNull); assert(host.isNull); } with (UserMask("[email protected]")) { assert(nickname == "user"); assert(ident.get == "id"); assert(host.get == "example.net"); } with (UserMask("user!id@example!!!.net")) { assert(nickname == "user"); assert(ident.get == "id"); assert(host.get == "example!!!.net"); } with (UserMask("user!id@ex@mple!!!.net")) { assert(nickname == "user"); assert(ident.get == "id"); assert(host.get == "ex@mple!!!.net"); } with (UserMask("user!id!@ex@mple!!!.net")) { assert(nickname == "user"); assert(ident.get == "id!"); assert(host.get == "ex@mple!!!.net"); } with (UserMask("user!id")) { assert(nickname == "user"); assert(ident.get == "id"); assert(host.isNull); } with (UserMask("[email protected]")) { assert(nickname == "user"); assert(ident.isNull); assert(host.get == "example.net"); } } @safe pure unittest { import std.conv : text; { UserMask mask; mask.nickname = "Nick"; assert(mask.text == "Nick"); } { UserMask mask; mask.nickname = "Nick"; mask.ident = "user"; mask.host = "domain"; assert(mask.text == "Nick!user@domain"); } }
D
/Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/Build/Intermediates.noindex/CryptoSwift.build/Debug/CryptoSwift.build/Objects-normal/x86_64/PKCS7.o : /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA3.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/MD5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt128.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OCB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HKDF.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Updatable.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/DigestType.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ISO78164Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/NoPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ZeroPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Blowfish.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Checksum.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt32+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt64+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt16+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt8+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/String+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CompactMap.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Authenticator.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Generics.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SecureBytes.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Utils.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Operators.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Bit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Rabbit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Scrypt.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Digest.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/Build/Intermediates.noindex/CryptoSwift.build/Debug/CryptoSwift.build/Objects-normal/x86_64/PKCS7~partial.swiftmodule : /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA3.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/MD5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt128.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OCB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HKDF.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Updatable.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/DigestType.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ISO78164Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/NoPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ZeroPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Blowfish.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Checksum.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt32+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt64+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt16+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt8+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/String+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CompactMap.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Authenticator.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Generics.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SecureBytes.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Utils.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Operators.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Bit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Rabbit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Scrypt.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Digest.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/Build/Intermediates.noindex/CryptoSwift.build/Debug/CryptoSwift.build/Objects-normal/x86_64/PKCS7~partial.swiftdoc : /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA3.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/MD5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt128.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OCB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HKDF.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Updatable.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/DigestType.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ISO78164Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/NoPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ZeroPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Blowfish.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Checksum.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt32+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt64+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt16+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt8+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/String+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CompactMap.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Authenticator.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Generics.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SecureBytes.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Utils.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Operators.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Bit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Rabbit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Scrypt.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Digest.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/Build/Intermediates.noindex/CryptoSwift.build/Debug/CryptoSwift.build/Objects-normal/x86_64/PKCS7~partial.swiftsourceinfo : /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF1.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PBKDF2.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SHA3.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEADChaCha20Poly1305.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/MD5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS5.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt128.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/ECB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OCB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/OFB.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CBCMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HMAC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/PCBC.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AEAD/AEAD.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/HKDF.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/GCM.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CTR.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockMode.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Updatable.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/DigestType.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ISO78164Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/PKCS/PKCS7Padding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/NoPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/ZeroPadding.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Blowfish.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Checksum.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt32+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt64+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt16+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/UInt8+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Data+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/String+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Collection+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Int+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Array+Extension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/String+FoundationExtension.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/ChaCha20+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/HMAC+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/AES+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Utils+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Foundation/Array+Foundation.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BatchedCollection.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/CompactMap.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockCipher.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/CipherModeWorker.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Authenticator.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamDecryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/StreamEncryptor.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Generics.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/SecureBytes.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Utils.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/BlockMode/BlockModeOptions.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Operators.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/AES.Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Cryptors.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Bit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Rabbit.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Scrypt.swift /Users/darthjuda/Documents/snippets/swiftPackage/ovhAPI/DerivedData/ovhAPI/SourcePackages/checkouts/CryptoSwift/Sources/CryptoSwift/Digest.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/dyld.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/mach-o/compact_unwind_encoding.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
module android.java.java.io.ObjectOutputStream; public import android.java.java.io.ObjectOutputStream_d_interface; import arsd.jni : ImportExportImpl; mixin ImportExportImpl!ObjectOutputStream; import import2 = android.java.java.lang.Class; import import1 = android.java.java.io.ObjectOutputStream_PutField;
D
a domesticated animal kept for companionship or amusement a special loved one a fit of petulance or sulkiness (especially at what is felt to be a slight) using a computerized radiographic technique to examine the metabolic activity in various tissues (especially in the brain) stroke or caress gently stroke or caress in an erotic manner, as during lovemaking preferred above all others and treated with partiality
D
E: c38, c330, c642, c63, c9, c633, c732, c591, c378, c758, c428, c673, c455, c786, c733, c46, c341, c357, c355, c358, c523, c19, c57, c217, c687, c503, c369, c324, c676, c54, c214, c790, c314, c610, c561, c182, c722, c604, c707, c818, c412, c663, c486, c376, c528, c115, c403, c683, c560, c465, c238, c0, c305, c30, c816, c650, c110, c422, c501, c695, c519, c184, c655, c400, c489, c364, c749, c623, c551, c701, c18, c470, c618, c466, c148, c835, c715, c586, c566, c672, c627, c746, c406, c680, c714, c189, c558, c712, c143, c598, c827, c433, c56, c123, c33, c537, c456, c549, c151, c647, c25, c457, c332, c4, c813, c281, c665, c339, c258, c345, c548, c44, c361, c552, c499, c697, c116, c793, c121, c754, c765, c68, c207, c507, c737, c197, c763, c821, c291, c308, c237, c762, c386, c129, c632, c289, c383, c814, c550, c667, c126, c524, c565, c679, c205, c52, c506, c188, c742, c605, c696, c535, c37, c280, c60, c241, c296, c322, c603, c411, c829, c222, c225, c718, c437, c196, c285, c484, c434, c741, c768, c651, c607, c516. p8(E,E) c38,c330 c9,c633 c378,c758 c733,c46 c341,c357 c9,c758 c355,c358 c57,c330 c217,c758 c324,c330 c341,c610 c63,c642 c324,c722 c341,c722 c57,c528 c115,c642 c403,c610 c324,c501 c465,c695 c217,c642 c400,c330 c551,c701 c503,c722 c148,c835 c715,c528 c586,c566 c715,c758 c672,c357 c217,c695 c406,c0 c324,c695 c400,c357 c115,c714 c672,c189 c558,c189 c586,c714 c54,c18 c217,c633 c503,c680 c598,c46 c433,c455 c672,c633 c715,c642 c56,c714 c115,c687 c672,c455 c33,c537 c57,c695 c433,c549 c406,c676 c57,c642 c151,c214 c403,c189 c715,c330 c503,c501 c378,c566 c38,c714 c457,c676 c4,c551 c558,c633 c665,c110 c465,c633 c403,c566 c503,c687 c9,c345 c341,c642 c56,c642 c378,c455 c115,c189 c650,c816 c406,c566 c339,c714 c457,c110 c217,c676 c465,c680 c433,c722 c672,c722 c558,c345 c406,c722 c378,c549 c406,c695 c457,c722 c38,c566 c433,c758 c57,c687 c457,c680 c586,c345 c465,c345 c754,c818 c378,c633 c503,c0 c9,c680 c38,c528 c217,c345 c400,c633 c9,c746 c715,c189 c400,c746 c403,c676 c586,c455 c465,c746 c400,c549 c400,c455 c465,c455 c558,c722 c715,c714 c672,c758 c672,c714 c115,c549 c38,c189 c433,c357 c217,c680 c403,c501 c291,c749 c217,c746 c457,c549 c586,c695 c503,c189 c586,c680 c457,c642 c38,c610 c712,c143 c406,c549 c715,c746 c403,c549 c503,c642 c386,c683 c217,c566 c558,c566 c586,c528 c433,c345 c217,c110 c38,c549 c672,c345 c715,c680 c341,c110 c56,c746 c378,c330 c503,c455 c341,c330 c400,c680 c558,c528 c558,c357 c38,c687 c586,c110 c715,c633 c115,c676 c457,c0 c737,c827 c400,c758 c406,c642 c126,c406 c465,c330 c341,c633 c586,c0 c57,c676 c400,c642 c403,c455 c217,c330 c403,c758 c57,c345 c324,c0 c38,c345 c715,c455 c121,c549 c57,c722 c465,c110 c115,c610 c341,c189 c672,c549 c57,c680 c457,c501 c56,c455 c558,c714 c403,c0 c400,c189 c197,c123 c9,c610 c465,c676 c217,c528 c663,c412 c586,c501 c457,c695 c433,c189 c115,c722 c38,c455 c115,c566 c205,c489 c558,c687 c383,c499 c56,c676 c558,c0 c406,c189 c30,c357 c506,c507 c115,c680 c378,c695 c457,c189 c57,c501 c406,c610 c341,c714 c9,c528 c57,c110 c324,c676 c403,c330 c400,c0 c9,c695 c403,c680 c457,c345 c433,c0 c433,c676 c503,c110 c217,c722 c341,c762 c188,c207 c742,c821 c715,c722 c433,c566 c56,c357 c324,c746 c715,c676 c465,c758 c715,c566 c672,c528 c558,c676 c38,c722 c403,c345 c57,c610 c503,c633 c433,c687 c217,c357 c25,c523 c403,c695 c332,c722 c465,c687 c189,c687 c715,c549 c400,c566 c457,c528 c403,c633 c322,c501 c503,c330 c465,c642 c672,c566 c406,c110 c586,c633 c558,c610 c470,c18 c433,c633 c524,c790 c68,c746 c433,c642 c308,c647 c672,c110 c715,c357 c324,c357 c324,c687 c341,c455 c672,c680 c403,c110 c9,c722 c672,c687 c586,c549 c422,c673 c503,c695 c503,c758 c550,c207 c305,c0 c324,c714 c586,c330 c406,c528 c56,c680 c457,c687 c9,c0 c38,c633 c400,c110 c465,c722 c38,c357 c225,c281 c341,c676 c217,c687 c115,c758 c115,c501 c718,c37 c324,c189 c341,c549 c217,c455 c400,c695 c433,c714 c672,c746 c341,c0 c378,c357 c341,c687 c503,c357 c56,c695 c715,c345 c52,c618 c57,c0 c715,c695 c433,c528 c503,c714 c465,c501 c503,c528 c457,c758 c378,c610 c433,c680 c60,c683 c324,c549 c25,c566 c434,c537 c355,c376 c560,c683 c314,c790 c465,c549 c503,c676 c341,c499 c623,c123 c289,c633 c324,c758 c558,c330 c403,c722 c217,c549 c465,c610 c115,c0 c406,c501 c672,c676 c457,c746 c378,c680 c403,c687 c38,c758 c406,c680 c672,c642 c324,c345 c763,c680 c341,c501 c9,c357 c378,c714 c378,c189 c341,c680 c9,c189 c503,c746 c403,c528 c519,c184 c503,c566 c433,c610 c406,c330 c400,c676 c433,c695 c433,c501 c400,c501 c558,c746 c56,c633 c465,c528 c486,c376 c19,c523 c9,c642 c38,c676 c607,c241 c403,c714 c57,c566 c9,c110 c400,c345 c115,c357 c56,c549 c558,c110 c324,c610 . p5(E,E) c642,c63 c732,c591 c523,c19 c790,c314 c561,c182 c683,c560 c0,c305 c816,c650 c673,c422 c489,c364 c18,c470 c701,c551 c537,c33 c523,c25 c123,c623 c376,c486 c816,c258 c714,c361 c566,c25 c358,c552 c835,c148 c376,c355 c549,c121 c746,c68 c18,c54 c123,c197 c680,c763 c647,c308 c358,c355 c44,c237 c762,c341 c749,c623 c499,c341 c110,c665 c633,c289 c207,c550 c821,c667 c827,c737 c790,c524 c357,c30 c647,c558 c499,c383 c714,c339 c184,c519 c687,c189 c184,c814 c412,c663 c818,c754 c46,c733 c44,c548 c411,c829 c406,c126 c673,c428 c618,c52 c46,c598 c455,c786 c714,c605 c683,c484 c722,c332 c143,c712 c749,c291 c683,c386 c330,c768 c610,c129 c618,c466 c683,c60 c501,c322 c676,c456 . p2(E,E) c633,c633 c428,c673 c54,c214 c707,c818 c486,c376 c314,c790 c358,c358 c519,c184 c712,c143 c827,c827 c123,c123 c357,c357 c456,c676 c786,c455 c33,c537 c813,c281 c339,c714 c548,c44 c566,c566 c733,c46 c610,c610 c207,c207 c378,c507 c737,c827 c821,c821 c523,c523 c305,c0 c25,c523 c129,c610 c383,c499 c814,c184 c550,c207 c182,c561 c19,c523 c361,c714 c549,c549 c623,c123 c110,c110 c665,c110 c676,c676 c605,c714 c52,c618 c60,c683 c258,c816 c189,c687 c642,c642 c746,c746 c184,c184 c701,c701 c489,c489 c714,c714 c647,c647 c68,c746 c341,c499 c25,c566 c524,c790 c46,c46 c673,c673 c598,c46 c289,c633 c816,c816 c749,c749 c501,c501 c63,c642 c296,c241 c197,c123 c560,c683 c308,c647 c470,c18 c291,c749 c663,c412 c561,c561 c364,c489 c697,c551 c455,c455 c412,c412 c355,c376 c551,c701 . p9(E,E) c455,c786 c687,c687 c676,c676 c412,c663 c357,c30 c749,c623 c618,c466 c46,c46 c701,c551 c642,c63 c790,c790 c647,c647 c0,c0 c123,c123 c722,c332 c714,c714 c330,c330 c143,c712 c499,c341 c551,c697 c676,c456 c123,c623 c566,c566 c537,c537 c722,c722 c818,c707 c549,c549 c489,c489 c701,c701 c412,c412 c827,c827 c749,c749 c610,c129 c816,c258 c746,c746 c184,c814 c184,c184 c566,c25 c455,c455 c746,c68 c618,c52 c44,c548 c499,c499 c18,c470 c44,c237 c18,c54 c37,c280 c523,c523 c207,c550 c18,c18 c241,c296 c207,c207 c827,c737 c507,c378 c683,c60 c561,c561 c673,c673 c821,c667 c714,c339 c214,c54 c110,c665 c376,c376 c714,c361 c610,c610 c44,c44 c143,c143 c642,c642 c281,c813 c633,c633 c683,c484 c683,c560 c376,c355 c680,c680 c376,c486 c110,c110 c714,c605 c680,c763 c816,c816 c501,c501 c647,c558 c618,c618 c673,c422 c821,c821 c46,c733 c501,c322 c647,c308 c357,c357 c358,c358 c687,c189 c749,c291 c683,c683 c790,c314 . p3(E,E) c503,c369 c217,c604 c465,c238 c38,c655 c586,c627 c341,c46 c715,c116 c9,c793 c403,c765 c558,c632 c457,c565 c433,c679 c115,c696 c406,c535 c324,c603 c56,c222 c672,c437 c38,c196 c57,c285 c378,c741 c400,c651 c586,c516 . p10(E,E) c110,c110 c746,c746 c680,c680 c676,c676 c714,c714 c455,c455 c695,c695 c722,c722 c501,c501 c330,c330 c549,c549 c345,c345 c687,c687 c566,c566 c0,c0 c758,c758 c357,c357 c528,c528 c189,c189 c633,c633 c610,c610 c642,c642 .
D
/****************************************************************************** License: Copyright (c) 2007 Jarrett Billingsley This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ******************************************************************************/ module minid.oslib; import minid.iolib; import minid.types; import minid.utils; import tango.stdc.stdlib; import tango.stdc.stringz; import tango.sys.Environment; import tango.sys.Process; final class OSLib { private MDProcessClass processClass; private IOLib.MDInputStreamClass inputStreamClass; private IOLib.MDOutputStreamClass outputStreamClass; private this(MDObject _Object, MDNamespace ioLib) { processClass = new MDProcessClass(_Object); inputStreamClass = ioLib["InputStream"d].to!(IOLib.MDInputStreamClass); outputStreamClass = ioLib["OutputStream"d].to!(IOLib.MDOutputStreamClass); } public static void init(MDContext context) { context.setModuleLoader("os", context.newClosure(function int(MDState s, uint numParams) { auto ioLib = s.context.importModule("io"); auto osLib = new OSLib(s.context.globals.get!(MDObject)("Object"d), ioLib); auto lib = s.getParam!(MDNamespace)(1); lib.addList ( "Process"d, osLib.processClass, "system"d, new MDClosure(lib, &system, "os.system"), "getEnv"d, new MDClosure(lib, &getEnv, "os.getEnv") ); return 0; }, "os")); context.importModule("os"); } static int system(MDState s, uint numParams) { if(numParams == 0) s.push(.system(null) ? true : false); else s.push(.system(toStringz(s.getParam!(char[])(0)))); return 1; } static int getEnv(MDState s, uint numParams) { if(numParams == 0) s.push(Environment.get()); else { char[] def = null; if(numParams > 1) def = s.getParam!(char[])(1); char[] val = Environment.get(s.getParam!(char[])(0), def); if(val is null) s.pushNull(); else s.push(val); } return 1; } class MDProcessClass : MDObject { static class MDProcess : MDObject { protected Process mProcess; protected MDObject mStdin; protected MDObject mStdout; protected MDObject mStderr; public this(MDObject owner) { super("Process", owner); mProcess = new Process(); } } public this(MDObject owner) { super("Process", owner); fields.addList ( "clone"d, new MDClosure(fields, &clone, "Process.clone"), "isRunning"d, new MDClosure(fields, &isRunning, "Process.isRunning"), "workDir"d, new MDClosure(fields, &workDir, "Process.workDir"), "stdin"d, new MDClosure(fields, &stdin, "Process.stdin"), "stdout"d, new MDClosure(fields, &stdout, "Process.stdout"), "stderr"d, new MDClosure(fields, &stderr, "Process.stderr"), "execute"d, new MDClosure(fields, &execute, "Process.execute"), "wait"d, new MDClosure(fields, &wait, "Process.wait"), "kill"d, new MDClosure(fields, &kill, "Process.kill") ); } public int clone(MDState s, uint numParams) { s.push(new MDProcess(this)); return 1; } public int isRunning(MDState s, uint numParams) { s.push(s.safeCode(s.getContext!(MDProcess)().mProcess.isRunning())); return 1; } public int workDir(MDState s, uint numParams) { if(numParams == 0) { s.push(s.safeCode(s.getContext!(MDProcess)().mProcess.workDir())); return 1; } s.safeCode(s.getContext!(MDProcess)().mProcess.workDir(s.getParam!(char[])(0))); return 0; } public int execute(MDState s, uint numParams) { auto self = s.getContext!(MDProcess); char[][char[]] env = null; if(numParams > 1) env = s.getParam!(char[][char[]])(1); if(s.isParam!("string")(0)) s.safeCode(self.mProcess.execute(s.getParam!(char[])(0), env)); else s.safeCode(self.mProcess.execute(s.getParam!(char[][])(0), env)); self.mStdin = null; self.mStdout = null; self.mStderr = null; return 0; } public int stdin(MDState s, uint numParams) { auto self = s.getContext!(MDProcess); if(!self.mStdin) self.mStdin = outputStreamClass.nativeClone(self.mProcess.stdin.output); s.push(self.mStdin); return 1; } public int stdout(MDState s, uint numParams) { auto self = s.getContext!(MDProcess); if(!self.mStdout) self.mStdout = inputStreamClass.nativeClone(self.mProcess.stdout.input); s.push(self.mStdout); return 1; } public int stderr(MDState s, uint numParams) { auto self = s.getContext!(MDProcess); if(!self.mStderr) self.mStderr = inputStreamClass.nativeClone(self.mProcess.stderr.input); s.push(self.mStderr); return 1; } public int wait(MDState s, uint numParams) { auto res = s.safeCode(s.getContext!(MDProcess)().mProcess.wait()); switch(res.reason) { case Process.Result.Exit: s.push("exit"); break; case Process.Result.Signal: s.push("signal"); break; case Process.Result.Stop: s.push("stop"); break; case Process.Result.Continue: s.push("continue"); break; case Process.Result.Error: s.push("error"); break; } s.push(res.status); return 2; } public int kill(MDState s, uint numParams) { s.safeCode(s.getContext!(MDProcess)().mProcess.kill()); return 0; } } }
D
// Written in the D programming language. /** Utilities for manipulating files and scanning directories. Functions in this module handle files as a unit, e.g., read or write one _file at a time. For opening files and manipulating them via handles refer to module $(MREF std, stdio). $(SCRIPT inhibitQuickIndex = 1;) $(BOOKTABLE, $(TR $(TH Category) $(TH Functions)) $(TR $(TD General) $(TD $(LREF exists) $(LREF isDir) $(LREF isFile) $(LREF isSymlink) $(LREF rename) $(LREF thisExePath) )) $(TR $(TD Directories) $(TD $(LREF chdir) $(LREF dirEntries) $(LREF getcwd) $(LREF mkdir) $(LREF mkdirRecurse) $(LREF rmdir) $(LREF rmdirRecurse) $(LREF tempDir) )) $(TR $(TD Files) $(TD $(LREF append) $(LREF copy) $(LREF read) $(LREF readText) $(LREF remove) $(LREF slurp) $(LREF write) )) $(TR $(TD Symlinks) $(TD $(LREF symlink) $(LREF readLink) )) $(TR $(TD Attributes) $(TD $(LREF attrIsDir) $(LREF attrIsFile) $(LREF attrIsSymlink) $(LREF getAttributes) $(LREF getLinkAttributes) $(LREF getSize) $(LREF setAttributes) )) $(TR $(TD Timestamp) $(TD $(LREF getTimes) $(LREF getTimesWin) $(LREF setTimes) $(LREF timeLastModified) )) $(TR $(TD Other) $(TD $(LREF DirEntry) $(LREF FileException) $(LREF PreserveAttributes) $(LREF SpanMode) )) ) Copyright: Copyright Digital Mars 2007 - 2011. See_Also: The $(HTTP ddili.org/ders/d.en/files.html, official tutorial) for an introduction to working with files in D, module $(MREF std, stdio) for opening files and manipulating them via handles, and module $(MREF std, path) for manipulating path strings. License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0). Authors: $(HTTP digitalmars.com, Walter Bright), $(HTTP erdani.org, Andrei Alexandrescu), Jonathan M Davis Source: $(PHOBOSSRC std/_file.d) */ module std.file; import core.stdc.errno, core.stdc.stdlib, core.stdc.string; import core.time : abs, dur, hnsecs, seconds; import std.datetime.date : DateTime; import std.datetime.systime : Clock, SysTime, unixTimeToStdTime; import std.internal.cstring; import std.meta; import std.range.primitives; import std.traits; import std.typecons; version (Windows) { import core.sys.windows.windows, std.windows.syserror; } else version (Posix) { import core.sys.posix.dirent, core.sys.posix.fcntl, core.sys.posix.sys.stat, core.sys.posix.sys.time, core.sys.posix.unistd, core.sys.posix.utime; } else static assert(false, "Module " ~ .stringof ~ " not implemented for this OS."); // Character type used for operating system filesystem APIs version (Windows) { private alias FSChar = wchar; } else version (Posix) { private alias FSChar = char; } else static assert(0); // Purposefully not documented. Use at your own risk @property string deleteme() @safe { import std.conv : to; import std.path : buildPath; import std.process : thisProcessID; static _deleteme = "deleteme.dmd.unittest.pid"; static _first = true; if (_first) { _deleteme = buildPath(tempDir(), _deleteme) ~ to!string(thisProcessID); _first = false; } return _deleteme; } version(unittest) private struct TestAliasedString { string get() @safe @nogc pure nothrow { return _s; } alias get this; @disable this(this); string _s; } version(Android) { package enum system_directory = "/system/etc"; package enum system_file = "/system/etc/hosts"; } else version(Posix) { package enum system_directory = "/usr/include"; package enum system_file = "/usr/include/assert.h"; } /++ Exception thrown for file I/O errors. +/ class FileException : Exception { import std.conv : text, to; /++ OS error code. +/ immutable uint errno; /++ Constructor which takes an error message. Params: name = Name of file for which the error occurred. msg = Message describing the error. file = The _file where the error occurred. line = The _line where the error occurred. +/ this(in char[] name, in char[] msg, string file = __FILE__, size_t line = __LINE__) @safe pure { if (msg.empty) super(name.idup, file, line); else super(text(name, ": ", msg), file, line); errno = 0; } /++ Constructor which takes the error number ($(LUCKY GetLastError) in Windows, $(D_PARAM errno) in Posix). Params: name = Name of file for which the error occurred. errno = The error number. file = The _file where the error occurred. Defaults to $(D __FILE__). line = The _line where the error occurred. Defaults to $(D __LINE__). +/ version(Windows) this(in char[] name, uint errno = .GetLastError(), string file = __FILE__, size_t line = __LINE__) @safe { this(name, sysErrorString(errno), file, line); this.errno = errno; } else version(Posix) this(in char[] name, uint errno = .errno, string file = __FILE__, size_t line = __LINE__) @trusted { import std.exception : errnoString; this(name, errnoString(errno), file, line); this.errno = errno; } } private T cenforce(T)(T condition, lazy const(char)[] name, string file = __FILE__, size_t line = __LINE__) { if (condition) return condition; version (Windows) { throw new FileException(name, .GetLastError(), file, line); } else version (Posix) { throw new FileException(name, .errno, file, line); } } version (Windows) @trusted private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez, string file = __FILE__, size_t line = __LINE__) { if (condition) return condition; if (!name) { import core.stdc.wchar_ : wcslen; import std.conv : to; auto len = namez ? wcslen(namez) : 0; name = to!string(namez[0 .. len]); } throw new FileException(name, .GetLastError(), file, line); } version (Posix) @trusted private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez, string file = __FILE__, size_t line = __LINE__) { if (condition) return condition; if (!name) { import core.stdc.string : strlen; auto len = namez ? strlen(namez) : 0; name = namez[0 .. len].idup; } throw new FileException(name, .errno, file, line); } @safe unittest { // issue 17102 try { cenforce(false, null, null, __FILE__, __LINE__); } catch (FileException) {} } /* ********************************** * Basic File operations. */ /******************************************** Read entire contents of file $(D name) and returns it as an untyped array. If the file size is larger than $(D upTo), only $(D upTo) bytes are _read. Params: name = string or range of characters representing the file _name upTo = if present, the maximum number of bytes to _read Returns: Untyped array of bytes _read. Throws: $(LREF FileException) on error. */ void[] read(R)(R name, size_t upTo = size_t.max) if (isInputRange!R && isSomeChar!(ElementEncodingType!R) && !isInfinite!R && !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) return readImpl(name, name.tempCString!FSChar(), upTo); else return readImpl(null, name.tempCString!FSChar(), upTo); } /// @safe unittest { import std.utf : byChar; scope(exit) { assert(exists(deleteme)); remove(deleteme); } write(deleteme, "1234"); // deleteme is the name of a temporary file assert(read(deleteme, 2) == "12"); assert(read(deleteme.byChar) == "1234"); assert((cast(const(ubyte)[])read(deleteme)).length == 4); } /// ditto void[] read(R)(auto ref R name, size_t upTo = size_t.max) if (isConvertibleToString!R) { return read!(StringTypeOf!R)(name, upTo); } @safe unittest { static assert(__traits(compiles, read(TestAliasedString(null)))); } version (Posix) private void[] readImpl(const(char)[] name, const(FSChar)* namez, size_t upTo = size_t.max) @trusted { import core.memory : GC; import std.algorithm.comparison : min; import std.array : uninitializedArray; import std.conv : to; import std.experimental.checkedint : checked; // A few internal configuration parameters { enum size_t minInitialAlloc = 1024 * 4, maxInitialAlloc = size_t.max / 2, sizeIncrement = 1024 * 16, maxSlackMemoryAllowed = 1024; // } immutable fd = core.sys.posix.fcntl.open(namez, core.sys.posix.fcntl.O_RDONLY); cenforce(fd != -1, name); scope(exit) core.sys.posix.unistd.close(fd); stat_t statbuf = void; cenforce(fstat(fd, &statbuf) == 0, name, namez); immutable initialAlloc = min(upTo, to!size_t(statbuf.st_size ? min(statbuf.st_size + 1, maxInitialAlloc) : minInitialAlloc)); void[] result = uninitializedArray!(ubyte[])(initialAlloc); scope(failure) GC.free(result.ptr); auto size = checked(size_t(0)); for (;;) { immutable actual = core.sys.posix.unistd.read(fd, result.ptr + size.get, (min(result.length, upTo) - size).get); cenforce(actual != -1, name, namez); if (actual == 0) break; size += actual; if (size >= upTo) break; if (size < result.length) continue; immutable newAlloc = size + sizeIncrement; result = GC.realloc(result.ptr, newAlloc.get, GC.BlkAttr.NO_SCAN)[0 .. newAlloc.get]; } return result.length - size >= maxSlackMemoryAllowed ? GC.realloc(result.ptr, size.get, GC.BlkAttr.NO_SCAN)[0 .. size.get] : result[0 .. size.get]; } version (Windows) private void[] readImpl(const(char)[] name, const(FSChar)* namez, size_t upTo = size_t.max) @safe { import core.memory : GC; import std.algorithm.comparison : min; import std.array : uninitializedArray; static trustedCreateFileW(const(wchar)* namez, DWORD dwDesiredAccess, DWORD dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) @trusted { return CreateFileW(namez, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } static trustedCloseHandle(HANDLE hObject) @trusted { return CloseHandle(hObject); } static trustedGetFileSize(HANDLE hFile, out ulong fileSize) @trusted { DWORD sizeHigh; DWORD sizeLow = GetFileSize(hFile, &sizeHigh); const bool result = sizeLow != INVALID_FILE_SIZE; if (result) fileSize = makeUlong(sizeLow, sizeHigh); return result; } static trustedReadFile(HANDLE hFile, void *lpBuffer, ulong nNumberOfBytesToRead) @trusted { // Read by chunks of size < 4GB (Windows API limit) ulong totalNumRead = 0; while (totalNumRead != nNumberOfBytesToRead) { const uint chunkSize = min(nNumberOfBytesToRead - totalNumRead, 0xffff_0000); DWORD numRead = void; const result = ReadFile(hFile, lpBuffer + totalNumRead, chunkSize, &numRead, null); if (result == 0 || numRead != chunkSize) return false; totalNumRead += chunkSize; } return true; } alias defaults = AliasSeq!(GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, (SECURITY_ATTRIBUTES*).init, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, HANDLE.init); auto h = trustedCreateFileW(namez, defaults); cenforce(h != INVALID_HANDLE_VALUE, name, namez); scope(exit) cenforce(trustedCloseHandle(h), name, namez); ulong fileSize = void; cenforce(trustedGetFileSize(h, fileSize), name, namez); size_t size = min(upTo, fileSize); auto buf = uninitializedArray!(ubyte[])(size); scope(failure) { () @trusted { GC.free(buf.ptr); } (); } if (size) cenforce(trustedReadFile(h, &buf[0], size), name, namez); return buf[0 .. size]; } version (linux) @safe unittest { // A file with "zero" length that doesn't have 0 length at all auto s = std.file.readText("/proc/sys/kernel/osrelease"); assert(s.length > 0); //writefln("'%s'", s); } @safe unittest { scope(exit) if (exists(deleteme)) remove(deleteme); import std.stdio; auto f = File(deleteme, "w"); f.write("abcd"); f.flush(); assert(read(deleteme) == "abcd"); } /++ Reads and validates (using $(REF validate, std, utf)) a text file. S can be an array of any character type. However, no width or endian conversions are performed. So, if the width or endianness of the characters in the given file differ from the width or endianness of the element type of S, then validation will fail. Params: name = string or range of characters representing the file _name Returns: Array of characters read. Throws: $(LREF FileException) if there is an error reading the file, $(REF UTFException, std, utf) on UTF decoding error. +/ S readText(S = string, R)(auto ref R name) if (isSomeString!S && (isInputRange!R && !isInfinite!R && isSomeChar!(ElementType!R) || is(StringTypeOf!R))) { import std.algorithm.searching : startsWith; import std.encoding : getBOM, BOM; import std.exception : enforce; import std.format : format; import std.utf : UTFException, validate; static if (is(StringTypeOf!R)) StringTypeOf!R filename = name; else auto filename = name; static auto trustedCast(T)(void[] buf) @trusted { return cast(T) buf; } auto data = trustedCast!(ubyte[])(read(filename)); immutable bomSeq = getBOM(data); immutable bom = bomSeq.schema; static if (is(Unqual!(ElementEncodingType!S) == char)) { with(BOM) switch (bom) { case utf16be: case utf16le: throw new UTFException("UTF-8 requested. BOM is for UTF-16"); case utf32be: case utf32le: throw new UTFException("UTF-8 requested. BOM is for UTF-32"); default: break; } } else static if (is(Unqual!(ElementEncodingType!S) == wchar)) { with(BOM) switch (bom) { case utf8: throw new UTFException("UTF-16 requested. BOM is for UTF-8"); case utf16be: { version(BigEndian) break; else throw new UTFException("BOM is for UTF-16 LE on Big Endian machine"); } case utf16le: { version(BigEndian) throw new UTFException("BOM is for UTF-16 BE on Little Endian machine"); else break; } case utf32be: case utf32le: throw new UTFException("UTF-8 requested. BOM is for UTF-32"); default: break; } } else { with(BOM) switch (bom) { case utf8: throw new UTFException("UTF-16 requested. BOM is for UTF-8"); case utf16be: case utf16le: throw new UTFException("UTF-8 requested. BOM is for UTF-16"); case utf32be: { version(BigEndian) break; else throw new UTFException("BOM is for UTF-32 LE on Big Endian machine"); } case utf32le: { version(BigEndian) throw new UTFException("BOM is for UTF-32 BE on Little Endian machine"); else break; } default: break; } } if (data.length % ElementEncodingType!S.sizeof != 0) throw new UTFException(format!"The content of %s is not UTF-%s"(filename, ElementEncodingType!S.sizeof * 8)); auto result = trustedCast!S(data); validate(result); return result; } // Read file with UTF-8 text. @safe unittest { write(deleteme, "abc"); // deleteme is the name of a temporary file scope(exit) remove(deleteme); string content = readText(deleteme); assert(content == "abc"); } // Read file with UTF-8 text but try to read it as UTF-16. @safe unittest { import std.exception : assertThrown; import std.utf : UTFException; write(deleteme, "abc"); scope(exit) remove(deleteme); // Throws because the file is not valid UTF-16. assertThrown!UTFException(readText!wstring(deleteme)); } // Read file with UTF-16 text. @safe unittest { import std.algorithm.searching : skipOver; write(deleteme, "\uFEFFabc"w); // With BOM scope(exit) remove(deleteme); auto content = readText!wstring(deleteme); assert(content == "\uFEFFabc"w); // Strips BOM if present. content.skipOver('\uFEFF'); assert(content == "abc"w); } @safe unittest { static assert(__traits(compiles, readText(TestAliasedString(null)))); } @system unittest { import std.array : appender; import std.bitmanip : append, Endian; import std.exception : assertThrown; import std.path : buildPath; import std.string : representation; import std.utf : UTFException; mkdir(deleteme); scope(exit) rmdirRecurse(deleteme); immutable none8 = buildPath(deleteme, "none8"); immutable none16 = buildPath(deleteme, "none16"); immutable utf8 = buildPath(deleteme, "utf8"); immutable utf16be = buildPath(deleteme, "utf16be"); immutable utf16le = buildPath(deleteme, "utf16le"); immutable utf32be = buildPath(deleteme, "utf32be"); immutable utf32le = buildPath(deleteme, "utf32le"); immutable utf7 = buildPath(deleteme, "utf7"); write(none8, "京都市"); write(none16, "京都市"w); write(utf8, (cast(char[])[0xEF, 0xBB, 0xBF]) ~ "京都市"); { auto str = "\uFEFF京都市"w; auto arr = appender!(ubyte[])(); foreach (c; str) arr.append(c); write(utf16be, arr.data); } { auto str = "\uFEFF京都市"w; auto arr = appender!(ubyte[])(); foreach (c; str) arr.append!(ushort, Endian.littleEndian)(c); write(utf16le, arr.data); } { auto str = "\U0000FEFF京都市"d; auto arr = appender!(ubyte[])(); foreach (c; str) arr.append(c); write(utf32be, arr.data); } { auto str = "\U0000FEFF京都市"d; auto arr = appender!(ubyte[])(); foreach (c; str) arr.append!(uint, Endian.littleEndian)(c); write(utf32le, arr.data); } write(utf7, (cast(ubyte[])[0x2B, 0x2F, 0x76, 0x38, 0x2D]) ~ "foobar".representation); assertThrown!UTFException(readText(none16)); assert(readText(utf8) == (cast(char[])[0xEF, 0xBB, 0xBF]) ~ "京都市"); assertThrown!UTFException(readText(utf16be)); assertThrown!UTFException(readText(utf16le)); assertThrown!UTFException(readText(utf32be)); assertThrown!UTFException(readText(utf32le)); assert(readText(utf7) == (cast(char[])[0x2B, 0x2F, 0x76, 0x38, 0x2D]) ~ "foobar"); assertThrown!UTFException(readText!wstring(none8)); assert(readText!wstring(none16) == "京都市"w); assertThrown!UTFException(readText!wstring(utf8)); version(BigEndian) { assert(readText!wstring(utf16be) == "\uFEFF京都市"w); assertThrown!UTFException(readText!wstring(utf16le)); } else { assertThrown!UTFException(readText!wstring(utf16be)); assert(readText!wstring(utf16le) == "\uFEFF京都市"w); } assertThrown!UTFException(readText!wstring(utf32be)); assertThrown!UTFException(readText!wstring(utf32le)); assertThrown!UTFException(readText!wstring(utf7)); assertThrown!UTFException(readText!dstring(utf8)); assertThrown!UTFException(readText!dstring(utf16be)); assertThrown!UTFException(readText!dstring(utf16le)); version(BigEndian) { assert(readText!dstring(utf32be) == "\U0000FEFF京都市"d); assertThrown!UTFException(readText!dstring(utf32le)); } else { assertThrown!UTFException(readText!dstring(utf32be)); assert(readText!dstring(utf32le) == "\U0000FEFF京都市"d); } assertThrown!UTFException(readText!dstring(utf7)); } /********************************************* Write $(D buffer) to file $(D name). Creates the file if it does not already exist. Params: name = string or range of characters representing the file _name buffer = data to be written to file Throws: $(D FileException) on error. See_also: $(REF toFile, std,stdio) */ void write(R)(R name, const void[] buffer) if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) writeImpl(name, name.tempCString!FSChar(), buffer, false); else writeImpl(null, name.tempCString!FSChar(), buffer, false); } /// @system unittest { scope(exit) { assert(exists(deleteme)); remove(deleteme); } int[] a = [ 0, 1, 1, 2, 3, 5, 8 ]; write(deleteme, a); // deleteme is the name of a temporary file assert(cast(int[]) read(deleteme) == a); } /// ditto void write(R)(auto ref R name, const void[] buffer) if (isConvertibleToString!R) { write!(StringTypeOf!R)(name, buffer); } @safe unittest { static assert(__traits(compiles, write(TestAliasedString(null), null))); } /********************************************* Appends $(D buffer) to file $(D name). Creates the file if it does not already exist. Params: name = string or range of characters representing the file _name buffer = data to be appended to file Throws: $(D FileException) on error. */ void append(R)(R name, const void[] buffer) if ((isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isSomeString!R) && !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) writeImpl(name, name.tempCString!FSChar(), buffer, true); else writeImpl(null, name.tempCString!FSChar(), buffer, true); } /// @system unittest { scope(exit) { assert(exists(deleteme)); remove(deleteme); } int[] a = [ 0, 1, 1, 2, 3, 5, 8 ]; write(deleteme, a); // deleteme is the name of a temporary file int[] b = [ 13, 21 ]; append(deleteme, b); assert(cast(int[]) read(deleteme) == a ~ b); } /// ditto void append(R)(auto ref R name, const void[] buffer) if (isConvertibleToString!R) { append!(StringTypeOf!R)(name, buffer); } @safe unittest { static assert(__traits(compiles, append(TestAliasedString("foo"), [0, 1, 2, 3]))); } // Posix implementation helper for write and append version(Posix) private void writeImpl(const(char)[] name, const(FSChar)* namez, in void[] buffer, bool append) @trusted { import std.conv : octal; // append or write auto mode = append ? O_CREAT | O_WRONLY | O_APPEND : O_CREAT | O_WRONLY | O_TRUNC; immutable fd = core.sys.posix.fcntl.open(namez, mode, octal!666); cenforce(fd != -1, name, namez); { scope(failure) core.sys.posix.unistd.close(fd); immutable size = buffer.length; size_t sum, cnt = void; while (sum != size) { cnt = (size - sum < 2^^30) ? (size - sum) : 2^^30; const numwritten = core.sys.posix.unistd.write(fd, buffer.ptr + sum, cnt); if (numwritten != cnt) break; sum += numwritten; } cenforce(sum == size, name, namez); } cenforce(core.sys.posix.unistd.close(fd) == 0, name, namez); } // Windows implementation helper for write and append version(Windows) private void writeImpl(const(char)[] name, const(FSChar)* namez, in void[] buffer, bool append) @trusted { HANDLE h; if (append) { alias defaults = AliasSeq!(GENERIC_WRITE, 0, null, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, HANDLE.init); h = CreateFileW(namez, defaults); cenforce(h != INVALID_HANDLE_VALUE, name, namez); cenforce(SetFilePointer(h, 0, null, FILE_END) != INVALID_SET_FILE_POINTER, name, namez); } else // write { alias defaults = AliasSeq!(GENERIC_WRITE, 0, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, HANDLE.init); h = CreateFileW(namez, defaults); cenforce(h != INVALID_HANDLE_VALUE, name, namez); } immutable size = buffer.length; size_t sum, cnt = void; DWORD numwritten = void; while (sum != size) { cnt = (size - sum < 2^^30) ? (size - sum) : 2^^30; WriteFile(h, buffer.ptr + sum, cast(uint) cnt, &numwritten, null); if (numwritten != cnt) break; sum += numwritten; } cenforce(sum == size && CloseHandle(h), name, namez); } /*************************************************** * Rename file $(D from) _to $(D to). * If the target file exists, it is overwritten. * Params: * from = string or range of characters representing the existing file name * to = string or range of characters representing the target file name * Throws: $(D FileException) on error. */ void rename(RF, RT)(RF from, RT to) if ((isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) || isSomeString!RF) && !isConvertibleToString!RF && (isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) || isSomeString!RT) && !isConvertibleToString!RT) { // Place outside of @trusted block auto fromz = from.tempCString!FSChar(); auto toz = to.tempCString!FSChar(); static if (isNarrowString!RF && is(Unqual!(ElementEncodingType!RF) == char)) alias f = from; else enum string f = null; static if (isNarrowString!RT && is(Unqual!(ElementEncodingType!RT) == char)) alias t = to; else enum string t = null; renameImpl(f, t, fromz, toz); } /// ditto void rename(RF, RT)(auto ref RF from, auto ref RT to) if (isConvertibleToString!RF || isConvertibleToString!RT) { import std.meta : staticMap; alias Types = staticMap!(convertToString, RF, RT); rename!Types(from, to); } @safe unittest { static assert(__traits(compiles, rename(TestAliasedString(null), TestAliasedString(null)))); static assert(__traits(compiles, rename("", TestAliasedString(null)))); static assert(__traits(compiles, rename(TestAliasedString(null), ""))); import std.utf : byChar; static assert(__traits(compiles, rename(TestAliasedString(null), "".byChar))); } private void renameImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, const(FSChar)* toz) @trusted { version(Windows) { import std.exception : enforce; const result = MoveFileExW(fromz, toz, MOVEFILE_REPLACE_EXISTING); if (!result) { import core.stdc.wchar_ : wcslen; import std.conv : to, text; if (!f) f = to!(typeof(f))(fromz[0 .. wcslen(fromz)]); if (!t) t = to!(typeof(t))(toz[0 .. wcslen(toz)]); enforce(false, new FileException( text("Attempting to rename file ", f, " to ", t))); } } else version(Posix) { static import core.stdc.stdio; cenforce(core.stdc.stdio.rename(fromz, toz) == 0, t, toz); } } @safe unittest { import std.utf : byWchar; auto t1 = deleteme, t2 = deleteme~"2"; scope(exit) foreach (t; [t1, t2]) if (t.exists) t.remove(); write(t1, "1"); rename(t1, t2); assert(readText(t2) == "1"); write(t1, "2"); rename(t1, t2.byWchar); assert(readText(t2) == "2"); } /*************************************************** Delete file $(D name). Params: name = string or range of characters representing the file _name Throws: $(D FileException) on error. */ void remove(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) removeImpl(name, name.tempCString!FSChar()); else removeImpl(null, name.tempCString!FSChar()); } /// ditto void remove(R)(auto ref R name) if (isConvertibleToString!R) { remove!(StringTypeOf!R)(name); } @safe unittest { static assert(__traits(compiles, remove(TestAliasedString("foo")))); } private void removeImpl(const(char)[] name, const(FSChar)* namez) @trusted { version(Windows) { cenforce(DeleteFileW(namez), name, namez); } else version(Posix) { static import core.stdc.stdio; if (!name) { import core.stdc.string : strlen; auto len = strlen(namez); name = namez[0 .. len]; } cenforce(core.stdc.stdio.remove(namez) == 0, "Failed to remove file " ~ name); } } version(Windows) private WIN32_FILE_ATTRIBUTE_DATA getFileAttributesWin(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { auto namez = name.tempCString!FSChar(); WIN32_FILE_ATTRIBUTE_DATA fad = void; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) { static void getFA(const(char)[] name, const(FSChar)* namez, out WIN32_FILE_ATTRIBUTE_DATA fad) @trusted { import std.exception : enforce; enforce(GetFileAttributesExW(namez, GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, &fad), new FileException(name.idup)); } getFA(name, namez, fad); } else { static void getFA(const(FSChar)* namez, out WIN32_FILE_ATTRIBUTE_DATA fad) @trusted { import core.stdc.wchar_ : wcslen; import std.conv : to; import std.exception : enforce; enforce(GetFileAttributesExW(namez, GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, &fad), new FileException(namez[0 .. wcslen(namez)].to!string)); } getFA(namez, fad); } return fad; } version(Windows) private ulong makeUlong(DWORD dwLow, DWORD dwHigh) @safe pure nothrow @nogc { ULARGE_INTEGER li; li.LowPart = dwLow; li.HighPart = dwHigh; return li.QuadPart; } /*************************************************** Get size of file $(D name) in bytes. Params: name = string or range of characters representing the file _name Throws: $(D FileException) on error (e.g., file not found). */ ulong getSize(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { with (getFileAttributesWin(name)) return makeUlong(nFileSizeLow, nFileSizeHigh); } else version(Posix) { auto namez = name.tempCString(); static trustedStat(const(FSChar)* namez, out stat_t buf) @trusted { return stat(namez, &buf); } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; stat_t statbuf = void; cenforce(trustedStat(namez, statbuf) == 0, names, namez); return statbuf.st_size; } } /// ditto ulong getSize(R)(auto ref R name) if (isConvertibleToString!R) { return getSize!(StringTypeOf!R)(name); } @safe unittest { static assert(__traits(compiles, getSize(TestAliasedString("foo")))); } @safe unittest { // create a file of size 1 write(deleteme, "a"); scope(exit) { assert(exists(deleteme)); remove(deleteme); } assert(getSize(deleteme) == 1); // create a file of size 3 write(deleteme, "abc"); import std.utf : byChar; assert(getSize(deleteme.byChar) == 3); } // Reads a time field from a stat_t with full precision. version(Posix) private SysTime statTimeToStdTime(char which)(ref stat_t statbuf) { auto unixTime = mixin(`statbuf.st_` ~ which ~ `time`); long stdTime = unixTimeToStdTime(unixTime); static if (is(typeof(mixin(`statbuf.st_` ~ which ~ `tim`)))) stdTime += mixin(`statbuf.st_` ~ which ~ `tim.tv_nsec`) / 100; else static if (is(typeof(mixin(`statbuf.st_` ~ which ~ `timensec`)))) stdTime += mixin(`statbuf.st_` ~ which ~ `timensec`) / 100; else static if (is(typeof(mixin(`statbuf.st_` ~ which ~ `time_nsec`)))) stdTime += mixin(`statbuf.st_` ~ which ~ `time_nsec`) / 100; else static if (is(typeof(mixin(`statbuf.__st_` ~ which ~ `timensec`)))) stdTime += mixin(`statbuf.__st_` ~ which ~ `timensec`) / 100; return SysTime(stdTime); } /++ Get the access and modified times of file or folder $(D name). Params: name = File/Folder _name to get times for. accessTime = Time the file/folder was last accessed. modificationTime = Time the file/folder was last modified. Throws: $(D FileException) on error. +/ void getTimes(R)(R name, out SysTime accessTime, out SysTime modificationTime) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { import std.datetime.systime : FILETIMEToSysTime; with (getFileAttributesWin(name)) { accessTime = FILETIMEToSysTime(&ftLastAccessTime); modificationTime = FILETIMEToSysTime(&ftLastWriteTime); } } else version(Posix) { auto namez = name.tempCString(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted { return stat(namez, &buf); } stat_t statbuf = void; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedStat(namez, statbuf) == 0, names, namez); accessTime = statTimeToStdTime!'a'(statbuf); modificationTime = statTimeToStdTime!'m'(statbuf); } } /// ditto void getTimes(R)(auto ref R name, out SysTime accessTime, out SysTime modificationTime) if (isConvertibleToString!R) { return getTimes!(StringTypeOf!R)(name, accessTime, modificationTime); } @safe unittest { SysTime atime, mtime; static assert(__traits(compiles, getTimes(TestAliasedString("foo"), atime, mtime))); } @system unittest { import std.stdio : writefln; auto currTime = Clock.currTime(); write(deleteme, "a"); scope(exit) { assert(exists(deleteme)); remove(deleteme); } SysTime accessTime1 = void; SysTime modificationTime1 = void; getTimes(deleteme, accessTime1, modificationTime1); enum leeway = dur!"seconds"(5); { auto diffa = accessTime1 - currTime; auto diffm = modificationTime1 - currTime; scope(failure) writefln("[%s] [%s] [%s] [%s] [%s]", accessTime1, modificationTime1, currTime, diffa, diffm); assert(abs(diffa) <= leeway); assert(abs(diffm) <= leeway); } version(fullFileTests) { import core.thread; enum sleepTime = dur!"seconds"(2); Thread.sleep(sleepTime); currTime = Clock.currTime(); write(deleteme, "b"); SysTime accessTime2 = void; SysTime modificationTime2 = void; getTimes(deleteme, accessTime2, modificationTime2); { auto diffa = accessTime2 - currTime; auto diffm = modificationTime2 - currTime; scope(failure) writefln("[%s] [%s] [%s] [%s] [%s]", accessTime2, modificationTime2, currTime, diffa, diffm); //There is no guarantee that the access time will be updated. assert(abs(diffa) <= leeway + sleepTime); assert(abs(diffm) <= leeway); } assert(accessTime1 <= accessTime2); assert(modificationTime1 <= modificationTime2); } } version(StdDdoc) { /++ $(BLUE This function is Windows-Only.) Get creation/access/modified times of file $(D name). This is the same as $(D getTimes) except that it also gives you the file creation time - which isn't possible on Posix systems. Params: name = File _name to get times for. fileCreationTime = Time the file was created. fileAccessTime = Time the file was last accessed. fileModificationTime = Time the file was last modified. Throws: $(D FileException) on error. +/ void getTimesWin(R)(R name, out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R); } else version(Windows) { void getTimesWin(R)(R name, out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { import std.datetime.systime : FILETIMEToSysTime; with (getFileAttributesWin(name)) { fileCreationTime = FILETIMEToSysTime(&ftCreationTime); fileAccessTime = FILETIMEToSysTime(&ftLastAccessTime); fileModificationTime = FILETIMEToSysTime(&ftLastWriteTime); } } void getTimesWin(R)(auto ref R name, out SysTime fileCreationTime, out SysTime fileAccessTime, out SysTime fileModificationTime) if (isConvertibleToString!R) { getTimesWin!(StringTypeOf!R)(name, fileCreationTime, fileAccessTime, fileModificationTime); } } version(Windows) @system unittest { import std.stdio : writefln; auto currTime = Clock.currTime(); write(deleteme, "a"); scope(exit) { assert(exists(deleteme)); remove(deleteme); } SysTime creationTime1 = void; SysTime accessTime1 = void; SysTime modificationTime1 = void; getTimesWin(deleteme, creationTime1, accessTime1, modificationTime1); enum leeway = dur!"seconds"(5); { auto diffc = creationTime1 - currTime; auto diffa = accessTime1 - currTime; auto diffm = modificationTime1 - currTime; scope(failure) { writefln("[%s] [%s] [%s] [%s] [%s] [%s] [%s]", creationTime1, accessTime1, modificationTime1, currTime, diffc, diffa, diffm); } // Deleting and recreating a file doesn't seem to always reset the "file creation time" //assert(abs(diffc) <= leeway); assert(abs(diffa) <= leeway); assert(abs(diffm) <= leeway); } version(fullFileTests) { import core.thread; Thread.sleep(dur!"seconds"(2)); currTime = Clock.currTime(); write(deleteme, "b"); SysTime creationTime2 = void; SysTime accessTime2 = void; SysTime modificationTime2 = void; getTimesWin(deleteme, creationTime2, accessTime2, modificationTime2); { auto diffa = accessTime2 - currTime; auto diffm = modificationTime2 - currTime; scope(failure) { writefln("[%s] [%s] [%s] [%s] [%s]", accessTime2, modificationTime2, currTime, diffa, diffm); } assert(abs(diffa) <= leeway); assert(abs(diffm) <= leeway); } assert(creationTime1 == creationTime2); assert(accessTime1 <= accessTime2); assert(modificationTime1 <= modificationTime2); } { SysTime ctime, atime, mtime; static assert(__traits(compiles, getTimesWin(TestAliasedString("foo"), ctime, atime, mtime))); } } /++ Set access/modified times of file or folder $(D name). Params: name = File/Folder _name to get times for. accessTime = Time the file/folder was last accessed. modificationTime = Time the file/folder was last modified. Throws: $(D FileException) on error. +/ void setTimes(R)(R name, SysTime accessTime, SysTime modificationTime) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { import std.datetime.systime : SysTimeToFILETIME; auto namez = name.tempCString!FSChar(); static auto trustedCreateFileW(const(FSChar)* namez, DWORD dwDesiredAccess, DWORD dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) @trusted { return CreateFileW(namez, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } static auto trustedCloseHandle(HANDLE hObject) @trusted { return CloseHandle(hObject); } static auto trustedSetFileTime(HANDLE hFile, in FILETIME *lpCreationTime, in ref FILETIME lpLastAccessTime, in ref FILETIME lpLastWriteTime) @trusted { return SetFileTime(hFile, lpCreationTime, &lpLastAccessTime, &lpLastWriteTime); } const ta = SysTimeToFILETIME(accessTime); const tm = SysTimeToFILETIME(modificationTime); alias defaults = AliasSeq!(GENERIC_WRITE, 0, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_BACKUP_SEMANTICS, HANDLE.init); auto h = trustedCreateFileW(namez, defaults); static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(h != INVALID_HANDLE_VALUE, names, namez); scope(exit) cenforce(trustedCloseHandle(h), names, namez); cenforce(trustedSetFileTime(h, null, ta, tm), names, namez); } else version(Posix) { auto namez = name.tempCString!FSChar(); static if (is(typeof(&utimensat))) { static auto trustedUtimensat(int fd, const(FSChar)* namez, const ref timespec[2] times, int flags) @trusted { return utimensat(fd, namez, times, flags); } timespec[2] t = void; t[0] = accessTime.toTimeSpec(); t[1] = modificationTime.toTimeSpec(); static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedUtimensat(AT_FDCWD, namez, t, 0) == 0, names, namez); } else { static auto trustedUtimes(const(FSChar)* namez, const ref timeval[2] times) @trusted { return utimes(namez, times); } timeval[2] t = void; t[0] = accessTime.toTimeVal(); t[1] = modificationTime.toTimeVal(); static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedUtimes(namez, t) == 0, names, namez); } } } /// ditto void setTimes(R)(auto ref R name, SysTime accessTime, SysTime modificationTime) if (isConvertibleToString!R) { setTimes!(StringTypeOf!R)(name, accessTime, modificationTime); } @safe unittest { if (false) // Test instatiation setTimes(TestAliasedString("foo"), SysTime.init, SysTime.init); } @system unittest { import std.stdio : File; string newdir = deleteme ~ r".dir"; string dir = newdir ~ r"/a/b/c"; string file = dir ~ "/file"; if (!exists(dir)) mkdirRecurse(dir); { auto f = File(file, "w"); } void testTimes(int hnsecValue) { foreach (path; [file, dir]) // test file and dir { SysTime atime = SysTime(DateTime(2010, 10, 4, 0, 0, 30), hnsecs(hnsecValue)); SysTime mtime = SysTime(DateTime(2011, 10, 4, 0, 0, 30), hnsecs(hnsecValue)); setTimes(path, atime, mtime); SysTime atime_res; SysTime mtime_res; getTimes(path, atime_res, mtime_res); assert(atime == atime_res); assert(mtime == mtime_res); } } testTimes(0); version (linux) testTimes(123_456_7); rmdirRecurse(newdir); } /++ Returns the time that the given file was last modified. Throws: $(D FileException) if the given file does not exist. +/ SysTime timeLastModified(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { SysTime dummy; SysTime ftm; getTimesWin(name, dummy, dummy, ftm); return ftm; } else version(Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted { return stat(namez, &buf); } stat_t statbuf = void; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedStat(namez, statbuf) == 0, names, namez); return statTimeToStdTime!'m'(statbuf); } } /// ditto SysTime timeLastModified(R)(auto ref R name) if (isConvertibleToString!R) { return timeLastModified!(StringTypeOf!R)(name); } @safe unittest { static assert(__traits(compiles, timeLastModified(TestAliasedString("foo")))); } /++ Returns the time that the given file was last modified. If the file does not exist, returns $(D returnIfMissing). A frequent usage pattern occurs in build automation tools such as $(HTTP gnu.org/software/make, make) or $(HTTP en.wikipedia.org/wiki/Apache_Ant, ant). To check whether file $(D target) must be rebuilt from file $(D source) (i.e., $(D target) is older than $(D source) or does not exist), use the comparison below. The code throws a $(D FileException) if $(D source) does not exist (as it should). On the other hand, the $(D SysTime.min) default makes a non-existing $(D target) seem infinitely old so the test correctly prompts building it. Params: name = The _name of the file to get the modification time for. returnIfMissing = The time to return if the given file does not exist. Example: -------------------- if (timeLastModified(source) >= timeLastModified(target, SysTime.min)) { // must (re)build } else { // target is up-to-date } -------------------- +/ SysTime timeLastModified(R)(R name, SysTime returnIfMissing) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R)) { version(Windows) { if (!exists(name)) return returnIfMissing; SysTime dummy; SysTime ftm; getTimesWin(name, dummy, dummy, ftm); return ftm; } else version(Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted { return stat(namez, &buf); } stat_t statbuf = void; return trustedStat(namez, statbuf) != 0 ? returnIfMissing : statTimeToStdTime!'m'(statbuf); } } @safe unittest { //std.process.system("echo a > deleteme") == 0 || assert(false); if (exists(deleteme)) remove(deleteme); write(deleteme, "a\n"); scope(exit) { assert(exists(deleteme)); remove(deleteme); } // assert(lastModified("deleteme") > // lastModified("this file does not exist", SysTime.min)); //assert(lastModified("deleteme") > lastModified(__FILE__)); } // Tests sub-second precision of querying file times. // Should pass on most modern systems running on modern filesystems. // Exceptions: // - FreeBSD, where one would need to first set the // vfs.timestamp_precision sysctl to a value greater than zero. // - OS X, where the native filesystem (HFS+) stores filesystem // timestamps with 1-second precision. version (FreeBSD) {} else version (DragonFlyBSD) {} else version (OSX) {} else @system unittest { import core.thread; if (exists(deleteme)) remove(deleteme); SysTime lastTime; foreach (n; 0 .. 3) { write(deleteme, "a"); auto time = timeLastModified(deleteme); remove(deleteme); assert(time != lastTime); lastTime = time; Thread.sleep(10.msecs); } } /** * Determine whether the given file (or directory) _exists. * Params: * name = string or range of characters representing the file _name * Returns: * true if the file _name specified as input _exists */ bool exists(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { return existsImpl(name.tempCString!FSChar()); } /// ditto bool exists(R)(auto ref R name) if (isConvertibleToString!R) { return exists!(StringTypeOf!R)(name); } private bool existsImpl(const(FSChar)* namez) @trusted nothrow @nogc { version(Windows) { // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ // fileio/base/getfileattributes.asp return GetFileAttributesW(namez) != 0xFFFFFFFF; } else version(Posix) { /* The reason why we use stat (and not access) here is the quirky behavior of access for SUID programs: if we used access, a file may not appear to "exist", despite that the program would be able to open it just fine. The behavior in question is described as follows in the access man page: > The check is done using the calling process's real > UID and GID, rather than the effective IDs as is > done when actually attempting an operation (e.g., > open(2)) on the file. This allows set-user-ID > programs to easily determine the invoking user's > authority. While various operating systems provide eaccess or euidaccess functions, these are not part of POSIX - so it's safer to use stat instead. */ stat_t statbuf = void; return lstat(namez, &statbuf) == 0; } else static assert(0); } @safe unittest { assert(exists(".")); assert(!exists("this file does not exist")); write(deleteme, "a\n"); scope(exit) { assert(exists(deleteme)); remove(deleteme); } assert(exists(deleteme)); } @safe unittest // Bugzilla 16573 { enum S : string { foo = "foo" } assert(__traits(compiles, S.foo.exists)); } /++ Returns the attributes of the given file. Note that the file attributes on Windows and Posix systems are completely different. On Windows, they're what is returned by $(HTTP msdn.microsoft.com/en-us/library/aa364944(v=vs.85).aspx, GetFileAttributes), whereas on Posix systems, they're the $(LUCKY st_mode) value which is part of the $(D stat struct) gotten by calling the $(HTTP en.wikipedia.org/wiki/Stat_%28Unix%29, $(D stat)) function. On Posix systems, if the given file is a symbolic link, then attributes are the attributes of the file pointed to by the symbolic link. Params: name = The file to get the attributes of. Throws: $(D FileException) on error. +/ uint getAttributes(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { auto namez = name.tempCString!FSChar(); static auto trustedGetFileAttributesW(const(FSChar)* namez) @trusted { return GetFileAttributesW(namez); } immutable result = trustedGetFileAttributesW(namez); static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(result != INVALID_FILE_ATTRIBUTES, names, namez); return result; } else version(Posix) { auto namez = name.tempCString!FSChar(); static auto trustedStat(const(FSChar)* namez, ref stat_t buf) @trusted { return stat(namez, &buf); } stat_t statbuf = void; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedStat(namez, statbuf) == 0, names, namez); return statbuf.st_mode; } } /// ditto uint getAttributes(R)(auto ref R name) if (isConvertibleToString!R) { return getAttributes!(StringTypeOf!R)(name); } @safe unittest { static assert(__traits(compiles, getAttributes(TestAliasedString(null)))); } /++ If the given file is a symbolic link, then this returns the attributes of the symbolic link itself rather than file that it points to. If the given file is $(I not) a symbolic link, then this function returns the same result as getAttributes. On Windows, getLinkAttributes is identical to getAttributes. It exists on Windows so that you don't have to special-case code for Windows when dealing with symbolic links. Params: name = The file to get the symbolic link attributes of. Returns: the attributes Throws: $(D FileException) on error. +/ uint getLinkAttributes(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { return getAttributes(name); } else version(Posix) { auto namez = name.tempCString!FSChar(); static auto trustedLstat(const(FSChar)* namez, ref stat_t buf) @trusted { return lstat(namez, &buf); } stat_t lstatbuf = void; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedLstat(namez, lstatbuf) == 0, names, namez); return lstatbuf.st_mode; } } /// ditto uint getLinkAttributes(R)(auto ref R name) if (isConvertibleToString!R) { return getLinkAttributes!(StringTypeOf!R)(name); } @safe unittest { static assert(__traits(compiles, getLinkAttributes(TestAliasedString(null)))); } /++ Set the _attributes of the given file. Params: name = the file _name attributes = the _attributes to set the file to Throws: $(D FileException) if the given file does not exist. +/ void setAttributes(R)(R name, uint attributes) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version (Windows) { auto namez = name.tempCString!FSChar(); static auto trustedSetFileAttributesW(const(FSChar)* namez, uint dwFileAttributes) @trusted { return SetFileAttributesW(namez, dwFileAttributes); } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(trustedSetFileAttributesW(namez, attributes), names, namez); } else version (Posix) { auto namez = name.tempCString!FSChar(); static auto trustedChmod(const(FSChar)* namez, mode_t mode) @trusted { return chmod(namez, mode); } assert(attributes <= mode_t.max); static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias names = name; else string names = null; cenforce(!trustedChmod(namez, cast(mode_t) attributes), names, namez); } } /// ditto void setAttributes(R)(auto ref R name, uint attributes) if (isConvertibleToString!R) { return setAttributes!(StringTypeOf!R)(name, attributes); } @safe unittest { static assert(__traits(compiles, setAttributes(TestAliasedString(null), 0))); } /++ Returns whether the given file is a directory. Params: name = The path to the file. Returns: true if name specifies a directory Throws: $(D FileException) if the given file does not exist. Example: -------------------- assert(!"/etc/fonts/fonts.conf".isDir); assert("/usr/share/include".isDir); -------------------- +/ @property bool isDir(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) { return (getAttributes(name) & FILE_ATTRIBUTE_DIRECTORY) != 0; } else version(Posix) { return (getAttributes(name) & S_IFMT) == S_IFDIR; } } /// ditto @property bool isDir(R)(auto ref R name) if (isConvertibleToString!R) { return name.isDir!(StringTypeOf!R); } @safe unittest { static assert(__traits(compiles, TestAliasedString(null).isDir)); } @safe unittest { version(Windows) { if ("C:\\Program Files\\".exists) assert("C:\\Program Files\\".isDir); if ("C:\\Windows\\system.ini".exists) assert(!"C:\\Windows\\system.ini".isDir); } else version(Posix) { if (system_directory.exists) assert(system_directory.isDir); if (system_file.exists) assert(!system_file.isDir); } } @system unittest { version(Windows) enum dir = "C:\\Program Files\\"; else version(Posix) enum dir = system_directory; if (dir.exists) { DirEntry de = DirEntry(dir); assert(de.isDir); assert(DirEntry(dir).isDir); } } /++ Returns whether the given file _attributes are for a directory. Params: attributes = The file _attributes. Returns: true if attributes specifies a directory Example: -------------------- assert(!attrIsDir(getAttributes("/etc/fonts/fonts.conf"))); assert(!attrIsDir(getLinkAttributes("/etc/fonts/fonts.conf"))); -------------------- +/ bool attrIsDir(uint attributes) @safe pure nothrow @nogc { version(Windows) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } else version(Posix) { return (attributes & S_IFMT) == S_IFDIR; } } @safe unittest { version(Windows) { if ("C:\\Program Files\\".exists) { assert(attrIsDir(getAttributes("C:\\Program Files\\"))); assert(attrIsDir(getLinkAttributes("C:\\Program Files\\"))); } if ("C:\\Windows\\system.ini".exists) { assert(!attrIsDir(getAttributes("C:\\Windows\\system.ini"))); assert(!attrIsDir(getLinkAttributes("C:\\Windows\\system.ini"))); } } else version(Posix) { if (system_directory.exists) { assert(attrIsDir(getAttributes(system_directory))); assert(attrIsDir(getLinkAttributes(system_directory))); } if (system_file.exists) { assert(!attrIsDir(getAttributes(system_file))); assert(!attrIsDir(getLinkAttributes(system_file))); } } } /++ Returns whether the given file (or directory) is a file. On Windows, if a file is not a directory, then it's a file. So, either $(D isFile) or $(D isDir) will return true for any given file. On Posix systems, if $(D isFile) is $(D true), that indicates that the file is a regular file (e.g. not a block not device). So, on Posix systems, it's possible for both $(D isFile) and $(D isDir) to be $(D false) for a particular file (in which case, it's a special file). You can use $(D getAttributes) to get the attributes to figure out what type of special it is, or you can use $(D DirEntry) to get at its $(D statBuf), which is the result from $(D stat). In either case, see the man page for $(D stat) for more information. Params: name = The path to the file. Returns: true if name specifies a file Throws: $(D FileException) if the given file does not exist. Example: -------------------- assert("/etc/fonts/fonts.conf".isFile); assert(!"/usr/share/include".isFile); -------------------- +/ @property bool isFile(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) return !name.isDir; else version(Posix) return (getAttributes(name) & S_IFMT) == S_IFREG; } /// ditto @property bool isFile(R)(auto ref R name) if (isConvertibleToString!R) { return isFile!(StringTypeOf!R)(name); } @system unittest // bugzilla 15658 { DirEntry e = DirEntry("."); static assert(is(typeof(isFile(e)))); } @safe unittest { static assert(__traits(compiles, TestAliasedString(null).isFile)); } @safe unittest { version(Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isFile); if ("C:\\Windows\\system.ini".exists) assert("C:\\Windows\\system.ini".isFile); } else version(Posix) { if (system_directory.exists) assert(!system_directory.isFile); if (system_file.exists) assert(system_file.isFile); } } /++ Returns whether the given file _attributes are for a file. On Windows, if a file is not a directory, it's a file. So, either $(D attrIsFile) or $(D attrIsDir) will return $(D true) for the _attributes of any given file. On Posix systems, if $(D attrIsFile) is $(D true), that indicates that the file is a regular file (e.g. not a block not device). So, on Posix systems, it's possible for both $(D attrIsFile) and $(D attrIsDir) to be $(D false) for a particular file (in which case, it's a special file). If a file is a special file, you can use the _attributes to check what type of special file it is (see the man page for $(D stat) for more information). Params: attributes = The file _attributes. Returns: true if the given file _attributes are for a file Example: -------------------- assert(attrIsFile(getAttributes("/etc/fonts/fonts.conf"))); assert(attrIsFile(getLinkAttributes("/etc/fonts/fonts.conf"))); -------------------- +/ bool attrIsFile(uint attributes) @safe pure nothrow @nogc { version(Windows) { return (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; } else version(Posix) { return (attributes & S_IFMT) == S_IFREG; } } @safe unittest { version(Windows) { if ("C:\\Program Files\\".exists) { assert(!attrIsFile(getAttributes("C:\\Program Files\\"))); assert(!attrIsFile(getLinkAttributes("C:\\Program Files\\"))); } if ("C:\\Windows\\system.ini".exists) { assert(attrIsFile(getAttributes("C:\\Windows\\system.ini"))); assert(attrIsFile(getLinkAttributes("C:\\Windows\\system.ini"))); } } else version(Posix) { if (system_directory.exists) { assert(!attrIsFile(getAttributes(system_directory))); assert(!attrIsFile(getLinkAttributes(system_directory))); } if (system_file.exists) { assert(attrIsFile(getAttributes(system_file))); assert(attrIsFile(getLinkAttributes(system_file))); } } } /++ Returns whether the given file is a symbolic link. On Windows, returns $(D true) when the file is either a symbolic link or a junction point. Params: name = The path to the file. Returns: true if name is a symbolic link Throws: $(D FileException) if the given file does not exist. +/ @property bool isSymlink(R)(R name) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { version(Windows) return (getAttributes(name) & FILE_ATTRIBUTE_REPARSE_POINT) != 0; else version(Posix) return (getLinkAttributes(name) & S_IFMT) == S_IFLNK; } /// ditto @property bool isSymlink(R)(auto ref R name) if (isConvertibleToString!R) { return name.isSymlink!(StringTypeOf!R); } @safe unittest { static assert(__traits(compiles, TestAliasedString(null).isSymlink)); } @system unittest { version(Windows) { if ("C:\\Program Files\\".exists) assert(!"C:\\Program Files\\".isSymlink); if ("C:\\Users\\".exists && "C:\\Documents and Settings\\".exists) assert("C:\\Documents and Settings\\".isSymlink); enum fakeSymFile = "C:\\Windows\\system.ini"; if (fakeSymFile.exists) { assert(!fakeSymFile.isSymlink); assert(!fakeSymFile.isSymlink); assert(!attrIsSymlink(getAttributes(fakeSymFile))); assert(!attrIsSymlink(getLinkAttributes(fakeSymFile))); assert(attrIsFile(getAttributes(fakeSymFile))); assert(attrIsFile(getLinkAttributes(fakeSymFile))); assert(!attrIsDir(getAttributes(fakeSymFile))); assert(!attrIsDir(getLinkAttributes(fakeSymFile))); assert(getAttributes(fakeSymFile) == getLinkAttributes(fakeSymFile)); } } else version(Posix) { if (system_directory.exists) { assert(!system_directory.isSymlink); immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); core.sys.posix.unistd.symlink(system_directory, symfile.ptr); assert(symfile.isSymlink); assert(!attrIsSymlink(getAttributes(symfile))); assert(attrIsSymlink(getLinkAttributes(symfile))); assert(attrIsDir(getAttributes(symfile))); assert(!attrIsDir(getLinkAttributes(symfile))); assert(!attrIsFile(getAttributes(symfile))); assert(!attrIsFile(getLinkAttributes(symfile))); } if (system_file.exists) { assert(!system_file.isSymlink); immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); core.sys.posix.unistd.symlink(system_file, symfile.ptr); assert(symfile.isSymlink); assert(!attrIsSymlink(getAttributes(symfile))); assert(attrIsSymlink(getLinkAttributes(symfile))); assert(!attrIsDir(getAttributes(symfile))); assert(!attrIsDir(getLinkAttributes(symfile))); assert(attrIsFile(getAttributes(symfile))); assert(!attrIsFile(getLinkAttributes(symfile))); } } static assert(__traits(compiles, () @safe { return "dummy".isSymlink; })); } /++ Returns whether the given file attributes are for a symbolic link. On Windows, return $(D true) when the file is either a symbolic link or a junction point. Params: attributes = The file attributes. Returns: true if attributes are for a symbolic link Example: -------------------- core.sys.posix.unistd.symlink("/etc/fonts/fonts.conf", "/tmp/alink"); assert(!getAttributes("/tmp/alink").isSymlink); assert(getLinkAttributes("/tmp/alink").isSymlink); -------------------- +/ bool attrIsSymlink(uint attributes) @safe pure nothrow @nogc { version(Windows) return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; else version(Posix) return (attributes & S_IFMT) == S_IFLNK; } /**************************************************** * Change directory to $(D pathname). * Throws: $(D FileException) on error. */ void chdir(R)(R pathname) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); version(Windows) { static auto trustedChdir(const(FSChar)* pathz) @trusted { return SetCurrentDirectoryW(pathz); } } else version(Posix) { static auto trustedChdir(const(FSChar)* pathz) @trusted { return core.sys.posix.unistd.chdir(pathz) == 0; } } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias pathStr = pathname; else string pathStr = null; cenforce(trustedChdir(pathz), pathStr, pathz); } /// ditto void chdir(R)(auto ref R pathname) if (isConvertibleToString!R) { return chdir!(StringTypeOf!R)(pathname); } @safe unittest { static assert(__traits(compiles, chdir(TestAliasedString(null)))); } /**************************************************** Make directory $(D pathname). Throws: $(D FileException) on Posix or $(D WindowsException) on Windows if an error occured. */ void mkdir(R)(R pathname) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { // Place outside of @trusted block const pathz = pathname.tempCString!FSChar(); version(Windows) { static auto trustedCreateDirectoryW(const(FSChar)* pathz) @trusted { return CreateDirectoryW(pathz, null); } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias pathStr = pathname; else string pathStr = null; wenforce(trustedCreateDirectoryW(pathz), pathStr, pathz); } else version(Posix) { import std.conv : octal; static auto trustedMkdir(const(FSChar)* pathz, mode_t mode) @trusted { return core.sys.posix.sys.stat.mkdir(pathz, mode); } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias pathStr = pathname; else string pathStr = null; cenforce(trustedMkdir(pathz, octal!777) == 0, pathStr, pathz); } } /// ditto void mkdir(R)(auto ref R pathname) if (isConvertibleToString!R) { return mkdir!(StringTypeOf!R)(pathname); } @safe unittest { import std.file : mkdir; static assert(__traits(compiles, mkdir(TestAliasedString(null)))); } // Same as mkdir but ignores "already exists" errors. // Returns: "true" if the directory was created, // "false" if it already existed. private bool ensureDirExists()(in char[] pathname) { import std.exception : enforce; const pathz = pathname.tempCString!FSChar(); version(Windows) { if (() @trusted { return CreateDirectoryW(pathz, null); }()) return true; cenforce(GetLastError() == ERROR_ALREADY_EXISTS, pathname.idup); } else version(Posix) { import std.conv : octal; if (() @trusted { return core.sys.posix.sys.stat.mkdir(pathz, octal!777); }() == 0) return true; cenforce(errno == EEXIST || errno == EISDIR, pathname); } enforce(pathname.isDir, new FileException(pathname.idup)); return false; } /**************************************************** * Make directory and all parent directories as needed. * * Does nothing if the directory specified by * $(D pathname) already exists. * * Throws: $(D FileException) on error. */ void mkdirRecurse(in char[] pathname) @safe { import std.path : dirName, baseName; const left = dirName(pathname); if (left.length != pathname.length && !exists(left)) { mkdirRecurse(left); } if (!baseName(pathname).empty) { ensureDirExists(pathname); } } @safe unittest { import std.exception : assertThrown; { import std.path : buildPath, buildNormalizedPath; immutable basepath = deleteme ~ "_dir"; scope(exit) () @trusted { rmdirRecurse(basepath); }(); auto path = buildPath(basepath, "a", "..", "b"); mkdirRecurse(path); path = path.buildNormalizedPath; assert(path.isDir); path = buildPath(basepath, "c"); write(path, ""); assertThrown!FileException(mkdirRecurse(path)); path = buildPath(basepath, "d"); mkdirRecurse(path); mkdirRecurse(path); // should not throw } version(Windows) { assertThrown!FileException(mkdirRecurse(`1:\foobar`)); } // bug3570 { immutable basepath = deleteme ~ "_dir"; version (Windows) { immutable path = basepath ~ "\\fake\\here\\"; } else version (Posix) { immutable path = basepath ~ `/fake/here/`; } mkdirRecurse(path); assert(basepath.exists && basepath.isDir); scope(exit) () @trusted { rmdirRecurse(basepath); }(); assert(path.exists && path.isDir); } } /**************************************************** Remove directory $(D pathname). Params: pathname = Range or string specifying the directory name Throws: $(D FileException) on error. */ void rmdir(R)(R pathname) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R) { // Place outside of @trusted block auto pathz = pathname.tempCString!FSChar(); version(Windows) { static auto trustedRmdir(const(FSChar)* pathz) @trusted { return RemoveDirectoryW(pathz); } } else version(Posix) { static auto trustedRmdir(const(FSChar)* pathz) @trusted { return core.sys.posix.unistd.rmdir(pathz) == 0; } } static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias pathStr = pathname; else string pathStr = null; cenforce(trustedRmdir(pathz), pathStr, pathz); } /// ditto void rmdir(R)(auto ref R pathname) if (isConvertibleToString!R) { rmdir!(StringTypeOf!R)(pathname); } @safe unittest { static assert(__traits(compiles, rmdir(TestAliasedString(null)))); } /++ $(BLUE This function is Posix-Only.) Creates a symbolic _link (_symlink). Params: original = The file that is being linked. This is the target path that's stored in the _symlink. A relative path is relative to the created _symlink. link = The _symlink to create. A relative path is relative to the current working directory. Throws: $(D FileException) on error (which includes if the _symlink already exists). +/ version(StdDdoc) void symlink(RO, RL)(RO original, RL link) if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || isConvertibleToString!RO) && (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || isConvertibleToString!RL)); else version(Posix) void symlink(RO, RL)(RO original, RL link) if ((isInputRange!RO && !isInfinite!RO && isSomeChar!(ElementEncodingType!RO) || isConvertibleToString!RO) && (isInputRange!RL && !isInfinite!RL && isSomeChar!(ElementEncodingType!RL) || isConvertibleToString!RL)) { static if (isConvertibleToString!RO || isConvertibleToString!RL) { import std.meta : staticMap; alias Types = staticMap!(convertToString, RO, RL); symlink!Types(original, link); } else { import std.conv : text; auto oz = original.tempCString(); auto lz = link.tempCString(); alias posixSymlink = core.sys.posix.unistd.symlink; immutable int result = () @trusted { return posixSymlink(oz, lz); } (); cenforce(result == 0, text(link)); } } version(Posix) @safe unittest { if (system_directory.exists) { immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); symlink(system_directory, symfile); assert(symfile.exists); assert(symfile.isSymlink); assert(!attrIsSymlink(getAttributes(symfile))); assert(attrIsSymlink(getLinkAttributes(symfile))); assert(attrIsDir(getAttributes(symfile))); assert(!attrIsDir(getLinkAttributes(symfile))); assert(!attrIsFile(getAttributes(symfile))); assert(!attrIsFile(getLinkAttributes(symfile))); } if (system_file.exists) { assert(!system_file.isSymlink); immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); symlink(system_file, symfile); assert(symfile.exists); assert(symfile.isSymlink); assert(!attrIsSymlink(getAttributes(symfile))); assert(attrIsSymlink(getLinkAttributes(symfile))); assert(!attrIsDir(getAttributes(symfile))); assert(!attrIsDir(getLinkAttributes(symfile))); assert(attrIsFile(getAttributes(symfile))); assert(!attrIsFile(getLinkAttributes(symfile))); } } version(Posix) @safe unittest { static assert(__traits(compiles, symlink(TestAliasedString(null), TestAliasedString(null)))); } /++ $(BLUE This function is Posix-Only.) Returns the path to the file pointed to by a symlink. Note that the path could be either relative or absolute depending on the symlink. If the path is relative, it's relative to the symlink, not the current working directory. Throws: $(D FileException) on error. +/ version(StdDdoc) string readLink(R)(R link) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isConvertibleToString!R); else version(Posix) string readLink(R)(R link) if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) || isConvertibleToString!R) { static if (isConvertibleToString!R) { return readLink!(convertToString!R)(link); } else { import std.conv : to; import std.exception : assumeUnique; alias posixReadlink = core.sys.posix.unistd.readlink; enum bufferLen = 2048; enum maxCodeUnits = 6; char[bufferLen] buffer; const linkz = link.tempCString(); auto size = () @trusted { return posixReadlink(linkz, buffer.ptr, buffer.length); } (); cenforce(size != -1, to!string(link)); if (size <= bufferLen - maxCodeUnits) return to!string(buffer[0 .. size]); auto dynamicBuffer = new char[](bufferLen * 3 / 2); foreach (i; 0 .. 10) { size = () @trusted { return posixReadlink(linkz, dynamicBuffer.ptr, dynamicBuffer.length); } (); cenforce(size != -1, to!string(link)); if (size <= dynamicBuffer.length - maxCodeUnits) { dynamicBuffer.length = size; return () @trusted { return assumeUnique(dynamicBuffer); } (); } dynamicBuffer.length = dynamicBuffer.length * 3 / 2; } throw new FileException(to!string(link), "Path is too long to read."); } } version(Posix) @safe unittest { import std.exception : assertThrown; import std.string; foreach (file; [system_directory, system_file]) { if (file.exists) { immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); symlink(file, symfile); assert(readLink(symfile) == file, format("Failed file: %s", file)); } } assertThrown!FileException(readLink("/doesnotexist")); } version(Posix) @safe unittest { static assert(__traits(compiles, readLink(TestAliasedString("foo")))); } version(Posix) @system unittest // input range of dchars { mkdirRecurse(deleteme); scope(exit) if (deleteme.exists) rmdirRecurse(deleteme); write(deleteme ~ "/f", ""); import std.range.interfaces : InputRange, inputRangeObject; import std.utf : byChar; immutable string link = deleteme ~ "/l"; symlink("f", link); InputRange!dchar linkr = inputRangeObject(link); alias R = typeof(linkr); static assert(isInputRange!R); static assert(!isForwardRange!R); assert(readLink(linkr) == "f"); } /**************************************************** * Get the current working directory. * Throws: $(D FileException) on error. */ version(Windows) string getcwd() { import std.conv : to; import std.experimental.checkedint : checked; /* GetCurrentDirectory's return value: 1. function succeeds: the number of characters that are written to the buffer, not including the terminating null character. 2. function fails: zero 3. the buffer (lpBuffer) is not large enough: the required size of the buffer, in characters, including the null-terminating character. */ version(unittest) enum BUF_SIZE = 10; // trigger reallocation code else enum BUF_SIZE = 4096; // enough for most common case wchar[BUF_SIZE] buffW = void; immutable n = cenforce(GetCurrentDirectoryW(to!DWORD(buffW.length), buffW.ptr), "getcwd"); // we can do it because toUTFX always produces a fresh string if (n < buffW.length) { return buffW[0 .. n].to!string; } else //staticBuff isn't enough { auto cn = checked(n); auto ptr = cast(wchar*) malloc((cn * wchar.sizeof).get); scope(exit) free(ptr); immutable n2 = GetCurrentDirectoryW(cn.get, ptr); cenforce(n2 && n2 < cn, "getcwd"); return ptr[0 .. n2].to!string; } } else version (Solaris) string getcwd() { /* BUF_SIZE >= PATH_MAX */ enum BUF_SIZE = 4096; /* The user should be able to specify any size buffer > 0 */ auto p = cenforce(core.sys.posix.unistd.getcwd(null, BUF_SIZE), "cannot get cwd"); scope(exit) core.stdc.stdlib.free(p); return p[0 .. core.stdc.string.strlen(p)].idup; } else version (Posix) string getcwd() { auto p = cenforce(core.sys.posix.unistd.getcwd(null, 0), "cannot get cwd"); scope(exit) core.stdc.stdlib.free(p); return p[0 .. core.stdc.string.strlen(p)].idup; } @system unittest { auto s = getcwd(); assert(s.length); } version (OSX) private extern (C) int _NSGetExecutablePath(char* buf, uint* bufsize); else version (FreeBSD) private extern (C) int sysctl (const int* name, uint namelen, void* oldp, size_t* oldlenp, const void* newp, size_t newlen); else version (NetBSD) private extern (C) int sysctl (const int* name, uint namelen, void* oldp, size_t* oldlenp, const void* newp, size_t newlen); /** * Returns the full path of the current executable. * * Throws: * $(REF1 Exception, object) */ @trusted string thisExePath () { version (OSX) { import core.sys.posix.stdlib : realpath; import std.conv : to; import std.exception : errnoEnforce; uint size; _NSGetExecutablePath(null, &size); // get the length of the path auto buffer = new char[size]; _NSGetExecutablePath(buffer.ptr, &size); auto absolutePath = realpath(buffer.ptr, null); // let the function allocate scope (exit) { if (absolutePath) free(absolutePath); } errnoEnforce(absolutePath); return to!(string)(absolutePath); } else version (linux) { return readLink("/proc/self/exe"); } else version (Windows) { import std.conv : to; import std.exception : enforce; wchar[MAX_PATH] buf; wchar[] buffer = buf[]; while (true) { auto len = GetModuleFileNameW(null, buffer.ptr, cast(DWORD) buffer.length); enforce(len, sysErrorString(GetLastError())); if (len != buffer.length) return to!(string)(buffer[0 .. len]); buffer.length *= 2; } } else version (FreeBSD) { import std.exception : errnoEnforce, assumeUnique; enum { CTL_KERN = 1, KERN_PROC = 14, KERN_PROC_PATHNAME = 12 } int[4] mib = [CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1]; size_t len; auto result = sysctl(mib.ptr, mib.length, null, &len, null, 0); // get the length of the path errnoEnforce(result == 0); auto buffer = new char[len - 1]; result = sysctl(mib.ptr, mib.length, buffer.ptr, &len, null, 0); errnoEnforce(result == 0); return buffer.assumeUnique; } else version (NetBSD) { return readLink("/proc/self/exe"); } else version (DragonFlyBSD) { return readLink("/proc/curproc/file"); } else version (Solaris) { import core.sys.posix.unistd : getpid; import std.string : format; // Only Solaris 10 and later return readLink(format("/proc/%d/path/a.out", getpid())); } else static assert(0, "thisExePath is not supported on this platform"); } @safe unittest { import std.path : isAbsolute; auto path = thisExePath(); assert(path.exists); assert(path.isAbsolute); assert(path.isFile); } version(StdDdoc) { /++ Info on a file, similar to what you'd get from stat on a Posix system. +/ struct DirEntry { @safe: /++ Constructs a $(D DirEntry) for the given file (or directory). Params: path = The file (or directory) to get a DirEntry for. Throws: $(D FileException) if the file does not exist. +/ this(string path); version (Windows) { private this(string path, in WIN32_FIND_DATAW *fd); } else version (Posix) { private this(string path, core.sys.posix.dirent.dirent* fd); } /++ Returns the path to the file represented by this $(D DirEntry). Example: -------------------- auto de1 = DirEntry("/etc/fonts/fonts.conf"); assert(de1.name == "/etc/fonts/fonts.conf"); auto de2 = DirEntry("/usr/share/include"); assert(de2.name == "/usr/share/include"); -------------------- +/ @property string name() const; /++ Returns whether the file represented by this $(D DirEntry) is a directory. Example: -------------------- auto de1 = DirEntry("/etc/fonts/fonts.conf"); assert(!de1.isDir); auto de2 = DirEntry("/usr/share/include"); assert(de2.isDir); -------------------- +/ @property bool isDir(); /++ Returns whether the file represented by this $(D DirEntry) is a file. On Windows, if a file is not a directory, then it's a file. So, either $(D isFile) or $(D isDir) will return $(D true). On Posix systems, if $(D isFile) is $(D true), that indicates that the file is a regular file (e.g. not a block not device). So, on Posix systems, it's possible for both $(D isFile) and $(D isDir) to be $(D false) for a particular file (in which case, it's a special file). You can use $(D attributes) or $(D statBuf) to get more information about a special file (see the stat man page for more details). Example: -------------------- auto de1 = DirEntry("/etc/fonts/fonts.conf"); assert(de1.isFile); auto de2 = DirEntry("/usr/share/include"); assert(!de2.isFile); -------------------- +/ @property bool isFile(); /++ Returns whether the file represented by this $(D DirEntry) is a symbolic link. On Windows, return $(D true) when the file is either a symbolic link or a junction point. +/ @property bool isSymlink(); /++ Returns the size of the the file represented by this $(D DirEntry) in bytes. +/ @property ulong size(); /++ $(BLUE This function is Windows-Only.) Returns the creation time of the file represented by this $(D DirEntry). +/ @property SysTime timeCreated() const; /++ Returns the time that the file represented by this $(D DirEntry) was last accessed. Note that many file systems do not update the access time for files (generally for performance reasons), so there's a good chance that $(D timeLastAccessed) will return the same value as $(D timeLastModified). +/ @property SysTime timeLastAccessed(); /++ Returns the time that the file represented by this $(D DirEntry) was last modified. +/ @property SysTime timeLastModified(); /++ Returns the _attributes of the file represented by this $(D DirEntry). Note that the file _attributes on Windows and Posix systems are completely different. On, Windows, they're what is returned by $(D GetFileAttributes) $(HTTP msdn.microsoft.com/en-us/library/aa364944(v=vs.85).aspx, GetFileAttributes) Whereas, an Posix systems, they're the $(D st_mode) value which is part of the $(D stat) struct gotten by calling $(D stat). On Posix systems, if the file represented by this $(D DirEntry) is a symbolic link, then _attributes are the _attributes of the file pointed to by the symbolic link. +/ @property uint attributes(); /++ On Posix systems, if the file represented by this $(D DirEntry) is a symbolic link, then $(D linkAttributes) are the attributes of the symbolic link itself. Otherwise, $(D linkAttributes) is identical to $(D attributes). On Windows, $(D linkAttributes) is identical to $(D attributes). It exists on Windows so that you don't have to special-case code for Windows when dealing with symbolic links. +/ @property uint linkAttributes(); version(Windows) alias stat_t = void*; /++ $(BLUE This function is Posix-Only.) The $(D stat) struct gotten from calling $(D stat). +/ @property stat_t statBuf(); } } else version(Windows) { struct DirEntry { @safe: public: alias name this; this(string path) { import std.datetime.systime : FILETIMEToSysTime; if (!path.exists()) throw new FileException(path, "File does not exist"); _name = path; with (getFileAttributesWin(path)) { _size = makeUlong(nFileSizeLow, nFileSizeHigh); _timeCreated = FILETIMEToSysTime(&ftCreationTime); _timeLastAccessed = FILETIMEToSysTime(&ftLastAccessTime); _timeLastModified = FILETIMEToSysTime(&ftLastWriteTime); _attributes = dwFileAttributes; } } private this(string path, WIN32_FIND_DATAW *fd) @trusted { import core.stdc.wchar_ : wcslen; import std.conv : to; import std.datetime.systime : FILETIMEToSysTime; import std.path : buildPath; fd.cFileName[$ - 1] = 0; size_t clength = wcslen(&fd.cFileName[0]); _name = buildPath(path, fd.cFileName[0 .. clength].to!string); _size = (cast(ulong) fd.nFileSizeHigh << 32) | fd.nFileSizeLow; _timeCreated = FILETIMEToSysTime(&fd.ftCreationTime); _timeLastAccessed = FILETIMEToSysTime(&fd.ftLastAccessTime); _timeLastModified = FILETIMEToSysTime(&fd.ftLastWriteTime); _attributes = fd.dwFileAttributes; } @property string name() const pure nothrow { return _name; } @property bool isDir() const pure nothrow { return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } @property bool isFile() const pure nothrow { //Are there no options in Windows other than directory and file? //If there are, then this probably isn't the best way to determine //whether this DirEntry is a file or not. return !isDir; } @property bool isSymlink() const pure nothrow { return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; } @property ulong size() const pure nothrow { return _size; } @property SysTime timeCreated() const pure nothrow { return cast(SysTime)_timeCreated; } @property SysTime timeLastAccessed() const pure nothrow { return cast(SysTime)_timeLastAccessed; } @property SysTime timeLastModified() const pure nothrow { return cast(SysTime)_timeLastModified; } @property uint attributes() const pure nothrow { return _attributes; } @property uint linkAttributes() const pure nothrow { return _attributes; } private: string _name; /// The file or directory represented by this DirEntry. SysTime _timeCreated; /// The time when the file was created. SysTime _timeLastAccessed; /// The time when the file was last accessed. SysTime _timeLastModified; /// The time when the file was last modified. ulong _size; /// The size of the file in bytes. uint _attributes; /// The file attributes from WIN32_FIND_DATAW. } } else version(Posix) { struct DirEntry { @safe: public: alias name this; this(string path) { if (!path.exists) throw new FileException(path, "File does not exist"); _name = path; _didLStat = false; _didStat = false; _dTypeSet = false; } private this(string path, core.sys.posix.dirent.dirent* fd) @safe { import std.algorithm.searching : countUntil; import std.path : buildPath; import std.string : representation; immutable len = fd.d_name[].representation.countUntil(0); _name = buildPath(path, fd.d_name[0 .. len]); _didLStat = false; _didStat = false; //fd_d_type doesn't work for all file systems, //in which case the result is DT_UNKOWN. But we //can determine the correct type from lstat, so //we'll only set the dtype here if we could //correctly determine it (not lstat in the case //of DT_UNKNOWN in case we don't ever actually //need the dtype, thus potentially avoiding the //cost of calling lstat). static if (__traits(compiles, fd.d_type != DT_UNKNOWN)) { if (fd.d_type != DT_UNKNOWN) { _dType = fd.d_type; _dTypeSet = true; } else _dTypeSet = false; } else { // e.g. Solaris does not have the d_type member _dTypeSet = false; } } @property string name() const pure nothrow { return _name; } @property bool isDir() { _ensureStatOrLStatDone(); return (_statBuf.st_mode & S_IFMT) == S_IFDIR; } @property bool isFile() { _ensureStatOrLStatDone(); return (_statBuf.st_mode & S_IFMT) == S_IFREG; } @property bool isSymlink() { _ensureLStatDone(); return (_lstatMode & S_IFMT) == S_IFLNK; } @property ulong size() { _ensureStatDone(); return _statBuf.st_size; } @property SysTime timeStatusChanged() { _ensureStatDone(); return statTimeToStdTime!'c'(_statBuf); } @property SysTime timeLastAccessed() { _ensureStatDone(); return statTimeToStdTime!'a'(_statBuf); } @property SysTime timeLastModified() { _ensureStatDone(); return statTimeToStdTime!'m'(_statBuf); } @property uint attributes() { _ensureStatDone(); return _statBuf.st_mode; } @property uint linkAttributes() { _ensureLStatDone(); return _lstatMode; } @property stat_t statBuf() { _ensureStatDone(); return _statBuf; } private: /++ This is to support lazy evaluation, because doing stat's is expensive and not always needed. +/ void _ensureStatDone() @trusted { import std.exception : enforce; if (_didStat) return; enforce(stat(_name.tempCString(), &_statBuf) == 0, "Failed to stat file `" ~ _name ~ "'"); _didStat = true; } /++ This is to support lazy evaluation, because doing stat's is expensive and not always needed. Try both stat and lstat for isFile and isDir to detect broken symlinks. +/ void _ensureStatOrLStatDone() @trusted { if (_didStat) return; if (stat(_name.tempCString(), &_statBuf) != 0) { _ensureLStatDone(); _statBuf = stat_t.init; _statBuf.st_mode = S_IFLNK; } else { _didStat = true; } } /++ This is to support lazy evaluation, because doing stat's is expensive and not always needed. +/ void _ensureLStatDone() @trusted { import std.exception : enforce; if (_didLStat) return; stat_t statbuf = void; enforce(lstat(_name.tempCString(), &statbuf) == 0, "Failed to stat file `" ~ _name ~ "'"); _lstatMode = statbuf.st_mode; _dTypeSet = true; _didLStat = true; } string _name; /// The file or directory represented by this DirEntry. stat_t _statBuf = void; /// The result of stat(). uint _lstatMode; /// The stat mode from lstat(). ubyte _dType; /// The type of the file. bool _didLStat = false; /// Whether lstat() has been called for this DirEntry. bool _didStat = false; /// Whether stat() has been called for this DirEntry. bool _dTypeSet = false; /// Whether the dType of the file has been set. } } @system unittest { version(Windows) { if ("C:\\Program Files\\".exists) { auto de = DirEntry("C:\\Program Files\\"); assert(!de.isFile); assert(de.isDir); assert(!de.isSymlink); } if ("C:\\Users\\".exists && "C:\\Documents and Settings\\".exists) { auto de = DirEntry("C:\\Documents and Settings\\"); assert(de.isSymlink); } if ("C:\\Windows\\system.ini".exists) { auto de = DirEntry("C:\\Windows\\system.ini"); assert(de.isFile); assert(!de.isDir); assert(!de.isSymlink); } } else version(Posix) { import std.exception : assertThrown; if (system_directory.exists) { { auto de = DirEntry(system_directory); assert(!de.isFile); assert(de.isDir); assert(!de.isSymlink); } immutable symfile = deleteme ~ "_slink\0"; scope(exit) if (symfile.exists) symfile.remove(); core.sys.posix.unistd.symlink(system_directory, symfile.ptr); { auto de = DirEntry(symfile); assert(!de.isFile); assert(de.isDir); assert(de.isSymlink); } symfile.remove(); core.sys.posix.unistd.symlink((deleteme ~ "_broken_symlink\0").ptr, symfile.ptr); { //Issue 8298 DirEntry de = DirEntry(symfile); assert(!de.isFile); assert(!de.isDir); assert(de.isSymlink); assertThrown(de.size); assertThrown(de.timeStatusChanged); assertThrown(de.timeLastAccessed); assertThrown(de.timeLastModified); assertThrown(de.attributes); assertThrown(de.statBuf); assert(symfile.exists); symfile.remove(); } } if (system_file.exists) { auto de = DirEntry(system_file); assert(de.isFile); assert(!de.isDir); assert(!de.isSymlink); } } } alias PreserveAttributes = Flag!"preserveAttributes"; version (StdDdoc) { /// Defaults to $(D Yes.preserveAttributes) on Windows, and the opposite on all other platforms. PreserveAttributes preserveAttributesDefault; } else version(Windows) { enum preserveAttributesDefault = Yes.preserveAttributes; } else { enum preserveAttributesDefault = No.preserveAttributes; } /*************************************************** Copy file $(D from) _to file $(D to). File timestamps are preserved. File attributes are preserved, if $(D preserve) equals $(D Yes.preserveAttributes). On Windows only $(D Yes.preserveAttributes) (the default on Windows) is supported. If the target file exists, it is overwritten. Params: from = string or range of characters representing the existing file name to = string or range of characters representing the target file name preserve = whether to _preserve the file attributes Throws: $(D FileException) on error. */ void copy(RF, RT)(RF from, RT to, PreserveAttributes preserve = preserveAttributesDefault) if (isInputRange!RF && !isInfinite!RF && isSomeChar!(ElementEncodingType!RF) && !isConvertibleToString!RF && isInputRange!RT && !isInfinite!RT && isSomeChar!(ElementEncodingType!RT) && !isConvertibleToString!RT) { // Place outside of @trusted block auto fromz = from.tempCString!FSChar(); auto toz = to.tempCString!FSChar(); static if (isNarrowString!RF && is(Unqual!(ElementEncodingType!RF) == char)) alias f = from; else enum string f = null; static if (isNarrowString!RT && is(Unqual!(ElementEncodingType!RT) == char)) alias t = to; else enum string t = null; copyImpl(f, t, fromz, toz, preserve); } /// ditto void copy(RF, RT)(auto ref RF from, auto ref RT to, PreserveAttributes preserve = preserveAttributesDefault) if (isConvertibleToString!RF || isConvertibleToString!RT) { import std.meta : staticMap; alias Types = staticMap!(convertToString, RF, RT); copy!Types(from, to, preserve); } @safe unittest // issue 15319 { assert(__traits(compiles, copy("from.txt", "to.txt"))); } private void copyImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, const(FSChar)* toz, PreserveAttributes preserve) @trusted { version(Windows) { assert(preserve == Yes.preserveAttributes); immutable result = CopyFileW(fromz, toz, false); if (!result) { import core.stdc.wchar_ : wcslen; import std.conv : to; if (!t) t = to!(typeof(t))(toz[0 .. wcslen(toz)]); throw new FileException(t); } } else version(Posix) { static import core.stdc.stdio; import std.conv : to, octal; immutable fdr = core.sys.posix.fcntl.open(fromz, O_RDONLY); cenforce(fdr != -1, f, fromz); scope(exit) core.sys.posix.unistd.close(fdr); stat_t statbufr = void; cenforce(fstat(fdr, &statbufr) == 0, f, fromz); //cenforce(core.sys.posix.sys.stat.fstat(fdr, &statbufr) == 0, f, fromz); immutable fdw = core.sys.posix.fcntl.open(toz, O_CREAT | O_WRONLY, octal!666); cenforce(fdw != -1, t, toz); { scope(failure) core.sys.posix.unistd.close(fdw); stat_t statbufw = void; cenforce(fstat(fdw, &statbufw) == 0, t, toz); if (statbufr.st_dev == statbufw.st_dev && statbufr.st_ino == statbufw.st_ino) throw new FileException(t, "Source and destination are the same file"); } scope(failure) core.stdc.stdio.remove(toz); { scope(failure) core.sys.posix.unistd.close(fdw); cenforce(ftruncate(fdw, 0) == 0, t, toz); auto BUFSIZ = 4096u * 16; auto buf = core.stdc.stdlib.malloc(BUFSIZ); if (!buf) { BUFSIZ = 4096; buf = core.stdc.stdlib.malloc(BUFSIZ); if (!buf) { import core.exception : onOutOfMemoryError; onOutOfMemoryError(); } } scope(exit) core.stdc.stdlib.free(buf); for (auto size = statbufr.st_size; size; ) { immutable toxfer = (size > BUFSIZ) ? BUFSIZ : cast(size_t) size; cenforce( core.sys.posix.unistd.read(fdr, buf, toxfer) == toxfer && core.sys.posix.unistd.write(fdw, buf, toxfer) == toxfer, f, fromz); assert(size >= toxfer); size -= toxfer; } if (preserve) cenforce(fchmod(fdw, to!mode_t(statbufr.st_mode)) == 0, f, fromz); } cenforce(core.sys.posix.unistd.close(fdw) != -1, f, fromz); utimbuf utim = void; utim.actime = cast(time_t) statbufr.st_atime; utim.modtime = cast(time_t) statbufr.st_mtime; cenforce(utime(toz, &utim) != -1, f, fromz); } } @safe unittest { import std.algorithm, std.file; // issue 14817 auto t1 = deleteme, t2 = deleteme~"2"; scope(exit) foreach (t; [t1, t2]) if (t.exists) t.remove(); write(t1, "11"); copy(t1, t2); assert(readText(t2) == "11"); write(t1, "2"); copy(t1, t2); assert(readText(t2) == "2"); import std.utf : byChar; copy(t1.byChar, t2.byChar); assert(readText(t2.byChar) == "2"); } @safe version(Posix) @safe unittest //issue 11434 { import std.conv : octal; auto t1 = deleteme, t2 = deleteme~"2"; scope(exit) foreach (t; [t1, t2]) if (t.exists) t.remove(); write(t1, "1"); setAttributes(t1, octal!767); copy(t1, t2, Yes.preserveAttributes); assert(readText(t2) == "1"); assert(getAttributes(t2) == octal!100767); } @safe unittest // issue 15865 { import std.exception : assertThrown; auto t = deleteme; write(t, "a"); scope(exit) t.remove(); assertThrown!FileException(copy(t, t)); assert(readText(t) == "a"); } /++ Remove directory and all of its content and subdirectories, recursively. Throws: $(D FileException) if there is an error (including if the given file is not a directory). +/ void rmdirRecurse(in char[] pathname) { //No references to pathname will be kept after rmdirRecurse, //so the cast is safe rmdirRecurse(DirEntry(cast(string) pathname)); } /++ Remove directory and all of its content and subdirectories, recursively. Throws: $(D FileException) if there is an error (including if the given file is not a directory). +/ void rmdirRecurse(ref DirEntry de) { if (!de.isDir) throw new FileException(de.name, "Not a directory"); if (de.isSymlink) { version (Windows) rmdir(de.name); else remove(de.name); } else { // all children, recursively depth-first foreach (DirEntry e; dirEntries(de.name, SpanMode.depth, false)) { attrIsDir(e.linkAttributes) ? rmdir(e.name) : remove(e.name); } // the dir itself rmdir(de.name); } } ///ditto //Note, without this overload, passing an RValue DirEntry still works, but //actually fully reconstructs a DirEntry inside the //"rmdirRecurse(in char[] pathname)" implementation. That is needlessly //expensive. //A DirEntry is a bit big (72B), so keeping the "by ref" signature is desirable. void rmdirRecurse(DirEntry de) { rmdirRecurse(de); } version(Windows) @system unittest { import std.exception : enforce; auto d = deleteme ~ r".dir\a\b\c\d\e\f\g"; mkdirRecurse(d); rmdirRecurse(deleteme ~ ".dir"); enforce(!exists(deleteme ~ ".dir")); } version(Posix) @system unittest { import std.exception : enforce, collectException; import std.process : executeShell; collectException(rmdirRecurse(deleteme)); auto d = deleteme~"/a/b/c/d/e/f/g"; enforce(collectException(mkdir(d))); mkdirRecurse(d); core.sys.posix.unistd.symlink((deleteme~"/a/b/c\0").ptr, (deleteme~"/link\0").ptr); rmdirRecurse(deleteme~"/link"); enforce(exists(d)); rmdirRecurse(deleteme); enforce(!exists(deleteme)); d = deleteme~"/a/b/c/d/e/f/g"; mkdirRecurse(d); version(Android) string link_cmd = "ln -s "; else string link_cmd = "ln -sf "; executeShell(link_cmd~deleteme~"/a/b/c "~deleteme~"/link"); rmdirRecurse(deleteme); enforce(!exists(deleteme)); } @system unittest { void[] buf; buf = new void[10]; (cast(byte[]) buf)[] = 3; string unit_file = deleteme ~ "-unittest_write.tmp"; if (exists(unit_file)) remove(unit_file); write(unit_file, buf); void[] buf2 = read(unit_file); assert(buf == buf2); string unit2_file = deleteme ~ "-unittest_write2.tmp"; copy(unit_file, unit2_file); buf2 = read(unit2_file); assert(buf == buf2); remove(unit_file); assert(!exists(unit_file)); remove(unit2_file); assert(!exists(unit2_file)); } /** * Dictates directory spanning policy for $(D_PARAM dirEntries) (see below). */ enum SpanMode { /** Only spans one directory. */ shallow, /** Spans the directory in $(HTTPS en.wikipedia.org/wiki/Tree_traversal#Post-order, _depth-first $(B post)-order), i.e. the content of any subdirectory is spanned before that subdirectory itself. Useful e.g. when recursively deleting files. */ depth, /** Spans the directory in $(HTTPS en.wikipedia.org/wiki/Tree_traversal#Pre-order, depth-first $(B pre)-order), i.e. the content of any subdirectory is spanned right after that subdirectory itself. Note that $(D SpanMode.breadth) will not result in all directory members occurring before any subdirectory members, i.e. it is not _true $(HTTPS en.wikipedia.org/wiki/Tree_traversal#Breadth-first_search, _breadth-first traversal). */ breadth, } private struct DirIteratorImpl { @safe: SpanMode _mode; // Whether we should follow symlinked directories while iterating. // It also indicates whether we should avoid functions which call // stat (since we should only need lstat in this case and it would // be more efficient to not call stat in addition to lstat). bool _followSymlink; DirEntry _cur; DirHandle[] _stack; DirEntry[] _stashed; //used in depth first mode //stack helpers void pushExtra(DirEntry de) { _stashed ~= de; } //ditto bool hasExtra() { return _stashed.length != 0; } //ditto DirEntry popExtra() { DirEntry de; de = _stashed[$-1]; _stashed.popBack(); return de; } version(Windows) { WIN32_FIND_DATAW _findinfo; struct DirHandle { string dirpath; HANDLE h; } bool stepIn(string directory) @safe { import std.path : chainPath; auto searchPattern = chainPath(directory, "*.*"); static auto trustedFindFirstFileW(typeof(searchPattern) pattern, WIN32_FIND_DATAW* findinfo) @trusted { return FindFirstFileW(pattern.tempCString!FSChar(), findinfo); } HANDLE h = trustedFindFirstFileW(searchPattern, &_findinfo); cenforce(h != INVALID_HANDLE_VALUE, directory); _stack ~= DirHandle(directory, h); return toNext(false, &_findinfo); } bool next() { if (_stack.length == 0) return false; return toNext(true, &_findinfo); } bool toNext(bool fetch, WIN32_FIND_DATAW* findinfo) @trusted { import core.stdc.wchar_ : wcscmp; if (fetch) { if (FindNextFileW(_stack[$-1].h, findinfo) == FALSE) { popDirStack(); return false; } } while (wcscmp(&findinfo.cFileName[0], ".") == 0 || wcscmp(&findinfo.cFileName[0], "..") == 0) if (FindNextFileW(_stack[$-1].h, findinfo) == FALSE) { popDirStack(); return false; } _cur = DirEntry(_stack[$-1].dirpath, findinfo); return true; } void popDirStack() @trusted { assert(_stack.length != 0); FindClose(_stack[$-1].h); _stack.popBack(); } void releaseDirStack() @trusted { foreach (d; _stack) FindClose(d.h); } bool mayStepIn() { return _followSymlink ? _cur.isDir : _cur.isDir && !_cur.isSymlink; } } else version(Posix) { struct DirHandle { string dirpath; DIR* h; } bool stepIn(string directory) { static auto trustedOpendir(string dir) @trusted { return opendir(dir.tempCString()); } auto h = directory.length ? trustedOpendir(directory) : trustedOpendir("."); cenforce(h, directory); _stack ~= (DirHandle(directory, h)); return next(); } bool next() @trusted { if (_stack.length == 0) return false; for (dirent* fdata; (fdata = readdir(_stack[$-1].h)) != null; ) { // Skip "." and ".." if (core.stdc.string.strcmp(&fdata.d_name[0], ".") && core.stdc.string.strcmp(&fdata.d_name[0], "..")) { _cur = DirEntry(_stack[$-1].dirpath, fdata); return true; } } popDirStack(); return false; } void popDirStack() @trusted { assert(_stack.length != 0); closedir(_stack[$-1].h); _stack.popBack(); } void releaseDirStack() @trusted { foreach (d; _stack) closedir(d.h); } bool mayStepIn() { return _followSymlink ? _cur.isDir : attrIsDir(_cur.linkAttributes); } } this(R)(R pathname, SpanMode mode, bool followSymlink) if (isInputRange!R && isSomeChar!(ElementEncodingType!R)) { _mode = mode; _followSymlink = followSymlink; static if (isNarrowString!R && is(Unqual!(ElementEncodingType!R) == char)) alias pathnameStr = pathname; else { import std.array : array; string pathnameStr = pathname.array; } if (stepIn(pathnameStr)) { if (_mode == SpanMode.depth) while (mayStepIn()) { auto thisDir = _cur; if (stepIn(_cur.name)) { pushExtra(thisDir); } else break; } } } @property bool empty() { return _stashed.length == 0 && _stack.length == 0; } @property DirEntry front() { return _cur; } void popFront() { switch (_mode) { case SpanMode.depth: if (next()) { while (mayStepIn()) { auto thisDir = _cur; if (stepIn(_cur.name)) { pushExtra(thisDir); } else break; } } else if (hasExtra()) _cur = popExtra(); break; case SpanMode.breadth: if (mayStepIn()) { if (!stepIn(_cur.name)) while (!empty && !next()){} } else while (!empty && !next()){} break; default: next(); } } ~this() { releaseDirStack(); } } struct DirIterator { @safe: private: RefCounted!(DirIteratorImpl, RefCountedAutoInitialize.no) impl = void; this(string pathname, SpanMode mode, bool followSymlink) @trusted { impl = typeof(impl)(pathname, mode, followSymlink); } public: @property bool empty() { return impl.empty; } @property DirEntry front() { return impl.front; } void popFront() { impl.popFront(); } } /++ Returns an input range of $(D DirEntry) that lazily iterates a given directory, also provides two ways of foreach iteration. The iteration variable can be of type $(D string) if only the name is needed, or $(D DirEntry) if additional details are needed. The span _mode dictates how the directory is traversed. The name of each iterated directory entry contains the absolute or relative _path (depending on _pathname). Params: path = The directory to iterate over. If empty, the current directory will be iterated. pattern = Optional string with wildcards, such as $(RED "*.d"). When present, it is used to filter the results by their file name. The supported wildcard strings are described under $(REF globMatch, std,_path). mode = Whether the directory's sub-directories should be iterated in depth-first port-order ($(LREF depth)), depth-first pre-order ($(LREF breadth)), or not at all ($(LREF shallow)). followSymlink = Whether symbolic links which point to directories should be treated as directories and their contents iterated over. Throws: $(D FileException) if the directory does not exist. Example: -------------------- // Iterate a directory in depth foreach (string name; dirEntries("destroy/me", SpanMode.depth)) { remove(name); } // Iterate the current directory in breadth foreach (string name; dirEntries("", SpanMode.breadth)) { writeln(name); } // Iterate a directory and get detailed info about it foreach (DirEntry e; dirEntries("dmd-testing", SpanMode.breadth)) { writeln(e.name, "\t", e.size); } // Iterate over all *.d files in current directory and all its subdirectories auto dFiles = dirEntries("", SpanMode.depth).filter!(f => f.name.endsWith(".d")); foreach (d; dFiles) writeln(d.name); // Hook it up with std.parallelism to compile them all in parallel: foreach (d; parallel(dFiles, 1)) //passes by 1 file to each thread { string cmd = "dmd -c " ~ d.name; writeln(cmd); std.process.system(cmd); } // Iterate over all D source files in current directory and all its // subdirectories auto dFiles = dirEntries("","*.{d,di}",SpanMode.depth); foreach (d; dFiles) writeln(d.name); -------------------- +/ auto dirEntries(string path, SpanMode mode, bool followSymlink = true) { return DirIterator(path, mode, followSymlink); } /// Duplicate functionality of D1's $(D std.file.listdir()): @safe unittest { string[] listdir(string pathname) { import std.algorithm; import std.array; import std.file; import std.path; return std.file.dirEntries(pathname, SpanMode.shallow) .filter!(a => a.isFile) .map!(a => std.path.baseName(a.name)) .array; } void main(string[] args) { import std.stdio; string[] files = listdir(args[1]); writefln("%s", files); } } @system unittest { import std.algorithm.comparison : equal; import std.algorithm.iteration : map; import std.algorithm.searching : startsWith; import std.array : array; import std.conv : to; import std.path : buildPath, absolutePath; import std.file : dirEntries; import std.process : thisProcessID; import std.range.primitives : walkLength; version(Android) string testdir = deleteme; // This has to be an absolute path when // called from a shared library on Android, // ie an apk else string testdir = "deleteme.dmd.unittest.std.file" ~ to!string(thisProcessID); // needs to be relative mkdirRecurse(buildPath(testdir, "somedir")); scope(exit) rmdirRecurse(testdir); write(buildPath(testdir, "somefile"), null); write(buildPath(testdir, "somedir", "somedeepfile"), null); // testing range interface size_t equalEntries(string relpath, SpanMode mode) { import std.exception : enforce; auto len = enforce(walkLength(dirEntries(absolutePath(relpath), mode))); assert(walkLength(dirEntries(relpath, mode)) == len); assert(equal( map!(a => absolutePath(a.name))(dirEntries(relpath, mode)), map!(a => a.name)(dirEntries(absolutePath(relpath), mode)))); return len; } assert(equalEntries(testdir, SpanMode.shallow) == 2); assert(equalEntries(testdir, SpanMode.depth) == 3); assert(equalEntries(testdir, SpanMode.breadth) == 3); // testing opApply foreach (string name; dirEntries(testdir, SpanMode.breadth)) { //writeln(name); assert(name.startsWith(testdir)); } foreach (DirEntry e; dirEntries(absolutePath(testdir), SpanMode.breadth)) { //writeln(name); assert(e.isFile || e.isDir, e.name); } //issue 7264 foreach (string name; dirEntries(testdir, "*.d", SpanMode.breadth)) { } foreach (entry; dirEntries(testdir, SpanMode.breadth)) { static assert(is(typeof(entry) == DirEntry)); } //issue 7138 auto a = array(dirEntries(testdir, SpanMode.shallow)); // issue 11392 auto dFiles = dirEntries(testdir, SpanMode.shallow); foreach (d; dFiles){} // issue 15146 dirEntries("", SpanMode.shallow).walkLength(); } /// Ditto auto dirEntries(string path, string pattern, SpanMode mode, bool followSymlink = true) { import std.algorithm.iteration : filter; import std.path : globMatch, baseName; bool f(DirEntry de) { return globMatch(baseName(de.name), pattern); } return filter!f(DirIterator(path, mode, followSymlink)); } @system unittest { import std.stdio : writefln; immutable dpath = deleteme ~ "_dir"; immutable fpath = deleteme ~ "_file"; immutable sdpath = deleteme ~ "_sdir"; immutable sfpath = deleteme ~ "_sfile"; scope(exit) { if (dpath.exists) rmdirRecurse(dpath); if (fpath.exists) remove(fpath); if (sdpath.exists) remove(sdpath); if (sfpath.exists) remove(sfpath); } mkdir(dpath); write(fpath, "hello world"); version (Posix) { core.sys.posix.unistd.symlink((dpath ~ '\0').ptr, (sdpath ~ '\0').ptr); core.sys.posix.unistd.symlink((fpath ~ '\0').ptr, (sfpath ~ '\0').ptr); } static struct Flags { bool dir, file, link; } auto tests = [dpath : Flags(true), fpath : Flags(false, true)]; version (Posix) { tests[sdpath] = Flags(true, false, true); tests[sfpath] = Flags(false, true, true); } auto past = Clock.currTime() - 2.seconds; auto future = past + 4.seconds; foreach (path, flags; tests) { auto de = DirEntry(path); assert(de.name == path); assert(de.isDir == flags.dir); assert(de.isFile == flags.file); assert(de.isSymlink == flags.link); assert(de.isDir == path.isDir); assert(de.isFile == path.isFile); assert(de.isSymlink == path.isSymlink); assert(de.size == path.getSize()); assert(de.attributes == getAttributes(path)); assert(de.linkAttributes == getLinkAttributes(path)); scope(failure) writefln("[%s] [%s] [%s] [%s]", past, de.timeLastAccessed, de.timeLastModified, future); assert(de.timeLastAccessed > past); assert(de.timeLastAccessed < future); assert(de.timeLastModified > past); assert(de.timeLastModified < future); assert(attrIsDir(de.attributes) == flags.dir); assert(attrIsDir(de.linkAttributes) == (flags.dir && !flags.link)); assert(attrIsFile(de.attributes) == flags.file); assert(attrIsFile(de.linkAttributes) == (flags.file && !flags.link)); assert(!attrIsSymlink(de.attributes)); assert(attrIsSymlink(de.linkAttributes) == flags.link); version(Windows) { assert(de.timeCreated > past); assert(de.timeCreated < future); } else version(Posix) { assert(de.timeStatusChanged > past); assert(de.timeStatusChanged < future); assert(de.attributes == de.statBuf.st_mode); } } } // Bugzilla 17962 - Make sure that dirEntries does not butcher Unicode file names. @system unittest { import std.algorithm.comparison : equal; import std.algorithm.iteration : map; import std.algorithm.sorting : sort; import std.array : array; import std.path : buildPath; import std.uni : normalize; // The Unicode normalization is required to make the tests pass on Mac OS X. auto dir = deleteme ~ normalize("𐐷"); scope(exit) if (dir.exists) rmdirRecurse(dir); mkdir(dir); auto files = ["Hello World", "Ma Chérie.jpeg", "さいごの果実.txt"].map!(a => buildPath(dir, normalize(a)))().array(); sort(files); foreach (file; files) write(file, "nothing"); auto result = dirEntries(dir, SpanMode.shallow).map!(a => a.name.normalize()).array(); sort(result); assert(equal(files, result)); } /** * Reads a file line by line and parses the line into a single value or a * $(REF Tuple, std,typecons) of values depending on the length of `Types`. * The lines are parsed using the specified format string. The format string is * passed to $(REF formattedRead, std,_format), and therefore must conform to the * _format string specification outlined in $(MREF std, _format). * * Params: * Types = the types that each of the elements in the line should be returned as * filename = the name of the file to read * format = the _format string to use when reading * * Returns: * If only one type is passed, then an array of that type. Otherwise, an * array of $(REF Tuple, std,typecons)s. * * Throws: * `Exception` if the format string is malformed. Also, throws `Exception` * if any of the lines in the file are not fully consumed by the call * to $(REF formattedRead, std,_format). Meaning that no empty lines or lines * with extra characters are allowed. */ Select!(Types.length == 1, Types[0][], Tuple!(Types)[]) slurp(Types...)(string filename, in char[] format) { import std.array : appender; import std.conv : text; import std.exception : enforce; import std.format : formattedRead; import std.stdio : File; auto app = appender!(typeof(return))(); ElementType!(typeof(return)) toAdd; auto f = File(filename); scope(exit) f.close(); foreach (line; f.byLine()) { formattedRead(line, format, &toAdd); enforce(line.empty, text("Trailing characters at the end of line: `", line, "'")); app.put(toAdd); } return app.data; } /// @system unittest { import std.typecons : tuple; scope(exit) { assert(exists(deleteme)); remove(deleteme); } write(deleteme, "12 12.25\n345 1.125"); // deleteme is the name of a temporary file // Load file; each line is an int followed by comma, whitespace and a // double. auto a = slurp!(int, double)(deleteme, "%s %s"); assert(a.length == 2); assert(a[0] == tuple(12, 12.25)); assert(a[1] == tuple(345, 1.125)); } /** Returns the path to a directory for temporary files. On Windows, this function returns the result of calling the Windows API function $(LINK2 http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992.aspx, $(D GetTempPath)). On POSIX platforms, it searches through the following list of directories and returns the first one which is found to exist: $(OL $(LI The directory given by the $(D TMPDIR) environment variable.) $(LI The directory given by the $(D TEMP) environment variable.) $(LI The directory given by the $(D TMP) environment variable.) $(LI $(D /tmp)) $(LI $(D /var/tmp)) $(LI $(D /usr/tmp)) ) On all platforms, $(D tempDir) returns $(D ".") on failure, representing the current working directory. The return value of the function is cached, so the procedures described above will only be performed the first time the function is called. All subsequent runs will return the same string, regardless of whether environment variables and directory structures have changed in the meantime. The POSIX $(D tempDir) algorithm is inspired by Python's $(LINK2 http://docs.python.org/library/tempfile.html#tempfile.tempdir, $(D tempfile.tempdir)). */ string tempDir() @trusted { static string cache; if (cache is null) { version(Windows) { import std.conv : to; // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx wchar[MAX_PATH + 2] buf; DWORD len = GetTempPathW(buf.length, buf.ptr); if (len) cache = buf[0 .. len].to!string; } else version(Posix) { import std.process : environment; // This function looks through the list of alternative directories // and returns the first one which exists and is a directory. static string findExistingDir(T...)(lazy T alternatives) { foreach (dir; alternatives) if (!dir.empty && exists(dir)) return dir; return null; } cache = findExistingDir(environment.get("TMPDIR"), environment.get("TEMP"), environment.get("TMP"), "/tmp", "/var/tmp", "/usr/tmp"); } else static assert(false, "Unsupported platform"); if (cache is null) cache = getcwd(); } return cache; }
D
module components.material; import core, components, graphics, utility; import yaml; import derelict.opengl3.gl3, derelict.freeimage.freeimage; import std.variant, std.conv, std.string; shared final class Material : IComponent { private: Texture _diffuse, _normal, _specular; public: mixin( Property!(_diffuse, AccessModifier.Public) ); mixin( Property!(_normal, AccessModifier.Public) ); mixin( Property!(_specular, AccessModifier.Public) ); this() { _diffuse = _normal = _specular = defaultTex; } /** * Create a Material from a Yaml node. */ static shared(Material) createFromYaml( Node yamlObj ) { auto obj = new shared Material; Variant prop; if( Config.tryGet!string( "Diffuse", prop, yamlObj ) ) obj.diffuse = Assets.get!Texture( prop.get!string ); if( Config.tryGet!string( "Normal", prop, yamlObj ) ) obj.normal = Assets.get!Texture( prop.get!string ); if( Config.tryGet!string( "Specular", prop, yamlObj ) ) obj.specular = Assets.get!Texture( prop.get!string ); return obj; } override void update() { } override void shutdown() { } } shared class Texture { protected: uint _width, _height, _glID; this( ubyte* buffer ) { glGenTextures( 1, cast(uint*)&_glID ); glBindTexture( GL_TEXTURE_2D, glID ); updateBuffer( buffer ); } void updateBuffer( const ubyte* buffer ) { // Set texture to update glBindTexture( GL_TEXTURE_2D, glID ); // Update texture glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_BGRA, GL_UNSIGNED_BYTE, cast(GLvoid*)buffer ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); } public: mixin( Property!_width ); mixin( Property!_height ); mixin( Property!_glID ); this( string filePath ) { filePath ~= "\0"; auto imageData = FreeImage_ConvertTo32Bits( FreeImage_Load( FreeImage_GetFileType( filePath.ptr, 0 ), filePath.ptr, 0 ) ); width = FreeImage_GetWidth( imageData ); height = FreeImage_GetHeight( imageData ); this( cast(ubyte*)FreeImage_GetBits( imageData ) ); FreeImage_Unload( imageData ); } void shutdown() { glBindTexture( GL_TEXTURE_2D, 0 ); glDeleteBuffers( 1, cast(uint*)&_glID ); } } @property shared(Texture) defaultTex() { static shared Texture def; if( !def ) def = new shared Texture( [0, 0, 0, 255] ); return def; } static this() { IComponent.initializers[ "Material" ] = ( Node yml, shared GameObject obj ) { obj.material = Assets.get!Material( yml.get!string ); return obj.material; }; }
D
module dwtx.dwtxhelper.CharacterIterator; interface CharacterIterator { static const char DONE = '\u00FF'; Object clone(); char current(); char first(); int getBeginIndex(); int getEndIndex(); int getIndex(); char last(); char next(); char previous(); char setIndex(int position); }
D
/Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKBaseanti.build/API/DescribeIpResourceInfoResponse.swift.o : /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/CleanThresholdSpec.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResource.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlowDetail.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceProtectInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/SetCleanThresholdExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceProtectInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourcesExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceFlowExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/BaseantiClient.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlow.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKBaseanti.build/DescribeIpResourceInfoResponse~partial.swiftmodule : /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/CleanThresholdSpec.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResource.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlowDetail.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceProtectInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/SetCleanThresholdExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceProtectInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourcesExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceFlowExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/BaseantiClient.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlow.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKBaseanti.build/DescribeIpResourceInfoResponse~partial.swiftdoc : /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/CleanThresholdSpec.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResource.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResponse.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlowDetail.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceProtectInfo.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/SetCleanThresholdExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceProtectInfoExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourcesExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/DescribeIpResourceFlowExecutor.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowResult.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Client/BaseantiClient.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/SetCleanThresholdRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceProtectInfoRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourcesRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/API/DescribeIpResourceFlowRequest.swift /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/Sources/JDCloudSDKBaseanti/Model/IpResourceFlow.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/lishijun1/Documents/swiftworkspace/JDCloudSDKSwift/jdcloud-sdk-swift-github/JDCloudSDKSwift/.build/x86_64-apple-macosx10.10/debug/JDCloudSDKCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
import std.stdio; import std.c.stdio; /******************************************/ struct S { int opStar() { return 7; } } void test1() { S s; printf("%d\n", *s); assert(*s == 7); } /******************************************/ void test2() { double[1][2] bar; bar[0][0] = 1.0; bar[1][0] = 2.0; foo2(bar); } void foo2(T...)(T args) { foreach (arg; args[0 .. $]) { //writeln(arg); bar2!(typeof(arg))(&arg); } } void bar2(D)(const(void)* arg) { D obj = *cast(D*) arg; } /***************************************************/ void test3() { version (unittest) { printf("unittest!\n"); } else { printf("no unittest!\n"); } version (assert) { printf("assert!\n"); } else { printf("no assert!\n"); } } /***************************************************/ void test4() { immutable int maxi = 8; int[][maxi] neighbors = [ cast(int[])[ ], [ 0 ], [ 0, 1], [ 0, 2], [1, 2], [1, 2, 3, 4], [ 2, 3, 5], [ 4, 5, 6 ] ]; int[maxi] grid; // neighbors[0].length = 0; void place(int k, uint mask) { if(k<maxi) { for(uint m = 1, d = 1; d <= maxi; d++, m<<=1) if(!(mask & m)) { bool ok = true; int dif; foreach(nb; neighbors[k]) if((dif=grid[nb]-d)==1 || dif==-1) { ok = false; break; } if(ok) { grid[k] = d; place(k+1, mask | m); } } } else { printf(" %d\n%d %d %d\n%d %d %d\n %d\n\n", grid[0], grid[1], grid[2], grid[3], grid[4], grid[5], grid[6], grid[7]); } } place(0, 0); } /***************************************************/ struct S5 { enum S5 some_constant = {2}; int member; } void test5() { } /***************************************************/ struct S6 { int a, b, c; } struct T6 { S6 s; int b = 7; S6* opDot() { return &s; } } void test6() { T6 t; t.a = 4; t.b = 5; t.c = 6; assert(t.a == 4); assert(t.b == 5); assert(t.c == 6); assert(t.s.b == 0); assert(t.sizeof == 4*4); assert(t.init.sizeof == 4*4); } /***************************************************/ struct S7 { int a, b, c; } class C7 { S7 s; int b = 7; S7* opDot() { return &s; } } void test7() { C7 t = new C7(); t.a = 4; t.b = 5; t.c = 6; assert(t.a == 4); assert(t.b == 5); assert(t.c == 6); assert(t.s.b == 0); assert(t.sizeof == (void*).sizeof); assert(t.init is null); } /***************************************************/ void foo8(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__) { assert(n1 < n2); printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s.length, s.ptr); } void test8() { foo8(); } /***************************************************/ void foo9(int n1 = __LINE__ + 0, int n2 = __LINE__, string s = __FILE__)() { assert(n1 < n2); printf("n1 = %d, n2 = %d, s = %.*s\n", n1, n2, s.length, s.ptr); } void test9() { foo9(); } /***************************************************/ int foo10(char c) pure nothrow { return 1; } void test10() { int function(char c) fp; int function(char c) pure nothrow fq; fp = &foo10; fq = &foo10; } /***************************************************/ class Base11 {} class Derived11 : Base11 {} class MoreDerived11 : Derived11 {} int fun11(Base11) { return 1; } int fun11(Derived11) { return 2; } void test11() { MoreDerived11 m; auto i = fun11(m); assert(i == 2); } /***************************************************/ interface ABC {}; interface AB: ABC {}; interface BC: ABC {}; interface AC: ABC {}; interface A: AB, AC {}; interface B: AB, BC {}; interface C: AC, BC {}; int f12(AB ab) { return 1; } int f12(ABC abc) { return 2; } void test12() { A a; auto i = f12(a); assert(i == 1); } /***************************************************/ template Foo13(alias x) { enum bar = x + 1; } static assert(Foo13!(2+1).bar == 4); template Bar13(alias x) { enum bar = x; } static assert(Bar13!("abc").bar == "abc"); void test13() { } /***************************************************/ template Foo14(alias a) { alias Bar14!(a) Foo14; } int Bar14(alias a)() { return a.sizeof; } void test14() { auto i = Foo14!("hello")(); printf("i = %d\n", i); assert(i == "hello".sizeof); i = Foo14!(1)(); printf("i = %d\n", i); assert(i == 4); } /***************************************************/ auto foo15()(int x) { return 3 + x; } void test15() { auto bar()(int x) { return 5 + x; } printf("%d\n", foo15(4)); printf("%d\n", bar(4)); } /***************************************************/ int foo16(int x) { return 1; } int foo16(ref int x) { return 2; } void test16() { int y; auto i = foo16(y); printf("i == %d\n", i); assert(i == 2); i = foo16(3); assert(i == 1); } /***************************************************/ class A17 { } class B17 : A17 { } class C17 : B17 { } int foo17(A17, ref int x) { return 1; } int foo17(B17, ref int x) { return 2; } void test17() { C17 c; int y; auto i = foo17(c, y); printf("i == %d\n", i); assert(i == 2); } /***************************************************/ class C18 { void foo(int x) { foo("abc"); } void foo(string s) { } // this is hidden, but that's ok 'cuz no overlap void bar() { foo("abc"); } } class D18 : C18 { override void foo(int x) { } } void test18() { D18 d = new D18(); d.bar(); } /***************************************************/ int foo19(alias int a)() { return a; } void test19() { int y = 7; auto i = foo19!(y)(); printf("i == %d\n", i); assert(i == 7); i = foo19!(4)(); printf("i == %d\n", i); assert(i == 4); } /***************************************************/ template Foo20(int x) if (x & 1) { const int Foo20 = 6; } template Foo20(int x) if ((x & 1) == 0) { const int Foo20 = 7; } void test20() { int i = Foo20!(3); printf("%d\n", i); assert(i == 6); i = Foo20!(4); printf("%d\n", i); assert(i == 7); } /***************************************************/ template isArray21(T : U[], U) { static const isArray21 = 1; } template isArray21(T) { static const isArray21 = 0; } int foo21(T)(T x) if (isArray21!(T)) { return 1; } int foo21(T)(T x) if (!isArray21!(T)) { return 2; } void test21() { auto i = foo21(5); assert(i == 2); int[] a; i = foo21(a); assert(i == 1); } /***************************************************/ void test22() { immutable uint x, y; foreach (i; x .. y) {} } /***************************************************/ const bool foo23 = is(typeof(function void() { })); const bar23 = is(typeof(function void() { })); void test23() { assert(foo23 == true); assert(bar23 == true); } /***************************************************/ ref int foo24(int i) { static int x; x = i; return x; } void test24() { int x = foo24(3); assert(x == 3); } /***************************************************/ ref int foo25(int i) { static int x; x = i; return x; } int bar25(ref int x) { return x + 1; } void test25() { int x = bar25(foo25(3)); assert(x == 4); } /***************************************************/ static int x26; ref int foo26(int i) { x26 = i; return x26; } void test26() { int* p = &foo26(3); assert(*p == 3); } /***************************************************/ static int x27 = 3; ref int foo27(int i) { return x27; } void test27() { foo27(3) = 4; assert(x27 == 4); } /***************************************************/ ref int foo28(ref int x) { return x; } void test28() { int a; foo28(a); } /***************************************************/ void wyda(int[] a) { printf("aaa\n"); } void wyda(int[int] a) { printf("bbb\n"); } struct S29 { int[] a; void wyda() { a.wyda; a.wyda(); } } void test29() { int[] a; a.wyda; int[5] b; b.wyda; int[int] c; c.wyda; S29 s; s.wyda(); } /***************************************************/ void foo30(D)(D arg) if (isIntegral!D) { } struct S30(T) { } struct U30(int T) { } alias int myint30; void test30() { S30!myint30 u; S30!int s; S30!(int) t = s; // U30!3 v = s; } /***************************************************/ class A31 { void foo(int* p) { } } class B31 : A31 { override void foo(scope int* p) { } } void test31() { } /***************************************************/ void bar32() { } nothrow void foo32(int* p) { //try { bar32(); } catch (Object o) { } try { bar32(); } catch (Throwable o) { } try { bar32(); } catch (Exception o) { } } void test32() { int i; foo32(&i); } /***************************************************/ struct Integer { this(int i) { this.i = i; } this(long ii) { i = 3; } const int i; } void test33() { } /***************************************************/ void test34() { alias uint Uint; foreach(Uint u;1..10) {} for(Uint u=1;u<10;u++) {} } /***************************************************/ ref int foo35(bool condition, ref int lhs, ref int rhs) { if ( condition ) return lhs; return rhs; } ref int bar35()(bool condition, ref int lhs, ref int rhs) { if ( condition ) return lhs; return rhs; } void test35() { int a = 10, b = 11; foo35(a<b, a, b) = 42; printf("a = %d and b = %d\n", a, b); // a = 42 and b = 11 assert(a == 42 && b == 11); bar35(a<b, a, b) = 52; printf("a = %d and b = %d\n", a, b); assert(a == 42 && b == 52); } /***************************************************/ int foo36(T...)(T ts) if (T.length > 1) { return T.length; } int foo36(T...)(T ts) if (T.length <= 1) { return T.length * 7; } void test36() { auto i = foo36!(int,int)(1, 2); assert(i == 2); i = foo36(1, 2, 3); assert(i == 3); i = foo36(1); assert(i == 7); i = foo36(); assert(i == 0); } /***************************************************/ void test6685() { struct S { int x; }; with({ return S(); }()) { x++; } } /***************************************************/ struct A37(alias T) { } void foo37(X)(X x) if (is(X Y == A37!(U), alias U)) { } void bar37() {} void test37() { A37!(bar37) a2; foo37(a2); foo37!(A37!bar37)(a2); } /***************************************************/ struct A38 { this(this) { printf("B's copy\n"); } bool empty() {return false;} void popFront() {} int front() { return 1; } // ref A38 opSlice() { return this; } } void test38() { A38 a; int i; foreach (e; a) { if (++i == 100) break; } } /***************************************************/ alias int function() Fun39; alias ref int function() Gun39; static assert(!is(Fun39 == Gun39)); void test39() { } /***************************************************/ int x40; struct Proxy { ref int at(int i)() { return x40; } } void test40() { Proxy p; auto x = p.at!(1); } /***************************************************/ template Foo41(TList...) { alias TList Foo41; } alias Foo41!(immutable(ubyte)[], ubyte[]) X41; void test41() { } /***************************************************/ bool endsWith(A1, A2)(A1 longer, A2 shorter) { static if (is(typeof(longer[0 .. 0] == shorter))) { } else { } return false; } void test42() { char[] a; byte[] b; endsWith(a, b); } /***************************************************/ void f43(S...)(S s) if (S.length > 3) { } void test43() { f43(1, 2, 3, 4); } /***************************************************/ struct S44(int x = 1){} void fun()(S44!(1) b) { } void test44() { S44!() s; fun(s); } /***************************************************/ // 2006 void test2006() { string [][] aas = []; assert(aas.length == 0); aas ~= cast (string []) []; assert(aas.length == 1); aas = aas ~ cast (string []) []; assert(aas.length == 2); } /***************************************************/ // 8442 void test8442() { enum int[] fooEnum = []; immutable fooImmutable = fooEnum; } /***************************************************/ class A45 { int x; int f() { printf("A\n"); return 1; } } class B45 : A45 { override const int f() { printf("B\n"); return 2; } } void test45() { A45 y = new B45; int i = y.f; assert(i == 2); } /***************************************************/ struct Test46 { int foo; } void test46() { enum Test46 test = {}; enum q = test.foo; } /***************************************************/ pure int double_sqr(int x) { int y = x; void do_sqr() { y *= y; } do_sqr(); return y; } void test47() { assert(double_sqr(10) == 100); } /***************************************************/ void sort(alias less)(string[] r) { bool pred() { return less("a", "a"); } .sort!(less)(r); } void foo48() { int[string] freqs; string[] words; sort!((a, b) { return freqs[a] > freqs[b]; })(words); sort!((string a, string b) { return freqs[a] > freqs[b]; })(words); //sort!(bool (a, b) { return freqs[a] > freqs[b]; })(words); //sort!(function (a, b) { return freqs[a] > freqs[b]; })(words); //sort!(function bool(a, b) { return freqs[a] > freqs[b]; })(words); sort!(delegate bool(string a, string b) { return freqs[a] > freqs[b]; })(words); } void test48() { } /***************************************************/ struct S49 { static void* p; this( string name ) { printf( "(ctor) &%.*s.x = %p\n", name.length, name.ptr, &x ); p = cast(void*)&x; } invariant() {} int x; } void test49() { auto s = new S49("s2"); printf( "&s2.x = %p\n", &s.x ); assert(cast(void*)&s.x == S49.p); } /***************************************************/ auto max50(Ts...)(Ts args) if (Ts.length >= 2 && is(typeof(Ts[0].init > Ts[1].init ? Ts[1].init : Ts[0].init))) { static if (Ts.length == 2) return args[1] > args[0] ? args[1] : args[0]; else return max50(max50(args[0], args[1]), args[2 .. $]); } void test50() { assert(max50(4, 5) == 5); assert(max50(2.2, 4.5) == 4.5); assert(max50("Little", "Big") == "Little"); assert(max50(4, 5.5) == 5.5); assert(max50(5.5, 4) == 5.5); } /***************************************************/ void test51() { static immutable int[2] array = [ 42 ]; enum e = array[1]; static immutable int[1] array2 = [ 0: 42 ]; enum e2 = array2[0]; assert(e == 0); assert(e2 == 42); } /***************************************************/ enum ubyte[4] a52 = [5,6,7,8]; void test52() { int x=3; assert(a52[x]==8); } /***************************************************/ void test53() { size_t func2(immutable(void)[] t) { return 0; } } /***************************************************/ void foo54(void delegate(void[]) dg) { } void test54() { void func(void[] t) pure { } foo54(&func); // void func2(const(void)[] t) { } // foo54(&func2); } /***************************************************/ class Foo55 { synchronized void noop1() { } void noop2() shared { } } void test55() { auto foo = new shared(Foo55); foo.noop1(); foo.noop2(); } /***************************************************/ enum float one56 = 1 * 1; template X56(float E) { int X56 = 2; } alias X56!(one56 * one56) Y56; void test56() { assert(Y56 == 2); } /***************************************************/ void test57() { alias shared(int) T; assert (is(T == shared)); } /***************************************************/ struct A58 { int a,b; } void test58() { A58[2] rg=[{1,2},{5,6}]; assert(rg[0].a == 1); assert(rg[0].b == 2); assert(rg[1].a == 5); assert(rg[1].b == 6); } /***************************************************/ class A59 { const foo(int i) { return i; } } /***************************************************/ void test60() { enum real ONE = 1.0; real x; for (x=0.0; x<10.0; x+=ONE) printf("%Lg\n", x); printf("%Lg\n", x); assert(x == 10); } /***************************************************/ pure immutable(T)[] fooPT(T)(immutable(T)[] x, immutable(T)[] y){ immutable(T)[] fooState; immutable(T)[] bar(immutable(T)[] x){ fooState = "hello "; return x ~ y; } return fooState ~ bar(x); } void test61() { writeln(fooPT("p", "c")); } /***************************************************/ int[3] foo62(int[3] a) { a[1]++; return a; } void test62() { int[3] b; b[0] = 1; b[1] = 2; b[2] = 3; auto c = foo62(b); assert(b[0] == 1); assert(b[1] == 2); assert(b[2] == 3); assert(c[0] == 1); assert(c[1] == 3); assert(c[2] == 3); } /***************************************************/ void test3927() { int[] array; assert(array.length++ == 0); assert(array.length == 1); assert(array.length-- == 1); assert(array.length == 0); } /***************************************************/ void test63() { int[3] b; b[0] = 1; b[1] = 2; b[2] = 3; auto c = b; b[1]++; assert(b[0] == 1); assert(b[1] == 3); assert(b[2] == 3); assert(c[0] == 1); assert(c[1] == 2); assert(c[2] == 3); } /***************************************************/ void test64() { int[3] b; b[0] = 1; b[1] = 2; b[2] = 3; int[3] c; c = b; b[1]++; assert(b[0] == 1); assert(b[1] == 3); assert(b[2] == 3); assert(c[0] == 1); assert(c[1] == 2); assert(c[2] == 3); } /***************************************************/ int[2] foo65(int[2] a) { a[1]++; return a; } void test65() { int[2] b; b[0] = 1; b[1] = 2; int[2] c = foo65(b); assert(b[0] == 1); assert(b[1] == 2); assert(c[0] == 1); assert(c[1] == 3); } /***************************************************/ int[1] foo66(int[1] a) { a[0]++; return a; } void test66() { int[1] b; b[0] = 1; int[1] c = foo66(b); assert(b[0] == 1); assert(c[0] == 2); } /***************************************************/ int[2] foo67(out int[2] a) { a[0] = 5; a[1] = 6; return a; } void test67() { int[2] b; b[0] = 1; b[1] = 2; int[2] c = foo67(b); assert(b[0] == 5); assert(b[1] == 6); assert(c[0] == 5); assert(c[1] == 6); } /***************************************************/ void test68() { digestToString(cast(ubyte[16])x"c3fcd3d76192e4007dfb496cca67e13b"); } void digestToString(const ubyte[16] digest) { assert(digest[0] == 0xc3); assert(digest[15] == 0x3b); } /***************************************************/ void test69() { digestToString69(cast(ubyte[16])x"c3fcd3d76192e4007dfb496cca67e13b"); } void digestToString69(ref const ubyte[16] digest) { assert(digest[0] == 0xc3); assert(digest[15] == 0x3b); } /***************************************************/ void test70() { digestToString70("1234567890123456"); } void digestToString70(ref const char[16] digest) { assert(digest[0] == '1'); assert(digest[15] == '6'); } /***************************************************/ void foo71(out shared int o) {} /***************************************************/ struct foo72 { int bar() shared { return 1; } } void test72() { shared foo72 f; auto x = f.bar; } /***************************************************/ class Foo73 { static if (is(typeof(this) T : shared T)) static assert(0); static if (is(typeof(this) U == shared U)) static assert(0); static if (is(typeof(this) U == const U)) static assert(0); static if (is(typeof(this) U == immutable U)) static assert(0); static if (is(typeof(this) U == const shared U)) static assert(0); static assert(!is(int == const)); static assert(!is(int == immutable)); static assert(!is(int == shared)); static assert(is(int == int)); static assert(is(const(int) == const)); static assert(is(immutable(int) == immutable)); static assert(is(shared(int) == shared)); static assert(is(const(shared(int)) == shared)); static assert(is(const(shared(int)) == const)); static assert(!is(const(shared(int)) == immutable)); static assert(!is(const(int) == immutable)); static assert(!is(const(int) == shared)); static assert(!is(shared(int) == const)); static assert(!is(shared(int) == immutable)); static assert(!is(immutable(int) == const)); static assert(!is(immutable(int) == shared)); } template Bar(T : T) { alias T Bar; } template Barc(T : const(T)) { alias T Barc; } template Bari(T : immutable(T)) { alias T Bari; } template Bars(T : shared(T)) { alias T Bars; } template Barsc(T : shared(const(T))) { alias T Barsc; } void test73() { auto f = new Foo73; alias int T; // 5*5 == 25 combinations, plus 2 for swapping const and shared static assert(is(Bar!(T) == T)); static assert(is(Bar!(const(T)) == const(T))); static assert(is(Bar!(immutable(T)) == immutable(T))); static assert(is(Bar!(shared(T)) == shared(T))); static assert(is(Bar!(shared(const(T))) == shared(const(T)))); static assert(is(Barc!(const(T)) == T)); static assert(is(Bari!(immutable(T)) == T)); static assert(is(Bars!(shared(T)) == T)); static assert(is(Barsc!(shared(const(T))) == T)); static assert(is(Barc!(T) == T)); static assert(is(Barc!(immutable(T)) == T)); static assert(is(Barc!(const(shared(T))) == shared(T))); static assert(is(Barsc!(immutable(T)) == T)); static assert(is(Bars!(const(shared(T))) == const(T))); static assert(is(Barsc!(shared(T)) == T)); Bars!(shared(const(T))) b; pragma(msg, typeof(b)); static assert(is(Bars!(shared(const(T))) == const(T))); static assert(is(Barc!(shared(const(T))) == shared(T))); static assert(!is(Bari!(T))); static assert(!is(Bari!(const(T)))); static assert(!is(Bari!(shared(T)))); static assert(!is(Bari!(const(shared(T))))); static assert(is(Barc!(shared(T)))); static assert(!is(Bars!(T))); static assert(!is(Bars!(const(T)))); static assert(!is(Bars!(immutable(T)))); static assert(!is(Barsc!(T))); static assert(!is(Barsc!(const(T)))); } /***************************************************/ pure nothrow { alias void function(int) A74; } alias void function(int) pure nothrow B74; alias pure nothrow void function(int) C74; void test74() { A74 a = null; B74 b = null; C74 c = null; a = b; a = c; } /***************************************************/ class A75 { pure static void raise(string s) { throw new Exception(s); } } void test75() { int x = 0; try { A75.raise("a"); } catch (Exception e) { x = 1; } assert(x == 1); } /***************************************************/ void test76() { int x, y; bool which; (which ? x : y) += 5; assert(y == 5); } /***************************************************/ void test77() { auto a = ["hello", "world"]; pragma(msg, typeof(a)); auto b = a; assert(a is b); assert(a == b); b = a.dup; assert(a == b); assert(a !is b); } /***************************************************/ void test78() { auto array = [0, 2, 4, 6, 8, 10]; array = array[0 .. $ - 2]; // Right-shrink by two elements assert(array == [0, 2, 4, 6]); array = array[1 .. $]; // Left-shrink by one element assert(array == [2, 4, 6]); array = array[1 .. $ - 1]; // Shrink from both sides assert(array == [4]); } /***************************************************/ void test79() { auto a = [87, 40, 10]; a ~= 42; assert(a == [87, 40, 10, 42]); a ~= [5, 17]; assert(a == [87, 40, 10, 42, 5, 17]); } /***************************************************/ void test6317() { int b = 12345; struct nested { int a; int fun() { return b; } } static assert(!__traits(compiles, { nested x = { 3, null }; })); nested g = { 7 }; auto h = nested(7); assert(g.fun() == 12345); assert(h.fun() == 12345); } /***************************************************/ void test80() { auto array = new int[10]; array.length += 1000; assert(array.length == 1010); array.length /= 10; assert(array.length == 101); array.length -= 1; assert(array.length == 100); array.length |= 1; assert(array.length == 101); array.length ^= 3; assert(array.length == 102); array.length &= 2; assert(array.length == 2); array.length *= 2; assert(array.length == 4); array.length <<= 1; assert(array.length == 8); array.length >>= 1; assert(array.length == 4); array.length >>>= 1; assert(array.length == 2); array.length %= 2; assert(array.length == 0); int[]* foo() { static int x; x++; assert(x == 1); auto p = &array; return p; } (*foo()).length += 2; assert(array.length == 2); } /***************************************************/ void test81() { int[3] a = [1, 2, 3]; int[3] b = a; a[1] = 42; assert(b[1] == 2); // b is an independent copy of a int[3] fun(int[3] x, int[3] y) { // x and y are copies of the arguments x[0] = y[0] = 100; return x; } auto c = fun(a, b); // c has type int[3] assert(c == [100, 42, 3]); assert(b == [1, 2, 3]); // b is unaffected by fun } /***************************************************/ void test82() { auto a1 = [ "Jane":10.0, "Jack":20, "Bob":15 ]; auto a2 = a1; // a1 and a2 refer to the same data a1["Bob"] = 100; // Changing a1 assert(a2["Bob"] == 100); //is same as changing a2 a2["Sam"] = 3.5; //and vice assert(a2["Sam"] == 3.5); // versa } /***************************************************/ void bump(ref int x) { ++x; } void test83() { int x = 1; bump(x); assert(x == 2); } /***************************************************/ interface Test4174 { void func(T)() {} } /***************************************************/ auto foo84 = [1, 2.4]; void test84() { pragma(msg, typeof([1, 2.4])); static assert(is(typeof([1, 2.4]) == double[])); pragma(msg, typeof(foo84)); static assert(is(typeof(foo84) == double[])); } /***************************************************/ void test85() { dstring c = "V\u00E4rld"; c = c ~ '!'; assert(c == "V\u00E4rld!"); c = '@' ~ c; assert(c == "@V\u00E4rld!"); wstring w = "V\u00E4rld"; w = w ~ '!'; assert(w == "V\u00E4rld!"); w = '@' ~ w; assert(w == "@V\u00E4rld!"); string s = "V\u00E4rld"; s = s ~ '!'; assert(s == "V\u00E4rld!"); s = '@' ~ s; assert(s == "@V\u00E4rld!"); } /***************************************************/ void test86() { int[][] a = [ [1], [2,3], [4] ]; int[][] w = [ [1, 2], [3], [4, 5], [] ]; int[][] x = [ [], [1, 2], [3], [4, 5], [] ]; } /***************************************************/ // Bugzilla 3379 T1[] find(T1, T2)(T1[] longer, T2[] shorter) if (is(typeof(longer[0 .. 1] == shorter) : bool)) { while (longer.length >= shorter.length) { if (longer[0 .. shorter.length] == shorter) break; longer = longer[1 .. $]; } return longer; } auto max(T...)(T a) if (T.length == 2 && is(typeof(a[1] > a[0] ? a[1] : a[0])) || T.length > 2 && is(typeof(max(max(a[0], a[1]), a[2 .. $])))) { static if (T.length == 2) { return a[1] > a[0] ? a[1] : a[0]; } else { return max(max(a[0], a[1]), a[2 .. $]); } } // Cases which would ICE or segfault struct Bulldog(T){ static void cat(Frog)(Frog f) if (true) { } } void mouse(){ Bulldog!(int).cat(0); } void test87() { double[] d1 = [ 6.0, 1.5, 2.4, 3 ]; double[] d2 = [ 1.5, 2.4 ]; assert(find(d1, d2) == d1[1 .. $]); assert(find(d1, d2) == d1[1 .. $]); // Check for memory corruption assert(max(4, 5) == 5); assert(max(3, 4, 5) == 5); } /***************************************************/ template test4284(alias v) { enum test4284 = v.length == 0; } static assert(test4284!(cast(string)null)); static assert(test4284!(cast(string[])null)); /***************************************************/ struct S88 { void opDispatch(string s, T)(T i) { printf("S.opDispatch('%.*s', %d)\n", s.length, s.ptr, i); } } class C88 { void opDispatch(string s)(int i) { printf("C.opDispatch('%.*s', %d)\n", s.length, s.ptr, i); } } struct D88 { template opDispatch(string s) { enum int opDispatch = 8; } } void test88() { S88 s; s.opDispatch!("hello")(7); s.foo(7); auto c = new C88(); c.foo(8); D88 d; printf("d.foo = %d\n", d.foo); assert(d.foo == 8); } /***************************************************/ void test89() { static struct X { int x; int bar() { return x; } } X s; printf("%d\n", s.sizeof); assert(s.sizeof == 4); } /***************************************************/ struct S90 { void opDispatch( string name, T... )( T values ) { assert(values[0] == 3.14); } } void test90( ) { S90 s; s.opDispatch!("foo")( 3.14 ); s.foo( 3.14 ); } /***************************************************/ struct A7439(int r, int c) { alias r R; alias c C; alias float[R * C] Data; Data _data; alias _data this; this(Data ar){ _data = ar; } pure ref float opIndex(size_t rr, size_t cc){ return _data[cc + rr * C]; } } void test7439() { A7439!(2, 2) a = A7439!(2, 2)([8, 3, 2, 9]); a[0,0] -= a[0,0] * 2.0; } /***************************************************/ void foo91(uint line = __LINE__) { printf("%d\n", line); } void test91() { foo91(); printf("%d\n", __LINE__); } /***************************************************/ auto ref foo92(ref int x) { return x; } int bar92(ref int x) { return x; } void test92() { int x = 3; int i = bar92(foo92(x)); assert(i == 3); } /***************************************************/ struct Foo93 { public int foo() const { return 2; } } void test93() { const Foo93 bar = Foo93(); enum bla = bar.foo(); assert(bla == 2); } /***************************************************/ struct Foo94 { int x, y; real z; } pure nothrow Foo94 makeFoo(const int x, const int y) { return Foo94(x, y, 3.0); } void test94() { auto f = makeFoo(1, 2); assert(f.x==1); assert(f.y==2); assert(f.z==3); } /***************************************************/ struct T95 { @disable this(this) { } } struct S95 { T95 t; } @disable void foo95() { } struct T95A { @disable this(this); } struct S95A { T95A t; } @disable void foo95A() { } void test95() { S95 s; S95 t; static assert(!__traits(compiles, t = s)); static assert(!__traits(compiles, foo95())); S95A u; S95A v; static assert(!__traits(compiles, v = u)); static assert(!__traits(compiles, foo95A())); } /***************************************************/ struct S96(alias init) { int[] content = init; } void test96() { S96!([12, 3]) s1; S96!([1, 23]) s2; writeln(s1.content); writeln(s2.content); assert(!is(typeof(s1) == typeof(s2))); } /***************************************************/ struct A97 { const bool opEquals(ref const A97) { return true; } ref A97 opUnary(string op)() if (op == "++") { return this; } } void test97() { A97 a, b; foreach (e; a .. b) { } } /***************************************************/ void test98() { auto a = new int[2]; // the name "length" should not pop up in an index expression static assert(!is(typeof(a[length - 1]))); } /***************************************************/ string s99; void bar99(string i) { } void function(string) foo99(string i) { return &bar99; } void test99() { foo99 (s99 ~= "a") (s99 ~= "b"); assert(s99 == "ab"); } /***************************************************/ void test5081() { static pure immutable(int[]) x() { return new int[](10); } static pure int[] y() { return new int[](10); } immutable a = x(); immutable b = y(); } /***************************************************/ void test100() { string s; /* Testing order of evaluation */ void delegate(string, string) fun(string) { s ~= "b"; return delegate void(string x, string y) { s ~= "e"; }; } fun(s ~= "a")(s ~= "c", s ~= "d"); assert(s == "abcde", s); } /***************************************************/ void test101() { int[] d1 = [ 6, 1, 2 ]; byte[] d2 = [ 6, 1, 2 ]; assert(d1 == d2); d2 ~= [ 6, 1, 2 ]; assert(d1 != d2); } /***************************************************/ void test5403() { struct S { static int front; enum back = "yes!"; bool empty; void popAny() { empty = true; } alias popAny popFront; alias popAny popBack; } S.front = 7; foreach(int i; S()) assert(i == 7); S.front = 2; foreach(i; S()) assert(i == 2); foreach_reverse(i; S()) assert(i == "yes!"); } /***************************************************/ static assert([1,2,3] == [1.0,2,3]); /***************************************************/ int transmogrify(uint) { return 1; } int transmogrify(long) { return 2; } void test103() { assert(transmogrify(42) == 1); } /***************************************************/ int foo104(int x) { int* p = &(x += 1); return *p; } int bar104(int *x) { int* p = &(*x += 1); return *p; } void test104() { auto i = foo104(1); assert(i == 2); i = bar104(&i); assert(i == 3); } /***************************************************/ ref int bump105(ref int x) { return ++x; } void test105() { int x = 1; bump105(bump105(x)); // two increments assert(x == 3); } /***************************************************/ pure int genFactorials(int n) { static pure int factorial(int n) { if (n==2) return 1; return factorial(2); } return factorial(n); } /***************************************************/ void test107() { int[6] a; writeln(a); writeln(a.init); assert(a.init == [0,0,0,0,0,0]); } /***************************************************/ void bug4072(T)(T x) if (is(typeof(bug4072(x)))) {} static assert(!is(typeof(bug4072(7)))); /***************************************************/ class A109 {} void test109() { immutable(A109) b; A109 c; auto z = true ? b : c; //writeln(typeof(z).stringof); static assert(is(typeof(z) == const(A109))); } /***************************************************/ template Boo(T) {} struct Foo110(T, alias V = Boo!T) { pragma(msg, V.stringof); const s = V.stringof; } alias Foo110!double B110; alias Foo110!int A110; static assert(B110.s == "Boo!(double)"); static assert(A110.s == "Boo!(int)"); /***************************************************/ // 3716 void test111() { auto k1 = true ? [1,2] : []; // OK auto k2 = true ? [[1,2]] : [[]]; auto k3 = true ? [] : [[1,2]]; auto k4 = true ? [[[]]] : [[[1,2]]]; auto k5 = true ? [[[1,2]]] : [[[]]]; auto k6 = true ? [] : [[[]]]; static assert(!is(typeof(true ? [[[]]] : [[1,2]]))); // Must fail } /***************************************************/ void test3069() { ubyte id = 0; void[] v = [id] ~ [id]; } /***************************************************/ // 4303 template foo112() if (__traits(compiles,undefined)) { enum foo112 = false; } template foo112() if (true) { enum foo112 = true; } pragma(msg,__traits(compiles,foo112!())); static assert(__traits(compiles,foo112!())); const bool bar112 = foo112!(); /***************************************************/ struct File113 { this(int name) { } ~this() { } void opAssign(File113 rhs) { } struct ByLine { File113 file; this(int) { } } ByLine byLine() { return ByLine(1); } } auto filter113(File113.ByLine rs) { struct Filter { this(File113.ByLine r) { } } return Filter(rs); } void test113() { auto f = File113(1); auto rx = f.byLine(); auto file = filter113(rx); } /***************************************************/ template foo114(fun...) { auto foo114(int[] args) { return 1; } } pragma(msg, typeof(foo114!"a + b"([1,2,3]))); /***************************************************/ // Bugzilla 3935 struct Foo115 { void opBinary(string op)(Foo other) { pragma(msg, "op: " ~ op); assert(0); } } void test115() { Foo115 f; f = f; } /***************************************************/ // Bugzilla 2477 void foo116(T,)(T t) { T x; } void test116() { int[] data = [1,2,3,]; // OK data = [ 1,2,3, ]; // fails auto i = data[1,]; foo116!(int)(3); foo116!(int,)(3); foo116!(int,)(3,); } /***************************************************/ void test1891() { struct C { char[8] x = "helloabc"; } int main() { C* a = new C; C*[] b; b ~= new C; auto g = a ~ b; assert(g[0] && g[1] && g[0].x == g[1].x); return 0; } } /***************************************************/ // Bugzilla 4291 void test117() pure { mixin declareVariable; var = 42; mixin declareFunction; readVar(); } template declareVariable() { int var; } template declareFunction() { int readVar() { return var; } } /***************************************************/ // Bugzilla 4177 pure real log118(real x) { if (__ctfe) return 0.0; else return 1.0; } enum x118 = log118(4.0); void test118() {} /***************************************************/ void bug4465() { const a = 2 ^^ 2; int b = a; } /***************************************************/ pure void foo(int *p) { *p = 3; } pure void test120() { int i; foo(&i); assert(i == 3); } /***************************************************/ // 4866 immutable int[3] statik = [ 1, 2, 3 ]; enum immutable(int)[] dynamic = statik; static assert(is(typeof(dynamic) == immutable(int)[])); static if (! is(typeof(dynamic) == immutable(int)[])) { static assert(0); // (7) } pragma(msg, "!! ", typeof(dynamic)); /***************************************************/ // 2943 struct Foo2943 { int a; int b; alias b this; } void test122() { Foo2943 foo, foo2; foo.a = 1; foo.b = 2; foo2.a = 3; foo2.b = 4; foo2 = foo; assert(foo2.a == foo.a); } /***************************************************/ // 4641 struct S123 { int i; alias i this; } void test123() { S123[int] ss; ss[0] = S123.init; // This line causes Range Violation. } /***************************************************/ // 2451 struct Foo124 { int z = 3; void opAssign(Foo124 x) { z= 2;} } struct Bar124 { int z = 3; this(this){ z = 17; } } void test124() { Foo124[string] stuff; stuff["foo"] = Foo124.init; assert(stuff["foo"].z == 2); Bar124[string] stuff2; Bar124 q; stuff2["dog"] = q; assert(stuff2["dog"].z == 17); } /***************************************************/ void doNothing() {} void bug5071(short d, ref short c) { assert(c==0x76); void closure() { auto c2 = c; auto d2 = d; doNothing(); } auto useless = &closure; } void test125() { short c = 0x76; bug5071(7, c); } /***************************************************/ struct Foo126 { static Foo126 opCall(in Foo126 _f) pure { return _f; } } /***************************************************/ void test796() { struct S { invariant() { throw new Exception(""); } } S* s; try { assert(s); } catch (Error) { } } /***************************************************/ struct Tuple127(S...) { S expand; alias expand this; } alias Tuple127!(int, int) Foo127; void test127() { Foo127[] m_array; Foo127 f; m_array ~= f; } /***************************************************/ struct Bug4434 {} alias const Bug4434* IceConst4434; alias shared Bug4434* IceShared4434; alias shared Bug4434[] IceSharedArray4434; alias immutable Bug4434* IceImmutable4434; alias shared const Bug4434* IceSharedConst4434; alias int MyInt4434; alias const MyInt4434[3] IceConstInt4434; alias immutable string[] Bug4830; /***************************************************/ // 4254 void bub(const inout int other) {} void test128() { bub(1); } /***************************************************/ pure nothrow @safe auto bug4915a() { return 0; } pure nothrow @safe int bug4915b() { return bug4915a(); } void bug4915c() { pure nothrow @safe int d() { return 0; } int e() pure nothrow @safe { return d(); } } /***************************************************/ // 5164 static if (is(int Q == int, Z...)) { } /***************************************************/ // 5195 alias typeof(foo5195) food5195; const int * foo5195 = null; alias typeof(foo5195) good5195; static assert( is (food5195 == good5195)); /***************************************************/ version (Windows) { } else { int[0] var5332; void test5332() { auto x = var5332; } } /***************************************************/ // 5191 struct Foo129 { void add(T)(T value) nothrow { this.value += value; } this(int value) { this.value = value; } int value; } void test129() { auto foo = Foo129(5); assert(foo.value == 5); foo.add(2); writeln(foo.value); assert(foo.value == 7); foo.add(3); writeln(foo.value); assert(foo.value == 10); foo.add(3); writeln(foo.value); assert(foo.value == 13); void delegate (int) nothrow dg = &foo.add!(int); dg(7); assert(foo.value == 20); } /***************************************************/ const shared class C5107 { int x; } static assert(is(typeof(C5107.x) == const)); // okay static assert(is(typeof(C5107.x) == shared)); // fails! /***************************************************/ immutable struct S3598 { static void funkcja() { } } /***************************************************/ // 4211 @safe struct X130 { void func() { } } @safe class Y130 { void func() { } } @safe void test130() { X130 x; x.func(); auto y = new Y130; y.func(); } /***************************************************/ template Return(alias fun) { static if (is(typeof(fun) R == return)) alias R Return; } interface I4217 { int square(int n); real square(real n); } alias Return!( __traits(getOverloads, I4217, "square")[0] ) R4217; alias Return!( __traits(getOverloads, I4217, "square")[1] ) S4217; static assert(! is(R4217 == S4217)); /***************************************************/ // 5094 void test131() { S131 s; int[] conv = s; } struct S131 { @property int[] get() { return [1,2,3]; } alias get this; } /***************************************************/ struct S7545 { uint id; alias id this; } void test7545() { auto id = 0 ? S7545() : -1; } /***************************************************/ // 5020 void test132() { S132 s; if (!s) {} } struct S132 { bool cond; alias cond this; } /***************************************************/ // 5343 struct Tuple5343(Specs...) { Specs[0] field; } struct S5343(E) { immutable E x; } enum A5343{a,b,c} alias Tuple5343!(A5343) TA5343; alias S5343!(A5343) SA5343; /***************************************************/ // 5365 interface IFactory { void foo(); } class A133 { protected static class Factory : IFactory { void foo() { } } this() { _factory = createFactory(); } protected IFactory createFactory() { return new Factory; } private IFactory _factory; @property final IFactory factory() { return _factory; } alias factory this; } void test133() { IFactory f = new A133; f.foo(); // segfault } /***************************************************/ // 5365 class B134 { } class A134 { B134 _b; this() { _b = new B134; } B134 b() { return _b; } alias b this; } void test134() { auto a = new A134; B134 b = a; // b is null assert(a._b is b); // fails } /***************************************************/ // 5025 struct S135 { void delegate() d; } void test135() { shared S135[] s; if (0) s[0] = S135(); } /***************************************************/ // 5545 bool enforce136(bool value, lazy const(char)[] msg = null) { if(!value) { return false; } return value; } struct Perm { byte[3] perm; ubyte i; this(byte[] input) { foreach(elem; input) { enforce136(i < 3); perm[i++] = elem; std.stdio.stderr.writeln(i); // Never gets incremented. Stays at 0. } } } void test136() { byte[] stuff = [0, 1, 2]; auto perm2 = Perm(stuff); writeln(perm2.perm); // Prints [2, 0, 0] assert(perm2.perm[] == [0, 1, 2]); } /***************************************************/ // 4097 void foo4097() { } alias typeof(&foo4097) T4097; static assert(is(T4097 X : X*) && is(X == function)); static assert(!is(X)); /***************************************************/ // 5798 void assign9(ref int lhs) pure { lhs = 9; } void assign8(ref int rhs) pure { rhs = 8; } int test137(){ int a=1,b=2; assign8(b),assign9(a); assert(a == 9); assert(b == 8); // <-- fail assign9(b),assign8(a); assert(a == 8); assert(b == 9); // <-- fail return 0; } /***************************************************/ struct Size138 { union { struct { int width; int height; } long size; } } enum Size138 foo138 = {2 ,5}; Size138 bar138 = foo138; void test138() { assert(bar138.width == 2); assert(bar138.height == 5); } /***************************************************/ void test3822() { import core.stdc.stdlib; int i = 0; void* ptr; while(i++ != 2) { auto p = alloca(2); assert(p != ptr); ptr = p; } } /***************************************************/ // 5939, 5940 template map(fun...) { auto map(double[] r) { struct Result { this(double[] input) { } } return Result(r); } } void test139() { double[] x; alias typeof(map!"a"(x)) T; T a = void; auto b = map!"a"(x); auto c = [map!"a"(x)]; T[3] d; } /***************************************************/ // 5966 string[] foo5966(string[] a) { a[0] = a[0][0..$]; return a; } enum var5966 = foo5966([""]); /***************************************************/ // 5975 int foo5975(wstring replace) { wstring value = ""; value ~= replace; return 1; } enum X5975 = foo5975("X"w); /***************************************************/ // 5965 template mapx(fun...) if (fun.length >= 1) { int mapx(Range)(Range r) { return 1; } } void test140() { int foo(int i) { return i; } int[] arr; auto x = mapx!( (int a){return foo(a);} )(arr); } /***************************************************/ void bug5976() { int[] barr; int * k; foreach (ref b; barr) { scope(failure) k = &b; k = &b; } } /***************************************************/ // 5771 struct S141 { this(A)(auto ref A a){} } void test141() { S141 s = S141(10); } /***************************************************/ // 3688 struct S142 { int v; this(int n) { v = n; } const bool opCast(T:bool)() { return true; } } void test142() { if (int a = 1) assert(a == 1); else assert(0); if (const int a = 2) assert(a == 2); else assert(0); if (immutable int a = 3) assert(a == 3); else assert(0); if (auto s = S142(10)) assert(s.v == 10); else assert(0); if (auto s = const(S142)(20)) assert(s.v == 20); else assert(0); if (auto s = immutable(S142)(30)) assert(s.v == 30); else assert(0); } /***************************************************/ // 6072 static assert({ if (int x = 5) {} return true; }()); /***************************************************/ // 5959 int n; void test143() { ref int f(){ return n; } // NG f() = 1; assert(n == 1); nothrow ref int f1(){ return n; } // OK f1() = 2; assert(n == 2); auto ref int f2(){ return n; } // OK f2() = 3; assert(n == 3); } /***************************************************/ // 6119 void startsWith(alias pred) () if (is(typeof(pred('c', 'd')) : bool)) { } void startsWith(alias pred) () if (is(typeof(pred('c', "abc")) : bool)) { } void test144() { startsWith!((a, b) { return a == b; })(); } /***************************************************/ void test145() { import std.c.stdio; printf("hello world 145\n"); } void test146() { test1(); static import std.c.stdio; std.c.stdio.printf("hello world 146\n"); } /***************************************************/ // 5856 struct X147 { void f() { writeln("X.f mutable"); } void f() const { writeln("X.f const"); } void g()() { writeln("X.g mutable"); } void g()() const { writeln("X.g const"); } void opOpAssign(string op)(int n) { writeln("X+= mutable"); } void opOpAssign(string op)(int n) const { writeln("X+= const"); } } void test147() { X147 xm; xm.f(); // prints "X.f mutable" xm.g(); // prints "X.g mutable" xm += 10; // should print "X+= mutable" (1) const(X147) xc; xc.f(); // prints "X.f const" xc.g(); // prints "X.g const" xc += 10; // should print "X+= const" (2) } /***************************************************/ void test3559() { static class A { int foo(int a) { return 0; } int foo(float a) { return 1; } int bar(float a) { return 1; } int bar(int a) { return 0; } } static class B : A { override int foo(float a) { return 2; } alias A.foo foo; alias A.bar bar; override int bar(float a) { return 2; } } { auto x = new A; auto f1 = cast(int delegate(int))&x.foo; auto f2 = cast(int delegate(float))&x.foo; int delegate(int) f3 = &x.foo; int delegate(float) f4 = &x.foo; assert(f1(0) == 0); assert(f2(0) == 1); assert(f3(0) == 0); assert(f4(0) == 1); } { auto x = new B; auto f1 = cast(int delegate(int))&x.foo; auto f2 = cast(int delegate(float))&x.foo; int delegate(int) f3 = &x.foo; int delegate(float) f4 = &x.foo; assert(f1(0) == 0); assert(f2(0) == 2); assert(f3(0) == 0); assert(f4(0) == 2); } { auto x = new A; auto f1 = cast(int delegate(int))&x.bar; auto f2 = cast(int delegate(float))&x.bar; int delegate(int) f3 = &x.bar; int delegate(float) f4 = &x.bar; assert(f1(0) == 0); assert(f2(0) == 1); assert(f3(0) == 0); assert(f4(0) == 1); } { auto x = new B; auto f1 = cast(int delegate(int))&x.bar; auto f2 = cast(int delegate(float))&x.bar; int delegate(int) f3 = &x.bar; int delegate(float) f4 = &x.bar; assert(f1(0) == 0); assert(f2(0) == 2); assert(f3(0) == 0); assert(f4(0) == 2); } } /***************************************************/ // 5897 struct A148{ int n; } struct B148{ int n, m; this(A148 a){ n = a.n, m = a.n*2; } } struct C148{ int n, m; static C148 opCall(A148 a) { C148 b; b.n = a.n, b.m = a.n*2; return b; } } void test148() { auto a = A148(10); auto b = cast(B148)a; assert(b.n == 10 && b.m == 20); auto c = cast(C148)a; assert(c.n == 10 && c.m == 20); } /***************************************************/ // 4969 class MyException : Exception { this() { super("An exception!"); } } void throwAway() { throw new MyException; } void cantthrow() nothrow { try throwAway(); catch(MyException me) assert(0); catch(Exception e) assert(0); } /***************************************************/ class A2540 { int a; int foo() { return 0; } alias int X; } class B2540 : A2540 { int b; override super.X foo() { return 1; } alias this athis; alias this.b thisb; alias super.a supera; alias super.foo superfoo; alias this.foo thisfoo; } struct X2540 { alias this athis; } void test2540() { auto x = X2540.athis.init; static assert(is(typeof(x) == X2540)); B2540 b = new B2540(); assert(&b.a == &b.supera); assert(&b.b == &b.thisb); assert(b.thisfoo() == 1); } /***************************************************/ // 7295 struct S7295 { int member; @property ref int refCountedPayload() { return member; } alias refCountedPayload this; } void foo7295(S)(immutable S t, int qq) pure { } void foo7295(S)(S s) pure { } void bar7295() pure { S7295 b; foo7295(b); } /***************************************************/ // 5659 void test149() { import std.traits; char a; immutable(char) b; static assert(is(typeof(true ? a : b) == const(char))); static assert(is(typeof([a, b][0]) == const(char))); static assert(is(CommonType!(typeof(a), typeof(b)) == const(char))); } /***************************************************/ // 1373 void func1373a(){} static assert(typeof(func1373a).stringof == "void()"); static assert(typeof(func1373a).mangleof == "FZv"); static assert(!__traits(compiles, typeof(func1373a).alignof)); static assert(!__traits(compiles, typeof(func1373a).init)); static assert(!__traits(compiles, typeof(func1373a).offsetof)); void func1373b(int n){} static assert(typeof(func1373b).stringof == "void(int n)"); static assert(typeof(func1373b).mangleof == "FiZv"); static assert(!__traits(compiles, typeof(func1373b).alignof)); static assert(!__traits(compiles, typeof(func1373b).init)); static assert(!__traits(compiles, typeof(func1373b).offsetof)); /***************************************************/ void bar150(T)(T n) { } @safe void test150() { bar150(1); } /***************************************************/ void test5785() { static struct x { static int y; } assert(x.y !is 1); assert(x.y !in [1:0]); } /***************************************************/ void bar151(T)(T n) { } nothrow void test151() { bar151(1); } /***************************************************/ @property int coo() { return 1; } @property auto doo(int i) { return i; } @property int eoo() { return 1; } @property auto ref hoo(int i) { return i; } // 3359 int goo(int i) pure { return i; } auto ioo(int i) pure { return i; } auto ref boo(int i) pure nothrow { return i; } class A152 { auto hoo(int i) pure { return i; } const boo(int i) const { return i; } auto coo(int i) const { return i; } auto doo(int i) immutable { return i; } auto eoo(int i) shared { return i; } } // 4706 struct Foo152(T) { @property auto ref front() { return T.init; } @property void front(T num) {} } void test152() { Foo152!int foo; auto a = foo.front; foo.front = 2; } /***************************************************/ // 6733 void bug6733(int a, int b) pure nothrow { } void test6733() { int z = 1; bug6733(z++, z++); assert(z==3); } /***************************************************/ // 3799 void test153() { void bar() { } static assert(!__traits(isStaticFunction, bar)); } /***************************************************/ // 3632 void test154() { float f; assert(f is float.init); double d; assert(d is double.init); real r; assert(r is real.init); assert(float.nan is float.nan); assert(double.nan is double.nan); assert(real.nan is real.nan); } /***************************************************/ // 3147 void test155() { byte b = 1; short s; int i; long l; s = b + b; b = s % b; s = s >> b; b = 1; b = i % b; b = b >> i; } /***************************************************/ // 2521 immutable int val = 23; const int val2 = 23; ref immutable(int) func2521_() { return val; } ref immutable(int) func2521_2() { return *&val; } ref immutable(int) func2521_3() { return func2521_; } ref const(int) func2521_4() { return val2; } ref const(int) func2521_5() { return val; } auto ref func2521_6() { return val; } ref func2521_7() { return val; } /***************************************************/ void test5554() { class MA { } class MB : MA { } class MC : MB { } class A { abstract MA foo(); } interface I { MB foo(); } class B : A { override MC foo() { return null; } } class C : B, I { override MC foo() { return null; } } } /***************************************************/ // 5962 struct S156 { auto g()(){ return 1; } const auto g()(){ return 2; } } void test156() { auto ms = S156(); assert(ms.g() == 1); auto cs = const(S156)(); assert(cs.g() == 2); } /***************************************************/ // 4258 struct Vec4258 { Vec4258 opOpAssign(string Op)(auto ref Vec4258 other) if (Op == "+") { return this; } Vec4258 opBinary(string Op:"+")(Vec4258 other) { Vec4258 result; return result += other; } } void test4258() { Vec4258 v; v += Vec4258() + Vec4258(); // line 12 } // regression fix test struct Foo4258 { // binary ++/-- int opPostInc()() if (false) { return 0; } // binary 1st int opAdd(R)(R rhs) if (false) { return 0; } int opAdd_r(R)(R rhs) if (false) { return 0; } // compare int opCmp(R)(R rhs) if (false) { return 0; } // binary-op assign int opAddAssign(R)(R rhs) if (false) { return 0; } } struct Bar4258 { // binary commutive 1 int opAdd_r(R)(R rhs) if (false) { return 0; } // binary-op assign int opOpAssign(string op, R)(R rhs) if (false) { return 0; } } struct Baz4258 { // binary commutive 2 int opAdd(R)(R rhs) if (false) { return 0; } } static assert(!is(typeof(Foo4258.init++))); static assert(!is(typeof(Foo4258.init + 1))); static assert(!is(typeof(1 + Foo4258.init))); static assert(!is(typeof(Foo4258.init < Foo4258.init))); static assert(!is(typeof(Foo4258.init += 1))); static assert(!is(typeof(Bar4258.init + 1))); static assert(!is(typeof(Bar4258.init += 1))); static assert(!is(typeof(1 + Baz4258.init))); /***************************************************/ // 4539 void test4539() { static assert(!__traits(compiles, "hello" = "red")); void foo1(ref string s){} void foo2(ref const char[10] s){} void foo3(ref char[5] s){} void foo4(ref const char[5] s) { assert(s[0] == 'h'); assert(s[4] == 'o'); } void foo5(ref const ubyte[5] s) { assert(s[0] == 0xc3); assert(s[4] == 0x61); } static assert(!__traits(compiles, foo1("hello"))); static assert(!__traits(compiles, foo2("hello"))); static assert(!__traits(compiles, foo3("hello"))); // same as test68, 69, 70 foo4("hello"); foo5(cast(ubyte[5])x"c3fcd3d761"); //import std.conv; //static assert(!__traits(compiles, parse!int("10") == 10)); } /***************************************************/ // 1471 void test1471() { int n; string bar = "BOOM"[n..$-1]; assert(bar == "BOO"); } /***************************************************/ deprecated @disable int bug6389; static assert(!is(typeof(bug6389 = bug6389))); /***************************************************/ void test4963() { struct Value { byte a; }; Value single() { return Value(); } Value[] list; auto x = single() ~ list; } /***************************************************/ pure int test4031() { static const int x = 8; return x; } /***************************************************/ // 5437 template EnumMembers5437(E) { template TypeTuple(T...){ alias T TypeTuple; } alias TypeTuple!("A", "B") EnumMembers5437; } template IntValue5437() { int IntValue5437 = 10; } void test5437() { enum Foo { A, B } alias EnumMembers5437!Foo members; // OK enum n1 = members.length; // OK enum n2 = (EnumMembers5437!Foo).length; // NG, type -> symbol enum s1 = IntValue5437!().sizeof; // OK enum s2 = (IntValue5437!()).sizeof; // NG, type -> expression } /***************************************************/ // 1962 void test1962() { class C { abstract void x(); } assert(C.classinfo.create() is null); } /***************************************************/ // 6228 void test6228() { const(int)* ptr; const(int) temp; auto x = (*ptr) ^^ temp; } /***************************************************/ int test7544() { try { throw new Exception(""); } catch (Exception e) static assert(1); return 1; } static assert(test7544()); /***************************************************/ struct S6230 { int p; int q() const pure { return p; } void r() pure { p = 231; } } class C6230 { int p; int q() const pure { return p; } void r() pure { p = 552; } } int q6230(ref const S6230 s) pure { // <-- Currently OK return s.p; } int q6230(ref const C6230 c) pure { // <-- Currently OK return c.p; } void r6230(ref S6230 s) pure { s.p = 244; } void r6230(ref C6230 c) pure { c.p = 156; } bool test6230pure() pure { auto s = S6230(4); assert(s.p == 4); assert(q6230(s) == 4); assert(s.q == 4); auto c = new C6230; c.p = 6; assert(q6230(c) == 6); assert(c.q == 6); r6230(s); assert(s.p == 244); s.r(); assert(s.p == 231); r6230(c); assert(c.p == 156); c.r(); assert(c.p == 552); return true; } void test6230() { assert(test6230pure()); } /***************************************************/ void test6264() { struct S { auto opSlice() { return this; } } int[] a; S s; static assert(!is(typeof(a[] = s[]))); int*[] b; static assert(!is(typeof(b[] = [new immutable(int)]))); char[] c = new char[](5); c[] = "hello"; } /***************************************************/ // 5046 void test5046() { auto va = S5046!("", int)(); auto vb = makeS5046!("", int)(); } struct S5046(alias p, T) { T s; T fun() { return s; } // (10) } S5046!(p, T) makeS5046(alias p, T)() { return typeof(return)(); } /***************************************************/ // 6335 struct S6335 { const int value; this()(int n){ value = n; } } void test6335() { S6335 s = S6335(10); } /***************************************************/ struct S6295(int N) { int[N] x; const nothrow pure @safe f() { return x.length; } } void test6295() { auto bar(T: S6295!(N), int N)(T x) { return x.f(); } S6295!4 x; assert(bar(x) == 4); } /***************************************************/ template TT4536(T...) { alias T TT4536; } void test4536() { auto x = TT4536!(int, long, [1, 2]).init; assert(x[0] is int.init); assert(x[1] is long.init); assert(x[2] is [1, 2].init); } /***************************************************/ struct S6284 { int a; } class C6284 { int a; } pure int bug6284a() { S6284 s = {4}; auto b = s.a; // ok with (s) { b += a; // should be ok. } return b; } pure int bug6284b() { auto s = new S6284; s.a = 4; auto b = s.a; with (*s) { b += a; } return b; } pure int bug6284c() { auto s = new C6284; s.a = 4; auto b = s.a; with (s) { b += a; } return b; } void test6284() { assert(bug6284a() == 8); assert(bug6284b() == 8); assert(bug6284c() == 8); } /***************************************************/ class C6293 { C6293 token; } void f6293(in C6293[] a) pure { auto x0 = a[0].token; assert(x0 is a[0].token.token.token); assert(x0 is (&x0).token); auto p1 = &x0 + 1; assert(x0 is (p1 - 1).token); int c = 0; assert(x0 is a[c].token); } void test6293() { auto x = new C6293; x.token = x; f6293([x]); } /***************************************************/ // 2774 int foo2774(int n){ return 0; } static assert(foo2774.mangleof == "_D7xtest467foo2774FiZi"); class C2774 { int foo2774(){ return 0; } } static assert(C2774.foo2774.mangleof == "_D7xtest465C27747foo2774MFZi"); template TFoo2774(T){} static assert(TFoo2774!int.mangleof == "7xtest4615__T8TFoo2774TiZ"); void test2774() { int foo2774(int n){ return 0; } static assert(foo2774.mangleof == "_D7xtest468test2774FZv7foo2774MFiZi"); } /***************************************************/ // 6220 void test6220() { struct Foobar { real x; real y; real z;}; switch("x") { foreach(i,member; __traits(allMembers, Foobar)) { case member : break; } default : break; } } /***************************************************/ // 5799 void test5799() { int a; int *u = &(a ? a : (a ? a : a)); assert(u == &a); } /***************************************************/ // 6529 enum Foo6529 : char { A='a' } ref const(Foo6529) func6529(const(Foo6529)[] arr){ return arr[0]; } /***************************************************/ void test783() { const arr = [ 1,2,3 ]; const i = 2; auto jhk = new int[arr[i]]; // "need size of rightmost array, not type arr[i]" } /***************************************************/ template X157(alias x) { alias x X157; } template Parent(alias foo) { alias X157!(__traits(parent, foo)) Parent; } template ParameterTypeTuple(alias foo) { static if (is(typeof(foo) P == function)) alias P ParameterTypeTuple; else static assert(0, "argument has no parameters"); } template Mfp(alias foo) { auto Mfp = function(Parent!foo self, ParameterTypeTuple!foo i) { return self.foo(i); }; } class C157 { int a = 3; int foo(int i, int y) { return i + a + y; } } void test157() { auto c = new C157(); auto mfp = Mfp!(C157.foo); auto i = mfp(c, 1, 7); assert(i == 11); } /***************************************************/ // 6473 struct Eins6473 { ~this() {} } struct Zwei6473 { void build(Eins6473 devices = Eins6473()) { } } void build(Eins6473 devices = Eins6473()) {} void test6473() { void build(Eins6473 devices = Eins6473()) {} } /***************************************************/ // 6630 void test6630() { static class B {} static class A { this() { b = new B(); } B b; alias b this; } void fun(A a) { a = null; assert(a is null); } auto a = new A; assert(a.b !is null); fun(a); assert(a !is null); assert(a.b !is null); } /***************************************************/ // 6690 T useLazy6690(T)(lazy T val) { return val; // val is converted to delegate call, but it is typed as int delegate() - not @safe! } void test6690() @safe { useLazy6690(0); // Error: safe function 'test6690' cannot call system function 'useLazy6690' } /***************************************************/ template Hoge6691() { immutable static int[int] dict; immutable static int value; static this() { dict = [1:1, 2:2]; value = 10; } } alias Hoge6691!() H6691; /***************************************************/ // 2953 template Tuple2953(T...) { alias T Tuple2953; } template Range2953(int b) { alias Tuple2953!(1) Range2953; } void foo2953()() { Tuple2953!(int, int) args; foreach( x ; Range2953!(args.length) ){ } } void test2953() { foo2953!()(); } /***************************************************/ // 2997 abstract class B2997 { void foo(); } interface I2997 { void bar(); } abstract class C2997 : B2997, I2997 {} //pragma(msg, __traits(allMembers, C).stringof); void test2997() { enum ObjectMembers = ["toString","toHash","opCmp","opEquals","Monitor","factory"]; static assert([__traits(allMembers, C2997)] == ["foo"] ~ ObjectMembers ~ ["bar"]); } /***************************************************/ // 6596 extern (C) int function() pfunc6596; extern (C) int cfunc6596(){ return 0; } static assert(typeof(pfunc6596).stringof == "extern (C) int function()"); static assert(typeof(cfunc6596).stringof == "extern (C) int()"); /***************************************************/ // 4647 interface Timer { final int run() { printf("Timer.run()\n"); return 1; }; } interface Application { final int run() { printf("Application.run()\n"); return 2; }; } class TimedApp : Timer, Application { } void test4647() { auto app = new TimedApp; assert(app.Timer.run() == 1); // error, no Timer property assert(app.Application.run() == 2); // error, no Application property assert(app.run() == 1); // This would call Timer.run() if the two calls // above were commented out } /***************************************************/ template T1064(E...) { alias E T1064; } int[] var1064 = [ T1064!(T1064!(T1064!(1, 2), T1064!(), T1064!(3)), T1064!(4, T1064!(T1064!(T1064!(T1064!(5)))), T1064!(T1064!(T1064!(T1064!())))),6) ]; void test1064() { assert(var1064 == [1,2,3,4,5,6]); } /***************************************************/ // 5696 template Seq5696(T...){ alias T Seq5696; } template Pred5696(T) { alias T Pred5696; } // TOKtemplate template Scope5696(int n){ template X(T) { alias T X; } } // TOKimport T foo5696(T)(T x) { return x; } void test5696() { foreach (pred; Seq5696!(Pred5696, Pred5696)) { static assert(is(pred!int == int)); } foreach (scop; Seq5696!(Scope5696!0, Scope5696!1)) { static assert(is(scop.X!int == int)); } alias Seq5696!(foo5696, foo5696) funcs; assert(funcs[0](0) == 0); assert(funcs[1](1) == 1); foreach (i, fn; funcs) { assert(fn(i) == i); } } /***************************************************/ // 6084 template TypeTuple6084(T...){ alias T TypeTuple6084; } void test6084() { int foo(int x)() { return x; } foreach(i; TypeTuple6084!(0)) foo!(i); } /***************************************************/ // 3133 void test3133() { short[2] x = [1,2]; int[1] y = cast(int[1])x; short[1] z = [1]; static assert(!__traits(compiles, y = cast(int[1])z)); } /***************************************************/ // 6763 template TypeTuple6763(TList...) { alias TList TypeTuple6763; } alias TypeTuple6763!(int) T6763; void f6763( T6763) { } /// void c6763(const T6763) { } ///T now is (const int) void r6763(ref T6763) { } ///T now is(ref const int) void i6763(in T6763) { } ///Uncomment to get an Assertion failure in 'mtype.c' void o6763(out T6763) { } ///ditto void test6763() { int n; f6763(0); //With D2: Error: function main.f ((ref const const(int) _param_0)) is not callable using argument types (int) c6763(0); r6763(n); static assert(!__traits(compiles, r6763(0))); i6763(0); o6763(n); static assert(!__traits(compiles, o6763(0))); // 6755 static assert(typeof(f6763).stringof == "void(int _param_0)"); static assert(typeof(c6763).stringof == "void(const(int) _param_0)"); static assert(typeof(r6763).stringof == "void(ref int _param_0)"); static assert(typeof(i6763).stringof == "void(const(int) _param_0)"); static assert(typeof(o6763).stringof == "void(out int _param_0)"); } /***************************************************/ // 6695 struct X6695 { void mfunc() { static assert(is(typeof(this) == X6695)); } void cfunc() const { static assert(is(typeof(this) == const(X6695))); } void ifunc() immutable { static assert(is(typeof(this) == immutable(X6695))); } void sfunc() shared { static assert(is(typeof(this) == shared(X6695))); } void scfunc() shared const { static assert(is(typeof(this) == shared(const(X6695)))); } void wfunc() inout { static assert(is(typeof(this) == inout(X6695))); } void swfunc() shared inout { static assert(is(typeof(this) == shared(inout(X6695)))); } static assert(is(typeof(this) == X6695)); } /***************************************************/ // 6087 template True6087(T) { immutable True6087 = true; } struct Foo6087 { static assert( True6087!(typeof(this)) ); } struct Bar6087 { static assert( is(typeof(this) == Bar6087) ); } /***************************************************/ // 6848 class Foo6848 {} class Bar6848 : Foo6848 { void func() immutable { static assert(is(typeof(this) == immutable(Bar6848))); // immutable(Bar6848) auto t = this; static assert(is(typeof(t) == immutable(Bar6848))); // immutable(Bar6848) static assert(is(typeof(super) == immutable(Foo6848))); // Foo6848 instead of immutable(Foo6848) auto s = super; static assert(is(typeof(s) == immutable(Foo6848))); // Foo6848 instead of immutable(Foo6848) } } /***************************************************/ // 6847 template True6847(T) { immutable True6847 = true; } class Foo6847 {} class Bar6847 : Foo6847 { static assert( True6847!(typeof(super)) ); static assert( is(typeof(super) == Foo6847) ); } /***************************************************/ // http://d.puremagic.com/issues/show_bug.cgi?id=6488 struct TickDuration { template to(T) if (__traits(isIntegral,T)) { const T to() { return 1; } } template to(T) if (__traits(isFloating,T)) { const T to() { return 0; } } const long seconds() { return to!(long)(); } } void test6488() { TickDuration d; d.seconds(); } /***************************************************/ // 6836 template map6836(fun...) if (fun.length >= 1) { auto map6836(Range)(Range r) { } } void test6836() { [1].map6836!"a"(); } /***************************************************/ // 6837 struct Ref6837a(T) { T storage; alias storage this; } struct Ref6837b(T) { T storage; @property ref T get(){ return storage; } alias get this; } int front6837(int[] arr){ return arr[0]; } void popFront6837(ref int[] arr){ arr = arr[1..$]; } void test6837() { assert([1,2,3].front6837 == 1); auto r1 = Ref6837a!(int[])([1,2,3]); assert(r1.front6837() == 1); // ng assert(r1.front6837 == 1); // ok r1.popFront6837(); // ng r1.storage.popFront6837(); // ok auto r2 = Ref6837b!(int[])([1,2,3]); assert(r2.front6837() == 1); // ng assert(r2.front6837 == 1); // ok r2.popFront6837(); // ng r2.get.popFront6837(); // ng r2.get().popFront6837(); // ok } /***************************************************/ // 6927 @property int[] foo6927() { return [1, 2]; } int[] bar6927(int[] a) { return a; } void test6927() { bar6927(foo6927); // OK foo6927.bar6927(); // line 9, Error } /***************************************************/ struct Foo6813(T) { Foo6813 Bar() { return Foo6813(_indices.abc()); } T _indices; } struct SortedRange(alias pred) { SortedRange abc() { return SortedRange(); } } void test6813() { auto ind = SortedRange!({ })(); auto a = Foo6813!(typeof(ind))(); } /***************************************************/ struct Interval6753{ int a,b; } @safe struct S6753 { int[] arr; @trusted @property auto byInterval() const { return cast(const(Interval6753)[])arr; } } /***************************************************/ // 6859 class Parent6859 { public: bool isHage() const @property; public: abstract void fuga() out { assert(isHage); } body { } } class Child6859 : Parent6859 { override bool isHage() const @property { return true; } override void fuga() { //nop } } void test6859() { auto t = new Child6859; t.fuga(); printf("done.\n"); } /***************************************************/ // 6910 template Test6910(alias i, B) { void fn() { foreach(t; B.Types) { switch(i) { case 0://IndexOf!(t, B.Types): { pragma(msg, __traits(allMembers, t)); pragma(msg, __traits(hasMember, t, "m")); static assert(__traits(hasMember, t, "m")); // test break; } default: {} } } } } void test6910() { static struct Bag(S...) { alias S Types; } static struct A { int m; } int i; alias Test6910!(i, Bag!(A)).fn func; } /***************************************************/ // 6902 void test6902() { static assert(is(typeof({ return int.init; // int, long, real, etc. }))); int f() pure nothrow { assert(0); } alias int T() pure nothrow; static if(is(typeof(&f) DT == delegate)) { static assert(is(DT* == T*)); // ok // Error: static assert (is(pure nothrow int() == pure nothrow int())) is false static assert(is(DT == T)); } } /***************************************************/ // 6330 struct S6330 { void opAssign(S6330 s) @disable { assert(0); // This fails. } } void test6330() { S6330 s; S6330 s2; static assert(!is(typeof({ s2 = s; }))); } /***************************************************/ // 5311 class C5311 { private static int globalData; void breaksPure() pure const { static assert(!__traits(compiles, { globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { X.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { this.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { int a = this.globalData; })); } } static void breaksPure5311a(C5311 x) pure { static assert(!__traits(compiles, { x.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { int a = x.globalData; })); } struct S5311 { private static int globalData; void breaksPure() pure const { static assert(!__traits(compiles, { globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { X.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { this.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { int a = this.globalData; })); } } static void breaksPure5311b(S5311 x) pure { static assert(!__traits(compiles, { x.globalData++; })); // SHOULD BE ERROR static assert(!__traits(compiles, { int a = x.globalData; })); } /***************************************************/ // 6868 @property bool empty6868(T)(in T[] a) @safe pure nothrow { return !a.length; } void test6868() { alias int[] Range; static if (is(char[1 + Range.empty6868])) // Line 9 enum bool isInfinite = true; char[0] s; // need } /***************************************************/ // 2856 struct foo2856 { static void opIndex(int i) { printf("foo\n"); } } struct bar2856(T) { static void opIndex(int i) { printf("bar\n"); } } void test2856() { foo2856[1]; bar2856!(float)[1]; // Error (# = __LINE__) alias bar2856!(float) B; B[1]; // Okay } /***************************************************/ // 3091 void test3091(inout int = 0) { struct Foo {} auto pm = new Foo; static assert(is( typeof( pm) == Foo * )); auto pc = new const Foo; static assert(is( typeof( pc) == const(Foo) * )); auto pw = new inout Foo; static assert(is( typeof( pw) == inout(Foo) * )); auto psm = new shared Foo; static assert(is( typeof(psm) == shared(Foo) * )); auto psc = new shared const Foo; static assert(is( typeof(psc) == shared(const(Foo))* )); auto psw = new shared inout Foo; static assert(is( typeof(psw) == shared(inout(Foo))* )); auto pi = new immutable Foo; static assert(is( typeof( pi) == immutable(Foo) * )); auto m = Foo(); static assert(is( typeof( m) == Foo )); auto c = const Foo(); static assert(is( typeof( c) == const(Foo) )); auto w = inout Foo(); static assert(is( typeof( w) == inout(Foo) )); auto sm = shared Foo(); static assert(is( typeof(sm) == shared(Foo) )); auto sc = shared const Foo(); static assert(is( typeof(sc) == shared(const(Foo)) )); auto sw = shared inout Foo(); static assert(is( typeof(sw) == shared(inout(Foo)) )); auto i = immutable Foo(); static assert(is( typeof( i) == immutable(Foo) )); } /***************************************************/ // 6837 template Id6837(T) { alias T Id6837; } static assert(is(Id6837!(shared const int) == shared const int)); static assert(is(Id6837!(shared inout int) == shared inout int)); /***************************************************/ // 6056 fixup template ParameterTypeTuple6056(func) { static if (is(func Fptr : Fptr*) && is(Fptr P == function)) alias P ParameterTypeTuple6056; else static assert(0, "argument has no parameters"); } extern(C) alias void function() fpw_t; alias void function(fpw_t fp) cb_t; void bar6056(ParameterTypeTuple6056!(cb_t) args) { pragma (msg, "TFunction1: " ~ typeof(args[0]).stringof); } extern(C) void foo6056() { } void test6056() { bar6056(&foo6056); } /***************************************************/ // 7108 static assert(!__traits(hasMember, int, "x")); static assert( __traits(hasMember, int, "init")); /***************************************************/ // 7073 void test7073() { string f(int[] arr...) { return ""; } } /***************************************************/ // 7150 struct A7150 { static int cnt; this(T)(T thing, int i) { this(thing, i > 0); // Error: constructor call must be in a constructor ++cnt; } this(T)(T thing, bool b) { ++cnt; } } void test7150() { auto a = A7150(5, 5); // Error: template instance constructtest.A.__ctor!(int) error instantiating assert(A7150.cnt == 2); } /***************************************************/ // 7160 class HomeController { static if (false) { mixin(q{ int a; }); } void foo() { foreach (m; __traits(derivedMembers, HomeController)) { } } } void test7160() {} /***************************************************/ // 7168 void test7168() { static class X { void foo(){} } static class Y : X { void bar(){} } enum ObjectMembers = ["toString","toHash","opCmp","opEquals","Monitor","factory"]; static assert([__traits(allMembers, X)] == ["foo"]~ObjectMembers); // pass static assert([__traits(allMembers, Y)] == ["bar", "foo"]~ObjectMembers); // fail static assert([__traits(allMembers, Y)] != ["bar", "foo"]); // fail } /***************************************************/ // 7170 T to7170(T)(string x) { return 1; } void test7170() { // auto i = to7170!int("1"); // OK auto j = "1".to7170!int(); // NG, Internal error: e2ir.c 683 } /***************************************************/ // 7196 auto foo7196(int x){return x;} auto foo7196(double x){return x;} void test7196() { auto x = (&foo7196)(1); // ok auto y = (&foo7196)(1.0); // fail } /***************************************************/ // 7285 int[2] spam7285() { int[2] ab; if (true) return (true) ? ab : [0, 0]; // Error else return (true) ? [0, 0] : ab; // OK } void test7285() { auto sa = spam7285(); } /***************************************************/ // 7321 void test7321() { static assert(is(typeof((){})==void function()pure nothrow @safe)); // ok static assert(is(typeof((){return;})==void function()pure nothrow @safe)); // fail } /***************************************************/ class A158 { pure void foo1() { } const void foo2() { } nothrow void foo3() { } @safe void foo4() { } } class B158 : A158 { override void foo1() { } override void foo2() { } override void foo3() { } override void foo4() { } } /***************************************************/ // 3282 class Base3282 { string f() { return "Base.f()"; } } class Derived3282 : Base3282 { override string f() { return "Derived.f()"; } override string f() const { return "Derived.f() const"; } } void test3282() { auto x = new Base3282; assert(x.f() == "Base.f()"); auto y = new Derived3282; assert(y.f() == "Derived.f()");// calls "Derived.f() const", but it is expected that be called non-const. auto z = new const(Derived3282); assert(z.f() == "Derived.f() const"); } /***************************************************/ // 7534 class C7534 { int foo(){ return 1; } } class D7534 : C7534 { override int foo(){ return 2; } override int foo() const { return 3; } // Error: D.foo multiple overrides of same function } void test7534() { C7534 mc = new C7534(); assert(mc.foo() == 1); D7534 md = new D7534(); assert(md.foo() == 2); mc = md; assert(mc.foo() == 2); const(D7534) cd = new const(D7534)(); assert(cd.foo() == 3); md = cast()cd; assert(md.foo() == 2); } /***************************************************/ // 7534 + return type covariance class X7534 {} class Y7534 : X7534 { int value; this(int n){ value = n; } } class V7534 { X7534 foo(){ return new X7534(); } } class W7534 : V7534 { override Y7534 foo(){ return new Y7534(1); } override Y7534 foo() const { return new Y7534(2); } } void test7534cov() { auto mv = new V7534(); assert(typeid(mv.foo()) == typeid(X7534)); auto mw = new W7534(); assert(typeid(mw.foo()) == typeid(Y7534)); assert(mw.foo().value == 1); mv = mw; assert(typeid(mv.foo()) == typeid(Y7534)); assert((cast(Y7534)mv.foo()).value == 1); auto cw = new const(W7534)(); assert(typeid(cw.foo()) == typeid(Y7534)); assert(cw.foo().value == 2); } /***************************************************/ // 7562 static struct MyInt { private int value; mixin ProxyOf!value; } mixin template ProxyOf(alias a) { template X1(){} template X2(){} template X3(){} template X4(){} template X5(){} template X6(){} template X7(){} template X8(){} template X9(){} template X10(){} void test1(this X)(){} void test2(this Y)(){} } /***************************************************/ // 7583 template Tup7583(E...) { alias E Tup7583; } struct S7583 { Tup7583!(float, char) field; alias field this; this(int x) { } } int bug7583() { S7583[] arr; arr ~= S7583(0); return 1; } static assert (bug7583()); /***************************************************/ // 7618 void test7618(const int x = 1) { int func(ref int x) { return 1; } static assert(!__traits(compiles, func(x))); // Error: function test.foo.func (ref int _param_0) is not callable using argument types (const(int)) int delegate(ref int) dg = (ref int x) => 1; static assert(!__traits(compiles, dg(x))); // --> no error, bad! int function(ref int) fp = (ref int x) => 1; static assert(!__traits(compiles, fp(x))); // --> no error, bad! } /***************************************************/ // 7621 void test7621() { enum uint N = 4u; char[] A = "hello".dup; uint[immutable char[4u]] dict; dict[*cast(immutable char[4]*)(A[0 .. N].ptr)] = 0; // OK dict[*cast(immutable char[N]*)(A[0 .. N].ptr)] = 0; // line 6, error } /***************************************************/ // 7682 template ConstOf7682(T) { alias const(T) ConstOf7682; } bool pointsTo7682(S)(ref const S source) @trusted pure nothrow { return true; } void test7682() { shared(ConstOf7682!(int[])) x; // line A struct S3 { int[10] a; } shared(S3) sh3; shared(int[]) sh3sub = sh3.a[]; assert(pointsTo7682(sh3sub)); // line B } /***************************************************/ // 7735 void a7735(void[][] data...) { //writeln(data); assert(data.length == 1); b7735(data); } void b7735(void[][] data...) { //writeln(data); assert(data.length == 1); c7735(data); } void c7735(void[][] data...) { //writeln(data); assert(data.length == 1); } void test7735() { a7735([]); a7735([]); } /***************************************************/ // 7815 mixin template Helpers() { static if (is(Flags!Move)) { Flags!Move flags; } else { // DMD will happily instantiate the allegedly // non-existent Flags!This here. (!) pragma(msg, __traits(derivedMembers, Flags!Move)); } } template Flags(T) { mixin({ int defs = 1; foreach (name; __traits(derivedMembers, Move)) { defs++; } if (defs) { return "struct Flags { bool a; }"; } else { return ""; } }()); } struct Move { int a; mixin Helpers!(); } enum a7815 = Move.init.flags; /***************************************************/ struct A7823 { long a; enum A7823 b = {0}; } void test7823(A7823 a = A7823.b) { } /***************************************************/ // 7871 struct Tuple7871 { string field; alias field this; } //auto findSplitBefore(R1)(R1 haystack) auto findSplitBefore7871(string haystack) { return Tuple7871(haystack); } void test7871() { string line = `<bookmark href="https://stuff">`; auto a = findSplitBefore7871(line[0 .. $])[0]; } /***************************************************/ // 7906 void test7906() { static assert(!__traits(compiles, { enum s = [string.min]; })); } /***************************************************/ // 7907 template Id7907(E) { alias E Id7907; } template Id7907(alias E) { alias E Id7907; } void test7907() { static assert(!__traits(compiles, { alias Id7907!([string.min]) X; })); } /***************************************************/ // 1175 class A1175 { class I1 { } } class B1175 : A1175 { class I2 : I1 { } I1 getI() { return new I2; } } /***************************************************/ // 7983 class A7983 { void f() { g7983(this); } unittest { } } void g7983(T)(T a) { foreach (name; __traits(allMembers, T)) { pragma(msg, name); static if (__traits(compiles, &__traits(getMember, a, name))) { } } } /***************************************************/ // 8004 void test8004() { auto n = (int n = 10){ return n; }(); assert(n == 10); } /***************************************************/ // 8064 void test8064() { uint[5] arry; ref uint acc(size_t i) { return arry[i]; } auto arryacc = &acc; arryacc(3) = 5; // same error } /***************************************************/ void func8105(in ref int x) { } void test8105() { } /***************************************************/ template ParameterTypeTuple159(alias foo) { static if (is(typeof(foo) P == __parameters)) alias P ParameterTypeTuple159; else static assert(0, "argument has no parameters"); } int func159(int i, long j = 7) { return 3; } alias ParameterTypeTuple159!func159 PT; int bar159(PT) { return 4; } pragma(msg, typeof(bar159)); pragma(msg, PT[1]); PT[1] boo159(PT[1..2] a) { return a[0]; } void test159() { assert(bar159(1) == 4); assert(boo159() == 7); } /***************************************************/ // 8283 struct Foo8283 { this(long) { } } struct FooContainer { Foo8283 value; } auto get8283() { union Buf { FooContainer result; } Buf buf = {}; return buf.result; } void test8283() { auto a = get8283(); } /***************************************************/ // 8395 struct S8395 { int v; this(T : long)(T x) { v = x * 2; } } void test8395() { S8395 ms = 6; assert(ms.v == 12); const S8395 cs = 7; assert(cs.v == 14); } /***************************************************/ enum E160 : ubyte { jan = 1 } struct D160 { short _year = 1; E160 _month = E160.jan; ubyte _day = 1; this(int year, int month, int day) pure { _year = cast(short)year; _month = cast(E160)month; _day = cast(ubyte)day; } } struct T160 { ubyte _hour; ubyte _minute; ubyte _second; this(int hour, int minute, int second = 0) pure { _hour = cast(ubyte)hour; _minute = cast(ubyte)minute; _second = cast(ubyte)second; } } struct DT160 { D160 _date; T160 _tod; this(int year, int month, int day, int hour = 0, int minute = 0, int second = 0) pure { _date = D160(year, month, day); _tod = T160(hour, minute, second); } } void foo160(DT160 dateTime) { printf("test7 year %d, day %d\n", dateTime._date._year, dateTime._date._day); assert(dateTime._date._year == 1999); assert(dateTime._date._day == 6); } void test160() { auto dateTime = DT160(1999, 7, 6, 12, 30, 33); printf("test5 year %d, day %d\n", dateTime._date._year, dateTime._date._day); assert(dateTime._date._year == 1999); assert(dateTime._date._day == 6); foo160(DT160(1999, 7, 6, 12, 30, 33)); } /***************************************************/ // 8437 class Cgi8437 { struct PostParserState { UploadedFile piece; } static struct UploadedFile { string contentFilename; } } /***************************************************/ int main() { test1(); test2(); test3(); test4(); test5(); test6(); test7(); test8(); test9(); test10(); test11(); test12(); test13(); test14(); test15(); test16(); test17(); test18(); test19(); test20(); test21(); test22(); test23(); test24(); test25(); test26(); test27(); test28(); test29(); test30(); test31(); test32(); test33(); test34(); test35(); test36(); test37(); test38(); test39(); test40(); test41(); test42(); test43(); test44(); test45(); test46(); test47(); test48(); test49(); test796(); test50(); test51(); test52(); test53(); test54(); test55(); test56(); test57(); test58(); test60(); test61(); test62(); test63(); test64(); test65(); test66(); test67(); test68(); test69(); test70(); test5785(); test72(); test73(); test74(); test75(); test76(); test77(); test78(); test79(); test80(); test81(); test82(); test83(); test3559(); test84(); test85(); test2006(); test8442(); test86(); test87(); test5554(); test88(); test7545(); test89(); test90(); test91(); test92(); test4536(); test93(); test94(); test95(); test5403(); test96(); test97(); test98(); test99(); test100(); test101(); test103(); test104(); test105(); test3927(); test107(); test109(); test111(); test113(); test115(); test116(); test117(); test3822(); test118(); test5081(); test120(); test122(); test123(); test124(); test125(); test3133(); test6763(); test127(); test128(); test1891(); test129(); test130(); test1064(); test131(); test132(); test133(); test134(); test135(); test136(); test137(); test138(); test1962(); test139(); test140(); test141(); test6317(); test142(); test143(); test144(); test145(); test146(); test147(); test6685(); test148(); test149(); test2540(); test150(); test151(); test152(); test153(); test154(); test155(); test156(); test4258(); test4539(); test4963(); test4031(); test5437(); test6230(); test6264(); test6284(); test6295(); test6293(); test5046(); test1471(); test6335(); test6228(); test2774(); test6220(); test5799(); test157(); test6473(); test6630(); test6690(); test2953(); test2997(); test4647(); test5696(); test6084(); test6488(); test6836(); test6837(); test6927(); test6733(); test6813(); test6859(); test6910(); test6902(); test6330(); test6868(); test2856(); test3091(); test6056(); test7073(); test7150(); test7160(); test7168(); test7170(); test7196(); test7285(); test7321(); test3282(); test7534(); test7534cov(); test7618(); test7621(); test7682(); test7735(); test7823(); test7871(); test7906(); test7907(); test8004(); test8064(); test8105(); test159(); test8283(); test8395(); test160(); printf("Success\n"); return 0; }
D
// Written in the D programming language. /** $(SCRIPT inhibitQuickIndex = 1;) This module defines facilities for efficient checking of integral operations against overflow, casting with loss of precision, unexpected change of sign, etc. The checking (and possibly correction) can be done at operation level, for example $(LREF opChecked)$(D !"+"(x, y, overflow)) adds two integrals `x` and `y` and sets `overflow` to `true` if an overflow occurred. The flag `overflow` (a `bool` passed by reference) is not touched if the operation succeeded, so the same flag can be reused for a sequence of operations and tested at the end. Issuing individual checked operations is flexible and efficient but often tedious. The $(LREF Checked) facility offers encapsulated integral wrappers that do all checking internally and have configurable behavior upon erroneous results. For example, `Checked!int` is a type that behaves like `int` but aborts execution immediately whenever involved in an operation that produces the arithmetically wrong result. The accompanying convenience function $(LREF checked) uses type deduction to convert a value `x` of integral type `T` to `Checked!T` by means of `checked(x)`. For example: --- void main() { import std.experimental.checkedint, std.stdio; writeln((checked(5) + 7).get); // 12 writeln((checked(10) * 1000 * 1000 * 1000).get); // Overflow } --- Similarly, $(D checked(-1) > uint(0)) aborts execution (even though the built-in comparison $(D int(-1) > uint(0)) is surprisingly true due to language's conversion rules modeled after C). Thus, `Checked!int` is a virtually drop-in replacement for `int` useable in debug builds, to be replaced by `int` in release mode if efficiency demands it. `Checked` has customizable behavior with the help of a second type parameter, `Hook`. Depending on what methods `Hook` defines, core operations on the underlying integral may be verified for overflow or completely redefined. If `Hook` defines no method at all and carries no state, there is no change in behavior, i.e. $(D Checked!(int, void)) is a wrapper around `int` that adds no customization at all. This module provides a few predefined hooks (below) that add useful behavior to `Checked`: $(BOOKTABLE , $(TR $(TD $(LREF Abort)) $(TD fails every incorrect operation with a message to $(REF stderr, std, stdio) followed by a call to `assert(0)`. It is the default second parameter, i.e. `Checked!short` is the same as $(D Checked!(short, Abort)). )) $(TR $(TD $(LREF Throw)) $(TD fails every incorrect operation by throwing an exception. )) $(TR $(TD $(LREF Warn)) $(TD prints incorrect operations to $(REF stderr, std, stdio) but otherwise preserves the built-in behavior. )) $(TR $(TD $(LREF ProperCompare)) $(TD fixes the comparison operators `==`, `!=`, `<`, `<=`, `>`, and `>=` to return correct results in all circumstances, at a slight cost in efficiency. For example, $(D Checked!(uint, ProperCompare)(1) > -1) is `true`, which is not the case for the built-in comparison. Also, comparing numbers for equality with floating-point numbers only passes if the integral can be converted to the floating-point number precisely, so as to preserve transitivity of equality. )) $(TR $(TD $(LREF WithNaN)) $(TD reserves a special "Not a Number" (NaN) value akin to the homonym value reserved for floating-point values. Once a $(D Checked!(X, WithNaN)) gets this special value, it preserves and propagates it until reassigned. $(LREF isNaN) can be used to query whether the object is not a number. )) $(TR $(TD $(LREF Saturate)) $(TD implements saturating arithmetic, i.e. $(D Checked!(int, Saturate)) "stops" at `int.max` for all operations that would cause an `int` to overflow toward infinity, and at `int.min` for all operations that would correspondingly overflow toward negative infinity. )) ) These policies may be used alone, e.g. $(D Checked!(uint, WithNaN)) defines a `uint`-like type that reaches a stable NaN state for all erroneous operations. They may also be "stacked" on top of each other, owing to the property that a checked integral emulates an actual integral, which means another checked integral can be built on top of it. Some combinations of interest include: $(BOOKTABLE , $(TR $(TD $(D Checked!(Checked!int, ProperCompare)))) $(TR $(TD defines an `int` with fixed comparison operators that will fail with `assert(0)` upon overflow. (Recall that `Abort` is the default policy.) The order in which policies are combined is important because the outermost policy (`ProperCompare` in this case) has the first crack at intercepting an operator. The converse combination $(D Checked!(Checked!(int, ProperCompare))) is meaningless because `Abort` will intercept comparison and will fail without giving `ProperCompare` a chance to intervene. )) $(TR $(TD)) $(TR $(TDNW $(D Checked!(Checked!(int, ProperCompare), WithNaN)))) $(TR $(TD defines an `int`-like type that supports a NaN value. For values that are not NaN, comparison works properly. Again the composition order is important; $(D Checked!(Checked!(int, WithNaN), ProperCompare)) does not have good semantics because `ProperCompare` intercepts comparisons before the numbers involved are tested for NaN. )) ) The hook's members are looked up statically in a Design by Introspection manner and are all optional. The table below illustrates the members that a hook type may define and their influence over the behavior of the `Checked` type using it. In the table, `hook` is an alias for `Hook` if the type `Hook` does not introduce any state, or an object of type `Hook` otherwise. $(TABLE , $(TR $(TH `Hook` member) $(TH Semantics in $(D Checked!(T, Hook))) ) $(TR $(TD `defaultValue`) $(TD If defined, `Hook.defaultValue!T` is used as the default initializer of the payload.) ) $(TR $(TD `min`) $(TD If defined, `Hook.min!T` is used as the minimum value of the payload.) ) $(TR $(TD `max`) $(TD If defined, `Hook.max!T` is used as the maximum value of the payload.) ) $(TR $(TD `hookOpCast`) $(TD If defined, `hook.hookOpCast!U(get)` is forwarded to unconditionally when the payload is to be cast to type `U`.) ) $(TR $(TD `onBadCast`) $(TD If defined and `hookOpCast` is $(I not) defined, `onBadCast!U(get)` is forwarded to when the payload is to be cast to type `U` and the cast would lose information or force a change of sign.) ) $(TR $(TD `hookOpEquals`) $(TD If defined, $(D hook.hookOpEquals(get, rhs)) is forwarded to unconditionally when the payload is compared for equality against value `rhs` of integral, floating point, or Boolean type.) ) $(TR $(TD `hookOpCmp`) $(TD If defined, $(D hook.hookOpCmp(get, rhs)) is forwarded to unconditionally when the payload is compared for ordering against value `rhs` of integral, floating point, or Boolean type.) ) $(TR $(TD `hookOpUnary`) $(TD If defined, `hook.hookOpUnary!op(get)` (where `op` is the operator symbol) is forwarded to for unary operators `-` and `~`. In addition, for unary operators `++` and `--`, `hook.hookOpUnary!op(payload)` is called, where `payload` is a reference to the value wrapped by `Checked` so the hook can change it.) ) $(TR $(TD `hookOpBinary`) $(TD If defined, $(D hook.hookOpBinary!op(get, rhs)) (where `op` is the operator symbol and `rhs` is the right-hand side operand) is forwarded to unconditionally for binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>`.) ) $(TR $(TD `hookOpBinaryRight`) $(TD If defined, $(D hook.hookOpBinaryRight!op(lhs, get)) (where `op` is the operator symbol and `lhs` is the left-hand side operand) is forwarded to unconditionally for binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>`.) ) $(TR $(TD `onOverflow`) $(TD If defined, `hook.onOverflow!op(get)` is forwarded to for unary operators that overflow but only if `hookOpUnary` is not defined. Unary `~` does not overflow; unary `-` overflows only when the most negative value of a signed type is negated, and the result of the hook call is returned. When the increment or decrement operators overflow, the payload is assigned the result of `hook.onOverflow!op(get)`. When a binary operator overflows, the result of $(D hook.onOverflow!op(get, rhs)) is returned, but only if `Hook` does not define `hookOpBinary`.) ) $(TR $(TD `hookOpOpAssign`) $(TD If defined, $(D hook.hookOpOpAssign!op(payload, rhs)) (where `op` is the operator symbol and `rhs` is the right-hand side operand) is forwarded to unconditionally for binary operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=`.) ) $(TR $(TD `onLowerBound`) $(TD If defined, $(D hook.onLowerBound(value, bound)) (where `value` is the value being assigned) is forwarded to when the result of binary operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=` is smaller than the smallest value representable by `T`.) ) $(TR $(TD `onUpperBound`) $(TD If defined, $(D hook.onUpperBound(value, bound)) (where `value` is the value being assigned) is forwarded to when the result of binary operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=` is larger than the largest value representable by `T`.) ) $(TR $(TD `hookToHash`) $(TD If defined, $(D hook.hookToHash(payload)) (where `payload` is a reference to the value wrapped by Checked) is forwarded to when `toHash` is called on a Checked type. Custom hashing can be implemented in a `Hook`, otherwise the built-in hashing is used.) ) ) Source: $(PHOBOSSRC std/experimental/checkedint.d) */ module std.experimental.checkedint; import std.traits : isFloatingPoint, isIntegral, isNumeric, isUnsigned, Unqual; /// @system unittest { int[] concatAndAdd(int[] a, int[] b, int offset) { // Aborts on overflow on size computation auto r = new int[(checked(a.length) + b.length).get]; // Aborts on overflow on element computation foreach (i; 0 .. a.length) r[i] = (a[i] + checked(offset)).get; foreach (i; 0 .. b.length) r[i + a.length] = (b[i] + checked(offset)).get; return r; } assert(concatAndAdd([1, 2, 3], [4, 5], -1) == [0, 1, 2, 3, 4]); } /// `Saturate` stops at an overflow @safe unittest { auto x = (cast(byte) 127).checked!Saturate; assert(x == 127); x++; assert(x == 127); } /// `WithNaN` has a special "Not a Number" (NaN) value akin to the homonym value reserved for floating-point values @safe unittest { auto x = 100.checked!WithNaN; assert(x == 100); x /= 0; assert(x.isNaN); } /// `ProperCompare` fixes the comparison operators ==, !=, <, <=, >, and >= to return correct results @safe unittest { uint x = 1; auto y = x.checked!ProperCompare; assert(x < -1); // built-in comparison assert(y > -1); // ProperCompare } /// `Throw` fails every incorrect operation by throwing an exception @safe unittest { import std.exception : assertThrown; auto x = -1.checked!Throw; assertThrown(x / 0); assertThrown(x + int.min); assertThrown(x == uint.max); } /** Checked integral type wraps an integral `T` and customizes its behavior with the help of a `Hook` type. The type wrapped must be one of the predefined integrals (unqualified), or another instance of `Checked`. */ struct Checked(T, Hook = Abort) if (isIntegral!T || is(T == Checked!(U, H), U, H)) { import std.algorithm.comparison : among; import std.experimental.allocator.common : stateSize; import std.traits : hasMember; /** The type of the integral subject to checking. */ alias Representation = T; // state { static if (hasMember!(Hook, "defaultValue")) private T payload = Hook.defaultValue!T; else private T payload; /** `hook` is a member variable if it has state, or an alias for `Hook` otherwise. */ static if (stateSize!Hook > 0) Hook hook; else alias hook = Hook; // } state // get /** Returns a copy of the underlying value. */ auto get() inout { return payload; } /// @safe unittest { auto x = checked(ubyte(42)); static assert(is(typeof(x.get()) == ubyte)); assert(x.get == 42); const y = checked(ubyte(42)); static assert(is(typeof(y.get()) == const ubyte)); assert(y.get == 42); } /** Defines the minimum and maximum. These values are hookable by defining `Hook.min` and/or `Hook.max`. */ static if (hasMember!(Hook, "min")) { enum Checked!(T, Hook) min = Checked!(T, Hook)(Hook.min!T); /// @system unittest { assert(Checked!short.min == -32768); assert(Checked!(short, WithNaN).min == -32767); assert(Checked!(uint, WithNaN).max == uint.max - 1); } } else enum Checked!(T, Hook) min = Checked(T.min); /// ditto static if (hasMember!(Hook, "max")) enum Checked!(T, Hook) max = Checked(Hook.max!T); else enum Checked!(T, Hook) max = Checked(T.max); /** Constructor taking a value properly convertible to the underlying type. `U` may be either an integral that can be converted to `T` without a loss, or another `Checked` instance whose representation may be in turn converted to `T` without a loss. */ this(U)(U rhs) if (valueConvertible!(U, T) || !isIntegral!T && is(typeof(T(rhs))) || is(U == Checked!(V, W), V, W) && is(typeof(Checked!(T, Hook)(rhs.get)))) { static if (isIntegral!U) payload = rhs; else payload = rhs.payload; } /// @system unittest { auto a = checked(42L); assert(a == 42); auto b = Checked!long(4242); // convert 4242 to long assert(b == 4242); } /** Assignment operator. Has the same constraints as the constructor. */ void opAssign(U)(U rhs) if (is(typeof(Checked!(T, Hook)(rhs)))) { static if (isIntegral!U) payload = rhs; else payload = rhs.payload; } /// @system unittest { Checked!long a; a = 42L; assert(a == 42); a = 4242; assert(a == 4242); } // opCast /** Casting operator to integral, `bool`, or floating point type. If `Hook` defines `hookOpCast`, the call immediately returns `hook.hookOpCast!U(get)`. Otherwise, casting to `bool` yields $(D get != 0) and casting to another integral that can represent all values of `T` returns `get` promoted to `U`. If a cast to a floating-point type is requested and `Hook` defines `onBadCast`, the cast is verified by ensuring $(D get == cast(T) U(get)). If that is not `true`, `hook.onBadCast!U(get)` is returned. If a cast to an integral type is requested and `Hook` defines `onBadCast`, the cast is verified by ensuring `get` and $(D cast(U) get) are the same arithmetic number. (Note that `int(-1)` and `uint(1)` are different values arithmetically although they have the same bitwise representation and compare equal by language rules.) If the numbers are not arithmetically equal, `hook.onBadCast!U(get)` is returned. */ U opCast(U, this _)() if (isIntegral!U || isFloatingPoint!U || is(U == bool)) { static if (hasMember!(Hook, "hookOpCast")) { return hook.hookOpCast!U(payload); } else static if (is(U == bool)) { return payload != 0; } else static if (valueConvertible!(T, U)) { return payload; } // may lose bits or precision else static if (!hasMember!(Hook, "onBadCast")) { return cast(U) payload; } else { if (isUnsigned!T || !isUnsigned!U || T.sizeof > U.sizeof || payload >= 0) { auto result = cast(U) payload; // If signedness is different, we need additional checks if (result == payload && (!isUnsigned!T || isUnsigned!U || result >= 0)) return result; } return hook.onBadCast!U(payload); } } /// @system unittest { assert(cast(uint) checked(42) == 42); assert(cast(uint) checked!WithNaN(-42) == uint.max); } // opEquals /** Compares `this` against `rhs` for equality. If `Hook` defines `hookOpEquals`, the function forwards to $(D hook.hookOpEquals(get, rhs)). Otherwise, the result of the built-in operation $(D get == rhs) is returned. If `U` is also an instance of `Checked`, both hooks (left- and right-hand side) are introspected for the method `hookOpEquals`. If both define it, priority is given to the left-hand side. */ bool opEquals(U, this _)(U rhs) if (isIntegral!U || isFloatingPoint!U || is(U == bool) || is(U == Checked!(V, W), V, W) && is(typeof(this == rhs.payload))) { static if (is(U == Checked!(V, W), V, W)) { alias R = typeof(payload + rhs.payload); static if (is(Hook == W)) { // Use the lhs hook if there return this == rhs.payload; } else static if (valueConvertible!(T, R) && valueConvertible!(V, R)) { return payload == rhs.payload; } else static if (hasMember!(Hook, "hookOpEquals")) { return hook.hookOpEquals(payload, rhs.payload); } else static if (hasMember!(W, "hookOpEquals")) { return rhs.hook.hookOpEquals(rhs.payload, payload); } else { return payload == rhs.payload; } } else static if (hasMember!(Hook, "hookOpEquals")) return hook.hookOpEquals(payload, rhs); else static if (isIntegral!U || isFloatingPoint!U || is(U == bool)) return payload == rhs; } /// static if (is(T == int) && is(Hook == void)) @safe unittest { static struct MyHook { static bool thereWereErrors; static bool hookOpEquals(L, R)(L lhs, R rhs) { if (lhs != rhs) return false; static if (isUnsigned!L && !isUnsigned!R) { if (lhs > 0 && rhs < 0) thereWereErrors = true; } else static if (isUnsigned!R && !isUnsigned!L) if (lhs < 0 && rhs > 0) thereWereErrors = true; // Preserve built-in behavior. return true; } } auto a = checked!MyHook(-42); assert(a == uint(-42)); assert(MyHook.thereWereErrors); MyHook.thereWereErrors = false; assert(checked!MyHook(uint(-42)) == -42); assert(MyHook.thereWereErrors); static struct MyHook2 { static bool hookOpEquals(L, R)(L lhs, R rhs) { return lhs == rhs; } } MyHook.thereWereErrors = false; assert(checked!MyHook2(uint(-42)) == a); // Hook on left hand side takes precedence, so no errors assert(!MyHook.thereWereErrors); } // toHash /** Generates a hash for `this`. If `Hook` defines `hookToHash`, the call immediately returns `hook.hookToHash(payload)`. If `Hook` does not implement `hookToHash`, but it has state, a hash will be generated for the `Hook` using the built-in function and it will be xored with the hash of the `payload`. */ size_t toHash() const nothrow @safe { static if (hasMember!(Hook, "hookToHash")) { return hook.hookToHash(payload); } else static if (stateSize!Hook > 0) { static if (hasMember!(typeof(payload), "toHash")) { return payload.toHash() ^ hashOf(hook); } else { return hashOf(payload) ^ hashOf(hook); } } else static if (hasMember!(typeof(payload), "toHash")) { return payload.toHash(); } else { return .hashOf(payload); } } // opCmp /** Compares `this` against `rhs` for ordering. If `Hook` defines `hookOpCmp`, the function forwards to $(D hook.hookOpCmp(get, rhs)). Otherwise, the result of the built-in comparison operation is returned. If `U` is also an instance of `Checked`, both hooks (left- and right-hand side) are introspected for the method `hookOpCmp`. If both define it, priority is given to the left-hand side. */ auto opCmp(U, this _)(const U rhs) //const pure @safe nothrow @nogc if (isIntegral!U || isFloatingPoint!U || is(U == bool)) { static if (hasMember!(Hook, "hookOpCmp")) { return hook.hookOpCmp(payload, rhs); } else static if (valueConvertible!(T, U) || valueConvertible!(U, T)) { return payload < rhs ? -1 : payload > rhs; } else static if (isFloatingPoint!U) { U lhs = payload; return lhs < rhs ? U(-1.0) : lhs > rhs ? U(1.0) : lhs == rhs ? U(0.0) : U.init; } else { return payload < rhs ? -1 : payload > rhs; } } /// ditto auto opCmp(U, Hook1, this _)(Checked!(U, Hook1) rhs) { alias R = typeof(payload + rhs.payload); static if (valueConvertible!(T, R) && valueConvertible!(U, R)) { return payload < rhs.payload ? -1 : payload > rhs.payload; } else static if (is(Hook == Hook1)) { // Use the lhs hook return this.opCmp(rhs.payload); } else static if (hasMember!(Hook, "hookOpCmp")) { return hook.hookOpCmp(get, rhs.get); } else static if (hasMember!(Hook1, "hookOpCmp")) { return -rhs.hook.hookOpCmp(rhs.payload, get); } else { return payload < rhs.payload ? -1 : payload > rhs.payload; } } /// static if (is(T == int) && is(Hook == void)) @safe unittest { static struct MyHook { static bool thereWereErrors; static int hookOpCmp(L, R)(L lhs, R rhs) { static if (isUnsigned!L && !isUnsigned!R) { if (rhs < 0 && rhs >= lhs) thereWereErrors = true; } else static if (isUnsigned!R && !isUnsigned!L) { if (lhs < 0 && lhs >= rhs) thereWereErrors = true; } // Preserve built-in behavior. return lhs < rhs ? -1 : lhs > rhs; } } auto a = checked!MyHook(-42); assert(a > uint(42)); assert(MyHook.thereWereErrors); static struct MyHook2 { static int hookOpCmp(L, R)(L lhs, R rhs) { // Default behavior return lhs < rhs ? -1 : lhs > rhs; } } MyHook.thereWereErrors = false; assert(Checked!(uint, MyHook2)(uint(-42)) <= a); //assert(Checked!(uint, MyHook2)(uint(-42)) >= a); // Hook on left hand side takes precedence, so no errors assert(!MyHook.thereWereErrors); assert(a <= Checked!(uint, MyHook2)(uint(-42))); assert(MyHook.thereWereErrors); } // For coverage static if (is(T == int) && is(Hook == void)) @system unittest { assert(checked(42) <= checked!void(42)); assert(checked!void(42) <= checked(42u)); assert(checked!void(42) <= checked!(void*)(42u)); } // opUnary /** Defines unary operators `+`, `-`, `~`, `++`, and `--`. Unary `+` is not overridable and always has built-in behavior (returns `this`). For the others, if `Hook` defines `hookOpUnary`, `opUnary` forwards to $(D Checked!(typeof(hook.hookOpUnary!op(get)), Hook)(hook.hookOpUnary!op(get))). If `Hook` does not define `hookOpUnary` but defines `onOverflow`, `opUnary` forwards to `hook.onOverflow!op(get)` in case an overflow occurs. For `++` and `--`, the payload is assigned from the result of the call to `onOverflow`. Note that unary `-` is considered to overflow if `T` is a signed integral of 32 or 64 bits and is equal to the most negative value. This is because that value has no positive negation. */ auto opUnary(string op, this _)() if (op == "+" || op == "-" || op == "~") { static if (op == "+") return Checked(this); // "+" is not hookable else static if (hasMember!(Hook, "hookOpUnary")) { auto r = hook.hookOpUnary!op(payload); return Checked!(typeof(r), Hook)(r); } else static if (op == "-" && isIntegral!T && T.sizeof >= 4 && !isUnsigned!T && hasMember!(Hook, "onOverflow")) { static assert(is(typeof(-payload) == typeof(payload))); bool overflow; import core.checkedint : negs; auto r = negs(payload, overflow); if (overflow) r = hook.onOverflow!op(payload); return Checked(r); } else return Checked(mixin(op ~ "payload")); } /// ditto ref Checked opUnary(string op)() return if (op == "++" || op == "--") { static if (hasMember!(Hook, "hookOpUnary")) hook.hookOpUnary!op(payload); else static if (hasMember!(Hook, "onOverflow")) { static if (op == "++") { if (payload == max.payload) payload = hook.onOverflow!"++"(payload); else ++payload; } else { if (payload == min.payload) payload = hook.onOverflow!"--"(payload); else --payload; } } else mixin(op ~ "payload;"); return this; } /// static if (is(T == int) && is(Hook == void)) @safe unittest { static struct MyHook { static bool thereWereErrors; static L hookOpUnary(string x, L)(L lhs) { if (x == "-" && lhs == -lhs) thereWereErrors = true; return -lhs; } } auto a = checked!MyHook(long.min); assert(a == -a); assert(MyHook.thereWereErrors); auto b = checked!void(42); assert(++b == 43); } // opBinary /** Defines binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>`. If `Hook` defines `hookOpBinary`, `opBinary` forwards to $(D Checked!(typeof(hook.hookOpBinary!op(get, rhs)), Hook)(hook.hookOpBinary!op(get, rhs))). If `Hook` does not define `hookOpBinary` but defines `onOverflow`, `opBinary` forwards to `hook.onOverflow!op(get, rhs)` in case an overflow occurs. If two `Checked` instances are involved in a binary operation and both define `hookOpBinary`, the left-hand side hook has priority. If both define `onOverflow`, a compile-time error occurs. */ auto opBinary(string op, Rhs)(const Rhs rhs) if (isIntegral!Rhs || isFloatingPoint!Rhs || is(Rhs == bool)) { return opBinaryImpl!(op, Rhs, typeof(this))(rhs); } /// ditto auto opBinary(string op, Rhs)(const Rhs rhs) const if (isIntegral!Rhs || isFloatingPoint!Rhs || is(Rhs == bool)) { return opBinaryImpl!(op, Rhs, typeof(this))(rhs); } private auto opBinaryImpl(string op, Rhs, this _)(const Rhs rhs) { alias R = typeof(mixin("payload" ~ op ~ "rhs")); static assert(is(typeof(mixin("payload" ~ op ~ "rhs")) == R)); static if (isIntegral!R) alias Result = Checked!(R, Hook); else alias Result = R; static if (hasMember!(Hook, "hookOpBinary")) { auto r = hook.hookOpBinary!op(payload, rhs); return Checked!(typeof(r), Hook)(r); } else static if (is(Rhs == bool)) { return mixin("this" ~ op ~ "ubyte(rhs)"); } else static if (isFloatingPoint!Rhs) { return mixin("payload" ~ op ~ "rhs"); } else static if (hasMember!(Hook, "onOverflow")) { bool overflow; auto r = opChecked!op(payload, rhs, overflow); if (overflow) r = hook.onOverflow!op(payload, rhs); return Result(r); } else { // Default is built-in behavior return Result(mixin("payload" ~ op ~ "rhs")); } } /// ditto auto opBinary(string op, U, Hook1)(Checked!(U, Hook1) rhs) { return opBinaryImpl2!(op, U, Hook1, typeof(this))(rhs); } /// ditto auto opBinary(string op, U, Hook1)(Checked!(U, Hook1) rhs) const { return opBinaryImpl2!(op, U, Hook1, typeof(this))(rhs); } private auto opBinaryImpl2(string op, U, Hook1, this _)(Checked!(U, Hook1) rhs) { alias R = typeof(get + rhs.payload); static if (valueConvertible!(T, R) && valueConvertible!(U, R) || is(Hook == Hook1)) { // Delegate to lhs return mixin("this" ~ op ~ "rhs.payload"); } else static if (hasMember!(Hook, "hookOpBinary")) { return hook.hookOpBinary!op(payload, rhs); } else static if (hasMember!(Hook1, "hookOpBinary")) { // Delegate to rhs return mixin("this.payload" ~ op ~ "rhs"); } else static if (hasMember!(Hook, "onOverflow") && !hasMember!(Hook1, "onOverflow")) { // Delegate to lhs return mixin("this" ~ op ~ "rhs.payload"); } else static if (hasMember!(Hook1, "onOverflow") && !hasMember!(Hook, "onOverflow")) { // Delegate to rhs return mixin("this.payload" ~ op ~ "rhs"); } else { static assert(0, "Conflict between lhs and rhs hooks," ~ " use .get on one side to disambiguate."); } } static if (is(T == int) && is(Hook == void)) @system unittest { const a = checked(42); assert(a + 1 == 43); assert(a + checked(uint(42)) == 84); assert(checked(42) + checked!void(42u) == 84); assert(checked!void(42) + checked(42u) == 84); static struct MyHook { static uint tally; static auto hookOpBinary(string x, L, R)(L lhs, R rhs) { ++tally; return mixin("lhs" ~ x ~ "rhs"); } } assert(checked!MyHook(42) + checked(42u) == 84); assert(checked!void(42) + checked!MyHook(42u) == 84); assert(MyHook.tally == 2); } // opBinaryRight /** Defines binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>` for the case when a built-in numeric or Boolean type is on the left-hand side, and a `Checked` instance is on the right-hand side. */ auto opBinaryRight(string op, Lhs)(const Lhs lhs) if (isIntegral!Lhs || isFloatingPoint!Lhs || is(Lhs == bool)) { return opBinaryRightImpl!(op, Lhs, typeof(this))(lhs); } /// ditto auto opBinaryRight(string op, Lhs)(const Lhs lhs) const if (isIntegral!Lhs || isFloatingPoint!Lhs || is(Lhs == bool)) { return opBinaryRightImpl!(op, Lhs, typeof(this))(lhs); } private auto opBinaryRightImpl(string op, Lhs, this _)(const Lhs lhs) { static if (hasMember!(Hook, "hookOpBinaryRight")) { auto r = hook.hookOpBinaryRight!op(lhs, payload); return Checked!(typeof(r), Hook)(r); } else static if (hasMember!(Hook, "hookOpBinary")) { auto r = hook.hookOpBinary!op(lhs, payload); return Checked!(typeof(r), Hook)(r); } else static if (is(Lhs == bool)) { return mixin("ubyte(lhs)" ~ op ~ "this"); } else static if (isFloatingPoint!Lhs) { return mixin("lhs" ~ op ~ "payload"); } else static if (hasMember!(Hook, "onOverflow")) { bool overflow; auto r = opChecked!op(lhs, T(payload), overflow); if (overflow) r = hook.onOverflow!op(42); return Checked!(typeof(r), Hook)(r); } else { // Default is built-in behavior auto r = mixin("lhs" ~ op ~ "T(payload)"); return Checked!(typeof(r), Hook)(r); } } static if (is(T == int) && is(Hook == void)) @system unittest { assert(1 + checked(1) == 2); static uint tally; static struct MyHook { static auto hookOpBinaryRight(string x, L, R)(L lhs, R rhs) { ++tally; return mixin("lhs" ~ x ~ "rhs"); } } assert(1 + checked!MyHook(1) == 2); assert(tally == 1); immutable x1 = checked(1); assert(1 + x1 == 2); immutable x2 = checked!MyHook(1); assert(1 + x2 == 2); assert(tally == 2); } // opOpAssign /** Defines operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=`. If `Hook` defines `hookOpOpAssign`, `opOpAssign` forwards to `hook.hookOpOpAssign!op(payload, rhs)`, where `payload` is a reference to the internally held data so the hook can change it. Otherwise, the operator first evaluates $(D auto result = opBinary!op(payload, rhs).payload), which is subject to the hooks in `opBinary`. Then, if `result` is less than $(D Checked!(T, Hook).min) and if `Hook` defines `onLowerBound`, the payload is assigned from $(D hook.onLowerBound(result, min)). If `result` is greater than $(D Checked!(T, Hook).max) and if `Hook` defines `onUpperBound`, the payload is assigned from $(D hook.onUpperBound(result, min)). If the right-hand side is also a Checked but with a different hook or underlying type, the hook and underlying type of this Checked takes precedence. In all other cases, the built-in behavior is carried out. Params: op = The operator involved (without the `"="`, e.g. `"+"` for `"+="` etc) rhs = The right-hand side of the operator (left-hand side is `this`) Returns: A reference to `this`. */ ref Checked opOpAssign(string op, Rhs)(const Rhs rhs) return if (isIntegral!Rhs || isFloatingPoint!Rhs || is(Rhs == bool)) { static assert(is(typeof(mixin("payload" ~ op ~ "=rhs")) == T)); static if (hasMember!(Hook, "hookOpOpAssign")) { hook.hookOpOpAssign!op(payload, rhs); } else { alias R = typeof(get + rhs); auto r = opBinary!op(rhs).get; import std.conv : unsigned; static if (ProperCompare.hookOpCmp(R.min, min.get) < 0 && hasMember!(Hook, "onLowerBound")) { if (ProperCompare.hookOpCmp(r, min.get) < 0) { // Example: Checked!uint(1) += int(-3) payload = hook.onLowerBound(r, min.get); return this; } } static if (ProperCompare.hookOpCmp(max.get, R.max) < 0 && hasMember!(Hook, "onUpperBound")) { if (ProperCompare.hookOpCmp(r, max.get) > 0) { // Example: Checked!uint(1) += long(uint.max) payload = hook.onUpperBound(r, max.get); return this; } } payload = cast(T) r; } return this; } /// ditto ref Checked opOpAssign(string op, Rhs)(const Rhs rhs) return if (is(Rhs == Checked!(RhsT, RhsHook), RhsT, RhsHook)) { return opOpAssign!(op, typeof(rhs.payload))(rhs.payload); } /// static if (is(T == int) && is(Hook == void)) @safe unittest { static struct MyHook { static bool thereWereErrors; static T onLowerBound(Rhs, T)(Rhs rhs, T bound) { thereWereErrors = true; return bound; } static T onUpperBound(Rhs, T)(Rhs rhs, T bound) { thereWereErrors = true; return bound; } } auto x = checked!MyHook(byte.min); x -= 1; assert(MyHook.thereWereErrors); MyHook.thereWereErrors = false; x = byte.max; x += 1; assert(MyHook.thereWereErrors); } } /** Convenience function that turns an integral into the corresponding `Checked` instance by using template argument deduction. The hook type may be specified (by default `Abort`). */ Checked!(T, Hook) checked(Hook = Abort, T)(const T value) if (is(typeof(Checked!(T, Hook)(value)))) { return Checked!(T, Hook)(value); } /// @system unittest { static assert(is(typeof(checked(42)) == Checked!int)); assert(checked(42) == Checked!int(42)); static assert(is(typeof(checked!WithNaN(42)) == Checked!(int, WithNaN))); assert(checked!WithNaN(42) == Checked!(int, WithNaN)(42)); } // get @safe unittest { void test(T)() { assert(Checked!(T, void)(ubyte(22)).get == 22); } test!ubyte; test!(const ubyte); test!(immutable ubyte); } // Abort /** Force all integral errors to fail by printing an error message to `stderr` and then abort the program. `Abort` is the default second argument for `Checked`. */ struct Abort { static: /** Called automatically upon a bad cast (one that loses precision or attempts to convert a negative value to an unsigned type). The source type is `Src` and the destination type is `Dst`. Params: src = The source of the cast Returns: Nominally the result is the desired value of the cast operation, which will be forwarded as the result of the cast. For `Abort`, the function never returns because it aborts the program. */ Dst onBadCast(Dst, Src)(Src src) { Warn.onBadCast!Dst(src); assert(0); } /** Called automatically upon a bounds error. Params: rhs = The right-hand side value in the assignment, after the operator has been evaluated bound = The value of the bound being violated Returns: Nominally the result is the desired value of the operator, which will be forwarded as result. For `Abort`, the function never returns because it aborts the program. */ T onLowerBound(Rhs, T)(Rhs rhs, T bound) { Warn.onLowerBound(rhs, bound); assert(0); } /// ditto T onUpperBound(Rhs, T)(Rhs rhs, T bound) { Warn.onUpperBound(rhs, bound); assert(0); } /** Called automatically upon a comparison for equality. In case of a erroneous comparison (one that would make a signed negative value appear equal to an unsigned positive value), this hook issues `assert(0)` which terminates the application. Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: Upon a correct comparison, returns the result of the comparison. Otherwise, the function terminates the application so it never returns. */ static bool hookOpEquals(Lhs, Rhs)(Lhs lhs, Rhs rhs) { bool error; auto result = opChecked!"=="(lhs, rhs, error); if (error) { Warn.hookOpEquals(lhs, rhs); assert(0); } return result; } /** Called automatically upon a comparison for ordering using one of the operators `<`, `<=`, `>`, or `>=`. In case the comparison is erroneous (i.e. it would make a signed negative value appear greater than or equal to an unsigned positive value), then application is terminated with `assert(0)`. Otherwise, the three-state result is returned (positive if $(D lhs > rhs), negative if $(D lhs < rhs), `0` otherwise). Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: For correct comparisons, returns a positive integer if $(D lhs > rhs), a negative integer if $(D lhs < rhs), `0` if the two are equal. Upon a mistaken comparison such as $(D int(-1) < uint(0)), the function never returns because it aborts the program. */ int hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { bool error; auto result = opChecked!"cmp"(lhs, rhs, error); if (error) { Warn.hookOpCmp(lhs, rhs); assert(0); } return result; } /** Called automatically upon an overflow during a unary or binary operation. Params: x = The operator, e.g. `-` lhs = The left-hand side (or sole) argument rhs = The right-hand side type involved in the operator Returns: Nominally the result is the desired value of the operator, which will be forwarded as result. For `Abort`, the function never returns because it aborts the program. */ typeof(~Lhs()) onOverflow(string x, Lhs)(Lhs lhs) { Warn.onOverflow!x(lhs); assert(0); } /// ditto typeof(Lhs() + Rhs()) onOverflow(string x, Lhs, Rhs)(Lhs lhs, Rhs rhs) { Warn.onOverflow!x(lhs, rhs); assert(0); } } @system unittest { void test(T)() { Checked!(int, Abort) x; x = 42; auto x1 = cast(T) x; assert(x1 == 42); //x1 += long(int.max); } test!short; test!(const short); test!(immutable short); } // Throw /** Force all integral errors to fail by throwing an exception of type `Throw.CheckFailure`. The message coming with the error is similar to the one printed by `Warn`. */ struct Throw { /** Exception type thrown upon any failure. */ static class CheckFailure : Exception { this(T...)(string f, T vals) { import std.format : format; super(format(f, vals)); } } /** Called automatically upon a bad cast (one that loses precision or attempts to convert a negative value to an unsigned type). The source type is `Src` and the destination type is `Dst`. Params: src = The source of the cast Returns: Nominally the result is the desired value of the cast operation, which will be forwarded as the result of the cast. For `Throw`, the function never returns because it throws an exception. */ static Dst onBadCast(Dst, Src)(Src src) { throw new CheckFailure("Erroneous cast: cast(%s) %s(%s)", Dst.stringof, Src.stringof, src); } /** Called automatically upon a bounds error. Params: rhs = The right-hand side value in the assignment, after the operator has been evaluated bound = The value of the bound being violated Returns: Nominally the result is the desired value of the operator, which will be forwarded as result. For `Throw`, the function never returns because it throws. */ static T onLowerBound(Rhs, T)(Rhs rhs, T bound) { throw new CheckFailure("Lower bound error: %s(%s) < %s(%s)", Rhs.stringof, rhs, T.stringof, bound); } /// ditto static T onUpperBound(Rhs, T)(Rhs rhs, T bound) { throw new CheckFailure("Upper bound error: %s(%s) > %s(%s)", Rhs.stringof, rhs, T.stringof, bound); } /** Called automatically upon a comparison for equality. Throws upon an erroneous comparison (one that would make a signed negative value appear equal to an unsigned positive value). Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: The result of the comparison. Throws: `CheckFailure` if the comparison is mathematically erroneous. */ static bool hookOpEquals(L, R)(L lhs, R rhs) { bool error; auto result = opChecked!"=="(lhs, rhs, error); if (error) { throw new CheckFailure("Erroneous comparison: %s(%s) == %s(%s)", L.stringof, lhs, R.stringof, rhs); } return result; } /** Called automatically upon a comparison for ordering using one of the operators `<`, `<=`, `>`, or `>=`. In case the comparison is erroneous (i.e. it would make a signed negative value appear greater than or equal to an unsigned positive value), throws a `Throw.CheckFailure` exception. Otherwise, the three-state result is returned (positive if $(D lhs > rhs), negative if $(D lhs < rhs), `0` otherwise). Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: For correct comparisons, returns a positive integer if $(D lhs > rhs), a negative integer if $(D lhs < rhs), `0` if the two are equal. Throws: Upon a mistaken comparison such as $(D int(-1) < uint(0)), the function never returns because it throws a `Throw.CheckedFailure` exception. */ static int hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { bool error; auto result = opChecked!"cmp"(lhs, rhs, error); if (error) { throw new CheckFailure("Erroneous ordering comparison: %s(%s) and %s(%s)", Lhs.stringof, lhs, Rhs.stringof, rhs); } return result; } /** Called automatically upon an overflow during a unary or binary operation. Params: x = The operator, e.g. `-` lhs = The left-hand side (or sole) argument rhs = The right-hand side type involved in the operator Returns: Nominally the result is the desired value of the operator, which will be forwarded as result. For `Throw`, the function never returns because it throws an exception. */ static typeof(~Lhs()) onOverflow(string x, Lhs)(Lhs lhs) { throw new CheckFailure("Overflow on unary operator: %s%s(%s)", x, Lhs.stringof, lhs); } /// ditto static typeof(Lhs() + Rhs()) onOverflow(string x, Lhs, Rhs)(Lhs lhs, Rhs rhs) { throw new CheckFailure("Overflow on binary operator: %s(%s) %s %s(%s)", Lhs.stringof, lhs, x, Rhs.stringof, rhs); } } /// @safe unittest { void test(T)() { Checked!(int, Throw) x; x = 42; auto x1 = cast(T) x; assert(x1 == 42); x = T.max + 1; import std.exception : assertThrown, assertNotThrown; assertThrown(cast(T) x); x = x.max; assertThrown(x += 42); assertThrown(x += 42L); x = x.min; assertThrown(-x); assertThrown(x -= 42); assertThrown(x -= 42L); x = -1; assertNotThrown(x == -1); assertThrown(x == uint(-1)); assertNotThrown(x <= -1); assertThrown(x <= uint(-1)); } test!short; test!(const short); test!(immutable short); } // Warn /** Hook that prints to `stderr` a trace of all integral errors, without affecting default behavior. */ struct Warn { import std.stdio : stderr; static: /** Called automatically upon a bad cast from `src` to type `Dst` (one that loses precision or attempts to convert a negative value to an unsigned type). Params: src = The source of the cast Dst = The target type of the cast Returns: `cast(Dst) src` */ Dst onBadCast(Dst, Src)(Src src) { stderr.writefln("Erroneous cast: cast(%s) %s(%s)", Dst.stringof, Src.stringof, src); return cast(Dst) src; } /** Called automatically upon a bad `opOpAssign` call (one that loses precision or attempts to convert a negative value to an unsigned type). Params: rhs = The right-hand side value in the assignment, after the operator has been evaluated bound = The bound being violated Returns: `cast(Lhs) rhs` */ Lhs onLowerBound(Rhs, T)(Rhs rhs, T bound) { stderr.writefln("Lower bound error: %s(%s) < %s(%s)", Rhs.stringof, rhs, T.stringof, bound); return cast(T) rhs; } /// ditto T onUpperBound(Rhs, T)(Rhs rhs, T bound) { stderr.writefln("Upper bound error: %s(%s) > %s(%s)", Rhs.stringof, rhs, T.stringof, bound); return cast(T) rhs; } /** Called automatically upon a comparison for equality. In case of an Erroneous comparison (one that would make a signed negative value appear equal to an unsigned positive value), writes a warning message to `stderr` as a side effect. Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: In all cases the function returns the built-in result of $(D lhs == rhs). */ bool hookOpEquals(Lhs, Rhs)(Lhs lhs, Rhs rhs) { bool error; auto result = opChecked!"=="(lhs, rhs, error); if (error) { stderr.writefln("Erroneous comparison: %s(%s) == %s(%s)", Lhs.stringof, lhs, Rhs.stringof, rhs); return lhs == rhs; } return result; } /// @system unittest { auto x = checked!Warn(-42); // Passes assert(x == -42); // Passes but prints a warning // assert(x == uint(-42)); } /** Called automatically upon a comparison for ordering using one of the operators `<`, `<=`, `>`, or `>=`. In case the comparison is erroneous (i.e. it would make a signed negative value appear greater than or equal to an unsigned positive value), then a warning message is printed to `stderr`. Params: lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` rhs = The right-hand side type involved in the operator Returns: In all cases, returns $(D lhs < rhs ? -1 : lhs > rhs). The result is not autocorrected in case of an erroneous comparison. */ int hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { bool error; auto result = opChecked!"cmp"(lhs, rhs, error); if (error) { stderr.writefln("Erroneous ordering comparison: %s(%s) and %s(%s)", Lhs.stringof, lhs, Rhs.stringof, rhs); return lhs < rhs ? -1 : lhs > rhs; } return result; } /// @system unittest { auto x = checked!Warn(-42); // Passes assert(x <= -42); // Passes but prints a warning // assert(x <= uint(-42)); } /** Called automatically upon an overflow during a unary or binary operation. Params: x = The operator involved Lhs = The first argument of `Checked`, e.g. `int` if the left-hand side of the operator is `Checked!int` Rhs = The right-hand side type involved in the operator Returns: $(D mixin(x ~ "lhs")) for unary, $(D mixin("lhs" ~ x ~ "rhs")) for binary */ typeof(~Lhs()) onOverflow(string x, Lhs)(ref Lhs lhs) { stderr.writefln("Overflow on unary operator: %s%s(%s)", x, Lhs.stringof, lhs); return mixin(x ~ "lhs"); } /// ditto typeof(Lhs() + Rhs()) onOverflow(string x, Lhs, Rhs)(Lhs lhs, Rhs rhs) { stderr.writefln("Overflow on binary operator: %s(%s) %s %s(%s)", Lhs.stringof, lhs, x, Rhs.stringof, rhs); return mixin("lhs" ~ x ~ "rhs"); } } /// @system unittest { auto x = checked!Warn(42); short x1 = cast(short) x; //x += long(int.max); auto y = checked!Warn(cast(const int) 42); short y1 = cast(const byte) y; } // ProperCompare /** Hook that provides arithmetically correct comparisons for equality and ordering. Comparing an object of type $(D Checked!(X, ProperCompare)) against another integral (for equality or ordering) ensures that no surprising conversions from signed to unsigned integral occur before the comparison. Using $(D Checked!(X, ProperCompare)) on either side of a comparison for equality against a floating-point number makes sure the integral can be properly converted to the floating point type, thus making sure equality is transitive. */ struct ProperCompare { /** Hook for `==` and `!=` that ensures comparison against integral values has the behavior expected by the usual arithmetic rules. The built-in semantics yield surprising behavior when comparing signed values against unsigned values for equality, for example $(D uint.max == -1) or $(D -1_294_967_296 == 3_000_000_000u). The call $(D hookOpEquals(x, y)) returns `true` if and only if `x` and `y` represent the same arithmetic number. If one of the numbers is an integral and the other is a floating-point number, $(D hookOpEquals(x, y)) returns `true` if and only if the integral can be converted exactly (without approximation) to the floating-point number. This is in order to preserve transitivity of equality: if $(D hookOpEquals(x, y)) and $(D hookOpEquals(y, z)) then $(D hookOpEquals(y, z)), in case `x`, `y`, and `z` are a mix of integral and floating-point numbers. Params: lhs = The left-hand side of the comparison for equality rhs = The right-hand side of the comparison for equality Returns: The result of the comparison, `true` if the values are equal */ static bool hookOpEquals(L, R)(L lhs, R rhs) { alias C = typeof(lhs + rhs); static if (isFloatingPoint!C) { static if (!isFloatingPoint!L) { return hookOpEquals(rhs, lhs); } else static if (!isFloatingPoint!R) { static assert(isFloatingPoint!L && !isFloatingPoint!R); auto rhs1 = C(rhs); return lhs == rhs1 && cast(R) rhs1 == rhs; } else return lhs == rhs; } else { bool error; auto result = opChecked!"=="(lhs, rhs, error); if (error) { // Only possible error is a wrong "true" return false; } return result; } } /** Hook for `<`, `<=`, `>`, and `>=` that ensures comparison against integral values has the behavior expected by the usual arithmetic rules. The built-in semantics yield surprising behavior when comparing signed values against unsigned values, for example $(D 0u < -1). The call $(D hookOpCmp(x, y)) returns `-1` if and only if `x` is smaller than `y` in abstract arithmetic sense. If one of the numbers is an integral and the other is a floating-point number, $(D hookOpEquals(x, y)) returns a floating-point number that is `-1` if `x < y`, `0` if `x == y`, `1` if `x > y`, and `NaN` if the floating-point number is `NaN`. Params: lhs = The left-hand side of the comparison for ordering rhs = The right-hand side of the comparison for ordering Returns: The result of the comparison (negative if $(D lhs < rhs), positive if $(D lhs > rhs), `0` if the values are equal) */ static auto hookOpCmp(L, R)(L lhs, R rhs) { alias C = typeof(lhs + rhs); static if (isFloatingPoint!C) { return lhs < rhs ? C(-1) : lhs > rhs ? C(1) : lhs == rhs ? C(0) : C.init; } else { static if (!valueConvertible!(L, C) || !valueConvertible!(R, C)) { static assert(isUnsigned!C); static assert(isUnsigned!L != isUnsigned!R); if (!isUnsigned!L && lhs < 0) return -1; if (!isUnsigned!R && rhs < 0) return 1; } return lhs < rhs ? -1 : lhs > rhs; } } } /// @safe unittest { alias opEqualsProper = ProperCompare.hookOpEquals; assert(opEqualsProper(42, 42)); assert(opEqualsProper(42.0, 42.0)); assert(opEqualsProper(42u, 42)); assert(opEqualsProper(42, 42u)); assert(-1 == 4294967295u); assert(!opEqualsProper(-1, 4294967295u)); assert(!opEqualsProper(const uint(-1), -1)); assert(!opEqualsProper(uint(-1), -1.0)); assert(3_000_000_000U == -1_294_967_296); assert(!opEqualsProper(3_000_000_000U, -1_294_967_296)); } @safe unittest { alias opCmpProper = ProperCompare.hookOpCmp; assert(opCmpProper(42, 42) == 0); assert(opCmpProper(42, 42.0) == 0); assert(opCmpProper(41, 42.0) < 0); assert(opCmpProper(42, 41.0) > 0); import std.math : isNaN; assert(isNaN(opCmpProper(41, double.init))); assert(opCmpProper(42u, 42) == 0); assert(opCmpProper(42, 42u) == 0); assert(opCmpProper(-1, uint(-1)) < 0); assert(opCmpProper(uint(-1), -1) > 0); assert(opCmpProper(-1.0, -1) == 0); } @safe unittest { auto x1 = Checked!(uint, ProperCompare)(42u); assert(x1.get < -1); assert(x1 > -1); } // WithNaN /** Hook that reserves a special value as a "Not a Number" representative. For signed integrals, the reserved value is `T.min`. For signed integrals, the reserved value is `T.max`. The default value of a $(D Checked!(X, WithNaN)) is its NaN value, so care must be taken that all variables are explicitly initialized. Any arithmetic and logic operation involving at least on NaN becomes NaN itself. All of $(D a == b), $(D a < b), $(D a > b), $(D a <= b), $(D a >= b) yield `false` if at least one of `a` and `b` is NaN. */ struct WithNaN { static: /** The default value used for values not explicitly initialized. It is the NaN value, i.e. `T.min` for signed integrals and `T.max` for unsigned integrals. */ enum T defaultValue(T) = T.min == 0 ? T.max : T.min; /** The maximum value representable is `T.max` for signed integrals, $(D T.max - 1) for unsigned integrals. The minimum value representable is $(D T.min + 1) for signed integrals, `0` for unsigned integrals. */ enum T max(T) = cast(T) (T.min == 0 ? T.max - 1 : T.max); /// ditto enum T min(T) = cast(T) (T.min == 0 ? T(0) : T.min + 1); /** If `rhs` is `WithNaN.defaultValue!Rhs`, returns `WithNaN.defaultValue!Lhs`. Otherwise, returns $(D cast(Lhs) rhs). Params: rhs = the value being cast (`Rhs` is the first argument to `Checked`) Lhs = the target type of the cast Returns: The result of the cast operation. */ Lhs hookOpCast(Lhs, Rhs)(Rhs rhs) { static if (is(Lhs == bool)) { return rhs != defaultValue!Rhs && rhs != 0; } else static if (valueConvertible!(Rhs, Lhs)) { return rhs != defaultValue!Rhs ? Lhs(rhs) : defaultValue!Lhs; } else { // Not value convertible, only viable option is rhs fits within the // bounds of Lhs static if (ProperCompare.hookOpCmp(Rhs.min, Lhs.min) < 0) { // Example: hookOpCast!short(int(42)), hookOpCast!uint(int(42)) if (ProperCompare.hookOpCmp(rhs, Lhs.min) < 0) return defaultValue!Lhs; } static if (ProperCompare.hookOpCmp(Rhs.max, Lhs.max) > 0) { // Example: hookOpCast!int(uint(42)) if (ProperCompare.hookOpCmp(rhs, Lhs.max) > 0) return defaultValue!Lhs; } return cast(Lhs) rhs; } } /// @safe unittest { auto x = checked!WithNaN(422); assert((cast(ubyte) x) == 255); x = checked!WithNaN(-422); assert((cast(byte) x) == -128); assert(cast(short) x == -422); assert(cast(bool) x); x = x.init; // set back to NaN assert(x != true); assert(x != false); } /** Returns `false` if $(D lhs == WithNaN.defaultValue!Lhs), $(D lhs == rhs) otherwise. Params: lhs = The left-hand side of the comparison (`Lhs` is the first argument to `Checked`) rhs = The right-hand side of the comparison Returns: `lhs != WithNaN.defaultValue!Lhs && lhs == rhs` */ bool hookOpEquals(Lhs, Rhs)(Lhs lhs, Rhs rhs) { return lhs != defaultValue!Lhs && lhs == rhs; } /** If $(D lhs == WithNaN.defaultValue!Lhs), returns `double.init`. Otherwise, has the same semantics as the default comparison. Params: lhs = The left-hand side of the comparison (`Lhs` is the first argument to `Checked`) rhs = The right-hand side of the comparison Returns: `double.init` if `lhs == WitnNaN.defaultValue!Lhs`, `-1.0` if $(D lhs < rhs), `0.0` if $(D lhs == rhs), `1.0` if $(D lhs > rhs). */ double hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { if (lhs == defaultValue!Lhs) return double.init; return lhs < rhs ? -1.0 : lhs > rhs ? 1.0 : lhs == rhs ? 0.0 : double.init; } /// @safe unittest { Checked!(int, WithNaN) x; assert(!(x < 0) && !(x > 0) && !(x == 0)); x = 1; assert(x > 0 && !(x < 0) && !(x == 0)); } /** Defines hooks for unary operators `-`, `~`, `++`, and `--`. For `-` and `~`, if $(D v == WithNaN.defaultValue!T), returns `WithNaN.defaultValue!T`. Otherwise, the semantics is the same as for the built-in operator. For `++` and `--`, if $(D v == WithNaN.defaultValue!Lhs) or the operation would result in an overflow, sets `v` to `WithNaN.defaultValue!T`. Otherwise, the semantics is the same as for the built-in operator. Params: x = The operator symbol v = The left-hand side of the comparison (`T` is the first argument to `Checked`) Returns: $(UL $(LI For $(D x == "-" || x == "~"): If $(D v == WithNaN.defaultValue!T), the function returns `WithNaN.defaultValue!T`. Otherwise it returns the normal result of the operator.) $(LI For $(D x == "++" || x == "--"): The function returns `void`.)) */ auto hookOpUnary(string x, T)(ref T v) { static if (x == "-" || x == "~") { return v != defaultValue!T ? mixin(x ~ "v") : v; } else static if (x == "++") { static if (defaultValue!T == T.min) { if (v != defaultValue!T) { if (v == T.max) v = defaultValue!T; else ++v; } } else { static assert(defaultValue!T == T.max); if (v != defaultValue!T) ++v; } } else static if (x == "--") { if (v != defaultValue!T) --v; } } /// @safe unittest { Checked!(int, WithNaN) x; ++x; assert(x.isNaN); x = 1; assert(!x.isNaN); x = -x; ++x; assert(!x.isNaN); } @safe unittest // for coverage { Checked!(uint, WithNaN) y; ++y; assert(y.isNaN); } /** Defines hooks for binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>` for cases where a `Checked` object is the left-hand side operand. If $(D lhs == WithNaN.defaultValue!Lhs), returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))) without evaluating the operand. Otherwise, evaluates the operand. If evaluation does not overflow, returns the result. Otherwise, returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))). Params: x = The operator symbol lhs = The left-hand side operand (`Lhs` is the first argument to `Checked`) rhs = The right-hand side operand Returns: If $(D lhs != WithNaN.defaultValue!Lhs) and the operator does not overflow, the function returns the same result as the built-in operator. In all other cases, returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))). */ auto hookOpBinary(string x, L, R)(L lhs, R rhs) { alias Result = typeof(lhs + rhs); if (lhs != defaultValue!L) { bool error; auto result = opChecked!x(lhs, rhs, error); if (!error) return result; } return defaultValue!Result; } /// @safe unittest { Checked!(int, WithNaN) x; assert((x + 1).isNaN); x = 100; assert(!(x + 1).isNaN); } /** Defines hooks for binary operators `+`, `-`, `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>` for cases where a `Checked` object is the right-hand side operand. If $(D rhs == WithNaN.defaultValue!Rhs), returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))) without evaluating the operand. Otherwise, evaluates the operand. If evaluation does not overflow, returns the result. Otherwise, returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))). Params: x = The operator symbol lhs = The left-hand side operand rhs = The right-hand side operand (`Rhs` is the first argument to `Checked`) Returns: If $(D rhs != WithNaN.defaultValue!Rhs) and the operator does not overflow, the function returns the same result as the built-in operator. In all other cases, returns $(D WithNaN.defaultValue!(typeof(lhs + rhs))). */ auto hookOpBinaryRight(string x, L, R)(L lhs, R rhs) { alias Result = typeof(lhs + rhs); if (rhs != defaultValue!R) { bool error; auto result = opChecked!x(lhs, rhs, error); if (!error) return result; } return defaultValue!Result; } /// @safe unittest { Checked!(int, WithNaN) x; assert((1 + x).isNaN); x = 100; assert(!(1 + x).isNaN); } /** Defines hooks for binary operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=` for cases where a `Checked` object is the left-hand side operand. If $(D lhs == WithNaN.defaultValue!Lhs), no action is carried. Otherwise, evaluates the operand. If evaluation does not overflow and fits in `Lhs` without loss of information or change of sign, sets `lhs` to the result. Otherwise, sets `lhs` to `WithNaN.defaultValue!Lhs`. Params: x = The operator symbol (without the `=`) lhs = The left-hand side operand (`Lhs` is the first argument to `Checked`) rhs = The right-hand side operand Returns: `void` */ void hookOpOpAssign(string x, L, R)(ref L lhs, R rhs) { if (lhs == defaultValue!L) return; bool error; auto temp = opChecked!x(lhs, rhs, error); lhs = error ? defaultValue!L : hookOpCast!L(temp); } /// @safe unittest { Checked!(int, WithNaN) x; x += 4; assert(x.isNaN); x = 0; x += 4; assert(!x.isNaN); x += int.max; assert(x.isNaN); } } /// @safe unittest { auto x1 = Checked!(int, WithNaN)(); assert(x1.isNaN); assert(x1.get == int.min); assert(x1 != x1); assert(!(x1 < x1)); assert(!(x1 > x1)); assert(!(x1 == x1)); ++x1; assert(x1.isNaN); assert(x1.get == int.min); --x1; assert(x1.isNaN); assert(x1.get == int.min); x1 = 42; assert(!x1.isNaN); assert(x1 == x1); assert(x1 <= x1); assert(x1 >= x1); static assert(x1.min == int.min + 1); x1 += long(int.max); } /** Queries whether a $(D Checked!(T, WithNaN)) object is not a number (NaN). Params: x = the `Checked` instance queried Returns: `true` if `x` is a NaN, `false` otherwise */ bool isNaN(T)(const Checked!(T, WithNaN) x) { return x.get == x.init.get; } /// @safe unittest { auto x1 = Checked!(int, WithNaN)(); assert(x1.isNaN); x1 = 1; assert(!x1.isNaN); x1 = x1.init; assert(x1.isNaN); } @safe unittest { void test1(T)() { auto x1 = Checked!(T, WithNaN)(); assert(x1.isNaN); assert(x1.get == int.min); assert(x1 != x1); assert(!(x1 < x1)); assert(!(x1 > x1)); assert(!(x1 == x1)); assert(x1.get == int.min); auto x2 = Checked!(T, WithNaN)(42); assert(!x2.isNaN); assert(x2 == x2); assert(x2 <= x2); assert(x2 >= x2); static assert(x2.min == T.min + 1); } test1!int; test1!(const int); test1!(immutable int); void test2(T)() { auto x1 = Checked!(T, WithNaN)(); assert(x1.get == T.min); assert(x1 != x1); assert(!(x1 < x1)); assert(!(x1 > x1)); assert(!(x1 == x1)); ++x1; assert(x1.get == T.min); --x1; assert(x1.get == T.min); x1 = 42; assert(x1 == x1); assert(x1 <= x1); assert(x1 >= x1); static assert(x1.min == T.min + 1); x1 += long(T.max); } test2!int; } @safe unittest { alias Smart(T) = Checked!(Checked!(T, ProperCompare), WithNaN); Smart!int x1; assert(x1 != x1); x1 = -1; assert(x1 < 1u); auto x2 = Smart!(const int)(42); } // Saturate /** Hook that implements $(I saturation), i.e. any arithmetic operation that would overflow leaves the result at its extreme value (`min` or `max` depending on the direction of the overflow). Saturation is not sticky; if a value reaches its saturation value, another operation may take it back to normal range. */ struct Saturate { static: /** Implements saturation for operators `+=`, `-=`, `*=`, `/=`, `%=`, `^^=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, and `>>>=`. This hook is called if the result of the binary operation does not fit in `Lhs` without loss of information or a change in sign. Params: Rhs = The right-hand side type in the assignment, after the operation has been computed bound = The bound being violated Returns: `Lhs.max` if $(D rhs >= 0), `Lhs.min` otherwise. */ T onLowerBound(Rhs, T)(Rhs rhs, T bound) { return bound; } /// ditto T onUpperBound(Rhs, T)(Rhs rhs, T bound) { return bound; } /// @safe unittest { auto x = checked!Saturate(short(100)); x += 33000; assert(x == short.max); x -= 70000; assert(x == short.min); } /** Implements saturation for operators `+`, `-` (unary and binary), `*`, `/`, `%`, `^^`, `&`, `|`, `^`, `<<`, `>>`, and `>>>`. For unary `-`, `onOverflow` is called if $(D lhs == Lhs.min) and `Lhs` is a signed type. The function returns `Lhs.max`. For binary operators, the result is as follows: $(UL $(LI `Lhs.max` if the result overflows in the positive direction, on division by `0`, or on shifting right by a negative value) $(LI `Lhs.min` if the result overflows in the negative direction) $(LI `0` if `lhs` is being shifted left by a negative value, or shifted right by a large positive value)) Params: x = The operator involved in the `opAssign` operation Lhs = The left-hand side of the operator (`Lhs` is the first argument to `Checked`) Rhs = The right-hand side type in the operator Returns: The saturated result of the operator. */ auto onOverflow(string x, Lhs)(Lhs lhs) { static assert(x == "-" || x == "++" || x == "--"); return x == "--" ? Lhs.min : Lhs.max; } /// ditto typeof(Lhs() + Rhs()) onOverflow(string x, Lhs, Rhs)(Lhs lhs, Rhs rhs) { static if (x == "+") return rhs >= 0 ? Lhs.max : Lhs.min; else static if (x == "*") return (lhs >= 0) == (rhs >= 0) ? Lhs.max : Lhs.min; else static if (x == "^^") return lhs > 0 || !(rhs & 1) ? Lhs.max : Lhs.min; else static if (x == "-") return rhs >= 0 ? Lhs.min : Lhs.max; else static if (x == "/" || x == "%") return Lhs.max; else static if (x == "<<") return rhs >= 0 ? Lhs.max : 0; else static if (x == ">>" || x == ">>>") return rhs >= 0 ? 0 : Lhs.max; else static assert(false); } /// @safe unittest { assert(checked!Saturate(int.max) + 1 == int.max); assert(checked!Saturate(100) ^^ 10 == int.max); assert(checked!Saturate(-100) ^^ 10 == int.max); assert(checked!Saturate(100) / 0 == int.max); assert(checked!Saturate(100) << -1 == 0); assert(checked!Saturate(100) << 33 == int.max); assert(checked!Saturate(100) >> -1 == int.max); assert(checked!Saturate(100) >> 33 == 0); } } /// @safe unittest { auto x = checked!Saturate(int.max); ++x; assert(x == int.max); --x; assert(x == int.max - 1); x = int.min; assert(-x == int.max); x -= 42; assert(x == int.min); assert(x * -2 == int.max); } /* Yields `true` if `T1` is "value convertible" (by C's "value preserving" rule, see $(HTTP c-faq.com/expr/preservingrules.html)) to `T2`, where the two are integral types. That is, all of values in `T1` are also in `T2`. For example `int` is value convertible to `long` but not to `uint` or `ulong`. */ private enum valueConvertible(T1, T2) = isIntegral!T1 && isIntegral!T2 && is(T1 : T2) && ( isUnsigned!T1 == isUnsigned!T2 || // same signedness !isUnsigned!T2 && T2.sizeof > T1.sizeof // safely convertible ); /** Defines binary operations with overflow checking for any two integral types. The result type obeys the language rules (even when they may be counterintuitive), and `overflow` is set if an overflow occurs (including inadvertent change of signedness, e.g. `-1` is converted to `uint`). Conceptually the behavior is: $(OL $(LI Perform the operation in infinite precision) $(LI If the infinite-precision result fits in the result type, return it and do not touch `overflow`) $(LI Otherwise, set `overflow` to `true` and return an unspecified value) ) The implementation exploits properties of types and operations to minimize additional work. Params: x = The binary operator involved, e.g. `/` lhs = The left-hand side of the operator rhs = The right-hand side of the operator overflow = The overflow indicator (assigned `true` in case there's an error) Returns: The result of the operation, which is the same as the built-in operator */ typeof(mixin(x == "cmp" ? "0" : ("L() " ~ x ~ " R()"))) opChecked(string x, L, R)(const L lhs, const R rhs, ref bool overflow) if (isIntegral!L && isIntegral!R) { static if (x == "cmp") alias Result = int; else alias Result = typeof(mixin("L() " ~ x ~ " R()")); import core.checkedint : addu, adds, subs, muls, subu, mulu; import std.algorithm.comparison : among; static if (x == "==") { alias C = typeof(lhs + rhs); static if (valueConvertible!(L, C) && valueConvertible!(R, C)) { // Values are converted to R before comparison, cool. return lhs == rhs; } else { static assert(isUnsigned!C); static assert(isUnsigned!L != isUnsigned!R); if (lhs != rhs) return false; // R(lhs) and R(rhs) have the same bit pattern, yet may be // different due to signedness change. static if (!isUnsigned!R) { if (rhs >= 0) return true; } else { if (lhs >= 0) return true; } overflow = true; return true; } } else static if (x == "cmp") { alias C = typeof(lhs + rhs); static if (!valueConvertible!(L, C) || !valueConvertible!(R, C)) { static assert(isUnsigned!C); static assert(isUnsigned!L != isUnsigned!R); if (!isUnsigned!L && lhs < 0) { overflow = true; return -1; } if (!isUnsigned!R && rhs < 0) { overflow = true; return 1; } } return lhs < rhs ? -1 : lhs > rhs; } else static if (x.among("<<", ">>", ">>>")) { // Handle shift separately from all others. The test below covers // negative rhs as well. import std.conv : unsigned; if (unsigned(rhs) > 8 * Result.sizeof) goto fail; return mixin("lhs" ~ x ~ "rhs"); } else static if (x.among("&", "|", "^")) { // Nothing to check return mixin("lhs" ~ x ~ "rhs"); } else static if (x == "^^") { // Exponentiation is weird, handle separately return pow(lhs, rhs, overflow); } else static if (valueConvertible!(L, Result) && valueConvertible!(R, Result)) { static if (L.sizeof < Result.sizeof && R.sizeof < Result.sizeof && x.among("+", "-", "*")) { // No checks - both are value converted and result is in range return mixin("lhs" ~ x ~ "rhs"); } else static if (x == "+") { static if (isUnsigned!Result) alias impl = addu; else alias impl = adds; return impl(Result(lhs), Result(rhs), overflow); } else static if (x == "-") { static if (isUnsigned!Result) alias impl = subu; else alias impl = subs; return impl(Result(lhs), Result(rhs), overflow); } else static if (x == "*") { static if (!isUnsigned!L && !isUnsigned!R && is(L == Result)) { if (lhs == Result.min && rhs == -1) goto fail; } static if (isUnsigned!Result) alias impl = mulu; else alias impl = muls; return impl(Result(lhs), Result(rhs), overflow); } else static if (x == "/" || x == "%") { static if (!isUnsigned!L && !isUnsigned!R && is(L == Result) && x == "/") { if (lhs == Result.min && rhs == -1) goto fail; } if (rhs == 0) goto fail; return mixin("lhs" ~ x ~ "rhs"); } else static assert(0, x); } else // Mixed signs { static assert(isUnsigned!Result); static assert(isUnsigned!L != isUnsigned!R); static if (x == "+") { static if (!isUnsigned!L) { if (lhs < 0) return subu(Result(rhs), Result(-lhs), overflow); } else static if (!isUnsigned!R) { if (rhs < 0) return subu(Result(lhs), Result(-rhs), overflow); } return addu(Result(lhs), Result(rhs), overflow); } else static if (x == "-") { static if (!isUnsigned!L) { if (lhs < 0) goto fail; } else static if (!isUnsigned!R) { if (rhs < 0) return addu(Result(lhs), Result(-rhs), overflow); } return subu(Result(lhs), Result(rhs), overflow); } else static if (x == "*") { static if (!isUnsigned!L) { if (lhs < 0) goto fail; } else static if (!isUnsigned!R) { if (rhs < 0) goto fail; } return mulu(Result(lhs), Result(rhs), overflow); } else static if (x == "/" || x == "%") { static if (!isUnsigned!L) { if (lhs < 0 || rhs == 0) goto fail; } else static if (!isUnsigned!R) { if (rhs <= 0) goto fail; } return mixin("Result(lhs)" ~ x ~ "Result(rhs)"); } else static assert(0, x); } debug assert(false); fail: overflow = true; return Result(0); } /// @safe unittest { bool overflow; assert(opChecked!"+"(const short(1), short(1), overflow) == 2 && !overflow); assert(opChecked!"+"(1, 1, overflow) == 2 && !overflow); assert(opChecked!"+"(1, 1u, overflow) == 2 && !overflow); assert(opChecked!"+"(-1, 1u, overflow) == 0 && !overflow); assert(opChecked!"+"(1u, -1, overflow) == 0 && !overflow); } /// @safe unittest { bool overflow; assert(opChecked!"-"(1, 1, overflow) == 0 && !overflow); assert(opChecked!"-"(1, 1u, overflow) == 0 && !overflow); assert(opChecked!"-"(1u, -1, overflow) == 2 && !overflow); assert(opChecked!"-"(-1, 1u, overflow) == 0 && overflow); } @safe unittest { bool overflow; assert(opChecked!"*"(2, 3, overflow) == 6 && !overflow); assert(opChecked!"*"(2, 3u, overflow) == 6 && !overflow); assert(opChecked!"*"(1u, -1, overflow) == 0 && overflow); //assert(mul(-1, 1u, overflow) == uint.max - 1 && overflow); } @safe unittest { bool overflow; assert(opChecked!"/"(6, 3, overflow) == 2 && !overflow); assert(opChecked!"/"(6, 3, overflow) == 2 && !overflow); assert(opChecked!"/"(6u, 3, overflow) == 2 && !overflow); assert(opChecked!"/"(6, 3u, overflow) == 2 && !overflow); assert(opChecked!"/"(11, 0, overflow) == 0 && overflow); overflow = false; assert(opChecked!"/"(6u, 0, overflow) == 0 && overflow); overflow = false; assert(opChecked!"/"(-6, 2u, overflow) == 0 && overflow); overflow = false; assert(opChecked!"/"(-6, 0u, overflow) == 0 && overflow); overflow = false; assert(opChecked!"cmp"(0u, -6, overflow) == 1 && overflow); overflow = false; assert(opChecked!"|"(1, 2, overflow) == 3 && !overflow); } /* Exponentiation function used by the implementation of operator `^^`. */ private pure @safe nothrow @nogc auto pow(L, R)(const L lhs, const R rhs, ref bool overflow) if (isIntegral!L && isIntegral!R) { if (rhs <= 1) { if (rhs == 0) return 1; static if (!isUnsigned!R) return rhs == 1 ? lhs : (rhs == -1 && (lhs == 1 || lhs == -1)) ? lhs : 0; else return lhs; } typeof(lhs ^^ rhs) b = void; static if (!isUnsigned!L && isUnsigned!(typeof(b))) { // Need to worry about mixed-sign stuff if (lhs < 0) { if (rhs & 1) { if (lhs < 0) overflow = true; return 0; } b = -lhs; } else { b = lhs; } } else { b = lhs; } if (b == 1) return 1; if (b == -1) return (rhs & 1) ? -1 : 1; if (rhs > 63) { overflow = true; return 0; } assert((b > 1 || b < -1) && rhs > 1); return powImpl(b, cast(uint) rhs, overflow); } // Inspiration: http://www.stepanovpapers.com/PAM.pdf pure @safe nothrow @nogc private T powImpl(T)(T b, uint e, ref bool overflow) if (isIntegral!T && T.sizeof >= 4) { assert(e > 1); import core.checkedint : muls, mulu; static if (isUnsigned!T) alias mul = mulu; else alias mul = muls; T r = b; --e; // Loop invariant: r * (b ^^ e) is the actual result for (;; e /= 2) { if (e % 2) { r = mul(r, b, overflow); if (e == 1) break; } b = mul(b, b, overflow); } return r; } @safe unittest { static void testPow(T)(T x, uint e) { bool overflow; assert(opChecked!"^^"(T(0), 0, overflow) == 1); assert(opChecked!"^^"(-2, T(0), overflow) == 1); assert(opChecked!"^^"(-2, T(1), overflow) == -2); assert(opChecked!"^^"(-1, -1, overflow) == -1); assert(opChecked!"^^"(-2, 1, overflow) == -2); assert(opChecked!"^^"(-2, -1, overflow) == 0); assert(opChecked!"^^"(-2, 4u, overflow) == 16); assert(!overflow); assert(opChecked!"^^"(-2, 3u, overflow) == 0); assert(overflow); overflow = false; assert(opChecked!"^^"(3, 64u, overflow) == 0); assert(overflow); overflow = false; foreach (uint i; 0 .. e) { assert(opChecked!"^^"(x, i, overflow) == x ^^ i); assert(!overflow); } assert(opChecked!"^^"(x, e, overflow) == x ^^ e); assert(overflow); } testPow!int(3, 21); testPow!uint(3, 21); testPow!long(3, 40); testPow!ulong(3, 41); } version (unittest) private struct CountOverflows { uint calls; auto onOverflow(string op, Lhs)(Lhs lhs) { ++calls; return mixin(op ~ "lhs"); } auto onOverflow(string op, Lhs, Rhs)(Lhs lhs, Rhs rhs) { ++calls; return mixin("lhs" ~ op ~ "rhs"); } T onLowerBound(Rhs, T)(Rhs rhs, T bound) { ++calls; return cast(T) rhs; } T onUpperBound(Rhs, T)(Rhs rhs, T bound) { ++calls; return cast(T) rhs; } } version (unittest) private struct CountOpBinary { uint calls; auto hookOpBinary(string op, Lhs, Rhs)(Lhs lhs, Rhs rhs) { ++calls; return mixin("lhs" ~ op ~ "rhs"); } } // opBinary @nogc nothrow pure @safe unittest { auto x = Checked!(const int, void)(42), y = Checked!(immutable int, void)(142); assert(x + y == 184); assert(x + 100 == 142); assert(y - x == 100); assert(200 - x == 158); assert(y * x == 142 * 42); assert(x / 1 == 42); assert(x % 20 == 2); auto x1 = Checked!(int, CountOverflows)(42); assert(x1 + 0 == 42); assert(x1 + false == 42); assert(is(typeof(x1 + 0.5) == double)); assert(x1 + 0.5 == 42.5); assert(x1.hook.calls == 0); assert(x1 + int.max == int.max + 42); assert(x1.hook.calls == 1); assert(x1 * 2 == 84); assert(x1.hook.calls == 1); assert(x1 / 2 == 21); assert(x1.hook.calls == 1); assert(x1 % 20 == 2); assert(x1.hook.calls == 1); assert(x1 << 2 == 42 << 2); assert(x1.hook.calls == 1); assert(x1 << 42 == x1.get << x1.get); assert(x1.hook.calls == 2); x1 = int.min; assert(x1 - 1 == int.max); assert(x1.hook.calls == 3); auto x2 = Checked!(int, CountOpBinary)(42); assert(x2 + 1 == 43); assert(x2.hook.calls == 1); auto x3 = Checked!(uint, CountOverflows)(42u); assert(x3 + 1 == 43); assert(x3.hook.calls == 0); assert(x3 - 1 == 41); assert(x3.hook.calls == 0); assert(x3 + (-42) == 0); assert(x3.hook.calls == 0); assert(x3 - (-42) == 84); assert(x3.hook.calls == 0); assert(x3 * 2 == 84); assert(x3.hook.calls == 0); assert(x3 * -2 == -84); assert(x3.hook.calls == 1); assert(x3 / 2 == 21); assert(x3.hook.calls == 1); assert(x3 / -2 == 0); assert(x3.hook.calls == 2); assert(x3 ^^ 2 == 42 * 42); assert(x3.hook.calls == 2); auto x4 = Checked!(int, CountOverflows)(42); assert(x4 + 1 == 43); assert(x4.hook.calls == 0); assert(x4 + 1u == 43); assert(x4.hook.calls == 0); assert(x4 - 1 == 41); assert(x4.hook.calls == 0); assert(x4 * 2 == 84); assert(x4.hook.calls == 0); x4 = -2; assert(x4 + 2u == 0); assert(x4.hook.calls == 0); assert(x4 * 2u == -4); assert(x4.hook.calls == 1); auto x5 = Checked!(int, CountOverflows)(3); assert(x5 ^^ 0 == 1); assert(x5 ^^ 1 == 3); assert(x5 ^^ 2 == 9); assert(x5 ^^ 3 == 27); assert(x5 ^^ 4 == 81); assert(x5 ^^ 5 == 81 * 3); assert(x5 ^^ 6 == 81 * 9); } // opBinaryRight @nogc nothrow pure @safe unittest { auto x1 = Checked!(int, CountOverflows)(42); assert(1 + x1 == 43); assert(true + x1 == 43); assert(0.5 + x1 == 42.5); auto x2 = Checked!(int, void)(42); assert(x1 + x2 == 84); assert(x2 + x1 == 84); } // opOpAssign @safe unittest { auto x1 = Checked!(int, CountOverflows)(3); assert((x1 += 2) == 5); x1 *= 2_000_000_000L; assert(x1.hook.calls == 1); x1 *= -2_000_000_000L; assert(x1.hook.calls == 2); auto x2 = Checked!(ushort, CountOverflows)(ushort(3)); assert((x2 += 2) == 5); assert(x2.hook.calls == 0); assert((x2 += ushort.max) == cast(ushort) (ushort(5) + ushort.max)); assert(x2.hook.calls == 1); auto x3 = Checked!(uint, CountOverflows)(3u); x3 *= ulong(2_000_000_000); assert(x3.hook.calls == 1); } // opAssign @safe unittest { Checked!(int, void) x; x = 42; assert(x.get == 42); x = x; assert(x.get == 42); x = short(43); assert(x.get == 43); x = ushort(44); assert(x.get == 44); } @safe unittest { static assert(!is(typeof(Checked!(short, void)(ushort(42))))); static assert(!is(typeof(Checked!(int, void)(long(42))))); static assert(!is(typeof(Checked!(int, void)(ulong(42))))); assert(Checked!(short, void)(short(42)).get == 42); assert(Checked!(int, void)(ushort(42)).get == 42); } // opCast @nogc nothrow pure @safe unittest { static assert(is(typeof(cast(float) Checked!(int, void)(42)) == float)); assert(cast(float) Checked!(int, void)(42) == 42); assert(is(typeof(cast(long) Checked!(int, void)(42)) == long)); assert(cast(long) Checked!(int, void)(42) == 42); static assert(is(typeof(cast(long) Checked!(uint, void)(42u)) == long)); assert(cast(long) Checked!(uint, void)(42u) == 42); auto x = Checked!(int, void)(42); if (x) {} else assert(0); x = 0; if (x) assert(0); static struct Hook1 { uint calls; Dst hookOpCast(Dst, Src)(Src value) { ++calls; return 42; } } auto y = Checked!(long, Hook1)(long.max); assert(cast(int) y == 42); assert(cast(uint) y == 42); assert(y.hook.calls == 2); static struct Hook2 { uint calls; Dst onBadCast(Dst, Src)(Src value) { ++calls; return 42; } } auto x1 = Checked!(uint, Hook2)(100u); assert(cast(ushort) x1 == 100); assert(cast(short) x1 == 100); assert(cast(float) x1 == 100); assert(cast(double) x1 == 100); assert(cast(real) x1 == 100); assert(x1.hook.calls == 0); assert(cast(int) x1 == 100); assert(x1.hook.calls == 0); x1 = uint.max; assert(cast(int) x1 == 42); assert(x1.hook.calls == 1); auto x2 = Checked!(int, Hook2)(-100); assert(cast(short) x2 == -100); assert(cast(ushort) x2 == 42); assert(cast(uint) x2 == 42); assert(cast(ulong) x2 == 42); assert(x2.hook.calls == 3); } // opEquals @nogc nothrow pure @safe unittest { assert(Checked!(int, void)(42) == 42L); assert(42UL == Checked!(int, void)(42)); static struct Hook1 { uint calls; bool hookOpEquals(Lhs, Rhs)(const Lhs lhs, const Rhs rhs) { ++calls; return lhs != rhs; } } auto x1 = Checked!(int, Hook1)(100); assert(x1 != Checked!(long, Hook1)(100)); assert(x1.hook.calls == 1); assert(x1 != 100u); assert(x1.hook.calls == 2); static struct Hook2 { uint calls; bool hookOpEquals(Lhs, Rhs)(Lhs lhs, Rhs rhs) { ++calls; return false; } } auto x2 = Checked!(int, Hook2)(-100); assert(x2 != x1); // For coverage: lhs has no hookOpEquals, rhs does assert(Checked!(uint, void)(100u) != x2); // For coverage: different types, neither has a hookOpEquals assert(Checked!(uint, void)(100u) == Checked!(int, void*)(100)); assert(x2.hook.calls == 0); assert(x2 != -100); assert(x2.hook.calls == 1); assert(x2 != cast(uint) -100); assert(x2.hook.calls == 2); x2 = 100; assert(x2 != cast(uint) 100); assert(x2.hook.calls == 3); x2 = -100; auto x3 = Checked!(uint, Hook2)(100u); assert(x3 != 100); x3 = uint.max; assert(x3 != -1); assert(x2 != x3); } // opCmp @nogc nothrow pure @safe unittest { Checked!(int, void) x; assert(x <= x); assert(x < 45); assert(x < 45u); assert(x > -45); assert(x < 44.2); assert(x > -44.2); assert(!(x < double.init)); assert(!(x > double.init)); assert(!(x <= double.init)); assert(!(x >= double.init)); static struct Hook1 { uint calls; int hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { ++calls; return 0; } } auto x1 = Checked!(int, Hook1)(42); assert(!(x1 < 43u)); assert(!(43u < x1)); assert(x1.hook.calls == 2); static struct Hook2 { uint calls; int hookOpCmp(Lhs, Rhs)(Lhs lhs, Rhs rhs) { ++calls; return ProperCompare.hookOpCmp(lhs, rhs); } } auto x2 = Checked!(int, Hook2)(-42); assert(x2 < 43u); assert(43u > x2); assert(x2.hook.calls == 2); x2 = 42; assert(x2 > 41u); auto x3 = Checked!(uint, Hook2)(42u); assert(x3 > 41); assert(x3 > -41); } // opUnary @nogc nothrow pure @safe unittest { auto x = Checked!(int, void)(42); assert(x == +x); static assert(is(typeof(-x) == typeof(x))); assert(-x == Checked!(int, void)(-42)); static assert(is(typeof(~x) == typeof(x))); assert(~x == Checked!(int, void)(~42)); assert(++x == 43); assert(--x == 42); static struct Hook1 { uint calls; auto hookOpUnary(string op, T)(T value) if (op == "-") { ++calls; return T(42); } auto hookOpUnary(string op, T)(T value) if (op == "~") { ++calls; return T(43); } } auto x1 = Checked!(int, Hook1)(100); assert(is(typeof(-x1) == typeof(x1))); assert(-x1 == Checked!(int, Hook1)(42)); assert(is(typeof(~x1) == typeof(x1))); assert(~x1 == Checked!(int, Hook1)(43)); assert(x1.hook.calls == 2); static struct Hook2 { uint calls; void hookOpUnary(string op, T)(ref T value) if (op == "++") { ++calls; --value; } void hookOpUnary(string op, T)(ref T value) if (op == "--") { ++calls; ++value; } } auto x2 = Checked!(int, Hook2)(100); assert(++x2 == 99); assert(x2 == 99); assert(--x2 == 100); assert(x2 == 100); auto x3 = Checked!(int, CountOverflows)(int.max - 1); assert(++x3 == int.max); assert(x3.hook.calls == 0); assert(++x3 == int.min); assert(x3.hook.calls == 1); assert(-x3 == int.min); assert(x3.hook.calls == 2); x3 = int.min + 1; assert(--x3 == int.min); assert(x3.hook.calls == 2); assert(--x3 == int.max); assert(x3.hook.calls == 3); } // @nogc nothrow pure @safe unittest { Checked!(int, void) x; assert(x == x); assert(x == +x); assert(x == -x); ++x; assert(x == 1); x++; assert(x == 2); x = 42; assert(x == 42); const short _short = 43; x = _short; assert(x == _short); ushort _ushort = 44; x = _ushort; assert(x == _ushort); assert(x == 44.0); assert(x != 44.1); assert(x < 45); assert(x < 44.2); assert(x > -45); assert(x > -44.2); assert(cast(long) x == 44); assert(cast(short) x == 44); const Checked!(uint, void) y; assert(y <= y); assert(y == 0); assert(y < x); x = -1; assert(x > y); } @nogc nothrow pure @safe unittest { alias cint = Checked!(int, void); cint a = 1, b = 2; a += b; assert(a == cint(3)); alias ccint = Checked!(cint, Saturate); ccint c = 14; a += c; assert(a == cint(17)); } // toHash @system unittest { assert(checked(42).toHash() == checked(42).toHash()); assert(checked(12).toHash() != checked(19).toHash()); static struct Hook1 { static size_t hookToHash(T)(T payload) nothrow @trusted { static if (size_t.sizeof == 4) { return typeid(payload).getHash(&payload) ^ 0xFFFF_FFFF; } else { return typeid(payload).getHash(&payload) ^ 0xFFFF_FFFF_FFFF_FFFF; } } } auto a = checked!Hook1(78); auto b = checked!Hook1(78); assert(a.toHash() == b.toHash()); assert(checked!Hook1(12).toHash() != checked!Hook1(13).toHash()); static struct Hook2 { static if (size_t.sizeof == 4) { static size_t hashMask = 0xFFFF_0000; } else { static size_t hashMask = 0xFFFF_0000_FFFF_0000; } static size_t hookToHash(T)(T payload) nothrow @trusted { return typeid(payload).getHash(&payload) ^ hashMask; } } auto x = checked!Hook2(1901); auto y = checked!Hook2(1989); assert((() nothrow @safe => x.toHash() == x.toHash())()); assert(x.toHash() == x.toHash()); assert(x.toHash() != y.toHash()); assert(checked!Hook1(1901).toHash() != x.toHash()); immutable z = checked!Hook1(1901); immutable t = checked!Hook1(1901); immutable w = checked!Hook2(1901); assert(z.toHash() == t.toHash()); assert(z.toHash() != x.toHash()); assert(z.toHash() != w.toHash()); const long c = 0xF0F0F0F0; const long d = 0xF0F0F0F0; assert(checked!Hook1(c).toHash() != checked!Hook2(c)); assert(checked!Hook1(c).toHash() != checked!Hook1(d)); // Hook with state, does not implement hookToHash static struct Hook3 { ulong var1 = ulong.max; uint var2 = uint.max; } assert(checked!Hook3(12).toHash() != checked!Hook3(13).toHash()); assert(checked!Hook3(13).toHash() == checked!Hook3(13).toHash()); // Hook with no state and no hookToHash, payload has its own hashing function auto x1 = Checked!(Checked!int, ProperCompare)(123); auto x2 = Checked!(Checked!int, ProperCompare)(123); auto x3 = Checked!(Checked!int, ProperCompare)(144); assert(x1.toHash() == x2.toHash()); assert(x1.toHash() != x3.toHash()); assert(x2.toHash() != x3.toHash()); } /// @system unittest { struct MyHook { static size_t hookToHash(T)(const T payload) nothrow @trusted { return .hashOf(payload); } } int[Checked!(int, MyHook)] aa; Checked!(int, MyHook) var = 42; aa[var] = 100; assert(aa[var] == 100); int[Checked!(int, Abort)] bb; Checked!(int, Abort) var2 = 42; bb[var2] = 100; assert(bb[var2] == 100); }
D
/Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/Exports.swift.o : /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/RFC1123.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/URL+HTTP.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/Forwarded.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/MediaTypePreference.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPMessage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaderName.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPScheme.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPResponse.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookies.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaders.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClient.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBody.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOZlib/include/CNIOZlib.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/CNIOHTTPParser.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/PostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentPostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Redis.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/Exports~partial.swiftmodule : /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/RFC1123.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/URL+HTTP.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/Forwarded.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/MediaTypePreference.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPMessage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaderName.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPScheme.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPResponse.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookies.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaders.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClient.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBody.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOZlib/include/CNIOZlib.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/CNIOHTTPParser.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/PostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentPostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Redis.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/Exports~partial.swiftdoc : /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/RFC1123.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/URL+HTTP.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/Forwarded.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/MediaTypePreference.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPMessage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaderName.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPScheme.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPResponse.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookies.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaders.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClient.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBody.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOZlib/include/CNIOZlib.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/CNIOHTTPParser.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/PostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentPostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Redis.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/Exports~partial.swiftsourceinfo : /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/RFC1123.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/URL+HTTP.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Basic.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/Forwarded.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/MediaTypePreference.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyStorage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPMessage.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBodyRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaderName.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPScheme.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPResponse.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookieValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPChunkedStream.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClientProtocolUpgrader.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServerResponder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Codable/HTTPMessageCoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPHeaders+Bearer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPServer.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/HTTPError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Cookies/HTTPCookies.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPHeaders.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Utilities/String+IsIPAddress.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Responder/HTTPClient.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Message/HTTPRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/http/Sources/HTTP/Body/HTTPBody.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOZlib/include/CNIOZlib.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/CNIOHTTPParser.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include/c_nio_http_parser.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/PostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentPostgreSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Redis.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppUsers/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
module siren.mysql.sirl.node_visitor; import siren.mysql.util; import siren.mysql.util; import siren.sirl; import std.array; import std.conv; class MySQLNodeVisitor : NodeVisitor { private: Appender!string _buffer; public: this() { _buffer = appender!string; } @property string data() { return _buffer.data; } override void visit(AndNode node) { node.left.accept(this); _buffer ~= " AND "; node.right.accept(this); } override void visit(ArithmeticNode node) { node.left.accept(this); _buffer ~= " " ~ node.operator ~ " "; node.right.accept(this); } override void visit(AssignNode node) { node.left.accept(this); _buffer ~= " = "; node.right.accept(this); } override void visit(DeleteNode node) { _buffer ~= "DELETE FROM "; node.table.accept(this); if(node.where !is null) { _buffer ~= " "; node.where.accept(this); } } override void visit(EqualityNode node) { node.left.accept(this); _buffer ~= " " ~ node.operator ~ " "; node.right.accept(this); } override void visit(FieldNode node) { if(node.table.length > 0) { _buffer ~= node.table.quoteName; _buffer ~= "."; } _buffer ~= node.field.quoteName; } override void visit(InNode node) { node.left.accept(this); _buffer ~= " " ~ node.operator ~ " "; node.right.accept(this); } override void visit(InsertNode node) { _buffer ~= "INSERT INTO "; node.table.accept(this); if(node.fields.length > 0) { _buffer ~= "("; foreach(index, field; node.fields) { field.accept(this); if(index < node.fields.length - 1) { _buffer ~= ", "; } } _buffer ~= ")"; } if(node.values !is null) { _buffer ~= " "; node.values.accept(this); } } override void visit(IsNullNode node) { node.operand.accept(this); _buffer ~= " " ~ node.operator; } override void visit(LimitNode node) { _buffer ~= "LIMIT "; _buffer ~= node.limit.text; } override void visit(LiteralNode node) { _buffer ~= node.value.expandParameter; } override void visit(NotNode node) { _buffer ~= "NOT "; node.operand.accept(this); } override void visit(OffsetNode node) { _buffer ~= "OFFSET "; _buffer ~= node.offset.text; } override void visit(OrNode node) { node.left.accept(this); _buffer ~= " OR "; node.right.accept(this); } override void visit(OrderNode node) { node.field.accept(this); _buffer ~= " " ~ node.direction; } override void visit(RelationNode node) { node.left.accept(this); _buffer ~= " " ~ node.operator ~ " "; node.right.accept(this); } override void visit(SelectNode node) { _buffer ~= "SELECT "; if(node.projection.length > 0) { foreach(index, field; node.projection) { field.accept(this); if(index < node.projection.length - 1) { _buffer ~= ", "; } } } else { FieldNode.create(node.table.table, null).accept(this); } _buffer ~= " FROM "; node.table.accept(this); if(node.where !is null) { _buffer ~= " "; node.where.accept(this); } if(node.orders.length > 0) { _buffer ~= " ORDER BY "; foreach(index, order; node.orders) { order.accept(this); if(index < node.orders.length - 1) { _buffer ~= ", "; } } } if(node.limit !is null) { _buffer ~= " "; node.limit.accept(this); } if(node.offset !is null) { _buffer ~= " "; node.offset.accept(this); } } override void visit(SetNode node) { _buffer ~= "SET "; foreach(index, set; node.sets) { set.accept(this); if(index < node.sets.length - 1) { _buffer ~= ", "; } } } override void visit(TableNode node) { if(node.database.length > 0) { _buffer ~= node.database.quoteName; _buffer ~= "."; } _buffer ~= node.table.quoteName; } override void visit(UpdateNode node) { _buffer ~= "UPDATE "; node.table.accept(this); if(node.set !is null) { _buffer ~= " "; node.set.accept(this); } if(node.where !is null) { _buffer ~= " "; node.where.accept(this); } } override void visit(ValuesNode node) { _buffer ~= "VALUES("; foreach(index, value; node.values) { value.accept(this); if(index < node.values.length - 1) { _buffer ~= ", "; } } _buffer ~= ")"; } override void visit(WhereNode node) { _buffer ~= "WHERE "; foreach(index, clause; node.clauses) { clause.accept(this); if(index < node.clauses.length - 1) { _buffer ~= " AND "; } } } }
D
instance PC_Fighter_NW_vor_DJG(Npc_Default) { name[0] = "Горн"; guild = GIL_SLD; id = 813; voice = 12; flags = 0; npcType = NPCTYPE_FRIEND; B_SetAttributesToChapter(self,6); fight_tactic = FAI_HUMAN_MASTER; B_CreateAmbientInv(self); B_SetNpcVisual(self,MALE,"Hum_Head_Fighter",Face_B_Gorn,BodyTex_B,ItAr_Sld_H); Mdl_SetModelFatness(self,0); Mdl_ApplyOverlayMds(self,"Humans_Militia.mds"); B_GiveNpcTalents(self); B_SetFightSkills(self,70); daily_routine = Rtn_Start_813; }; func void Rtn_Start_813() { TA_Sit_Chair(8,0,23,0,"NW_BIGFARM_HOUSE_14"); TA_Sit_Chair(23,0,8,0,"NW_BIGFARM_HOUSE_14"); }; func void Rtn_Tot_813() { TA_Sit_Campfire(8,0,23,0,"TOT"); TA_Sit_Campfire(23,0,8,0,"TOT"); };
D
import d2d.engine; int main(char[][] args) { auto engine = new Engine(args); engine.run(); return 0; }
D
instance NONE_117_NERGAL_EXIT(C_Info) { npc = none_117_nergal; nr = 999; condition = none_117_nergal_exit_condition; information = none_117_nergal_exit_info; permanent = TRUE; description = Dialog_Ende; }; func int none_117_nergal_exit_condition() { return TRUE; }; func void none_117_nergal_exit_info() { AI_StopProcessInfos(self); }; instance NONE_117_NERGAL_HALLO(C_Info) { npc = none_117_nergal; condition = none_117_nergal_hallo_condition; information = none_117_nergal_hallo_info; permanent = FALSE; important = TRUE; }; func int none_117_nergal_hallo_condition() { if(XARDASRITUALFAIL == TRUE) { return TRUE; }; }; func void none_117_nergal_hallo_info() { self.name[0] = "Duše Nergala"; B_GivePlayerXP(100); //Wld_PlayEffect("DEMENTOR_FX",hero,hero,0,0,0,FALSE); Wld_PlayEffect("spellFX_Fear",self,self,0,0,0,FALSE); Snd_Play("DEM_Warn"); AI_Output(self,other,"NONE_117_Nergal_Hallo_01_01"); //(mrtvolně) SMRTELNÍKU... Měl bych ti poděkovat. AI_Output(other,self,"NONE_117_Nergal_Hallo_01_02"); //Za co? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_03"); //Žes mě zbavil povinnosti odpovědět na otázky toho neschopného starého mága. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_04"); //Za tvou službu bych tě měl odměnit... (mrtvolně) Dovolím ti zemřít! AI_Output(other,self,"NONE_117_Nergal_Hallo_01_06"); //No, když mě stejně zabiješ, mohl bys mi alespoň na něco odpovědět? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_07"); //Chceš se na něco zeptat? Dobře tedy, ptej se. AI_Output(other,self,"NONE_117_Nergal_Hallo_01_08"); //Řekni mi, kde můžu najít Nekronomikon? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_09"); //Nekronomikon?! Tys mě sem přivolal, aby ses dozvěděl, kde jsem ten pradávný artefakt ukryl? AI_Output(other,self,"NONE_117_Nergal_Hallo_01_10"); //Je pro tebe důležitý? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_11"); //Ne, vůbec ne... Příčiny můžou být někdy různé, no výsledek je nakonec vždycky jenom jeden! AI_Output(other,self,"NONE_117_Nergal_Hallo_01_12"); //Zavři tlamu! Prostě mi odpověz. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_13"); //Jsi nějaký drzý, jak vidím... To se mi líbí! AI_Output(self,other,"NONE_117_Nergal_Hallo_01_14"); //Dobrá tedy! Odpovím ti na tvou otázku, protože odpověď ti stejně k ničemu nebude. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_15"); //Tu relikvii jsem skryl tam, kde se k ní žádný smrtelník jako ty nikdy nedostane... AI_Output(self,other,"NONE_117_Nergal_Hallo_01_17"); //Na vrchol temné věže Acheron! AI_Output(other,self,"NONE_117_Nergal_Hallo_01_18"); //Věž Acheron? A ta je kde? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_19"); //Už si přesně nepamatuji... (nostalgicky) Je to už dávno... AI_Output(other,self,"NONE_117_Nergal_Hallo_01_20"); //Tím pádem mi tedy stačí najít tu věži a artefakt bude v mé moci. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_21"); //Není to tak jednoduché, smrtelníku... Můj poklad střeží nemrtvé stvoření Temnoty, které nikdy neporazíš. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_22"); //Určitě se o to už mnozí pokoušeli! A jsem si jistý, že jsou teď všichni mrtví. AI_Output(other,self,"NONE_117_Nergal_Hallo_01_23"); //Není žádný způsob, jak to stvoření zneškodnit? AI_Output(self,other,"NONE_117_Nergal_Hallo_01_24"); //Jistěže je! Ale neprozradím ti ho... Proto se na něj raději ani neptej! AI_Output(other,self,"NONE_117_Nergal_Hallo_01_25"); //Fajn, díky za odpovědi. AI_Output(self,other,"NONE_117_Nergal_Hallo_01_26"); //Nemáš za co! A teď se připrav na smrt... Teď tě zničím! B_LogEntry(TOPIC_XARDASTASKSFOUR,"Duše nekromanta Nergala se mnou začala mluvit a než se mě pokusila zabít, souhlasila, že mi odpoví na otázku ohledně Nekronomikonu. Jak vysvitlo, tenhle artefakt je momentálně ukrytý na vrcholu temné věže Acheron. Nergal si už ale přesně nepamatuje, kde tahle věž stojí. Vstup navíc střeží nesmrtelná bytost stvořena samotnou Temnotou! Je sice nemožné jí zabít, ale jeden způsob, jak ji přemoci, přeci jen existuje. Na tuhle otázku mi ale samozřejmě Nergal neodpověděl. Teď je nejdůležitější najít věži a pak si rozmyslet, jak můžu přemoci tu příšeru."); KNOWWHERENERCONOMICON = TRUE; Info_ClearChoices(none_117_nergal_hallo); Info_AddChoice(none_117_nergal_hallo,"Tak to tedy zkus.",none_117_nergal_hallo_ex1); }; func void none_117_nergal_hallo_ex1() { AI_Output(other,self,"NONE_117_Nergal_Hallo_Ex1_01_01"); //Tak to tedy zkus. AI_Output(self,other,"NONE_117_Nergal_Hallo_Ex1_01_02"); //Arrgh... (mrtvolně) self.flags = NPC_FLAG_NONE; Wld_StopEffect("DEMENTOR_FX"); AI_StopProcessInfos(self); self.aivar[AIV_EnemyOverride] = FALSE; };
D
prototype MST_DEFAULT_DRAGON_FIRE(C_NPC) { name[0] = "Огненный дракон"; guild = GIL_DRAGON; aivar[AIV_MM_REAL_ID] = ID_DRAGON_FIRE; level = 450; bodystateinterruptableoverride = TRUE; // attribute[ATR_STRENGTH] = 140; attribute[ATR_STRENGTH] = 13; attribute[ATR_DEXTERITY] = 100; attribute[ATR_HITPOINTS_MAX] = 700; attribute[ATR_HITPOINTS] = 700; attribute[ATR_MANA_MAX] = 1000; attribute[ATR_MANA] = 1000; protection[PROT_BLUNT] = 100; protection[PROT_EDGE] = 100; protection[PROT_POINT] = 100; protection[PROT_FIRE] = 50; protection[PROT_FLY] = IMMUNE; protection[PROT_MAGIC] = 50; damagetype = DAM_FLY; fight_tactic = FAI_DRAGON; senses = SENSE_HEAR | SENSE_SEE | SENSE_SMELL; senses_range = PERC_DIST_DRAGON_ACTIVE_MAX; aivar[AIV_MM_FOLLOWTIME] = FOLLOWTIME_MEDIUM; aivar[AIV_MM_FOLLOWINWATER] = FALSE; aivar[AIV_MAXDISTTOWP] = 700; aivar[AIV_ORIGINALFIGHTTACTIC] = FAI_DRAGON; start_aistate = zs_mm_rtn_dragonrest; aivar[AIV_MM_RESTSTART] = ONLYROUTINE; }; func void b_setvisuals_dragon_fire() { Mdl_SetVisual(self,"Dragon.mds"); Mdl_SetVisualBody(self,"Dragon_FIRE_Body",DEFAULT,DEFAULT,"",DEFAULT,DEFAULT,-1); }; instance DRAGON_FIRE(MST_DEFAULT_DRAGON_FIRE) { name[0] = "Феоматар"; flags = NPC_FLAG_IMMORTAL; b_setvisuals_dragon_fire(); Npc_SetToFistMode(self); }; instance DRAGON_FIRE_ISLAND(MST_DEFAULT_DRAGON_FIRE) { name[0] = "Феодарон"; flags = NPC_FLAG_IMMORTAL; b_setvisuals_dragon_fire(); Npc_SetToFistMode(self); };
D
PLONG PLAT ED95 KD LOMAGAGE HIMAGAGE SLAT SLONG RESULTNO DP DM ROCKTYPE 244.5 81.6999969 9.80000019 0 2 10 -9.60000038 119.300003 1209 5.80000019 10.6999998 extrusives 249.300003 82.3000031 8.60000038 0 2 10 -9.69999981 120.099998 1208 5.0999999 9.39999962 sediments, tuffs 270.5 80.4000015 0 125 5 23 -32.5 138.5 1976 8.39999962 8.39999962 sediments, red clays 256.899994 86.9000015 0 88 5 23 -36 137 1974 8.39999962 8.39999962 sediments, weathered
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.typecons; alias T = Tuple!(long, long, long); long[] vs; long[T] memo; long n, k; long f(long l, long r, long m) { auto key = tuple(l, r, m); if (key in memo) return memo[key]; if (m < 0 || n-r-1 < l) return 0; long[] cands = [0]; cands ~= vs[l] + f(l+1, r , m-1); cands ~= vs[$-r-1] + f(l , r+1, m-1); if (m > 1) { cands ~= f(l+1, r , m-2); cands ~= f(l , r+1, m-2); } memo[key] = cands.reduce!max; return memo[key]; } void main() { scanf("%ld %ld\n", &n, &k); vs = readln.chomp.split.to!(long[]); f(0, 0, k-1).write; }
D
func void b_enter_newworld_kapitel_1() { }; var int enternw_kapitel2; func void b_enter_newworld_kapitel_2() { if(ENTERNW_KAPITEL2 == FALSE) { Wld_InsertNpc(bloodfly,"FP_ROAM_CITY_TO_FOREST_50"); Wld_InsertNpc(bloodfly,"FP_ROAM_CITY_TO_FOREST_49"); Wld_InsertNpc(wolf,"NW_CITY_TO_FOREST_10"); Wld_InsertNpc(wolf,"NW_CITY_TO_FOREST_05"); Wld_InsertNpc(sheep,"NW_FARM3_MOUNTAINLAKE_05"); Wld_InsertNpc(sheep,"NW_FARM3_MOUNTAINLAKE_05"); Wld_InsertNpc(scavenger,"NW_TROLLAREA_PLANE_05"); Wld_InsertNpc(scavenger,"NW_TROLLAREA_PLANE_05"); Wld_InsertNpc(scavenger,"NW_TROLLAREA_PLANE_06"); Wld_InsertNpc(scavenger,"NW_TROLLAREA_PLANE_04"); Wld_InsertNpc(scavenger,"NW_TROLLAREA_PLANE_04"); Wld_InsertNpc(lurker,"NW_TROLLAREA_PATH_72"); Wld_InsertNpc(lurker,"NW_TROLLAREA_PATH_72"); Wld_InsertNpc(lurker,"NW_TROLLAREA_PATH_75"); Wld_InsertNpc(waran,"NW_TROLLAREA_PATH_22_MONSTER"); Wld_InsertNpc(waran,"NW_TROLLAREA_PATH_22_MONSTER"); Wld_InsertNpc(molerat,"FP_ROAM_CITY_TO_FOREST_41"); Wld_InsertNpc(scavenger,"NW_FOREST_CONNECT_MONSTER2"); Wld_InsertNpc(scavenger,"NW_FOREST_CONNECT_MONSTER2"); Wld_InsertNpc(wolf,"NW_SHRINE_MONSTER"); Wld_InsertNpc(wolf,"NW_SHRINE_MONSTER"); Wld_InsertNpc(giant_bug,"NW_PATH_TO_MONASTER_AREA_01"); Wld_InsertNpc(giant_bug,"NW_PATH_TO_MONASTER_AREA_01"); Wld_InsertNpc(scavenger,"NW_PATH_TO_MONASTER_AREA_11"); Wld_InsertNpc(scavenger,"NW_PATH_TO_MONASTER_MONSTER22"); Wld_InsertNpc(giant_bug,"NW_FARM1_CITYWALL_RIGHT_02"); Wld_InsertNpc(wolf,"NW_FARM1_PATH_CITY_10_B"); Wld_InsertNpc(wolf,"NW_FARM1_PATH_CITY_SHEEP_04"); Wld_InsertNpc(giant_bug,"NW_FARM1_PATH_SPAWN_07"); Wld_InsertNpc(bloodfly,"FP_ROAM_CITY_TO_FOREST_34"); Wld_InsertNpc(bloodfly,"FP_ROAM_CITY_TO_FOREST_36"); Wld_InsertNpc(scavenger,"NW_TAVERNE_BIGFARM_MONSTER_01"); Wld_InsertNpc(scavenger,"NW_TAVERNE_BIGFARM_MONSTER_01"); Wld_InsertNpc(lurker,"NW_BIGFARM_LAKE_MONSTER_02_01"); Wld_InsertNpc(gobbo_black,"NW_BIGFARM_LAKE_03_MOVEMENT"); Wld_InsertNpc(gobbo_black,"NW_BIGFARM_LAKE_03_MOVEMENT"); Wld_InsertNpc(gobbo_black,"NW_TAVERNE_TROLLAREA_MONSTER_05_01"); Wld_InsertNpc(gobbo_green,"NW_BIGFARM_LAKE_MONSTER_05_01"); Wld_InsertNpc(gobbo_green,"NW_BIGFARM_LAKE_MONSTER_05_01"); Wld_InsertNpc(gobbo_green,"NW_BIGFARM_LAKE_MONSTER_05_01"); if((hero.guild == GIL_MIL) || (hero.guild == GIL_PAL)) { Wld_InsertItem(itam_dex_01,"FP_ROAM_XARDAS_SECRET_26"); } else if((hero.guild == GIL_SLD) || (hero.guild == GIL_DJG)) { Wld_InsertItem(itam_hp_01,"FP_ROAM_XARDAS_SECRET_26"); } else { Wld_InsertItem(itam_hp_mana_01,"FP_ROAM_XARDAS_SECRET_26"); }; if(hero.guild == GIL_KDF) { b_startotherroutine(agon,"StillAlive"); }; ENTERNW_KAPITEL2 = TRUE; }; }; var int enternw_kapitel3; func void b_enter_newworld_kapitel_3() { if(ENTERNW_KAPITEL3 == FALSE) { if(Npc_IsDead(salandril) == FALSE) { salandril.aivar[AIV_TOUGHGUY] = TRUE; }; cornelius.flags = 0; if(!Npc_IsDead(hodges)) { b_startotherroutine(hodges,"BENNETWEG"); }; if(Npc_IsDead(diegonw)) { Wld_InsertNpc(pc_thief_nw,"NW_CITY_ENTRANCE_01"); b_startotherroutine(diegonw,"START"); }; if(Npc_IsDead(gornnw_vor_djg)) { Wld_InsertNpc(pc_fighter_nw_vor_djg,"BIGFARM"); b_startotherroutine(gornnw_vor_djg,"START"); }; if(Npc_IsDead(lares) == FALSE) { b_startotherroutine(lares,"START"); }; Wld_InsertNpc(dmt_dementorambientspeaker,"NW_PASS_GATE_02"); b_killnpc(pal_297_ritter); b_killnpc(pal_298_ritter); if(hero.guild == GIL_KDF) { b_killnpc(ulf); }; Wld_InsertNpc(giant_bug,"FP_ROAM_MEDIUMFOREST_KAP2_01"); Wld_InsertNpc(giant_bug,"FP_ROAM_MEDIUMFOREST_KAP2_02"); Wld_InsertNpc(giant_bug,"FP_ROAM_MEDIUMFOREST_KAP2_05"); if(Npc_IsDead(sekob) == FALSE) { b_startotherroutine(sekob,"FleeDMT"); b_startotherroutine(rosi,"FleeDMT"); b_startotherroutine(till,"FleeDMT"); b_startotherroutine(balthasar,"FleeDMT"); b_startotherroutine(bau_933_rega,"FleeDMT"); b_startotherroutine(bau_934_babera,"FleeDMT"); b_startotherroutine(bau_937_bauer,"FleeDMT"); b_startotherroutine(bau_938_bauer,"FleeDMT"); Wld_InsertNpc(dmt_dementorambientsekob1,"NW_FARM4_IN_06"); Wld_InsertNpc(dmt_dementorambientsekob2,"NW_FARM4_IN_02"); Wld_InsertNpc(dmt_dementorambientsekob3,"NW_FARM4_IN_03"); Wld_InsertNpc(dmt_dementorambientsekob4,"NW_FARM4_IN_04"); sekob.flags = NPC_FLAG_IMMORTAL; }; b_startotherroutine(lester,"WAITFORPLAYER"); b_startotherroutine(bennet,"PRISON"); b_startotherroutine(sergio,"WAIT"); b_startotherroutine(peck,"STORAGE"); b_removenpc(pal_203_lothar); Wld_InsertNpc(wolf,"NW_PATH_TO_MONASTER_AREA_10"); Wld_InsertNpc(warg,"NW_XARDAS_GOBBO_01"); Wld_InsertNpc(warg,"NW_XARDAS_GOBBO_01"); Wld_InsertNpc(zombie02,"NW_FARM4_WOOD_MONSTER_MORE_02"); Wld_InsertNpc(zombie01,"NW_FARM4_WOOD_MONSTER_MORE_02"); Wld_InsertNpc(zombie02,"NW_BIGFARM_LAKE_03_MOVEMENT5"); Wld_InsertNpc(skeleton,"NW_FARM4_WOOD_MONSTER_MORE_01"); Wld_InsertNpc(skeleton,"NW_FARM4_WOOD_MONSTER_MORE_01"); Wld_InsertNpc(giant_bug,"NW_FARM4_WOOD_MONSTER_N_1_MONSTER"); Wld_InsertNpc(giant_bug,"NW_FARM4_WOOD_MONSTER_N_3"); Wld_InsertNpc(shadowbeast,"NW_FARM4_WOOD_MONSTER_05"); Wld_InsertNpc(dragonsnapper,"NW_FARM4_WOOD_MONSTER_05"); Wld_InsertNpc(dragonsnapper,"NW_FARM4_WOOD_MONSTER_05"); Wld_InsertNpc(dragonsnapper,"NW_CASTLEMINE_TROLL_02"); Wld_InsertNpc(dragonsnapper,"NW_CASTLEMINE_TROLL_02"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_PATH_11_SMALLRIVER_10"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_PATH_11_SMALLRIVER_10"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_MOUNTAINLAKE_03"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_BIGWOOD_03_C"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_BIGWOOD_03_C"); Wld_InsertNpc(dmt_dementorambientspeaker,"NW_CITY_TO_FARM2_03"); Wld_InsertNpc(dmt_dementorambient,"FP_ROAM_NW_BIGFARM_FELDREUBER11"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_02"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_03"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_04"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_05"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_06"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_CITY_TO_FOREST_01"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_CITY_TO_FOREST_15"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_07"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_08"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_09"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_10"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_11"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_12"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_13"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_14"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_15"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_16"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_17"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_18"); Wld_InsertNpc(dmt_dementorambientwalker11,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker9,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker6,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker3,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker1,"CITY1"); Wld_InsertNpc(bdt_1025_bandit_h,"NW_FOREST_CAVE1_02"); Wld_InsertNpc(bdt_1026_bandit_h,"NW_FOREST_CAVE1_03"); Wld_InsertNpc(bdt_1027_bandit_h,"NW_FOREST_CAVE1_04"); Wld_InsertNpc(follow_sheep_akil,"NW_FOREST_CAVE1_IN_02"); if(Npc_IsDead(malak) == FALSE) { b_startotherroutine(malak,"FleeFromPass"); MALAK_ISALIVE_KAP3 = TRUE; b_startotherroutine(bau_962_bauer,"FleeFromPass"); b_startotherroutine(bau_964_bauer,"FleeFromPass"); b_startotherroutine(bau_965_bauer,"FleeFromPass"); b_startotherroutine(bau_966_bauer,"FleeFromPass"); b_startotherroutine(bau_967_bauer,"FleeFromPass"); b_startotherroutine(bau_968_bauer,"FleeFromPass"); b_startotherroutine(bau_969_bauer,"FleeFromPass"); if(hero.guild == GIL_KDF) { CreateInvItems(malak,itwr_dementorobsessionbook_mis,1); }; }; if((hero.guild == GIL_MIL) || (hero.guild == GIL_PAL)) { b_startotherroutine(hilda,"Krank"); }; if((hero.guild == GIL_SLD) || (hero.guild == GIL_DJG)) { Wld_InsertItem(itmw_malethsgehstock_mis,"FP_ITEM_FARM1_01"); Wld_InsertNpc(shadowbeast,"NW_LITTLESTONEHENDGE"); Wld_InsertNpc(bdt_1024_malethsbandit,"NW_FARM1_BANDITS_CAVE_08"); Wld_InsertNpc(bdt_1006_bandit_h,"FP_STAND_DEMENTOR_KDF_29"); Wld_InsertNpc(bdt_1007_bandit_h,"FP_STAND_DEMENTOR_KDF_30"); Wld_InsertNpc(bdt_1008_bandit_h,"NW_FARM1_BANDITS_CAVE_03"); Wld_InsertNpc(bdt_1004_bandit_m,"NW_FARM1_BANDITS_CAVE_02"); Wld_InsertNpc(bdt_1005_bandit_m,"NW_FARM1_BANDITS_CAVE_04"); }; if(hero.guild == GIL_KDF) { Wld_InsertItem(itmi_karrasblessedstone_mis,"FP_ITEM_FARM1_03"); Wld_InsertItem(itmi_karrasblessedstone_mis,"FP_NW_ITEM_TROLL_10"); b_startotherroutine(hilda,"KRANK"); if(Npc_IsDead(vino) == FALSE) { b_startotherroutine(vino,"OBESESSIONRITUAL"); CreateInvItems(vino,itwr_dementorobsessionbook_mis,1); VINO_ISALIVE_KAP3 = TRUE; b_startotherroutine(lobart,"OBESESSIONRITUAL"); Wld_InsertNpc(dmt_dementorspeakervino1,"FP_STAND_DEMENTOR_KDF_31"); Wld_InsertNpc(dmt_dementorspeakervino2,"FP_STAND_DEMENTOR_KDF_32"); Wld_InsertNpc(dmt_dementorspeakervino3,"FP_STAND_DEMENTOR_KDF_33"); Wld_InsertNpc(dmt_dementorspeakervino4,"NW_LITTLESTONEHENDGE_02"); b_killnpc(ygiant_bug_vinoritual1); b_killnpc(ygiant_bug_vinoritual2); }; if(Npc_IsDead(bromor) == FALSE) { CreateInvItems(bromor,itwr_dementorobsessionbook_mis,1); }; }; if((MIS_CANTHARS_KOMPROBRIEF != LOG_SUCCESS) && (MIS_CANTHARS_KOMPROBRIEF != FALSE) && (CANTHAR_PAY == FALSE) && (Npc_IsDead(canthar) == FALSE)) { b_removenpc(sarah); b_startotherroutine(canthar,"MARKTSTAND"); AI_Teleport(canthar,"NW_CITY_SARAH"); CANTHAR_SPERRE = TRUE; CANTHAR_WIEDERRAUS = TRUE; }; CreateInvItems(lester,itmw_1h_bau_axe,1); CreateInvItems(ehnim,itmi_moleratlubric_mis,1); SHRINEISOBSESSED_NW_TROLLAREA_PATH_37 = TRUE; SHRINEISOBSESSED_NW_FARM1_CONNECT_XARDAS = TRUE; SHRINEISOBSESSED_NW_TROLLAREA_PATH_66 = TRUE; SHRINEISOBSESSED_NW_TROLLAREA_PATH_04 = TRUE; SHRINEISOBSESSED_SAGITTA = TRUE; SHRINEISOBSESSED_NW_BIGMILL_MALAKSVERSTECK_02 = TRUE; SHRINEISOBSESSED_NW_FARM3_BIGWOOD_02 = TRUE; if((hero.guild == GIL_MIL) || (hero.guild == GIL_PAL)) { IntroduceChapter(KAPWECHSEL_3,KAPWECHSEL_3_TEXT,"chapter3_MIL.tga","chapter_01.wav",6000); } else if(hero.guild == GIL_KDF) { IntroduceChapter(KAPWECHSEL_3,KAPWECHSEL_3_TEXT,"chapter3_KDF.tga","chapter_01.wav",6000); } else { IntroduceChapter(KAPWECHSEL_3,KAPWECHSEL_3_TEXT,"chapter3_SLD.tga","chapter_01.wav",6000); }; ENTERNW_KAPITEL3 = TRUE; }; }; var int enternw_kapitel4; func void b_enter_newworld_kapitel_4() { if(ENTERNW_KAPITEL4 == FALSE) { if(Npc_GetDistToWP(salandril,"ALTAR") < 10000) { b_startotherroutine(salandril,"Start"); }; b_startotherroutine(jorgen,"Kloster"); b_killnpc(bdt_1050_landstreicher); if(!Npc_IsDead(Sekob)) { Sekob.flags = 0; }; Wld_InsertItem(itat_dragonegg_mis,"FP_ITEM_XARDAS_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDASCAVE_DJG_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDASCAVE_DJG_02"); Wld_InsertNpc(draconian,"FP_ROAM_XARDASCAVE_DJG_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_12"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_10"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_09"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_VALLEY_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_VALLEY_01"); Wld_InsertNpc(orcelite_antipaladin,"NW_TROLLAREA_PLANE_05"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_PATH_44"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_PLANE_06"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_BIGWOOD_04"); Wld_InsertNpc(dragonsnapper,"NW_FARM3_BIGWOOD_04"); if(hero.guild == GIL_PAL) { Wld_InsertNpc(orcelite_antipaladin1,"NW_FARM3_PATH_BRIDGE"); Wld_InsertNpc(orcelite_antipaladin2,"NW_FARM1_PATH_CITY_13"); Wld_InsertNpc(orcelite_antipaladin3,"NW_CITY_TO_FOREST_11"); Wld_InsertNpc(orcelite_antipaladin,"NW_FARM3_PATH_12_MONSTER_03"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM3_PATH_12_MONSTER_03"); Wld_InsertNpc(orcelite_antipaladin,"NW_FARM3_PATH_10"); Wld_InsertNpc(orcelite_antipaladin,"NW_BIGFARM_LAKE_06"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_NW_BIGFARM_LAKE_MONSTER_01_04"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_NW_BIGFARM_LAKE_MONSTER_01_02"); Wld_InsertNpc(orcelite_antipaladin,"NW_TAVERNE_TROLLAREA_08"); Wld_InsertNpc(orcelite_antipaladin,"FP_ROAM_TAVERNE_TROLLAREA_03_02"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_TAVERNE_TROLLAREA_03_01"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_TAVERNE_TROLLAREA_03_03"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_TAVERNE_TROLLAREA_03_04"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_TAVERNE_TROLLAREA_03_05"); Wld_InsertNpc(orcelite_antipaladin,"NW_TROLLAREA_PATH_62"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_PATH_62"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_RIVERSIDE_07"); Wld_InsertNpc(orcelite_antipaladin,"NW_TROLLAREA_RITUAL_01"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_RITUAL_02"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_RITUAL_03"); Wld_InsertNpc(orcwarrior_roam,"NW_TROLLAREA_RITUAL_04"); Wld_InsertNpc(orcelite_antipaladin,"NW_FOREST_PATH_32"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM2_TO_TAVERN_10"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM3_PATH_12_MONSTER_01"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM3_PATH_12_MONSTER_02"); Wld_InsertNpc(orcelite_antipaladin,"FP_ROAM_XARDAS_GOBBO_01"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_XARDAS_GOBBO_02"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_XARDAS_GOBBO_03"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_GOBBO_02"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_GOBBO_03"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_GOBBO_04"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_WOLF_01"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_WOLF_02"); Wld_InsertNpc(orcwarrior_rest,"FP_ROAM_FARM1_WOLF_03"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_CITY_TO_FOREST_39"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_CITY_TO_FOREST_42"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_CITY_TO_FOREST_41"); Wld_InsertNpc(orcelite_antipaladin,"XARDAS"); Wld_InsertNpc(orcelite_antipaladin,"NW_BIGFARM_FARM4_PATH_04"); Wld_InsertNpc(orcwarrior_roam,"FP_PICK_NW_FARM4_FIELD_01"); Wld_InsertNpc(orcwarrior_roam,"FP_PICK_NW_FARM4_FIELD_04"); Wld_InsertNpc(orcwarrior_roam,"FP_PICK_NW_FARM4_FIELD_05"); Wld_InsertNpc(orcwarrior_roam,"FP_PICK_NW_FARM4_FIELD_02"); Wld_InsertNpc(orcwarrior_roam,"FP_PICK_NW_FARM4_FIELD_06"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM4_BRONKO"); Wld_InsertNpc(orcelite_antipaladin,"NW_PATH_TO_MONASTERY_06"); Wld_InsertNpc(orcwarrior_roam,"NW_PATH_TO_MONASTER_AREA_03"); Wld_InsertNpc(orcwarrior_roam,"NW_PATH_TO_MONASTERY_05"); Wld_InsertNpc(orcwarrior_roam,"NW_PATH_TO_MONASTER_AREA_09"); Wld_InsertNpc(orcwarrior_roam,"NW_PATH_TO_MONASTER_AREA_05"); Wld_InsertNpc(orcelite_antipaladin,"BIGCROSS"); Wld_InsertNpc(orcelite_antipaladin,"NW_FARM2_TO_TAVERN_05"); Wld_InsertNpc(orcwarrior_roam,"NW_FARM2_TO_TAVERN_05"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_CITY_TO_FOREST_45"); Wld_InsertNpc(orcwarrior_roam,"FP_ROAM_CITY_TO_FOREST_44"); Wld_InsertNpc(orkelite_antipaladinorkoberst,"NW_FARM1_BANDITS_CAVE_08"); Wld_InsertNpc(orcelite_antipaladin,"FP_STAND_DEMENTOR_KDF_29"); Wld_InsertNpc(orcelite_antipaladin,"FP_STAND_DEMENTOR_KDF_30"); Wld_InsertNpc(orcelite_antipaladin,"NW_FARM1_BANDITS_CAVE_03"); Wld_InsertNpc(orcelite_antipaladin,"NW_FARM1_BANDITS_CAVE_07"); }; if((hero.guild == GIL_DJG) || (hero.guild == GIL_PAL)) { Wld_InsertNpc(orcwarrior_lobart1,"NW_FARM1_PATH_CITY_SHEEP_04"); Wld_InsertNpc(orcwarrior_lobart2,"NW_FARM1_PATH_CITY_SHEEP_04"); Wld_InsertNpc(orcwarrior_lobart3,"NW_FARM1_PATH_CITY_SHEEP_04"); Wld_InsertNpc(orcwarrior_lobart4,"NW_FARM1_PATH_CITY_SHEEP_01"); Wld_InsertNpc(orcwarrior_lobart5,"NW_FARM1_PATH_CITY_SHEEP_01"); Wld_InsertNpc(orcwarrior_lobart6,"NW_FARM1_PATH_CITY_SHEEP_01"); b_startotherroutine(vino,"BugsThere"); b_startotherroutine(lobartsbauer1,"BugsThere"); b_startotherroutine(lobartsbauer2,"BugsThere"); }; if((hero.guild == GIL_KDF) || (hero.guild == GIL_DJG)) { SHRINEISOBSESSED_NW_TROLLAREA_PATH_37 = FALSE; SHRINEISOBSESSED_NW_FARM1_CONNECT_XARDAS = FALSE; SHRINEISOBSESSED_NW_TROLLAREA_PATH_66 = FALSE; SHRINEISOBSESSED_NW_TROLLAREA_PATH_04 = FALSE; SHRINEISOBSESSED_SAGITTA = FALSE; SHRINEISOBSESSED_NW_BIGMILL_MALAKSVERSTECK_02 = FALSE; SHRINEISOBSESSED_NW_FARM3_BIGWOOD_02 = FALSE; }; if(hero.guild == GIL_DJG) { Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_RIVERSIDE_EGG"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_06"); Wld_InsertNpc(draconian,"NW_TROLLAREA_RIVERSIDE_05"); Wld_InsertNpc(draconian,"NW_TROLLAREA_RIVERSIDE_04"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_07"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_MAGECAVE_EGG"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_16"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_19"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_19"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_19"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_01"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_02"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_11"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_06"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_07"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_08"); Wld_InsertNpc(draconian,"NW_TROLLAREA_PATH_01_01"); Wld_InsertNpc(draconian,"NW_TROLLAREA_PATH_01"); Wld_InsertNpc(draconian,"NW_TROLLAREA_PATH_01_02"); Wld_InsertNpc(draconian,"FP_ROAM_MAGECAVE_08"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_RITUALFOREST_CAVE_EGG"); Wld_InsertNpc(draconian,"NW_RITUALFOREST_CAVE_06"); Wld_InsertNpc(draconian,"FP_ROAM_RITUALFOREST_CAVE_01"); Wld_InsertNpc(draconian,"FP_ROAM_RITUALFOREST_CAVE_02"); Wld_InsertItem(itat_dragonegg_mis,"FP_ROAM_NW_CITY_SMFOREST_09_04"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_09_03"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_09_02"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_09_01"); Wld_InsertItem(itat_dragonegg_mis,"FP_ROAM_NW_CITY_SMFOREST_05_03"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_05_04"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_05_02"); Wld_InsertNpc(draconian,"FP_ROAM_NW_CITY_SMFOREST_05_01"); Wld_InsertItem(itat_dragonegg_mis,"FP_ROAM_CITYFOREST_KAP3_07"); Wld_InsertNpc(draconian,"FP_ROAM_CITYFOREST_KAP3_06"); Wld_InsertNpc(draconian,"FP_ROAM_CITYFOREST_KAP3_08"); Wld_InsertNpc(draconian,"FP_ROAM_CITYFOREST_KAP3_05"); Wld_InsertItem(itat_dragonegg_mis,"FP_ROAM_CITYFOREST_KAP3_07"); Wld_InsertNpc(draconian,"FP_ROAM_NW_BIGFARMFORESTCAVE_01"); Wld_InsertNpc(draconian,"FP_ROAM_NW_BIGFARMFORESTCAVE_02"); Wld_InsertNpc(draconian,"FP_ROAM_NW_BIGFARMFORESTCAVE_03"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_CASTLEMINE_EGG"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE_01"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE_02"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE_03"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_CASTLEMINE_EGG2"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE_04"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE_05"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_BIGFARMLAKECAVE_EGG"); Wld_InsertNpc(draconian,"FP_ROAM_BIGFARM_LAKE_CAVE_01"); Wld_InsertNpc(draconian,"FP_ROAM_BIGFARM_LAKE_CAVE_02"); Wld_InsertNpc(draconian,"FP_ROAM_BIGFARM_LAKE_CAVE_03"); Wld_InsertNpc(draconian,"FP_ROAM_BIGFARM_LAKE_CAVE_04"); Wld_InsertItem(itat_dragonegg_mis,"FP_NW_ITEM_CASTLEMINE2_EGG"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_16"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_15"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_14"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_13"); Wld_InsertItem(itat_dragonegg_mis,"FP_ITEM_FARM1_02"); Wld_InsertNpc(draconian,"NW_FARM1_BANDITS_CAVE_08"); Wld_InsertNpc(draconian,"FP_STAND_DEMENTOR_KDF_29"); Wld_InsertNpc(draconian,"FP_STAND_DEMENTOR_KDF_30"); Wld_InsertNpc(draconian,"NW_FARM1_BANDITS_CAVE_03"); Wld_InsertNpc(draconian,"NW_FARM1_BANDITS_CAVE_02"); Wld_InsertNpc(draconian,"NW_FARM1_BANDITS_CAVE_04"); Wld_InsertNpc(draconian,"NW_FARM1_BANDITS_CAVE_07"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_03"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_04"); Wld_InsertNpc(draconian,"FP_ROAM_CASTLEMINE2_05"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_VALLEY_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_VALLEY_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_VALLEY_04"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_MONSTER_02_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_MONSTER_02_02"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_MONSTER_02_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_MONSTER_02_04"); Wld_InsertNpc(draconian,"NW_XARDAS_GOBBO_01"); Wld_InsertNpc(draconian,"NW_XARDAS_GOBBO_01"); Wld_InsertNpc(draconian,"NW_XARDAS_GOBBO_02"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_4_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_4_02"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_4_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_TOWER_4_04"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_01"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_02"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_03"); Wld_InsertNpc(draconian,"FP_ROAM_XARDAS_CAVE_04"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_11"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_09"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_10"); Wld_InsertNpc(draconian,"FP_ROAM_TROLLAREA_08"); }; if(hero.guild == GIL_KDF) { Wld_InsertNpc(dmt_dementorambientspeaker,"NW_TROLLAREA_PATH_80"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_TROLLAREA_19"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_CITY_TO_FOREST_44"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_MEDIUMFOREST_KAP2_13"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_XARDAS_TOWER_3_02"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_ROAM_XARDAS_TOWER_3_02"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_04"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_05"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_06"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_07"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_08"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_09"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_10"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_11"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_13"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_14"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_22"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_23"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_24"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_25"); Wld_InsertNpc(dmt_dementorambientwalker10,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker8,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker7,"CITY1"); CreateInvItems(randolph,itwr_dementorobsessionbook_mis,1); b_startotherroutine(randolph,"Obsessed"); }; ENTERNW_KAPITEL4 = TRUE; }; if(TALBIN_FOLLOWSTHROUGHPASS == LOG_RUNNING) { Wld_InsertNpc(vlk_4132_talbin_nw,"LEVELCHANGE"); TALBIN_FOLLOWSTHROUGHPASS = LOG_SUCCESS; }; }; var int enternw_kapitel5; var int pal_schiffswache_exchange_onetime; var int rosi_fleefromsekob_kap5; func void b_enter_newworld_kapitel_5() { if(ENTERNW_KAPITEL5 == FALSE) { b_removenpc(xardas); b_startotherroutine(lester,"XardasWeg"); if(Npc_GetDistToWP(salandril,"ALTAR") < 10000) { b_startotherroutine(salandril,"Start"); }; if(Npc_IsDead(sekob) == FALSE) { b_startotherroutine(rosi,"FleeFromSekob"); b_startotherroutine(till,"FleeFromSekob"); ROSI_FLEEFROMSEKOB_KAP5 = TRUE; }; if(GORNDJG_IS_ALIVE == TRUE) { Wld_InsertNpc(pc_fighter_nw_nach_djg,"BIGFARM"); }; if(DJG_ANGAR_IS_ALIVE == TRUE) { Wld_InsertNpc(djg_705_angar_nw,"BIGFARM"); }; Wld_InsertNpc(xardas_dt_demon1,"FP_ROAM_NW_XARDASTOWER_DEMON_02"); Wld_InsertNpc(xardas_dt_demon2,"NW_XARDAS_TOWER_IN1_24"); Wld_InsertNpc(xardas_dt_demon3,"FP_ROAM_NW_XARDASTOWER_DEMON_03"); Wld_InsertNpc(xardas_dt_demon4,"FP_ROAM_NW_XARDASTOWER_DEMON_04"); Wld_InsertNpc(xardas_dt_demon5,"FP_ROAM_NW_XARDASTOWER_DEMON_05"); Wld_InsertNpc(xardas_dt_demonlord,"FP_ROAM_NW_XARDASTOWER_DEMONLORD_01"); Wld_InsertNpc(bloodfly,"NW_FARM3_PATH_11_SMALLRIVER_15"); Wld_InsertNpc(bloodfly,"NW_FARM3_PATH_11_SMALLRIVER_15"); Wld_InsertNpc(waran,"NW_FARM3_PATH_11_SMALLRIVER_11"); Wld_InsertNpc(waran,"NW_FARM3_PATH_11_SMALLRIVER_11"); Wld_InsertNpc(lurker,"NW_FARM3_MOUNTAINLAKE_05"); Wld_InsertNpc(lurker,"NW_FARM3_MOUNTAINLAKE_05"); Wld_InsertNpc(none_101_mario,"NW_CITY_ENTRANCE_01"); Wld_InsertItem(itwr_hallsofirdorath_mis,"FP_NW_ITEM_LIBRARY_IRDORATHBOOK"); Wld_InsertItem(itwr_seamap_irdorath,"FP_NW_ITEM_LIBRARY_SEAMAP"); Wld_InsertItem(itwr_xardasseamapbook_mis,"FP_NW_ITEM_LIBRARY_SEAMAP"); Wld_InsertItem(itpo_potionofdeath_01_mis,"FP_NW_ITEM_LIBRARY_SEAMAP2"); if(hero.guild == GIL_PAL) { Wld_InsertItem(itar_pal_h,"FP_ITEM_PALFINALARMOR"); Wld_InsertItem(itmi_runeblank,"FP_NW_ITEM_LIBRARY_SEAMAP"); }; if(hero.guild == GIL_DJG) { }; if(hero.guild == GIL_KDF) { Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_01"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_02"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_03"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_15"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_16"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_17"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_18"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_19"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_20"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_21"); Wld_InsertItem(itwr_dementorobsessionbook_mis,"FP_ITEM_FARM1_01"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_29"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_30"); Wld_InsertNpc(dmt_dementorambient,"NW_FARM1_BANDITS_CAVE_08"); Wld_InsertNpc(dmt_dementorambient,"NW_FARM1_BANDITS_CAVE_03"); Wld_InsertNpc(dmt_dementorambient,"NW_FARM1_BANDITS_CAVE_02"); Wld_InsertNpc(dmt_dementorambient,"NW_FARM1_BANDITS_CAVE_04"); Wld_InsertNpc(dmt_dementorambient,"NW_FARM1_BANDITS_CAVE_07"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_34"); Wld_InsertNpc(dmt_dementorambientspeaker,"FP_STAND_DEMENTOR_KDF_35"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_26"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_27"); Wld_InsertNpc(dmt_dementorambient,"FP_STAND_DEMENTOR_KDF_28"); Wld_InsertNpc(dmt_dementorambientwalker5,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker4,"CITY1"); Wld_InsertNpc(dmt_dementorambientwalker2,"CITY1"); if(Npc_IsDead(sekob) == FALSE) { CreateInvItems(sekob,itwr_dementorobsessionbook_mis,1); b_startotherroutine(sekob,"Obsessed"); }; }; Wld_InsertNpc(pal_285_ritter,"CITY1"); Wld_InsertNpc(pal_286_ritter,"CITY1"); Wld_InsertNpc(pal_287_ritter,"CITY1"); Wld_InsertNpc(pal_288_ritter,"CITY1"); Wld_InsertNpc(pal_289_ritter,"CITY1"); Wld_InsertNpc(pal_290_ritter,"CITY1"); Wld_InsertNpc(pal_291_ritter,"CITY1"); Wld_InsertNpc(pal_292_ritter,"CITY1"); Wld_InsertNpc(pal_293_ritter,"CITY1"); schiffswache_212.flags = 0; schiffswache_213.flags = 0; pal_220_schiffswache.flags = 0; pal_221_schiffswache.flags = 0; pal_222_schiffswache.flags = 0; pal_223_schiffswache.flags = 0; pal_224_schiffswache.flags = 0; pal_225_schiffswache.flags = 0; pal_226_schiffswache.flags = 0; pal_227_schiffswache.flags = 0; pal_228_schiffswache.flags = 0; b_startotherroutine(pal_220_schiffswache,"ShipFree"); b_startotherroutine(pal_221_schiffswache,"ShipFree"); b_startotherroutine(pal_222_schiffswache,"ShipFree"); b_startotherroutine(pal_223_schiffswache,"ShipFree"); b_startotherroutine(pal_224_schiffswache,"ShipFree"); b_startotherroutine(pal_225_schiffswache,"ShipFree"); b_startotherroutine(pal_226_schiffswache,"ShipFree"); b_startotherroutine(pal_227_schiffswache,"ShipFree"); b_startotherroutine(pal_228_schiffswache,"ShipFree"); b_startotherroutine(pal_230_ritter,"ShipFree"); b_startotherroutine(pal_231_ritter,"ShipFree"); b_startotherroutine(pal_240_ritter,"ShipFree"); b_startotherroutine(pal_241_ritter,"ShipFree"); if((hero.guild == GIL_MIL) || (hero.guild == GIL_PAL)) { IntroduceChapter(KAPWECHSEL_5,KAPWECHSEL_5_TEXT,"chapter5_PAL.tga","chapter_01.wav",6000); } else if(hero.guild == GIL_KDF) { IntroduceChapter(KAPWECHSEL_5,KAPWECHSEL_5_TEXT,"chapter5_KDF.tga","chapter_01.wav",6000); } else { IntroduceChapter(KAPWECHSEL_5,KAPWECHSEL_5_TEXT,"chapter5_DJG.tga","chapter_01.wav",6000); }; ENTERNW_KAPITEL5 = TRUE; }; if((MIS_OCGATEOPEN == TRUE) && (PAL_SCHIFFSWACHE_EXCHANGE_ONETIME == FALSE)) { b_startotherroutine(pal_212_schiffswache,"ShipFree"); b_startotherroutine(pal_213_schiffswache,"ShipFree"); PAL_SCHIFFSWACHE_EXCHANGE_ONETIME = TRUE; MIS_SHIPISFREE = TRUE; }; if(BIFF_FOLLOWSTHROUGHPASS == LOG_RUNNING) { Wld_InsertNpc(djg_713_biff_nw,"LEVELCHANGE"); BIFF_FOLLOWSTHROUGHPASS = LOG_SUCCESS; }; }; var int enternw_kapitel6; func void b_enter_newworld_kapitel_6() { if(ENTERNW_KAPITEL6 == FALSE) { ENTERNW_KAPITEL6 = TRUE; }; }; func void b_enter_newworld() { b_initnpcglobals(); if(KAPITEL >= 1) { b_enter_newworld_kapitel_1(); }; if(KAPITEL >= 2) { b_enter_newworld_kapitel_2(); }; if(KAPITEL >= 3) { b_enter_newworld_kapitel_3(); }; if(KAPITEL >= 4) { b_enter_newworld_kapitel_4(); }; if(KAPITEL >= 5) { b_enter_newworld_kapitel_5(); }; if(KAPITEL >= 6) { b_enter_newworld_kapitel_6(); }; CURRENTLEVEL = NEWWORLD_ZEN; b_initnpcglobals(); };
D
instance BAU_971_Bauer(Npc_Default) { name[0] = "Mac"; guild = GIL_OUT; id = 971; voice = 13; flags = 0; npcType = npctype_main; B_SetAttributesToChapter (self, 1); fight_tactic = FAI_HUMAN_COWARD; EquipItem (self, ItMw_1h_Bau_Axe); B_CreateAmbientInv (self); B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_N_NormalBart12, BodyTex_N, ITAR_Bau_L); Mdl_SetModelFatness (self, 2); Mdl_ApplyOverlayMds (self, "Humans_Relaxed.mds"); B_GiveNpcTalents (self); B_SetFightSkills (self, 15); daily_routine = Rtn_Start_971; }; func void Rtn_Start_971() { TA_Smalltalk (8, 0, 22, 0, "NW_TAVERNE_IN_05"); TA_Smalltalk (22, 0, 8, 0, "NW_TAVERNE_IN_05"); };
D
spectroscope for obtaining a mass spectrum by deflecting ions into a thin slit and measuring the ion current with an electrometer
D
/Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Preparation/Preparation.swift.o : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Preparation~partial.swiftmodule : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Preparation~partial.swiftdoc : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule
D
module stri; import std.format : format; import std.algorithm : map; auto parse(string s) { import std.string; import std.algorithm : find; import std.typecons; string fmt = s; string[] ids; auto subs = s.find("${"); // "${def}gh${i}..." while (!subs.empty) { auto ends = subs.find("}"); // "}gh${i}..." if (ends.empty) { // TODO assert here break; } auto _id = subs[2..$-ends.length]; // "def" auto idFmt = _id.find("%"); auto id = _id[0 .. $-idFmt.length]; ids ~= id; // [..., "def"] auto quote = subs[0..$+1-ends.length]; // "${def}" fmt = fmt.replace(quote, idFmt.empty ? "%s" : idFmt); subs = ends.find("${"); // "${i}..." } return tuple!("ids", "fmt")(ids, fmt); } mixin template s(string sfmt) { enum _ret = parse(sfmt); mixin(format!`immutable str = format!"%s"(%-(%s, %));`(_ret.fmt, _ret.ids)); } unittest { import std.stdio; auto a = 1; struct A { static a = 0.123; } enum _a0 = "D-lang"; mixin s!"${a} is one. ${_a0} is nice. ${a%03d}, ${A.a%.3f}" i; writeln(i.str); assert(i.str == "1 is one. D-lang is nice. 001, 0.123"); }
D
/Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorView.o : /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCircleStrokeSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorView~partial.swiftmodule : /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCircleStrokeSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/Objects-normal/x86_64/NVActivityIndicatorView~partial.swiftdoc : /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseSync.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOutRapid.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScale.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorViewable.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRippleMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotateMultiple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallScaleRipple.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorShape.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotateChase.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulseRise.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotatePulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallPulse.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorAnimationDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallClipRotate.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZag.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallTrianglePath.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBlank.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationPacman.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCircleStrokeSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSemiCircleSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationSquareSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationTriangleSkewSpin.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationCubeTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallSpinFadeLoader.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Presenter/NVActivityIndicatorPresenter.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallGridBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallBeat.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationBallZigZagDeflect.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationOrbit.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScalePulseOut.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView.swift /Users/benormos/Desktop/MyFutureBox/Pods/NVActivityIndicatorView/NVActivityIndicatorView/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationLineScaleParty.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/NVActivityIndicatorView/NVActivityIndicatorView-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/NVActivityIndicatorView.build/unextended-module.modulemap
D
/* THIS FILE GENERATED BY bcd.gen */ module bcd.fltk.filename; public import bcd.bind; public import std.c.dirent; const int FL_PATH_MAX = 256; alias int function(dirent * *, dirent * *) _BCD_func__4; alias _BCD_func__4 Fl_File_Sort_F; extern (C) int _BCD__Z16fl_filename_listPKcPPP6direntPFiS3_S3_E(char *, dirent * * *, _BCD_func__4); extern (C) int _BCD__Z20fl_filename_relativePcPKc(char *, char *); extern (C) int _BCD__Z20fl_filename_absolutePcPKc(char *, char *); extern (C) int _BCD__Z18fl_filename_expandPcPKc(char *, char *); extern (C) char * _BCD__Z18fl_filename_setextPcPKc(char *, char *); extern (C) int _BCD__Z17fl_filename_isdirPKc(char *); extern (C) int _BCD__Z17fl_filename_matchPKcS0_(char *, char *); extern (C) int _BCD__Z20fl_filename_relativePciPKc(char *, int, char *); extern (C) int _BCD__Z20fl_filename_absolutePciPKc(char *, int, char *); extern (C) int _BCD__Z18fl_filename_expandPciPKc(char *, int, char *); extern (C) char * _BCD__Z18fl_filename_setextPciPKc(char *, int, char *); extern (C) char * _BCD__Z15fl_filename_extPKc(char *); extern (C) char * _BCD__Z16fl_filename_namePKc(char *); int fl_filename_list(char * d, dirent * * * l, _BCD_func__4 s) { return _BCD__Z16fl_filename_listPKcPPP6direntPFiS3_S3_E(d, l, s); } int fl_filename_relative(char * to, char * from) { return _BCD__Z20fl_filename_relativePcPKc(to, from); } int fl_filename_absolute(char * to, char * from) { return _BCD__Z20fl_filename_absolutePcPKc(to, from); } int fl_filename_expand(char * to, char * from) { return _BCD__Z18fl_filename_expandPcPKc(to, from); } char * fl_filename_setext(char * to, char * ext) { return _BCD__Z18fl_filename_setextPcPKc(to, ext); } int fl_filename_isdir(char * name) { return _BCD__Z17fl_filename_isdirPKc(name); } int fl_filename_match(char * name, char * pattern) { return _BCD__Z17fl_filename_matchPKcS0_(name, pattern); } int fl_filename_relative(char * to, int tolen, char * from) { return _BCD__Z20fl_filename_relativePciPKc(to, tolen, from); } int fl_filename_absolute(char * to, int tolen, char * from) { return _BCD__Z20fl_filename_absolutePciPKc(to, tolen, from); } int fl_filename_expand(char * to, int tolen, char * from) { return _BCD__Z18fl_filename_expandPciPKc(to, tolen, from); } char * fl_filename_setext(char * to, int tolen, char * ext) { return _BCD__Z18fl_filename_setextPciPKc(to, tolen, ext); } char * fl_filename_ext(char * _0) { return _BCD__Z15fl_filename_extPKc(_0); } char * fl_filename_name(char * _0) { return _BCD__Z16fl_filename_namePKc(_0); }
D
/Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Leaf.build/Objects-normal/x86_64/Tag.o : /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Argument.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Byte+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Constants.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Context.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafComponent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Link.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/List.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Node+Rendered.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/NSData+File.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Parameter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Render.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Spawn.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/BufferProtocol.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/BasicTag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Tag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/TagTemplate.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Else.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Embed.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Equal.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Export.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Extend.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/If.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Import.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Index.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Loop.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Raw.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Uppercased.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Variable.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Leaf.build/Objects-normal/x86_64/Tag~partial.swiftmodule : /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Argument.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Byte+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Constants.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Context.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafComponent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Link.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/List.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Node+Rendered.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/NSData+File.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Parameter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Render.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Spawn.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/BufferProtocol.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/BasicTag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Tag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/TagTemplate.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Else.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Embed.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Equal.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Export.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Extend.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/If.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Import.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Index.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Loop.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Raw.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Uppercased.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Variable.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Leaf.build/Objects-normal/x86_64/Tag~partial.swiftdoc : /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Argument.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Byte+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Constants.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Context.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafComponent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/LeafError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Link.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/List.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Node+Rendered.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/NSData+File.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Parameter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Render.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem+Spawn.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Stem.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer+Leaf.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/Buffer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Buffer/BufferProtocol.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/BasicTag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Tag.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/TagTemplate.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Else.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Embed.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Equal.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Export.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Extend.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/If.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Import.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Index.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Loop.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Raw.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Uppercased.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Leaf-1.0.0/Sources/Leaf/Tag/Models/Variable.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule
D
/* Copyright (c) 2014-2020 Timur Gafarov Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ module gscript.program; import gscript.statement; import gscript.dynamic; import gscript.hostfunc; import gscript.vm; /* * A Program is some sort of a library that caches * imported modules and stores host functions, allowing * scripts to link against them */ class Program { HostFunction[string] hostFunctions; Module[string] modules; string[] importDirs; this() { } void addImportDir(string dir) { if (dir[$-1] == '\\') importDirs ~= dir[0..$-1] ~ "/"; else if (dir[$-1] != '/') importDirs ~= dir ~ "/"; else importDirs ~= dir; } void addHostFunction(string name, int numArgs, Dynamic delegate(VirtualMachine, Dynamic[]) func) { hostFunctions[name] = HostFunction(name, numArgs, func); } bool hasHostFunction(string name) { if (name in hostFunctions) return true; else return false; } }
D
/****************************************************************************** Test reading a channel with empty buckets inside Copyright: (c) 2016 Sociomantic Labs. All rights reserved. ******************************************************************************/ module test.versioning.cases.TestEmptyBuckets; import dlstest.DlsTestCase; import ocean.core.array.Search; import ocean.transition; /****************************************************************************** Test if the iteration through the channel works even if some of the buckets are empty. *******************************************************************************/ class GetAllEmptyBuckets: DlsTestCase { this ( ) { this.test_channel = "empty-bucket"; } override public Description description ( ) { Description desc; desc.priority = 100; desc.name = "GetAll over the channel which includes empty buckets"; return desc; } public override void run ( ) { // Do a GetAll to retrieve them all auto fetched = this.dls.getAll(this.test_channel); // Confirm the results (for this test, just the count would do fine) test!("==")(fetched.length, 8); } }
D
module dwt.internal.mozilla.imgIContainerObserver; import dwt.internal.mozilla.Common; import dwt.internal.mozilla.nsID; import dwt.internal.mozilla.nsISupports; import dwt.internal.mozilla.imgIContainer; import dwt.internal.mozilla.gfxIImageFrame; const char[] IMGICONTAINEROBSERVER_IID_STR = "53102f15-0f53-4939-957e-aea353ad2700"; const nsIID IMGICONTAINEROBSERVER_IID= { 0x53102f15, 0x0f53, 0x4939, [ 0x95, 0x7e, 0xae, 0xa3, 0x53, 0xad, 0x27, 0x00 ] }; interface imgIContainerObserver : nsISupports { static const char[] IID_STR = IMGICONTAINEROBSERVER_IID_STR; static const nsIID IID = IMGICONTAINEROBSERVER_IID; extern(System): nsresult FrameChanged(imgIContainer aContainer, gfxIImageFrame aFrame, nsIntRect * aDirtyRect); }
D
/** * This module contains Account data struct * * Copyright: &copy; 2017 Joshua Hodkinson * License: MIT as per included LICENSE document * Authors: Joshua Hodkinson */ module blogd.models.account; import vibe.db.mongo.mongo : MongoCollection; import vibe.web.validation : ValidEmail, ValidPassword; /** * The struct which holds data for a account db enitity * * * * Authors: Joshua Hodkinson */ struct Account { public string name; /// The auth'd user's display name //public ValidEmail email; /// The auth'd user's email public string email; /// The auth'd user's email //public ValidPassword password; /// The auth'd user's email public string password; /// The auth'd user's email }
D
/Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQLite.build/FluentSQLiteProvider.swift.o : /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteSchema.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+SchemaSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+JoinSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+MigrationSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+TransactionSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+QuerySupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteProvider.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteTypes.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteModels.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQLite.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Fluent.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQLite.build/FluentSQLiteProvider~partial.swiftmodule : /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteSchema.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+SchemaSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+JoinSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+MigrationSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+TransactionSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+QuerySupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteProvider.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteTypes.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteModels.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQLite.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Fluent.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQLite.build/FluentSQLiteProvider~partial.swiftdoc : /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteSchema.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+SchemaSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+JoinSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+MigrationSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+TransactionSupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteDatabase+QuerySupporting.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteProvider.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteError.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteTypes.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/SQLiteModels.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/Exports.swift /Users/Khanh/vapor/TILApp/.build/checkouts/fluent-sqlite.git--5503918280859119093/Sources/FluentSQLite/FluentSQLiteQuery.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/FluentSQL.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Command.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Service.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Console.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/SQLite.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Logging.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/DatabaseKit.swiftmodule /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/Fluent.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/Khanh/vapor/TILApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/Khanh/vapor/TILApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
D
lofty in style
D
module wiz.ast.inlineconditional; import wiz.lib; import wiz.ast.lib; class InlineConditional : Statement { private bool negated; private Expression trigger; private Statement action; public Statement alternative; private Block _block; private bool expanded; this(bool negated, Expression trigger, Statement action, compile.Location location) { super(location); this.negated = negated; this.trigger = trigger; this.action = action; } bool expand(compile.Program program) { if(expanded) { return false; } expanded = true; // Compile-time branching. if(trigger) { size_t value; bool known; if(compile.foldExpression(program, trigger, false, value, known) && known) { if(value && !negated) { _block = new Block([action], location); } else if(alternative) { _block = new Block([alternative], location); } return true; } } return true; } mixin compile.BranchAcceptor!(_block); mixin helper.Accessor!(_block); }
D
<?xml version="1.0" encoding="ASCII" standalone="no"?> <di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0"> <pageList> <availablePage> <emfPageIdentifier href="VAR_13_agm-9939798213.notation#_copSALmGEeKQQp7P9cQvNQ"/> </availablePage> </pageList> <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> <windows> <children xsi:type="di:TabFolder"> <children> <emfPageIdentifier href="VAR_13_agm-9939798213.notation#_copSALmGEeKQQp7P9cQvNQ"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>
D
/Users/eric/code/rust/add_workspace/target/debug/deps/librand-e087b5999210b44d.rlib: /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/lib.rs /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/distributions/mod.rs /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/rand_impls.rs /Users/eric/code/rust/add_workspace/target/debug/deps/rand-e087b5999210b44d.d: /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/lib.rs /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/distributions/mod.rs /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/rand_impls.rs /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/lib.rs: /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/distributions/mod.rs: /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.23/src/rand_impls.rs:
D
/home/jedhsu/wichai/monk/target/debug/deps/monk-9fa808be262726b9.rmeta: src/lib.rs /home/jedhsu/wichai/monk/target/debug/deps/monk-9fa808be262726b9.d: src/lib.rs src/lib.rs:
D
/Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.build/Exports.swift.o : /Users/mu/Hello/.build/checkouts/core/Sources/Async/Async+NIO.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Variadic.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Deprecated.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Void.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/FutureType.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Collection+Future.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+DoCatch.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Global.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Transform.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Flatten.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Map.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Worker.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/QueueHandler.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/AsyncError.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Exports.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.build/Exports~partial.swiftmodule : /Users/mu/Hello/.build/checkouts/core/Sources/Async/Async+NIO.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Variadic.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Deprecated.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Void.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/FutureType.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Collection+Future.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+DoCatch.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Global.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Transform.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Flatten.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Map.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Worker.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/QueueHandler.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/AsyncError.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Exports.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Users/mu/Hello/.build/x86_64-apple-macosx/debug/Async.build/Exports~partial.swiftdoc : /Users/mu/Hello/.build/checkouts/core/Sources/Async/Async+NIO.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Variadic.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Deprecated.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Void.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/FutureType.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Collection+Future.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+DoCatch.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Global.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Transform.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Flatten.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Future+Map.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Worker.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/QueueHandler.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/AsyncError.swift /Users/mu/Hello/.build/checkouts/core/Sources/Async/Exports.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Users/mu/Hello/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/mu/Hello/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/mu/Hello/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/mu/Hello/.build/checkouts/swift-nio-zlib-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes
D
/* REQUIRED_ARGS: -HC -c -o- PERMUTE_ARGS: TEST_OUTPUT: --- // Automatically generated by Digital Mars D Compiler v$n$ #pragma once #include <stddef.h> #include <stdint.h> struct S; struct S2; class C; class C2; typedef int32_t T; extern "C" int32_t x; // ignored variable dtoh_AliasDeclaration.x extern "C" int32_t foo(int32_t x); // ignored function dtoh_AliasDeclaration.foo extern int32_t foo2(int32_t x); // ignored function dtoh_AliasDeclaration.foo2 struct S; typedef S aliasS; struct S2; typedef S2 aliasS2; // ignoring non-cpp class C typedef C* aliasC; class C2; typedef C2* aliasC2; --- */ alias T = int; extern (C) int x; alias u = x; extern (C) int foo(int x) { return x * 42; } alias fun = foo; extern (C++) int foo2(int x) { return x * 42; } alias fun2 = foo2; extern (C) struct S; alias aliasS = S; extern (C++) struct S2; alias aliasS2 = S2; extern (C) class C; alias aliasC = C; extern (C++) class C2; alias aliasC2 = C2;
D
PLONG PLAT ED95 KD LOMAGAGE HIMAGAGE SLAT SLONG RESULTNO DP DM WT ROCKTYPE 279.899994 75.8000031 4.30000019 826 1 14 32.7999992 72.5 1137 2.9000001 5 0.307692308 sediments 326.600006 57.4000015 4.69999981 380.799988 1 14 32.7999992 73.1999969 1136 3.0999999 5.4000001 0.307692308 sediments 267.5 72.1999969 2 13 1 13 28 82 6129 1.10000002 2.0999999 0.333333333 sediments, sandstones
D
/** * This module is a set of types and functions for converting any object (value * or heap) into a generic box type, allowing the user to pass that object * around without knowing what's in the box, and then allowing him to recover * the value afterwards. * * Example: --- // Convert the integer 45 into a box. Box b = box(45); // Recover the integer and cast it to real. real r = unbox!(real)(b); --- * * That is the basic interface and will usually be all that you need to * understand. If it cannot unbox the object to the given type, it throws * UnboxException. As demonstrated, it uses implicit casts to behave in the exact * same way that static types behave. So for example, you can unbox from int to * real, but you cannot unbox from real to int: that would require an explicit * cast. * * This therefore means that attempting to unbox an int as a string will throw * an error instead of formatting it. In general, you can call the toString method * on the box and receive a good result, depending upon whether std.string.format * accepts it. * * Boxes can be compared to one another and they can be used as keys for * associative arrays. * * There are also functions for converting to and from arrays of boxes. * * Example: --- // Convert arguments into an array of boxes. Box[] a = boxArray(1, 45.4, "foobar"); // Convert an array of boxes back into arguments. TypeInfo[] arg_types; void* arg_data; boxArrayToArguments(a, arg_types, arg_data); // Convert the arguments back into boxes using a // different form of the function. a = boxArray(arg_types, arg_data); --- * One use of this is to support a variadic function more easily and robustly; * simply call "boxArray(_arguments, _argptr)", then do whatever you need to do * with the array. * * Authors: * Burton Radons * License: * Public Domain * Macros: * WIKI=Phobos/StdBoxer */ module std.boxer; private import std.format; private import std.string; private import std.utf; /* These functions and types allow packing objects into generic containers * and recovering them later. This comes into play in a wide spectrum of * utilities, such as with a scripting language, or as additional user data * for an object. * * Box an object by calling the box function: * * Box x = box(4); * * Recover the value by using the unbox template: * * int y = unbox!(int)(x); * * If it cannot unbox the object to that type, it throws UnboxException. It will * use implicit casts to behave in the exact same way as D does - for * instance: * * byte v; * int i = v; // Implicitly cast from byte to int. * int j = unbox!(int)(Box(i)); // Do the exact same thing at runtime. * * This therefore means that attempting to unbox an int as a string will * throw an error and not format it. In general, you can call the toString * method on the box and receive a good result, depending upon whether * std.string.format accepts it. * * Boxes can be compared to one another and they can be used as keys for * associative arrays. Boxes of different types can be compared to one * another, using the same casting rules as the main type system. * * boxArray has two forms: * * Box[] boxArray(...); * Box[] boxArray(TypeInfo[] types, void* data); * * This converts an array of arguments into an array of boxes. To convert * back into an array of arguments, use boxArrayToArguments: * * void boxArrayToArguments(Box[] arguments, out TypeInfo[] types, * out void[] data); * * Finally, you can discover whether unboxing as a certain type is legal by * using the unboxable template or method: * * bool unboxable!(T) (Box value); * bool Box.unboxable(TypeInfo T); */ /** Return the next type in an array typeinfo, or null if there is none. */ private bool isArrayTypeInfo(TypeInfo type) { char[] name = type.classinfo.name; return name.length >= 10 && name[9] == 'A' && name != "TypeInfo_AssociativeArray"; } /** The type class returned from Box.findTypeClass; the order of entries is important. */ private enum TypeClass { Bool, /**< bool */ Bit = Bool, // for backwards compatibility Integer, /**< byte, ubyte, short, ushort, int, uint, long, ulong */ Float, /**< float, double, real */ Complex, /**< cfloat, cdouble, creal */ Imaginary, /**< ifloat, idouble, ireal */ Class, /**< Inherits from Object */ Pointer, /**< Pointer type (T *) */ Array, /**< Array type (T []) */ Other, /**< Any other type, such as delegates, function pointers, struct, void... */ } /** * Box is a generic container for objects (both value and heap), allowing the * user to box them in a generic form and recover them later. * A box object contains a value in a generic fashion, allowing it to be * passed from one place to another without having to know its type. It is * created by calling the box function, and you can recover the value by * instantiating the unbox template. */ struct Box { private TypeInfo p_type; /**< The type of the contained object. */ private union { void* p_longData; /**< An array of the contained object. */ void[8] p_shortData; /**< Data used when the object is small. */ } private static TypeClass findTypeClass(TypeInfo type) { if (cast(TypeInfo_Class) type) return TypeClass.Class; if (cast(TypeInfo_Pointer) type) return TypeClass.Pointer; if (isArrayTypeInfo(type)) return TypeClass.Array; version (DigitalMars) { /* Depend upon the name of the base type classes. */ if (type.classinfo.name.length != "TypeInfo_?".length) return TypeClass.Other; switch (type.classinfo.name[9]) { case 'b', 'x': return TypeClass.Bool; case 'g', 'h', 's', 't', 'i', 'k', 'l', 'm': return TypeClass.Integer; case 'f', 'd', 'e': return TypeClass.Float; case 'q', 'r', 'c': return TypeClass.Complex; case 'o', 'p', 'j': return TypeClass.Imaginary; default: return TypeClass.Other; } } else { /* Use the name returned from toString, which might (but hopefully doesn't) include an allocation. */ switch (type.toString) { case "bool": return TypeClass.Bool; case "byte", "ubyte", "short", "ushort", "int", "uint", "long", "ulong": return TypeClass.Integer; case "float", "real", "double": return TypeClass.Float; case "cfloat", "cdouble", "creal": return TypeClass.Complex; case "ifloat", "idouble", "ireal": return TypeClass.Imaginary; default: return TypeClass.Other; } } assert(0); } /** Return whether this value could be unboxed as the given type without throwing. */ bool unboxable(TypeInfo test) { if (type is test) return true; TypeInfo_Class ca = cast(TypeInfo_Class) type, cb = cast(TypeInfo_Class) test; if (ca !is null && cb !is null) { ClassInfo ia = (*cast(Object *) data).classinfo, ib = cb.info; for ( ; ia !is null; ia = ia.base) if (ia is ib) return true; return false; } TypeClass ta = findTypeClass(type), tb = findTypeClass(test); if (type is typeid(void*) && *cast(void**) data is null) return (tb == TypeClass.Class || tb == TypeClass.Pointer || tb == TypeClass.Array); if (test is typeid(void*)) return (tb == TypeClass.Class || tb == TypeClass.Pointer || tb == TypeClass.Array); if (ta == TypeClass.Pointer && tb == TypeClass.Pointer) return (cast(TypeInfo_Pointer)type).next is (cast(TypeInfo_Pointer)test).next; if ((ta == tb && ta != TypeClass.Other) || (ta == TypeClass.Bool && tb == TypeClass.Integer) || (ta <= TypeClass.Integer && tb == TypeClass.Float) || (ta <= TypeClass.Imaginary && tb == TypeClass.Complex)) return true; return false; } /** * Property for the type contained by the box. * This is initially null and cannot be assigned directly. * Returns: the type of the contained object. */ TypeInfo type() { return p_type; } /** * Property for the data pointer to the value of the box. * This is initially null and cannot be assigned directly. * Returns: the data array. */ void[] data() { size_t size = type.tsize(); return size <= p_shortData.length ? p_shortData[0..size] : p_longData[0..size]; } /** * Attempt to convert the boxed value into a string using std.string.format; * this will throw if that function cannot handle it. If the box is * uninitialized then this returns "". */ char[] toString() { if (type is null) return "<empty box>"; TypeInfo[2] arguments; char[] string; void[] args = new void[(char[]).sizeof + data.length]; char[] format = "%s"; arguments[0] = typeid(char[]); arguments[1] = type; void putc(dchar ch) { std.utf.encode(string, ch); } args[0..(char[]).sizeof] = (cast(void*) &format)[0..(char[]).sizeof]; args[(char[]).sizeof..length] = data; std.format.doFormat(&putc, arguments, args.ptr); delete args; return string; } private bool opEqualsInternal(Box other, bool inverted) { if (type != other.type) { if (!unboxable(other.type)) { if (inverted) return false; return other.opEqualsInternal(*this, true); } TypeClass ta = findTypeClass(type), tb = findTypeClass(other.type); if (ta <= TypeClass.Integer && tb <= TypeClass.Integer) { char[] na = type.toString, nb = other.type.toString; if (na == "ulong" || nb == "ulong") return unbox!(ulong)(*this) == unbox!(ulong)(other); return unbox!(long)(*this) == unbox!(long)(other); } else if (tb == TypeClass.Float) return unbox!(real)(*this) == unbox!(real)(other); else if (tb == TypeClass.Complex) return unbox!(creal)(*this) == unbox!(creal)(other); else if (tb == TypeClass.Imaginary) return unbox!(ireal)(*this) == unbox!(ireal)(other); assert (0); } return cast(bool)type.equals(data.ptr, other.data.ptr); } /** * Compare this box's value with another box. This implicitly casts if the * types are different, identical to the regular type system. */ bool opEquals(Box other) { return opEqualsInternal(other, false); } private float opCmpInternal(Box other, bool inverted) { if (type != other.type) { if (!unboxable(other.type)) { if (inverted) return 0; return other.opCmpInternal(*this, true); } TypeClass ta = findTypeClass(type), tb = findTypeClass(other.type); if (ta <= TypeClass.Integer && tb == TypeClass.Integer) { if (type == typeid(ulong) || other.type == typeid(ulong)) { ulong va = unbox!(ulong)(*this), vb = unbox!(ulong)(other); return va > vb ? 1 : va < vb ? -1 : 0; } long va = unbox!(long)(*this), vb = unbox!(long)(other); return va > vb ? 1 : va < vb ? -1 : 0; } else if (tb == TypeClass.Float) { real va = unbox!(real)(*this), vb = unbox!(real)(other); return va > vb ? 1 : va < vb ? -1 : va == vb ? 0 : float.nan; } else if (tb == TypeClass.Complex) { creal va = unbox!(creal)(*this), vb = unbox!(creal)(other); return va == vb ? 0 : float.nan; } else if (tb == TypeClass.Imaginary) { ireal va = unbox!(ireal)(*this), vb = unbox!(ireal)(other); return va > vb ? 1 : va < vb ? -1 : va == vb ? 0 : float.nan; } assert (0); } return type.compare(data.ptr, other.data.ptr); } /** * Compare this box's value with another box. This implicitly casts if the * types are different, identical to the regular type system. */ float opCmp(Box other) { return opCmpInternal(other, false); } /** * Return the value's hash. */ hash_t toHash() { return type.getHash(data.ptr); } } /** * Box the single argument passed to the function. If more or fewer than one * argument is passed, this will assert. */ Box box(...) in { assert (_arguments.length == 1); } body { return box(_arguments[0], _argptr); } /** * Box the explicitly-defined object. type must not be null; data must not be * null if the type's size is greater than zero. * The data is copied. */ Box box(TypeInfo type, void* data) in { assert(type !is null); } body { Box result; size_t size = type.tsize(); result.p_type = type; if (size <= result.p_shortData.length) result.p_shortData[0..size] = data[0..size]; else result.p_longData = data[0..size].dup.ptr; return result; } /** Return the length of an argument in bytes. */ private size_t argumentLength(size_t baseLength) { return (baseLength + int.sizeof - 1) & ~(int.sizeof - 1); } /** * Convert a list of arguments into a list of boxes. */ Box[] boxArray(TypeInfo[] types, void* data) { Box[] array = new Box[types.length]; foreach(size_t index, TypeInfo type; types) { array[index] = box(type, data); data += argumentLength(type.tsize()); } return array; } /** * Box each argument passed to the function, returning an array of boxes. */ Box[] boxArray(...) { return boxArray(_arguments, _argptr); } /** * Convert an array of boxes into an array of arguments. */ void boxArrayToArguments(Box[] arguments, out TypeInfo[] types, out void* data) { size_t dataLength; void* pointer; /* Determine the number of bytes of data to allocate by summing the arguments. */ foreach (Box item; arguments) dataLength += argumentLength(item.data.length); types = new TypeInfo[arguments.length]; pointer = data = (new void[dataLength]).ptr; /* Stash both types and data. */ foreach (size_t index, Box item; arguments) { types[index] = item.type; pointer[0..item.data.length] = item.data; pointer += argumentLength(item.data.length); } } /** * This class is thrown if unbox is unable to cast the value into the desired * result. */ class UnboxException : Exception { Box object; /// This is the box that the user attempted to unbox. TypeInfo outputType; /// This is the type that the user attempted to unbox the value as. /** * Assign parameters and create the message in the form * <tt>"Could not unbox from type ... to ... ."</tt> */ this(Box object, TypeInfo outputType) { this.object = object; this.outputType = outputType; super(format("Could not unbox from type %s to %s.", object.type, outputType)); } } /** A generic unboxer for the real numeric types. */ private template unboxCastReal(T) { T unboxCastReal(Box value) { assert (value.type !is null); if (value.type is typeid(float)) return cast(T) *cast(float*) value.data; if (value.type is typeid(double)) return cast(T) *cast(double*) value.data; if (value.type is typeid(real)) return cast(T) *cast(real*) value.data; return unboxCastInteger!(T)(value); } } /** A generic unboxer for the integral numeric types. */ private template unboxCastInteger(T) { T unboxCastInteger(Box value) { assert (value.type !is null); if (value.type is typeid(int)) return cast(T) *cast(int*) value.data; if (value.type is typeid(uint)) return cast(T) *cast(uint*) value.data; if (value.type is typeid(long)) return cast(T) *cast(long*) value.data; if (value.type is typeid(ulong)) return cast(T) *cast(ulong*) value.data; if (value.type is typeid(bool)) return cast(T) *cast(bool*) value.data; if (value.type is typeid(byte)) return cast(T) *cast(byte*) value.data; if (value.type is typeid(ubyte)) return cast(T) *cast(ubyte*) value.data; if (value.type is typeid(short)) return cast(T) *cast(short*) value.data; if (value.type is typeid(ushort)) return cast(T) *cast(ushort*) value.data; throw new UnboxException(value, typeid(T)); } } /** A generic unboxer for the complex numeric types. */ private template unboxCastComplex(T) { T unboxCastComplex(Box value) { assert (value.type !is null); if (value.type is typeid(cfloat)) return cast(T) *cast(cfloat*) value.data; if (value.type is typeid(cdouble)) return cast(T) *cast(cdouble*) value.data; if (value.type is typeid(creal)) return cast(T) *cast(creal*) value.data; if (value.type is typeid(ifloat)) return cast(T) *cast(ifloat*) value.data; if (value.type is typeid(idouble)) return cast(T) *cast(idouble*) value.data; if (value.type is typeid(ireal)) return cast(T) *cast(ireal*) value.data; return unboxCastReal!(T)(value); } } /** A generic unboxer for the imaginary numeric types. */ private template unboxCastImaginary(T) { T unboxCastImaginary(Box value) { assert (value.type !is null); if (value.type is typeid(ifloat)) return cast(T) *cast(ifloat*) value.data; if (value.type is typeid(idouble)) return cast(T) *cast(idouble*) value.data; if (value.type is typeid(ireal)) return cast(T) *cast(ireal*) value.data; throw new UnboxException(value, typeid(T)); } } /** * The unbox template takes a type parameter and returns a function that * takes a box object and returns the specified type. * * To use it, instantiate the template with the desired result type, and then * call the function with the box to convert. * This will implicitly cast base types as necessary and in a way consistent * with static types - for example, it will cast a boxed byte into int, but it * won't cast a boxed float into short. * * Throws: UnboxException if it cannot cast * * Example: * --- * Box b = box(4.5); * bit u = unboxable!(real)(b); // This is true. * real r = unbox!(real)(b); * * Box y = box(4); * int x = unbox!(int) (y); * --- */ template unbox(T) { T unbox(Box value) { assert (value.type !is null); if (typeid(T) is value.type) return *cast(T*) value.data; throw new UnboxException(value, typeid(T)); } } template unbox(T : byte) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : ubyte) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : short) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : ushort) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : int) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : uint) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : long) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : ulong) { T unbox(Box value) { return unboxCastInteger!(T) (value); } } template unbox(T : float) { T unbox(Box value) { return unboxCastReal!(T) (value); } } template unbox(T : double) { T unbox(Box value) { return unboxCastReal!(T) (value); } } template unbox(T : real) { T unbox(Box value) { return unboxCastReal!(T) (value); } } template unbox(T : cfloat) { T unbox(Box value) { return unboxCastComplex!(T) (value); } } template unbox(T : cdouble) { T unbox(Box value) { return unboxCastComplex!(T) (value); } } template unbox(T : creal) { T unbox(Box value) { return unboxCastComplex!(T) (value); } } template unbox(T : ifloat) { T unbox(Box value) { return unboxCastImaginary!(T) (value); } } template unbox(T : idouble) { T unbox(Box value) { return unboxCastImaginary!(T) (value); } } template unbox(T : ireal) { T unbox(Box value) { return unboxCastImaginary!(T) (value); } } template unbox(T : Object) { T unbox(Box value) { assert (value.type !is null); if (typeid(T) == value.type || cast(TypeInfo_Class) value.type) { Object object = *cast(Object*)value.data; T result = cast(T)object; if (object is null) return null; if (result is null) throw new UnboxException(value, typeid(T)); return result; } if (typeid(void*) is value.type && *cast(void**) value.data is null) return null; throw new UnboxException(value, typeid(T)); } } template unbox(T : T[]) { T[] unbox(Box value) { assert (value.type !is null); if (typeid(T[]) is value.type) return *cast(T[]*) value.data; if (typeid(void*) is value.type && *cast(void**) value.data is null) return null; throw new UnboxException(value, typeid(T[])); } } template unbox(T : T*) { T* unbox(Box value) { assert (value.type !is null); if (typeid(T*) is value.type) return *cast(T**) value.data; if (typeid(void*) is value.type && *cast(void**) value.data is null) return null; if (typeid(T[]) is value.type) return (*cast(T[]*) value.data).ptr; throw new UnboxException(value, typeid(T*)); } } template unbox(T : void*) { T unbox(Box value) { assert (value.type !is null); if (cast(TypeInfo_Pointer) value.type) return *cast(void**) value.data; if (isArrayTypeInfo(value.type)) return (*cast(void[]*) value.data).ptr; if (cast(TypeInfo_Class) value.type) return cast(T)(*cast(Object*) value.data); throw new UnboxException(value, typeid(T)); } } /** * Return whether the value can be unboxed as the given type; if this returns * false, attempting to do so will throw UnboxException. */ template unboxable(T) { bool unboxable(Box value) { return value.unboxable(typeid(T)); } } /* Tests unboxing - assert that if it says it's unboxable, it is. */ private template unboxTest(T) { T unboxTest(Box value) { T result; bool unboxable = value.unboxable(typeid(T)); try result = unbox!(T) (value); catch (UnboxException error) { if (unboxable) throw new Error ("Could not unbox " ~ value.type.toString ~ " as " ~ typeid(T).toString ~ "; however, unboxable says it would work."); assert (!unboxable); throw error; } if (!unboxable) throw new Error ("Unboxed " ~ value.type.toString ~ " as " ~ typeid(T).toString ~ "; however, unboxable says it should fail."); return result; } } unittest { class A { } class B : A { } struct SA { } struct SB { } Box a, b; /* Call the function, catch UnboxException, return that it threw correctly. */ bool fails(void delegate()func) { try func(); catch (UnboxException error) return true; return false; } /* Check that equals and comparison work properly. */ a = box(0); b = box(32); assert (a != b); assert (a == a); assert (a < b); /* Check that toString works properly. */ assert (b.toString == "32"); /* Assert that unboxable works. */ assert (unboxable!(char[])(box("foobar"))); /* Assert that we can cast from int to byte. */ assert (unboxTest!(byte)(b) == 32); /* Assert that we can cast from int to real. */ assert (unboxTest!(real)(b) == 32.0L); /* Check that real works properly. */ assert (unboxTest!(real)(box(32.45L)) == 32.45L); /* Assert that we cannot implicitly cast from real to int. */ assert(fails(delegate void() { unboxTest!(int)(box(1.3)); })); /* Check that the unspecialized unbox template works. */ assert(unboxTest!(char[])(box("foobar")) == "foobar"); /* Assert that complex works correctly. */ assert(unboxTest!(cdouble)(box(1 + 2i)) == 1 + 2i); /* Assert that imaginary works correctly. */ assert(unboxTest!(ireal)(box(45i)) == 45i); /* Create an array of boxes from arguments. */ Box[] array = boxArray(16, "foobar", new Object); assert(array.length == 3); assert(unboxTest!(int)(array[0]) == 16); assert(unboxTest!(char[])(array[1]) == "foobar"); assert(unboxTest!(Object)(array[2]) !is null); /* Convert the box array back into arguments. */ TypeInfo[] array_types; void* array_data; boxArrayToArguments(array, array_types, array_data); assert (array_types.length == 3); /* Confirm the symmetry. */ assert (boxArray(array_types, array_data) == array); /* Assert that we can cast from int to creal. */ assert (unboxTest!(creal)(box(45)) == 45+0i); /* Assert that we can cast from idouble to creal. */ assert (unboxTest!(creal)(box(45i)) == 0+45i); /* Assert that equality testing casts properly. */ assert (box(1) == box(cast(byte)1)); assert (box(cast(real)4) == box(4)); assert (box(5) == box(5+0i)); assert (box(0+4i) == box(4i)); assert (box(8i) == box(0+8i)); /* Assert that comparisons cast properly. */ assert (box(450) < box(451)); assert (box(4) > box(3.0)); assert (box(0+3i) < box(0+4i)); /* Assert that casting from bool to int works. */ assert (1 == unboxTest!(int)(box(true))); assert (box(1) == box(true)); /* Assert that unboxing to an object works properly. */ assert (unboxTest!(B)(box(cast(A)new B)) !is null); /* Assert that illegal object casting fails properly. */ assert (fails(delegate void() { unboxTest!(B)(box(new A)); })); /* Assert that we can unbox a null. */ assert (unboxTest!(A)(box(cast(A)null)) is null); assert (unboxTest!(A)(box(null)) is null); /* Unboxing null in various contexts. */ assert (unboxTest!(char[])(box(null)) is null); assert (unboxTest!(int*)(box(null)) is null); /* Assert that unboxing between pointer types fails. */ int [1] p; assert (fails(delegate void() { unboxTest!(char*)(box(p.ptr)); })); /* Assert that unboxing various types as void* does work. */ assert (unboxTest!(void*)(box(p.ptr))); // int* assert (unboxTest!(void*)(box(p))); // int[] assert (unboxTest!(void*)(box(new A))); // Object /* Assert that we can't unbox an integer as bool. */ assert (!unboxable!(bool) (box(4))); /* Assert that we can't unbox a struct as another struct. */ SA sa; assert (!unboxable!(SB)(box(sa))); }
D
module imports.a14992; struct S1 { } struct S2 { int v; int[] a; }
D
func void ZS_Cook_Stove() { Perception_Set_Normal(); B_ResetAll(self); AI_SetWalkMode(self,NPC_WALK); if(!C_NpcIsOnRoutineWP(self)) { AI_GotoWP(self,self.wp); }; if(!Npc_HasItems(self,ItFoMuttonRaw)) { CreateInvItem(self,ItFoMuttonRaw); }; }; func int ZS_Cook_Stove_Loop() { if(!C_BodyStateContains(self,BS_MOBINTERACT_INTERRUPT) && Wld_IsMobAvailable(self,"STOVE")) { AI_UseMob(self,"STOVE",1); }; return LOOP_CONTINUE; }; func void ZS_Cook_Stove_End() { AI_UseMob(self,"STOVE",-1); if(Npc_HasItems(self,ItFoMutton)) { Npc_RemoveInvItems(self,ItFoMutton,1); }; };
D
/Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Validation.o : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/MultipartFormData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Timeline.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Response.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/TaskDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ParameterEncoding.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Validation.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ResponseSerialization.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/AFError.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Notifications.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Result.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Request.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Validation~partial.swiftmodule : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/MultipartFormData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Timeline.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Response.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/TaskDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ParameterEncoding.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Validation.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ResponseSerialization.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/AFError.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Notifications.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Result.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Request.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Validation~partial.swiftdoc : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/MultipartFormData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Timeline.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Alamofire.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Response.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/TaskDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionDelegate.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ParameterEncoding.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Validation.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ResponseSerialization.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/SessionManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/AFError.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Notifications.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Result.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/Request.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Alamofire/Source/ServerTrustPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap
D
/Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/Objects-normal/armv7/BLEManager.o : /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLECommon.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEManager.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLESerialCommunicator.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEDevice.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Swift.swiftmodule /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/ioFullColorLED.h /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreImage.swiftmodule /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/Objects-normal/armv7/BLEManager~partial.swiftmodule : /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLECommon.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEManager.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLESerialCommunicator.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEDevice.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Swift.swiftmodule /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/ioFullColorLED.h /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreImage.swiftmodule /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/Objects-normal/armv7/BLEManager~partial.swiftdoc : /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLECommon.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEManager.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLESerialCommunicator.swift /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/BLEDevice.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Swift.swiftmodule /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/ioFullColorLED/ioFullColorLED.h /Users/yamamoto/Documents/Xcode/ioFullColorLED/ioFullColorLED/Build/Intermediates/ioFullColorLED.build/Debug-iphoneos/ioFullColorLED.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/32/CoreImage.swiftmodule
D
/** * Configure the back end (optimizer and code generator) * * Compiler implementation of the * $(LINK2 https://www.dlang.org, D programming language). * * Copyright: Copyright (C) 2000-2022 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/backconfig.d, backend/backconfig.d) */ module dmd.backend.backconfig; import core.stdc.stdio; import dmd.backend.cdef; import dmd.backend.cc; import dmd.backend.code; import dmd.backend.global; import dmd.backend.ty; import dmd.backend.type; import dmd.backend.dwarfdbginf; extern (C++): nothrow: @safe: version (MARS) { void ph_init(); } /************************************** * Initialize configuration for backend. * Params: model = 32 for 32 bit code, 64 for 64 bit code, set bit 0 to generate MS-COFF instead of OMF on Windows exe = true for exe file, false for dll or shared library (generate PIC code) trace = add profiling code nofloat = do not pull in floating point code vasm = print generated assembler for each function verbose = verbose compile optimize = optimize code symdebug = add symbolic debug information, 1 for D, 2 for fake it with C symbolic debug info alwaysframe = always create standard function frame stackstomp = add stack stomping code avx = use AVX instruction set (0, 1, 2) pic = position independence level (0, 1, 2) useModuleInfo = implement ModuleInfo useTypeInfo = implement TypeInfo useExceptions = implement exception handling dwarf = DWARF version used _version = Compiler version exefmt = Executable file format generatedMain = a main entrypoint is generated */ public @trusted extern (C) void out_config_init( int model, bool exe, bool trace, bool nofloat, bool vasm, // print generated assembler for each function bool verbose, bool optimize, int symdebug, bool alwaysframe, bool stackstomp, ubyte avx, ubyte pic, bool useModuleInfo, bool useTypeInfo, bool useExceptions, ubyte dwarf, string _version, exefmt_t exefmt, bool generatedMain // a main entrypoint is generated ) { version (MARS) { //printf("out_config_init()\n"); auto cfg = &config; cfg._version = _version; if (!cfg.target_cpu) { cfg.target_cpu = TARGET_PentiumPro; cfg.target_scheduler = cfg.target_cpu; } cfg.fulltypes = CVNONE; cfg.fpxmmregs = false; cfg.inline8087 = 1; cfg.memmodel = 0; cfg.flags |= CFGuchar; // make sure TYchar is unsigned cfg.exe = exefmt; tytab[TYchar] |= TYFLuns; bool mscoff = model & 1; model &= 32 | 64; if (generatedMain) cfg.flags2 |= CFG2genmain; if (dwarf < 3 || dwarf > 5) { if (dwarf) { import dmd.backend.errors; error(null, 0, 0, "DWARF version %u is not supported", dwarf); } // Default DWARF version cfg.dwarf = 3; } else { cfg.dwarf = dwarf; } if (cfg.exe & EX_windos) { if (model == 64) { cfg.fpxmmregs = true; cfg.avx = avx; cfg.ehmethod = useExceptions ? EHmethod.EH_DM : EHmethod.EH_NONE; cfg.flags |= CFGnoebp; // test suite fails without this //cfg.flags |= CFGalwaysframe; cfg.flags |= CFGromable; // put switch tables in code segment cfg.objfmt = OBJ_MSCOFF; } else { cfg.ehmethod = useExceptions ? EHmethod.EH_WIN32 : EHmethod.EH_NONE; if (mscoff) cfg.flags |= CFGnoebp; // test suite fails without this cfg.objfmt = mscoff ? OBJ_MSCOFF : OBJ_OMF; if (mscoff) cfg.flags |= CFGnoebp; // test suite fails without this } if (exe) cfg.wflags |= WFexe; // EXE file only optimizations cfg.flags4 |= CFG4underscore; } if (cfg.exe & (EX_LINUX | EX_LINUX64)) { cfg.fpxmmregs = true; cfg.avx = avx; if (model == 64) { cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; } else { cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; if (!exe) cfg.flags |= CFGromable; // put switch tables in code segment } cfg.flags |= CFGnoebp; switch (pic) { case 0: // PIC.fixed break; case 1: // PIC.pic cfg.flags3 |= CFG3pic; break; case 2: // PIC.pie cfg.flags3 |= CFG3pic | CFG3pie; break; default: assert(0); } if (symdebug) cfg.flags |= CFGalwaysframe; cfg.objfmt = OBJ_ELF; } if (cfg.exe & (EX_OSX | EX_OSX64)) { cfg.fpxmmregs = true; cfg.avx = avx; cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; cfg.flags |= CFGnoebp; if (!exe) { cfg.flags3 |= CFG3pic; if (model == 64) cfg.flags |= CFGalwaysframe; // autotester fails without this // https://issues.dlang.org/show_bug.cgi?id=21042 } if (symdebug) cfg.flags |= CFGalwaysframe; cfg.flags |= CFGromable; // put switch tables in code segment cfg.objfmt = OBJ_MACH; } if (cfg.exe & (EX_FREEBSD | EX_FREEBSD64)) { if (model == 64) { cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; cfg.fpxmmregs = true; cfg.avx = avx; } else { cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; if (!exe) cfg.flags |= CFGromable; // put switch tables in code segment } cfg.flags |= CFGnoebp; if (!exe) { cfg.flags3 |= CFG3pic; } if (symdebug) cfg.flags |= CFGalwaysframe; cfg.objfmt = OBJ_ELF; } if (cfg.exe & (EX_OPENBSD | EX_OPENBSD64)) { if (model == 64) { cfg.fpxmmregs = true; cfg.avx = avx; } else { if (!exe) cfg.flags |= CFGromable; // put switch tables in code segment } cfg.flags |= CFGnoebp; cfg.flags |= CFGalwaysframe; if (!exe) cfg.flags3 |= CFG3pic; cfg.objfmt = OBJ_ELF; cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; } if (cfg.exe == EX_DRAGONFLYBSD64) { if (model == 64) { cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; cfg.fpxmmregs = true; cfg.avx = avx; } else { assert(0); // Only 64-bit supported on DragonFlyBSD } cfg.flags |= CFGnoebp; if (!exe) { cfg.flags3 |= CFG3pic; cfg.flags |= CFGalwaysframe; // PIC needs a frame for TLS fixups } cfg.objfmt = OBJ_ELF; } if (cfg.exe & (EX_SOLARIS | EX_SOLARIS64)) { if (model == 64) { cfg.fpxmmregs = true; cfg.avx = avx; } else { if (!exe) cfg.flags |= CFGromable; // put switch tables in code segment } cfg.flags |= CFGnoebp; cfg.flags |= CFGalwaysframe; if (!exe) cfg.flags3 |= CFG3pic; cfg.objfmt = OBJ_ELF; cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE; } cfg.flags2 |= CFG2nodeflib; // no default library cfg.flags3 |= CFG3eseqds; static if (0) { if (env.getEEcontext().EEcompile != 2) cfg.flags4 |= CFG4allcomdat; if (env.nochecks()) cfg.flags4 |= CFG4nochecks; // no runtime checking } if (cfg.exe & (EX_OSX | EX_OSX64)) { } else { cfg.flags4 |= CFG4allcomdat; } if (trace) cfg.flags |= CFGtrace; // turn on profiler if (nofloat) cfg.flags3 |= CFG3wkfloat; configv.vasm = vasm; configv.verbose = verbose; if (optimize) go_flag(cast(char*)"-o".ptr); if (symdebug) { if (cfg.exe & (EX_LINUX | EX_LINUX64 | EX_OPENBSD | EX_OPENBSD64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64)) { configv.addlinenumbers = 1; cfg.fulltypes = (symdebug == 1) ? CVDWARF_D : CVDWARF_C; } if (cfg.exe & (EX_windos)) { if (cfg.objfmt == OBJ_MSCOFF) { configv.addlinenumbers = 1; cfg.fulltypes = CV8; if(symdebug > 1) cfg.flags2 |= CFG2gms; } else { configv.addlinenumbers = 1; cfg.fulltypes = CV4; } } if (!optimize) cfg.flags |= CFGalwaysframe; } else { configv.addlinenumbers = 0; cfg.fulltypes = CVNONE; //cfg.flags &= ~CFGalwaysframe; } if (alwaysframe) cfg.flags |= CFGalwaysframe; if (stackstomp) cfg.flags2 |= CFG2stomp; cfg.useModuleInfo = useModuleInfo; cfg.useTypeInfo = useTypeInfo; cfg.useExceptions = useExceptions; ph_init(); block_init(); cod3_setdefault(); if (model == 64) { util_set64(cfg.exe); type_init(); cod3_set64(); } else { util_set32(cfg.exe); type_init(); cod3_set32(); } if (cfg.objfmt == OBJ_MACH) machDebugSectionsInit(); else if (cfg.objfmt == OBJ_ELF) elfDebugSectionsInit(); rtlsym_init(); // uses fregsaved, so must be after it's set inside cod3_set* } } /**************************** * Transmit internal compiler debugging flags. */ @trusted void out_config_debug( bool b, bool c, bool f, bool r, bool w, bool x, bool y ) { debugb = b; debugc = c; debugf = f; debugr = r; debugw = w; debugx = x; debugy = y; } /************************************* */ @trusted void util_set16() { // The default is 16 bits _tysize[TYldouble] = 10; _tysize[TYildouble] = 10; _tysize[TYcldouble] = 20; _tyalignsize[TYldouble] = 2; _tyalignsize[TYildouble] = 2; _tyalignsize[TYcldouble] = 2; } /******************************* * Redo tables from 8086/286 to 386/486. */ @trusted void util_set32(exefmt_t exe) { _tyrelax[TYenum] = TYlong; _tyrelax[TYint] = TYlong; _tyrelax[TYuint] = TYlong; tyequiv[TYint] = TYlong; tyequiv[TYuint] = TYulong; _tysize[TYenum] = LONGSIZE; _tysize[TYint ] = LONGSIZE; _tysize[TYuint] = LONGSIZE; _tysize[TYnullptr] = LONGSIZE; _tysize[TYnptr] = LONGSIZE; _tysize[TYnref] = LONGSIZE; if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64)) { _tysize[TYldouble] = 12; _tysize[TYildouble] = 12; _tysize[TYcldouble] = 24; } if (exe & (EX_OSX | EX_OSX64)) { _tysize[TYldouble] = 16; _tysize[TYildouble] = 16; _tysize[TYcldouble] = 32; } if (exe & EX_windos) { _tysize[TYldouble] = 10; _tysize[TYildouble] = 10; _tysize[TYcldouble] = 20; } _tysize[TYsptr] = LONGSIZE; _tysize[TYcptr] = LONGSIZE; _tysize[TYfptr] = 6; // NOTE: There are codgen test that check _tysize[TYvptr] = 6; // _tysize[x] == _tysize[TYfptr] so don't set _tysize[TYfref] = 6; // _tysize[TYfptr] to _tysize[TYnptr] _tyalignsize[TYenum] = LONGSIZE; _tyalignsize[TYint ] = LONGSIZE; _tyalignsize[TYuint] = LONGSIZE; _tyalignsize[TYnullptr] = LONGSIZE; _tyalignsize[TYnref] = LONGSIZE; _tyalignsize[TYnptr] = LONGSIZE; if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64)) { _tyalignsize[TYldouble] = 4; _tyalignsize[TYildouble] = 4; _tyalignsize[TYcldouble] = 4; } else if (exe & (EX_OSX | EX_OSX64)) { _tyalignsize[TYldouble] = 16; _tyalignsize[TYildouble] = 16; _tyalignsize[TYcldouble] = 16; } if (exe & EX_windos) { _tyalignsize[TYldouble] = 2; _tyalignsize[TYildouble] = 2; _tyalignsize[TYcldouble] = 2; } _tyalignsize[TYsptr] = LONGSIZE; _tyalignsize[TYcptr] = LONGSIZE; _tyalignsize[TYfptr] = LONGSIZE; // NOTE: There are codgen test that check _tyalignsize[TYvptr] = LONGSIZE; // _tysize[x] == _tysize[TYfptr] so don't set _tyalignsize[TYfref] = LONGSIZE; // _tysize[TYfptr] to _tysize[TYnptr] _tysize[TYimmutPtr] = _tysize[TYnptr]; _tysize[TYsharePtr] = _tysize[TYnptr]; _tysize[TYrestrictPtr] = _tysize[TYnptr]; _tysize[TYfgPtr] = _tysize[TYnptr]; _tyalignsize[TYimmutPtr] = _tyalignsize[TYnptr]; _tyalignsize[TYsharePtr] = _tyalignsize[TYnptr]; _tyalignsize[TYrestrictPtr] = _tyalignsize[TYnptr]; _tyalignsize[TYfgPtr] = _tyalignsize[TYnptr]; } /******************************* * Redo tables from 8086/286 to I64. */ @trusted void util_set64(exefmt_t exe) { _tyrelax[TYenum] = TYlong; _tyrelax[TYint] = TYlong; _tyrelax[TYuint] = TYlong; tyequiv[TYint] = TYlong; tyequiv[TYuint] = TYulong; _tysize[TYenum] = LONGSIZE; _tysize[TYint ] = LONGSIZE; _tysize[TYuint] = LONGSIZE; _tysize[TYnullptr] = 8; _tysize[TYnptr] = 8; _tysize[TYnref] = 8; if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64)) { _tysize[TYldouble] = 16; _tysize[TYildouble] = 16; _tysize[TYcldouble] = 32; } if (exe & EX_windos) { _tysize[TYldouble] = 10; _tysize[TYildouble] = 10; _tysize[TYcldouble] = 20; } _tysize[TYsptr] = 8; _tysize[TYcptr] = 8; _tysize[TYfptr] = 10; // NOTE: There are codgen test that check _tysize[TYvptr] = 10; // _tysize[x] == _tysize[TYfptr] so don't set _tysize[TYfref] = 10; // _tysize[TYfptr] to _tysize[TYnptr] _tyalignsize[TYenum] = LONGSIZE; _tyalignsize[TYint ] = LONGSIZE; _tyalignsize[TYuint] = LONGSIZE; _tyalignsize[TYnullptr] = 8; _tyalignsize[TYnptr] = 8; _tyalignsize[TYnref] = 8; if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64)) { _tyalignsize[TYldouble] = 16; _tyalignsize[TYildouble] = 16; _tyalignsize[TYcldouble] = 16; } if (exe & (EX_OSX | EX_OSX64)) { _tyalignsize[TYldouble] = 16; _tyalignsize[TYildouble] = 16; _tyalignsize[TYcldouble] = 16; } if (exe & EX_windos) { _tyalignsize[TYldouble] = 2; _tyalignsize[TYildouble] = 2; _tyalignsize[TYcldouble] = 2; } _tyalignsize[TYsptr] = 8; _tyalignsize[TYcptr] = 8; _tyalignsize[TYfptr] = 8; _tyalignsize[TYvptr] = 8; _tyalignsize[TYfref] = 8; tytab[TYjfunc] &= ~TYFLpascal; // set so caller cleans the stack (as in C) TYptrdiff = TYllong; TYsize = TYullong; TYsize_t = TYullong; TYdelegate = TYcent; TYdarray = TYucent; _tysize[TYimmutPtr] = _tysize[TYnptr]; _tysize[TYsharePtr] = _tysize[TYnptr]; _tysize[TYrestrictPtr] = _tysize[TYnptr]; _tysize[TYfgPtr] = _tysize[TYnptr]; _tyalignsize[TYimmutPtr] = _tyalignsize[TYnptr]; _tyalignsize[TYsharePtr] = _tyalignsize[TYnptr]; _tyalignsize[TYrestrictPtr] = _tyalignsize[TYnptr]; _tyalignsize[TYfgPtr] = _tyalignsize[TYnptr]; }
D
# /etc/conf.d/chrome-remote-desktop: config file for /etc/init.d/chrome-remote-desktop # List of users to start Chrome Remote Desktop for. CHROME_REMOTING_USERS='' # Options to pass to chrome-remote-desktop. Only the -s option is interesting. #OPTIONS='-s 1600x1200 -s 3840x1600'
D
/Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/build/ChampySwift.build/Release-iphonesimulator/ChampySwift.build/Objects-normal/x86_64/CHRequests.o : /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHChalenges.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSession.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHPush.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHImages.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementWin.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/PendingFriendsController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendCell.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UnConfirmedDuel.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NewChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementDone.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHGradients.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ScoreBorder.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/WakeUpChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementInProgress.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/DuelViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NoPendingRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AuthViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/MainViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHBanners.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/RoleControlViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUsers.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSettings.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIElements.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/APCustomBlurView.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIAnimations.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AppDelegate.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AllFriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/IJReachability.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/HistoryViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ChampySwift-Bridging-Header.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UICountingLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/iCarousel.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestDataAttachment.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphErrorRecoveryProcessor.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkResolver.h ./FBSDKCoreKit.framework/Headers/FBSDKButton.h ./FBSDKCoreKit.framework/Headers/FBSDKUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKTestUsersManager.h ./FBSDKCoreKit.framework/Headers/FBSDKSettings.h ./FBSDKCoreKit.framework/Headers/FBSDKProfilePictureView.h ./FBSDKCoreKit.framework/Headers/FBSDKProfile.h ./FBSDKCoreKit.framework/Headers/FBSDKMutableCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequest.h ./FBSDKCoreKit.framework/Headers/FBSDKConstants.h ./FBSDKCoreKit.framework/Headers/FBSDKApplicationDelegate.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKAppEvents.h ./FBSDKCoreKit.framework/Headers/FBSDKMacros.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestConnection.h ./FBSDKCoreKit.framework/Headers/FBSDKCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKAccessToken.h ./FBSDKCoreKit.framework/Headers/FBSDKCoreKit.h ./FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManagerLoginResult.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginConstants.h ./FBSDKLoginKit.framework/Headers/FBSDKTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManager.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginButton.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginKit.h ./FBSDKLoginKit.framework/Modules/module.modulemap ./FBSDKShareKit.framework/Headers/FBSDKShareVideoContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareVideo.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhotoContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhoto.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphAction.h ./FBSDKShareKit.framework/Headers/FBSDKShareLinkContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialogMode.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareConstants.h ./FBSDKShareKit.framework/Headers/FBSDKShareButton.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphValueContainer.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphObject.h ./FBSDKShareKit.framework/Headers/FBSDKShareAPI.h ./FBSDKShareKit.framework/Headers/FBSDKSharingButton.h ./FBSDKShareKit.framework/Headers/FBSDKSendButton.h ./FBSDKShareKit.framework/Headers/FBSDKSharingContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharing.h ./FBSDKShareKit.framework/Headers/FBSDKMessageDialog.h ./FBSDKShareKit.framework/Headers/FBSDKLikeControl.h ./FBSDKShareKit.framework/Headers/FBSDKLiking.h ./FBSDKShareKit.framework/Headers/FBSDKLikeObjectType.h ./FBSDKShareKit.framework/Headers/FBSDKLikeButton.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestDialog.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupJoinDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupAddDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareKit.h ./FBSDKShareKit.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreData.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/build/ChampySwift.build/Release-iphonesimulator/ChampySwift.build/Objects-normal/x86_64/CHRequests~partial.swiftmodule : /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHChalenges.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSession.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHPush.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHImages.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementWin.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/PendingFriendsController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendCell.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UnConfirmedDuel.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NewChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementDone.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHGradients.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ScoreBorder.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/WakeUpChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementInProgress.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/DuelViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NoPendingRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AuthViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/MainViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHBanners.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/RoleControlViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUsers.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSettings.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIElements.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/APCustomBlurView.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIAnimations.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AppDelegate.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AllFriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/IJReachability.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/HistoryViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ChampySwift-Bridging-Header.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UICountingLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/iCarousel.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestDataAttachment.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphErrorRecoveryProcessor.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkResolver.h ./FBSDKCoreKit.framework/Headers/FBSDKButton.h ./FBSDKCoreKit.framework/Headers/FBSDKUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKTestUsersManager.h ./FBSDKCoreKit.framework/Headers/FBSDKSettings.h ./FBSDKCoreKit.framework/Headers/FBSDKProfilePictureView.h ./FBSDKCoreKit.framework/Headers/FBSDKProfile.h ./FBSDKCoreKit.framework/Headers/FBSDKMutableCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequest.h ./FBSDKCoreKit.framework/Headers/FBSDKConstants.h ./FBSDKCoreKit.framework/Headers/FBSDKApplicationDelegate.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKAppEvents.h ./FBSDKCoreKit.framework/Headers/FBSDKMacros.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestConnection.h ./FBSDKCoreKit.framework/Headers/FBSDKCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKAccessToken.h ./FBSDKCoreKit.framework/Headers/FBSDKCoreKit.h ./FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManagerLoginResult.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginConstants.h ./FBSDKLoginKit.framework/Headers/FBSDKTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManager.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginButton.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginKit.h ./FBSDKLoginKit.framework/Modules/module.modulemap ./FBSDKShareKit.framework/Headers/FBSDKShareVideoContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareVideo.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhotoContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhoto.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphAction.h ./FBSDKShareKit.framework/Headers/FBSDKShareLinkContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialogMode.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareConstants.h ./FBSDKShareKit.framework/Headers/FBSDKShareButton.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphValueContainer.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphObject.h ./FBSDKShareKit.framework/Headers/FBSDKShareAPI.h ./FBSDKShareKit.framework/Headers/FBSDKSharingButton.h ./FBSDKShareKit.framework/Headers/FBSDKSendButton.h ./FBSDKShareKit.framework/Headers/FBSDKSharingContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharing.h ./FBSDKShareKit.framework/Headers/FBSDKMessageDialog.h ./FBSDKShareKit.framework/Headers/FBSDKLikeControl.h ./FBSDKShareKit.framework/Headers/FBSDKLiking.h ./FBSDKShareKit.framework/Headers/FBSDKLikeObjectType.h ./FBSDKShareKit.framework/Headers/FBSDKLikeButton.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestDialog.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupJoinDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupAddDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareKit.h ./FBSDKShareKit.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreData.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/build/ChampySwift.build/Release-iphonesimulator/ChampySwift.build/Objects-normal/x86_64/CHRequests~partial.swiftdoc : /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHChalenges.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSession.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHPush.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHImages.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementWin.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/PendingFriendsController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendCell.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UnConfirmedDuel.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NewChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementDone.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHGradients.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ScoreBorder.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/WakeUpChallenge.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SelfImprovementInProgress.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/FriendsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/DuelViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/NoPendingRequests.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AuthViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/MainViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHBanners.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/RoleControlViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUsers.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHSettings.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIElements.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/APCustomBlurView.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/CHUIAnimations.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AppDelegate.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/AllFriendsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/IJReachability.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/SettingsTableViewController.swift /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/HistoryViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/ChampySwift-Bridging-Header.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/UICountingLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/ChampySwift/iCarousel.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestDataAttachment.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphErrorRecoveryProcessor.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkResolver.h ./FBSDKCoreKit.framework/Headers/FBSDKButton.h ./FBSDKCoreKit.framework/Headers/FBSDKUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKTestUsersManager.h ./FBSDKCoreKit.framework/Headers/FBSDKSettings.h ./FBSDKCoreKit.framework/Headers/FBSDKProfilePictureView.h ./FBSDKCoreKit.framework/Headers/FBSDKProfile.h ./FBSDKCoreKit.framework/Headers/FBSDKMutableCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequest.h ./FBSDKCoreKit.framework/Headers/FBSDKConstants.h ./FBSDKCoreKit.framework/Headers/FBSDKApplicationDelegate.h ./FBSDKCoreKit.framework/Headers/FBSDKAppLinkUtility.h ./FBSDKCoreKit.framework/Headers/FBSDKAppEvents.h ./FBSDKCoreKit.framework/Headers/FBSDKMacros.h ./FBSDKCoreKit.framework/Headers/FBSDKGraphRequestConnection.h ./FBSDKCoreKit.framework/Headers/FBSDKCopying.h ./FBSDKCoreKit.framework/Headers/FBSDKAccessToken.h ./FBSDKCoreKit.framework/Headers/FBSDKCoreKit.h ./FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManagerLoginResult.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginConstants.h ./FBSDKLoginKit.framework/Headers/FBSDKTooltipView.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginManager.h /Volumes/10.9/work/CHAMPY/ChampySwift01/ChampySwift/FBSDKCoreKit.framework/Modules/module.modulemap ./FBSDKLoginKit.framework/Headers/FBSDKLoginButton.h ./FBSDKLoginKit.framework/Headers/FBSDKLoginKit.h ./FBSDKLoginKit.framework/Modules/module.modulemap ./FBSDKShareKit.framework/Headers/FBSDKShareVideoContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareVideo.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhotoContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharePhoto.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphAction.h ./FBSDKShareKit.framework/Headers/FBSDKShareLinkContent.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialogMode.h ./FBSDKShareKit.framework/Headers/FBSDKShareDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareConstants.h ./FBSDKShareKit.framework/Headers/FBSDKShareButton.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphValueContainer.h ./FBSDKShareKit.framework/Headers/FBSDKShareOpenGraphObject.h ./FBSDKShareKit.framework/Headers/FBSDKShareAPI.h ./FBSDKShareKit.framework/Headers/FBSDKSharingButton.h ./FBSDKShareKit.framework/Headers/FBSDKSendButton.h ./FBSDKShareKit.framework/Headers/FBSDKSharingContent.h ./FBSDKShareKit.framework/Headers/FBSDKSharing.h ./FBSDKShareKit.framework/Headers/FBSDKMessageDialog.h ./FBSDKShareKit.framework/Headers/FBSDKLikeControl.h ./FBSDKShareKit.framework/Headers/FBSDKLiking.h ./FBSDKShareKit.framework/Headers/FBSDKLikeObjectType.h ./FBSDKShareKit.framework/Headers/FBSDKLikeButton.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestDialog.h ./FBSDKShareKit.framework/Headers/FBSDKGameRequestContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppInviteContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupJoinDialog.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupContent.h ./FBSDKShareKit.framework/Headers/FBSDKAppGroupAddDialog.h ./FBSDKShareKit.framework/Headers/FBSDKShareKit.h ./FBSDKShareKit.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreData.swiftmodule
D
/* * Collie - An asynchronous event-driven network framework using Dlang development * * Copyright (C) 2015-2017 Shanghai Putao Technology Co., Ltd * * Developer: putao's Dlang team * * Licensed under the Apache-2.0 License. * */ module collie.bootstrap.client; import collie.channel; import collie.net; import collie.utils.memory; import collie.bootstrap.exception; import collie.net.client.linklogInfo; public import kiss.net.TcpStream; import kiss.event.task; final class ClientBootstrap(PipeLine) : PipelineManager { alias ConnCallBack = void delegate(PipeLine); alias LinklogInfo = TLinklogInfo!ConnCallBack; alias ClientCreatorCallBack = void delegate(TcpStream); this(EventLoop loop) { _loop = loop; } ~this() { if (_timer) _timer.destroy; if(_logInfo.client) _logInfo.client.destroy; } void setClientCreatorCallBack(ClientCreatorCallBack cback) { _oncreator = cback; } auto pipelineFactory(shared PipelineFactory!PipeLine pipeFactory) { _pipelineFactory = pipeFactory; return this; } /// time is s auto heartbeatTimeOut(uint second) { _timeOut = second * 1000; return this; } void connect(Address to, ConnCallBack cback = null) { if (_pipelineFactory is null) throw new NeedPipeFactoryException( "Pipeline must be not null! Please set Pipeline frist!"); if (_logInfo.client) throw new ConnectedException("This Socket is Connected! Please close before connect!"); _logInfo.addr = to; _logInfo.tryCount = 0; _logInfo.cback = cback; _loop.postTask(newTask(&doConnect)); } void close() { if (_logInfo.client is null) return; _logInfo.client.close(); } @property EventLoop eventLoop() { return _loop; } @property auto pipeLine() { if(_logInfo.client is null) return null; return _pipe; } @property tryCount(){return _tryCount;} @property tryCount(uint count){_tryCount = count;} protected: void doConnect() { _logInfo.client = new TcpStream(_loop,_logInfo.addr.addressFamily); if(_oncreator) _oncreator(_logInfo.client); _logInfo.client.setCloseHandle(&closeCallBack); _logInfo.client.setConnectHandle(&connectCallBack); _logInfo.client.setReadHandle(&readCallBack); _logInfo.client.connect(_logInfo.addr); } void closeCallBack() nothrow @trusted { catchAndLogException((){ if (_timer) _timer.stop(); if(_pipe) _pipe.transportInactive(); }()); } void connectCallBack(bool isconnect) nothrow @trusted { catchAndLogException((){ if (isconnect) { if (_timeOut > 0) { if (_timer is null) { _timer = new KissTimer(_loop); _timer.setTimerHandle(&onTimeOut); } if(!_timer.watched) { bool rv = _timer.start(_timeOut); //logDebug("start timer! : ", rv); } } _logInfo.tryCount = 0; _pipe = _pipelineFactory.newPipeline(_logInfo.client); if(_logInfo.cback) _logInfo.cback(_pipe); _pipe.finalize(); _pipe.pipelineManager(this); _pipe.transportActive(); }else if(_logInfo.tryCount < _tryCount){ _logInfo.client = null; _logInfo.tryCount ++; doConnect(); } else { if(_logInfo.cback) _logInfo.cback(null); _logInfo.client = null; _logInfo.cback = null; _logInfo.addr = null; _pipe = null; } }()); } void readCallBack(in ubyte[] buffer) nothrow @trusted { catchAndLogException(_pipe.read(cast(ubyte[])buffer)); } /// Client Time out is not refresh! void onTimeOut() nothrow @trusted { catchAndLogException((){ if(_pipe) _pipe.timeOut(); }()); } override void deletePipeline(PipelineBase pipeline) { if (_timer) _timer.stop(); gcFree(_logInfo.client); _logInfo.client = null; pipeline.pipelineManager(null); _pipe = null; } override void refreshTimeout() { } private: EventLoop _loop; PipeLine _pipe; shared PipelineFactory!PipeLine _pipelineFactory; KissTimer _timer = null; uint _timeOut = 0; uint _tryCount; LinklogInfo _logInfo; ClientCreatorCallBack _oncreator; }
D
/Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Multicast.o : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Multicast~partial.swiftmodule : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Multicast~partial.swiftdoc : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule
D
module android.java.java.lang.ArrayIndexOutOfBoundsException_d_interface; import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers; static import arsd.jni; import import1 = android.java.java.io.PrintStream_d_interface; import import4 = android.java.java.lang.Class_d_interface; import import3 = android.java.java.lang.StackTraceElement_d_interface; import import2 = android.java.java.io.PrintWriter_d_interface; import import0 = android.java.java.lang.JavaThrowable_d_interface; final class ArrayIndexOutOfBoundsException : IJavaObject { static immutable string[] _d_canCastTo = [ ]; @Import this(arsd.jni.Default); @Import this(int); @Import this(string); @Import string getMessage(); @Import string getLocalizedMessage(); @Import import0.JavaThrowable getCause(); @Import import0.JavaThrowable initCause(import0.JavaThrowable); @Import @JavaName("toString") string toString_(); override string toString() { return arsd.jni.javaObjectToString(this); } @Import void printStackTrace(); @Import void printStackTrace(import1.PrintStream); @Import void printStackTrace(import2.PrintWriter); @Import import0.JavaThrowable fillInStackTrace(); @Import import3.StackTraceElement[] getStackTrace(); @Import void setStackTrace(import3.StackTraceElement[]); @Import void addSuppressed(import0.JavaThrowable); @Import import0.JavaThrowable[] getSuppressed(); @Import import4.Class getClass(); @Import int hashCode(); @Import bool equals(IJavaObject); @Import void notify(); @Import void notifyAll(); @Import void wait(long); @Import void wait(long, int); @Import void wait(); mixin IJavaObjectImplementation!(false); public static immutable string _javaParameterString = "Ljava/lang/ArrayIndexOutOfBoundsException;"; }
D
/** A module for providing interop between reggae and dub */ module reggae.dub.interop; import reggae.from; public import reggae.dub.interop.reggaefile; void writeDubConfig(O)(ref O output, in from!"reggae.options".Options options, from!"std.stdio".File file) { import reggae.io: log; import reggae.dub.info: TargetType; import reggae.dub.interop.fetch: dubFetch; import reggae.dub.interop.dublib: Dub; output.log("Writing dub configuration"); scope(exit) output.log("Finished writing dub configuration"); if(!options.isDubProject) { file.writeln("enum isDubProject = false;"); return; } auto dubInfos = dubInfos(output, options); const targetType = dubInfos["default"].packages.length ? dubInfos["default"].packages[0].targetType : TargetType.sourceLibrary; file.writeln("import reggae.dub.info;"); file.writeln("enum isDubProject = true;"); file.writeln(`const configToDubInfo = assocList([`); foreach(k, v; dubInfos) { file.writeln(` assocEntry("`, k, `", `, v, `),`); } file.writeln(`]);`); file.writeln; } auto dubInfos(O)(ref O output, in from!"reggae.options".Options options) { import reggae.io: log; import reggae.dub.info: TargetType; import reggae.dub.interop.fetch: dubFetch; import reggae.dub.interop.dublib: Dub; // must check for dub.selections.json before creating dub instance const dubSelectionsJson = ensureDubSelectionsJson(output, options); auto dub = Dub(options); dubFetch(output, dub, options, dubSelectionsJson); output.log(" Getting dub build information"); auto ret = getDubInfos(output, dub, options); output.log(" Got dub build information"); return ret; } private string ensureDubSelectionsJson (O) (ref O output, in from!"reggae.options".Options options) @safe { import reggae.dub.interop.exec: callDub, dubEnvArgs; import reggae.io: log; import reggae.path: buildPath; import std.file: exists; import std.exception: enforce; const path = buildPath(options.projectPath, "dub.selections.json"); if(!path.exists) { output.log("Creating dub.selections.json"); const cmd = ["dub", "upgrade"] ~ dubEnvArgs; callDub(output, options, cmd); } enforce(path.exists, "Could not create dub.selections.json"); return path; } private from!"reggae.dub.info".DubInfo[string] getDubInfos (O) (ref O output, ref from!"reggae.dub.interop.dublib".Dub dub, in from!"reggae.options".Options options) { import reggae.io: log; import reggae.path: buildPath; import reggae.dub.info: DubInfo; import std.file: exists; import std.exception: enforce; DubInfo[string] ret; enforce(buildPath(options.projectPath, "dub.selections.json").exists, "Cannot find dub.selections.json"); auto settings = dub.getGeneratorSettings(options); const configs = dubConfigurations(output, dub, options, settings); const haveTestConfig = configs.test != ""; bool atLeastOneConfigOk; Exception dubInfoFailure; foreach(config; configs.configurations) { const isTestConfig = haveTestConfig && config == configs.test; try { ret[config] = handleDubConfig(output, dub, options, settings, config, isTestConfig); atLeastOneConfigOk = true; } catch(Exception ex) { output.log("ERROR: Could not get info for configuration ", config, ": ", ex.msg); if(dubInfoFailure is null) dubInfoFailure = ex; } } if(!atLeastOneConfigOk) { assert(dubInfoFailure !is null, "Internal error: no configurations worked and no exception to throw"); throw dubInfoFailure; } ret["default"] = ret[configs.default_]; // (additionally) expose the special `dub test` config as `unittest` config in the DSL (`configToDubInfo`) // (for `dubTestTarget!()`, `dubConfigurationTarget!(Configuration("unittest"))` etc.) if(haveTestConfig && configs.test != "unittest" && configs.test in ret) ret["unittest"] = ret[configs.test]; return ret; } private from!"reggae.dub.interop.configurations".DubConfigurations dubConfigurations (O) (ref O output, ref from!"reggae.dub.interop.dublib".Dub dub, in from!"reggae.options".Options options, in from!"dub.generators.generator".GeneratorSettings settings) { import reggae.dub.interop.configurations: DubConfigurations; import reggae.io: log; const allConfigs = options.dubConfig == ""; if(allConfigs) output.log("Getting dub configurations"); auto ret = dub.getConfigs(settings, options.dubConfig); if(allConfigs) output.log("Number of dub configurations: ", ret.configurations.length); // error out if the test config is explicitly requested but not available if(options.dubConfig == "unittest" && ret.test == "") { output.log("ERROR: No dub test configuration available (target type 'none'?)"); throw new Exception("No dub test configuration"); } // this happens e.g. the targetType is "none" if(ret.configurations.length == 0) return DubConfigurations([""], "", null); return ret; } private from!"reggae.dub.info".DubInfo handleDubConfig (O) (ref O output, ref from!"reggae.dub.interop.dublib".Dub dub, in from!"reggae.options".Options options, from!"dub.generators.generator".GeneratorSettings settings, in string config, in bool isTestConfig) { import reggae.io: log; import std.conv: text; output.log("Querying dub configuration '", config, "'"); auto dubInfo = dub.configToDubInfo(settings, config); /** For the `dub test` config, add `-unittest` (only for the main package, hence [0]). [Similarly, `dub test` implies `--build=unittest`, with the unittest build type being the debug one + `-unittest`.] This enables (assuming no custom reggaefile.d): * `reggae && ninja default ut` => default `debug` build type for default config, extra `-unittest` for test config * `reggae --dub-config=unittest && ninja` => no need for extra `--dub-build-type=unittest` */ if(isTestConfig) { if(dubInfo.packages.length == 0) throw new Exception( text("No main package in `", config, "` configuration")); dubInfo.packages[0].dflags ~= "-unittest"; } try callPreBuildCommands(output, options, dubInfo); catch(Exception e) { output.log("Error calling prebuild commands: ", e.msg); throw e; } return dubInfo; } private void callPreBuildCommands(O)(ref O output, in from!"reggae.options".Options options, in from!"reggae.dub.info".DubInfo dubInfo) @safe { import reggae.io: log; import std.process: executeShell, Config; import std.string: replace; import std.exception: enforce; import std.conv: text; const string[string] env = null; Config config = Config.none; size_t maxOutput = size_t.max; immutable workDir = options.projectPath; if(dubInfo.packages.length == 0) return; foreach(const package_; dubInfo.packages) { foreach(const dubCommandString; package_.preBuildCommands) { auto cmd = dubCommandString.replace("$project", options.projectPath); output.log("Executing pre-build command `", cmd, "`"); const ret = executeShell(cmd, env, config, maxOutput, workDir); enforce(ret.status == 0, text("Error calling ", cmd, ":\n", ret.output)); } } }
D
/** * D header file for OpenBSD. * * Authors: Iain Buclaw * Based-on: core/sys/freebsd/sys */ module core.sys.openbsd.sys.elf_common; version (OpenBSD): extern (C): import core.stdc.stdint; struct Elf_Note { uint32_t n_namesz; uint32_t n_descsz; uint32_t n_type; } struct Elf_GNU_Hash_Header { uint32_t gh_nbuckets; uint32_t gh_symndx; uint32_t gh_maskwords; uint32_t gh_shift2; } enum EI_MAG0 = 0; enum EI_MAG1 = 1; enum EI_MAG2 = 2; enum EI_MAG3 = 3; enum EI_CLASS = 4; enum EI_DATA = 5; enum EI_VERSION = 6; enum EI_OSABI = 7; enum EI_ABIVERSION = 8; enum OLD_EI_BRAND = 8; enum EI_PAD = 9; enum EI_NIDENT = 16; enum ELFMAG0 = 0x7f; enum ELFMAG1 = 'E'; enum ELFMAG2 = 'L'; enum ELFMAG3 = 'F'; enum ELFMAG = "\177ELF"; enum SELFMAG = 4; enum EV_NONE = 0; enum EV_CURRENT = 1; enum ELFCLASSNONE = 0; enum ELFCLASS32 = 1; enum ELFCLASS64 = 2; enum ELFDATANONE = 0; enum ELFDATA2LSB = 1; enum ELFDATA2MSB = 2; enum ELFOSABI_NONE = 0; enum ELFOSABI_SYSV = 0; enum ELFOSABI_HPUX = 1; enum ELFOSABI_NETBSD = 2; enum ELFOSABI_LINUX = 3; enum ELFOSABI_HURD = 4; enum ELFOSABI_86OPEN = 5; enum ELFOSABI_SOLARIS = 6; enum ELFOSABI_AIX = 7; enum ELFOSABI_MONTEREY = 7; enum ELFOSABI_IRIX = 8; enum ELFOSABI_FREEBSD = 9; enum ELFOSABI_TRU64 = 10; enum ELFOSABI_MODESTO = 11; enum ELFOSABI_OPENBSD = 12; enum ELFOSABI_OPENVMS = 13; enum ELFOSABI_NSK = 14; enum ELFOSABI_AROS = 15; enum ELFOSABI_ARM = 97; enum ELFOSABI_STANDALONE = 255; // just a pointer enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; extern (D) pure @safe { auto IS_ELF(T)(T ehdr) { return ehdr.e_ident[EI_MAG0] == ELFMAG0 && ehdr.e_ident[EI_MAG1] == ELFMAG1 && ehdr.e_ident[EI_MAG2] == ELFMAG2 && ehdr.e_ident[EI_MAG3] == ELFMAG3; } } enum ET_NONE = 0; enum ET_REL = 1; enum ET_EXEC = 2; enum ET_DYN = 3; enum ET_CORE = 4; enum ET_LOOS = 0xfe00; enum ET_HIOS = 0xfeff; enum ET_LOPROC = 0xff00; enum ET_HIPROC = 0xffff; enum EM_NONE = 0; enum EM_M32 = 1; enum EM_SPARC = 2; enum EM_386 = 3; enum EM_68K = 4; enum EM_88K = 5; enum EM_860 = 7; enum EM_MIPS = 8; enum EM_S370 = 9; enum EM_MIPS_RS3_LE = 10; enum EM_PARISC = 15; enum EM_VPP500 = 17; enum EM_SPARC32PLUS = 18; enum EM_960 = 19; enum EM_PPC = 20; enum EM_PPC64 = 21; enum EM_S390 = 22; enum EM_V800 = 36; enum EM_FR20 = 37; enum EM_RH32 = 38; enum EM_RCE = 39; enum EM_ARM = 40; enum EM_SH = 42; enum EM_SPARCV9 = 43; enum EM_TRICORE = 44; enum EM_ARC = 45; enum EM_H8_300 = 46; enum EM_H8_300H = 47; enum EM_H8S = 48; enum EM_H8_500 = 49; enum EM_IA_64 = 50; enum EM_MIPS_X = 51; enum EM_COLDFIRE = 52; enum EM_68HC12 = 53; enum EM_MMA = 54; enum EM_PCP = 55; enum EM_NCPU = 56; enum EM_NDR1 = 57; enum EM_STARCORE = 58; enum EM_ME16 = 59; enum EM_ST100 = 60; enum EM_TINYJ = 61; enum EM_X86_64 = 62; enum EM_AMD64 = 62; enum EM_PDSP = 63; enum EM_FX66 = 66; enum EM_ST9PLUS = 67; enum EM_ST7 = 68; enum EM_68HC16 = 69; enum EM_68HC11 = 70; enum EM_68HC08 = 71; enum EM_68HC05 = 72; enum EM_SVX = 73; enum EM_ST19 = 74; enum EM_VAX = 75; enum EM_CRIS = 76; enum EM_JAVELIN = 77; enum EM_FIREPATH = 78; enum EM_ZSP = 79; enum EM_MMIX = 80; enum EM_HUANY = 81; enum EM_PRISM = 82; enum EM_AVR = 83; enum EM_FR30 = 84; enum EM_D10V = 85; enum EM_D30V = 86; enum EM_V850 = 87; enum EM_M32R = 88; enum EM_MN10300 = 89; enum EM_MN10200 = 90; enum EM_PJ = 91; enum EM_OPENRISC = 92; enum EM_ARC_A5 = 93; enum EM_XTENSA = 94; enum EM_VIDEOCORE = 95; enum EM_TMM_GPP = 96; enum EM_NS32K = 97; enum EM_TPC = 98; enum EM_SNP1K = 99; enum EM_ST200 = 100; enum EM_IP2K = 101; enum EM_MAX = 102; enum EM_CR = 103; enum EM_F2MC16 = 104; enum EM_MSP430 = 105; enum EM_BLACKFIN = 106; enum EM_SE_C33 = 107; enum EM_SEP = 108; enum EM_ARCA = 109; enum EM_UNICORE = 110; enum EM_DXP = 112; enum EM_ALTERA_NIOS2 =113; enum EM_CRX = 114; enum EM_XGATE = 115; enum EM_C166 = 116; enum EM_M16C = 117; enum EM_DSPIC30F = 118; enum EM_CE = 119; enum EM_M32C = 120; enum EM_res121 = 121; enum EM_res122 = 122; enum EM_res123 = 123; enum EM_res124 = 124; enum EM_res125 = 125; enum EM_res126 = 126; enum EM_res127 = 127; enum EM_res128 = 128; enum EM_res129 = 129; enum EM_res130 = 130; enum EM_TSK3000 = 131; enum EM_RS08 = 132; enum EM_res133 = 133; enum EM_ECOG2 = 134; enum EM_SCORE = 135; enum EM_SCORE7 = 135; enum EM_DSP24 = 136; enum EM_VIDEOCORE3 = 137; enum EM_LATTICEMICO32 = 138; enum EM_SE_C17 = 139; enum EM_TI_C6000 = 140; enum EM_TI_C2000 = 141; enum EM_TI_C5500 = 142; enum EM_res143 = 143; enum EM_res144 = 144; enum EM_res145 = 145; enum EM_res146 = 146; enum EM_res147 = 147; enum EM_res148 = 148; enum EM_res149 = 149; enum EM_res150 = 150; enum EM_res151 = 151; enum EM_res152 = 152; enum EM_res153 = 153; enum EM_res154 = 154; enum EM_res155 = 155; enum EM_res156 = 156; enum EM_res157 = 157; enum EM_res158 = 158; enum EM_res159 = 159; enum EM_MMDSP_PLUS = 160; enum EM_CYPRESS_M8C = 161; enum EM_R32C = 162; enum EM_TRIMEDIA = 163; enum EM_QDSP6 = 164; enum EM_8051 = 165; enum EM_STXP7X = 166; enum EM_NDS32 = 167; enum EM_ECOG1 = 168; enum EM_ECOG1X = 168; enum EM_MAXQ30 = 169; enum EM_XIMO16 = 170; enum EM_MANIK = 171; enum EM_CRAYNV2 = 172; enum EM_RX = 173; enum EM_METAG = 174; enum EM_MCST_ELBRUS = 175; enum EM_ECOG16 = 176; enum EM_CR16 = 177; enum EM_ETPU = 178; enum EM_SLE9X = 179; enum EM_L1OM = 180; enum EM_K1OM = 181; enum EM_INTEL182 = 182; enum EM_res183 = 183; enum EM_res184 = 184; enum EM_AVR32 = 185; enum EM_STM8 = 186; enum EM_TILE64 = 187; enum EM_TILEPRO = 188; enum EM_MICROBLAZE = 189; enum EM_CUDA = 190; enum EM_TILEGX = 191; enum EM_486 = 6; enum EM_MIPS_RS4_BE = 10; enum EM_ALPHA_STD = 41; enum EM_ALPHA = 0x9026; enum SHN_UNDEF = 0; enum SHN_LORESERVE = 0xff00; enum SHN_LOPROC = 0xff00; enum SHN_HIPROC = 0xff1f; enum SHN_LOOS = 0xff20; enum SHN_HIOS = 0xff3f; enum SHN_ABS = 0xfff1; enum SHN_COMMON = 0xfff2; enum SHN_XINDEX = 0xffff; enum SHN_HIRESERVE = 0xffff; enum PT_NULL = 0; enum PT_LOAD = 1; enum PT_DYNAMIC = 2; enum PT_INTERP = 3; enum PT_NOTE = 4; enum PT_SHLIB = 5; enum PT_PHDR = 6; enum PT_TLS = 7; enum PT_LOOS = 0x60000000; enum PT_HIOS = 0x6fffffff; enum PT_LOPROC = 0x70000000; enum PT_HIPROC = 0x7fffffff; enum PT_GNU_EH_FRAME = PT_LOOS + 0x474e550; /* Frame unwind information */ enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME; /* Solaris uses the same value */ enum PT_GNU_STACK = PT_LOOS + 0x474e551; /* Stack flags */ enum PT_GNU_RELRO = PT_LOOS + 0x474e552; /* Read-only after relocation */ enum PF_X = 0x1; enum PF_W = 0x2; enum PF_R = 0x4; enum PF_MASKOS = 0x0ff00000; enum PF_MASKPROC = 0xf0000000; enum PN_XNUM = 0xffff; enum SHT_NULL = 0; enum SHT_PROGBITS = 1; enum SHT_SYMTAB = 2; enum SHT_STRTAB = 3; enum SHT_RELA = 4; enum SHT_HASH = 5; enum SHT_DYNAMIC = 6; enum SHT_NOTE = 7; enum SHT_NOBITS = 8; enum SHT_REL = 9; enum SHT_SHLIB = 10; enum SHT_DYNSYM = 11; enum SHT_INIT_ARRAY = 14; enum SHT_FINI_ARRAY = 15; enum SHT_PREINIT_ARRAY = 16; enum SHT_GROUP = 17; enum SHT_SYMTAB_SHNDX = 18; enum SHT_LOOS = 0x60000000; enum SHT_LOSUNW = 0x6ffffff4; enum SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700; enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; enum SHT_GNU_HASH = 0x6ffffff6; enum SHT_GNU_LIBLIST = 0x6ffffff7; //enum SHT_SUNW_dof = 0x6ffffff4; //enum SHT_SUNW_cap = 0x6ffffff5; //enum SHT_SUNW_SIGNATURE = 0x6ffffff6; enum SHT_SUNW_verdef = 0x6ffffffd; enum SHT_SUNW_verneed = 0x6ffffffe; enum SHT_SUNW_versym = 0x6fffffff; enum SHT_GNU_verdef = SHT_SUNW_verdef; enum SHT_GNU_verneed = SHT_SUNW_verneed; enum SHT_GNU_versym = SHT_SUNW_versym; enum SHT_LOPROC = 0x70000000; enum SHT_HIPROC = 0x7fffffff; enum SHT_LOUSER = 0x80000000; enum SHT_HIUSER = 0x8fffffff; /* enum SHT_GNU_HASH = 0x6ffffff6; enum SHT_SUNW_ANNOTATE = 0x6ffffff7; enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; enum SHT_SUNW_DEBUG = 0x6ffffff9; enum SHT_SUNW_move = 0x6ffffffa; enum SHT_SUNW_COMDAT = 0x6ffffffb; enum SHT_SUNW_syminfo = 0x6ffffffc; enum SHT_HISUNW = 0x6fffffff; enum SHT_HIOS = 0x6fffffff; enum SHT_AMD64_UNWIND = 0x70000001; enum SHT_ARM_EXIDX = 0x70000001; enum SHT_ARM_PREEMPTMAP = 0x70000002; enum SHT_ARM_ATTRIBUTES = 0x70000003; enum SHT_ARM_DEBUGOVERLAY = 0x70000004; enum SHT_ARM_OVERLAYSECTION = 0x70000005; enum SHT_MIPS_REGINFO = 0x70000006; enum SHT_MIPS_OPTIONS = 0x7000000d; enum SHT_MIPS_DWARF = 0x7000001e; */ enum SHF_WRITE = (1 << 0); enum SHF_ALLOC = (1 << 1); enum SHF_EXECINSTR = (1 << 2); enum SHF_MERGE = (1 << 4); enum SHF_STRINGS = (1 << 5); enum SHF_INFO_LINK = (1 << 6); enum SHF_LINK_ORDER = (1 << 7); enum SHF_OS_NONCONFORMING = (1 << 8); enum SHF_GROUP = (1 << 9); enum SHF_TLS = (1 << 10); enum SHF_COMPRESSED = (1 << 11); enum SHF_MASKOS = 0x0ff00000; enum SHF_MASKPROC = 0xf0000000; enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; enum NT_PRPSINFO = 3; enum NT_TASKSTRUCT = 4; enum NT_AUXV = 6; /* enum NT_THRMISC = 7; enum NT_PROCSTAT_PROC = 8; enum NT_PROCSTAT_FILES = 9; enum NT_PROCSTAT_VMMAP = 10; enum NT_PROCSTAT_GROUPS = 11; enum NT_PROCSTAT_UMASK = 12; enum NT_PROCSTAT_RLIMIT = 13; enum NT_PROCSTAT_OSREL = 14; enum NT_PROCSTAT_PSSTRINGS = 15; enum NT_PROCSTAT_AUXV = 16; */ enum STN_UNDEF = 0; enum STB_LOCAL = 0; enum STB_GLOBAL = 1; enum STB_WEAK = 2; enum STB_NUM = 3; enum STB_LOOS = 10; enum STB_HIOS = 12; enum STB_LOPROC = 13; enum STB_HIPROC = 15; enum STT_NOTYPE = 0; enum STT_OBJECT = 1; enum STT_FUNC = 2; enum STT_SECTION = 3; enum STT_FILE = 4; enum STT_COMMON = 5; enum STT_TLS = 6; enum STT_NUM = 7; enum STT_LOOS = 10; enum STT_GNU_IFUNC = 10; enum STT_HIOS = 12; enum STT_LOPROC = 13; enum STT_HIPROC = 15; enum STV_DEFAULT = 0; enum STV_INTERNAL = 1; enum STV_HIDDEN = 2; enum STV_PROTECTED = 3; /* enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; */ enum DT_NULL = 0; enum DT_NEEDED = 1; enum DT_PLTRELSZ = 2; enum DT_PLTGOT = 3; enum DT_HASH = 4; enum DT_STRTAB = 5; enum DT_SYMTAB = 6; enum DT_RELA = 7; enum DT_RELASZ = 8; enum DT_RELAENT = 9; enum DT_STRSZ = 10; enum DT_SYMENT = 11; enum DT_INIT = 12; enum DT_FINI = 13; enum DT_SONAME = 14; enum DT_RPATH = 15; enum DT_SYMBOLIC = 16; enum DT_REL = 17; enum DT_RELSZ = 18; enum DT_RELENT = 19; enum DT_PLTREL = 20; enum DT_DEBUG = 21; enum DT_TEXTREL = 22; enum DT_JMPREL = 23; enum DT_BIND_NOW = 24; enum DT_INIT_ARRAY = 25; enum DT_FINI_ARRAY = 26; enum DT_INIT_ARRAYSZ = 27; enum DT_FINI_ARRAYSZ = 28; enum DT_RUNPATH = 29; enum DT_FLAGS = 30; enum DT_ENCODING = 32; enum DT_PREINIT_ARRAY = 32; enum DT_PREINIT_ARRAYSZ = 33; //enum DT_MAXPOSTAGS = 34; enum DT_LOOS = 0x6000000d; enum DT_HIOS = 0x6ffff000; /* enum DT_SUNW_AUXILIARY = 0x6000000d; enum DT_SUNW_RTLDINF = 0x6000000e; enum DT_SUNW_FILTER = 0x6000000f; enum DT_SUNW_CAP = 0x60000010; */ enum DT_VALRNGLO = 0x6ffffd00; enum DT_GNU_PRELINKED = 0x6ffffdf5; enum DT_GNU_CONFLICTSZ =0x6ffffdf6; enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; enum DT_CHECKSUM = 0x6ffffdf8; enum DT_PLTPADSZ = 0x6ffffdf9; enum DT_MOVEENT = 0x6ffffdfa; enum DT_MOVESZ = 0x6ffffdfb; enum DT_FEATURE_1 = 0x6ffffdfc; enum DT_POSFLAG_1 = 0x6ffffdfd; enum DT_SYMINSZ = 0x6ffffdfe; enum DT_SYMINENT = 0x6ffffdff; enum DT_VALRNGHI = 0x6ffffdff; enum DT_ADDRRNGLO = 0x6ffffe00; enum DT_GNU_HASH = 0x6ffffef5; enum DT_TLSDESC_PLT = 0x6ffffef6; enum DT_TLSDESC_GOT = 0x6ffffef7; enum DT_GNU_CONFLICT = 0x6ffffef8; enum DT_GNU_LIBLIST = 0x6ffffef9; enum DT_CONFIG = 0x6ffffefa; enum DT_DEPAUDIT = 0x6ffffefb; enum DT_AUDIT = 0x6ffffefc; enum DT_PLTPAD = 0x6ffffefd; enum DT_MOVETAB = 0x6ffffefe; enum DT_SYMINFO = 0x6ffffeff; enum DT_ADDRRNGHI = 0x6ffffeff; enum DT_RELACOUNT = 0x6ffffff9; enum DT_RELCOUNT = 0x6ffffffa; enum DT_FLAGS_1 = 0x6ffffffb; enum DT_VERDEF = 0x6ffffffc; enum DT_VERDEFNUM = 0x6ffffffd; enum DT_VERNEED = 0x6ffffffe; enum DT_VERNEEDNUM = 0x6fffffff; enum DT_VERSYM = 0x6ffffff0; enum DT_LOPROC = 0x70000000; //enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; enum DT_FILTER = 0x7fffffff; enum DT_HIPROC = 0x7fffffff; enum DTF_1_PARINIT = 0x00000001; enum DTF_1_CONFEXP = 0x00000002; enum DF_P1_LAZYLOAD = 0x00000001; enum DF_P1_GROUPPERM= 0x00000002; enum DF_1_NOW = 0x00000001; enum DF_1_BIND_NOW = 0x00000001; enum DF_1_GLOBAL = 0x00000002; enum DF_1_GROUP = 0x00000004; enum DF_1_NODELETE = 0x00000008; enum DF_1_LOADFLTR = 0x00000010; enum DF_1_INITFIRST = 0x00000020; enum DF_1_NOOPEN = 0x00000040; enum DF_1_ORIGIN = 0x00000080; enum DF_1_DIRECT = 0x00000100; enum DF_1_TRANS = 0x00000200; enum DF_1_INTERPOSE = 0x00000400; enum DF_1_NODEFLIB = 0x00000800; enum DF_1_NODUMP = 0x00001000; enum DF_1_CONLFAT = 0x00002000; enum DF_ORIGIN = 0x00000001; enum DF_SYMBOLIC = 0x00000002; enum DF_TEXTREL = 0x00000004; enum DF_BIND_NOW = 0x00000008; enum DF_STATIC_TLS = 0x00000010; enum VER_DEF_NONE = 0; enum VER_DEF_CURRENT = 1; alias VER_NDX VER_DEF_IDX; enum VER_FLG_BASE = 0x1; enum VER_FLG_WEAK = 0x2; enum VER_FLG_INFO = 0x4; enum VER_NDX_LOCAL = 0; enum VER_NDX_GLOBAL = 1; enum VER_NDX_GIVEN = 2; enum VER_NDX_HIDDEN = 32768; extern (D) pure @safe { auto VER_NDX(V)(V v) { return v & ~(1u << 15); } } enum VER_NEED_NONE = 0; enum VER_NEED_CURRENT = 1; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; alias VER_NDX VER_NEED_IDX; /* enum CA_SUNW_NULL = 0; enum CA_SUNW_HW_1 = 1; enum CA_SUNW_SF_1 = 2; */ enum VERSYM_HIDDEN = 0x8000; enum VERSYM_VERSION = 0x7fff; enum ELF_VER_CHR = '@'; enum SYMINFO_BT_SELF = 0xffff; enum SYMINFO_BT_PARENT = 0xfffe; //enum SYMINFO_BT_NONE = 0xfffd; //enum SYMINFO_BT_EXTERN = 0xfffc; enum SYMINFO_BT_LOWRESERVE = 0xff00; enum SYMINFO_FLG_DIRECT = 0x0001; enum SYMINFO_FLG_PASSTHRU = 0x0002; enum SYMINFO_FLG_COPY = 0x0004; enum SYMINFO_FLG_LAZYLOAD = 0x0008; //enum SYMINFO_FLG_DIRECTBIND = 0x0010; //enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; //enum SYMINFO_FLG_FILTER = 0x0002; //enum SYMINFO_FLG_AUXILIARY = 0x0040; enum SYMINFO_NONE = 0; enum SYMINFO_CURRENT = 1; enum SYMINFO_NUM = 2; enum GRP_COMDAT = 0x1; enum R_386_NONE = 0; enum R_386_32 = 1; enum R_386_PC32 = 2; enum R_386_GOT32 = 3; enum R_386_PLT32 = 4; enum R_386_COPY = 5; enum R_386_GLOB_DAT = 6; enum R_386_JMP_SLOT = 7; enum R_386_RELATIVE = 8; enum R_386_GOTOFF = 9; enum R_386_GOTPC = 10; enum R_386_TLS_TPOFF = 14; enum R_386_TLS_IE = 15; enum R_386_TLS_GOTIE = 16; enum R_386_TLS_LE = 17; enum R_386_TLS_GD = 18; enum R_386_TLS_LDM = 19; enum R_386_TLS_GD_32 = 24; enum R_386_TLS_GD_PUSH = 25; enum R_386_TLS_GD_CALL = 26; enum R_386_TLS_GD_POP = 27; enum R_386_TLS_LDM_32 = 28; enum R_386_TLS_LDM_PUSH = 29; enum R_386_TLS_LDM_CALL = 30; enum R_386_TLS_LDM_POP = 31; enum R_386_TLS_LDO_32 = 32; enum R_386_TLS_IE_32 = 33; enum R_386_TLS_LE_32 = 34; enum R_386_TLS_DTPMOD32 = 35; enum R_386_TLS_DTPOFF32 = 36; enum R_386_TLS_TPOFF32 = 37; enum R_386_IRELATIVE = 42; enum R_X86_64_NONE = 0; enum R_X86_64_64 = 1; enum R_X86_64_PC32 = 2; enum R_X86_64_GOT32 = 3; enum R_X86_64_PLT32 = 4; enum R_X86_64_COPY = 5; enum R_X86_64_GLOB_DAT = 6; enum R_X86_64_JMP_SLOT = 7; enum R_X86_64_RELATIVE = 8; enum R_X86_64_GOTPCREL = 9; enum R_X86_64_32 = 10; enum R_X86_64_32S = 11; enum R_X86_64_16 = 12; enum R_X86_64_PC16 = 13; enum R_X86_64_8 = 14; enum R_X86_64_PC8 = 15; enum R_X86_64_DTPMOD64 = 16; enum R_X86_64_DTPOFF64 = 17; enum R_X86_64_TPOFF64 = 18; enum R_X86_64_TLSGD = 19; enum R_X86_64_TLSLD = 20; enum R_X86_64_DTPOFF32 = 21; enum R_X86_64_GOTTPOFF = 22; enum R_X86_64_TPOFF32 = 23; enum R_X86_64_IRELATIVE = 37;
D
/Users/xda/Desktop/swift_demo/demo/build/demo.build/Debug-iphonesimulator/demo.build/Objects-normal/x86_64/MessageViewController.o : /Users/xda/Desktop/swift_demo/demo/demo/Base/AppDelegate.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/MainBarController.swift /Users/xda/Desktop/swift_demo/demo/demo/ViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/HomePage/HomePageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Message/MessageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Myself/MyselfViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Discovery/DiscoverViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/BaseNavViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/xda/Desktop/swift_demo/demo/build/demo.build/Debug-iphonesimulator/demo.build/Objects-normal/x86_64/MessageViewController~partial.swiftmodule : /Users/xda/Desktop/swift_demo/demo/demo/Base/AppDelegate.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/MainBarController.swift /Users/xda/Desktop/swift_demo/demo/demo/ViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/HomePage/HomePageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Message/MessageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Myself/MyselfViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Discovery/DiscoverViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/BaseNavViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/xda/Desktop/swift_demo/demo/build/demo.build/Debug-iphonesimulator/demo.build/Objects-normal/x86_64/MessageViewController~partial.swiftdoc : /Users/xda/Desktop/swift_demo/demo/demo/Base/AppDelegate.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/MainBarController.swift /Users/xda/Desktop/swift_demo/demo/demo/ViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/HomePage/HomePageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Message/MessageViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Myself/MyselfViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Discovery/DiscoverViewController.swift /Users/xda/Desktop/swift_demo/demo/demo/Base/BaseNavViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule
D
module android.java.android.graphics.fonts.FontFamily; public import android.java.android.graphics.fonts.FontFamily_d_interface; import arsd.jni : ImportExportImpl; mixin ImportExportImpl!FontFamily; import import1 = android.java.java.lang.Class; import import0 = android.java.android.graphics.fonts.Font;
D
instance BDT_1020_Bandit_L(Npc_Default) { name[0] = "Highwayman"; guild = GIL_BDT; id = 1020; voice = 6; flags = 0; npcType = npctype_main; aivar[AIV_EnemyOverride] = TRUE; aivar[AIV_DropDeadAndKill] = TRUE; B_SetAttributesToChapter(self,1); fight_tactic = FAI_HUMAN_COWARD; EquipItem(self,ItMw_1h_Bau_Mace); B_CreateAmbientInv(self); B_SetNpcVisual(self,MALE,"Hum_Head_Fatbald",Face_N_Mud,BodyTex_N,ITAR_Leather_L); Mdl_SetModelFatness(self,0); Mdl_ApplyOverlayMds(self,"Humans_Relaxed.mds"); B_GiveNpcTalents(self); B_SetFightSkills(self,30); TA_Guard_Passage(0,0,12,0,"NW_TROLLAREA_PATH_47"); TA_Guard_Passage(12,0,0,0,"NW_TROLLAREA_PATH_47"); };
D
/******************************************************************************* copyright: Copyright (c) 2008 Kris Bell. все rights reserved license: BSD стиль: $(LICENSE) version: Apr 2008: Initial release authors: Kris Since: 0.99.7 Based upon Doug Lea's Java collection package *******************************************************************************/ module util.container.Slink; private import util.container.model.IContainer; /******************************************************************************* Slink экземпляры provопрe стандарт linked список следщ-fields, и support стандарт operations upon them. Slink structures are pure implementation tools, и perform no аргумент проверьing, no результат screening, и no synchronization. They rely on пользователь-уровень classes (see HashSet, for example) в_ do such things. Still, Slink is made `public' so that you can use it в_ build другой kinds of containers Note that when K is specified, support for ключи are включен. When Идентичность is stИПulated as 'да', those ключи are compared using an опрentity-сравнение instead of equality (using 'is'). Similarly, if ХэшКэш is установи да, an добавьitional attribute is создай in order в_ retain the хэш of K *******************************************************************************/ private typedef цел KeyDummy; struct Slink (V, K=KeyDummy, бул Идентичность = нет, бул ХэшКэш = нет) { alias Slink!(V, K, Идентичность, ХэшКэш) Тип; alias Тип *Реф; alias Сравни!(V) Сравнитель; Реф следщ; // pointer в_ следщ V значение; // элемент значение static if (ХэшКэш == да) { т_хэш кэш; // retain хэш значение? } /*********************************************************************** добавь support for ключи also? ***********************************************************************/ static if (!is(typeof(K) == KeyDummy)) { K ключ; final Реф установи (K k, V v, Реф n) { ключ = k; return установи (v, n); } final цел хэш() { return typeid(K).дайХэш(&ключ); } final Реф найдиКлюч (K ключ) { static if (Идентичность == да) { for (auto p=this; p; p = p.следщ) if (ключ is p.ключ) return p; } else { for (auto p=this; p; p = p.следщ) if (ключ == p.ключ) return p; } return пусто; } final Реф найдиПару (K ключ, V значение) { static if (Идентичность == да) { for (auto p=this; p; p = p.следщ) if (ключ is p.ключ && значение == p.значение) return p; } else { for (auto p=this; p; p = p.следщ) if (ключ == p.ключ && значение == p.значение) return p; } return пусто; } final цел индексируйКлюч (K ключ) { цел i = 0; static if (Идентичность == да) { for (auto p=this; p; p = p.следщ, ++i) if (ключ is p.ключ) return i; } else { for (auto p=this; p; p = p.следщ, ++i) if (ключ == p.ключ) return i; } return -1; } final цел индексируйПару (K ключ, V значение) { цел i = 0; static if (Идентичность == да) { for (auto p=this; p; p = p.следщ, ++i) if (ключ is p.ключ && значение == p.значение) return i; } else { for (auto p=this; p; p = p.следщ, ++i) if (ключ == p.ключ && значение == p.значение) return i; } return -1; } final цел учтиКлюч (K ключ) { цел c = 0; static if (Идентичность == да) { for (auto p=this; p; p = p.следщ) if (ключ is p.ключ) ++c; } else { for (auto p=this; p; p = p.следщ) if (ключ == p.ключ) ++c; } return c; } final цел учтиПару (K ключ, V значение) { цел c = 0; static if (Идентичность == да) { for (auto p=this; p; p = p.следщ) if (ключ is p.ключ && значение == p.значение) ++c; } else { for (auto p=this; p; p = p.следщ) if (ключ == p.ключ && значение == p.значение) ++c; } return c; } } /*********************************************************************** Набор в_ точка в_ n as следщ ячейка param: n, the new следщ ячейка ***********************************************************************/ final Реф установи (V v, Реф n) { следщ = n; значение = v; return this; } /*********************************************************************** Splice in p between текущ ячейка и whatever it was previously pointing в_ param: p, the ячейка в_ splice ***********************************************************************/ final проц прикрепи (Реф p) { if (p) p.следщ = следщ; следщ = p; } /*********************************************************************** Cause текущ ячейка в_ пропусти over the текущ следщ() one, effectively removing the следщ элемент из_ the список ***********************************************************************/ final проц отторочьСледщ() { if (следщ) следщ = следщ.следщ; } /*********************************************************************** Linear ищи down the список looking for элемент param: элемент в_ look for Возвращает: the ячейка containing элемент, or пусто if no such ***********************************************************************/ final Реф найди (V элемент) { for (auto p = this; p; p = p.следщ) if (элемент == p.значение) return p; return пусто; } /*********************************************************************** Return the число of cells traversed в_ найди первый occurrence of a ячейка with элемент() элемент, or -1 if not present ***********************************************************************/ final цел индекс (V элемент) { цел i; for (auto p = this; p; p = p.следщ, ++i) if (элемент == p.значение) return i; return -1; } /*********************************************************************** Счёт the число of occurrences of элемент in список ***********************************************************************/ final цел счёт (V элемент) { цел c; for (auto p = this; p; p = p.следщ) if (элемент == p.значение) ++c; return c; } /*********************************************************************** Return the число of cells in the список ***********************************************************************/ final цел счёт () { цел c; for (auto p = this; p; p = p.следщ) ++c; return c; } /*********************************************************************** Return the ячейка representing the последний элемент of the список (i.e., the one whose следщ() is пусто ***********************************************************************/ final Реф хвост () { auto p = this; while (p.следщ) p = p.следщ; return p; } /*********************************************************************** Return the н_ый ячейка of the список, or пусто if no such ***********************************************************************/ final Реф н_ый (цел n) { auto p = this; for (цел i; i < n; ++i) p = p.следщ; return p; } /*********************************************************************** Make a копируй of the список; i.e., a new список containing new cells but включая the same элементы in the same order ***********************************************************************/ final Реф копируй (Реф delegate() размести) { auto новый_список = dup (размести); auto текущ = новый_список; for (auto p = следщ; p; p = p.следщ) { текущ.следщ = p.dup (размести); текущ = текущ.следщ; } текущ.следщ = пусто; return новый_список; } /*********************************************************************** dup is shallow; i.e., just makes a копируй of the текущ ячейка ***********************************************************************/ private Реф dup (Реф delegate() размести) { auto возвр = размести(); static if (is(typeof(K) == KeyDummy)) возвр.установи (значение, следщ); else возвр.установи (ключ, значение, следщ); return возвр; } /*********************************************************************** Basic linkedlist merge algorithm. Merges the списки голова by fst и snd with respect в_ cmp param: fst голова of the первый список param: snd голова of the секунда список param: cmp a Сравнитель использован в_ сравни элементы Возвращает: the merged ordered список ***********************************************************************/ static Реф merge (Реф fst, Реф snd, Сравнитель cmp) { auto a = fst; auto b = snd; Реф hd = пусто; Реф текущ = пусто; for (;;) { if (a is пусто) { if (hd is пусто) hd = b; else текущ.следщ = b; return hd; } else if (b is пусто) { if (hd is пусто) hd = a; else текущ.следщ = a; return hd; } цел diff = cmp (a.значение, b.значение); if (diff <= 0) { if (hd is пусто) hd = a; else текущ.следщ = a; текущ = a; a = a.следщ; } else { if (hd is пусто) hd = b; else текущ.следщ = b; текущ = b; b = b.следщ; } } } /*********************************************************************** Standard список splitter, использован by сортируй. Splits the список in half. Returns the голова of the секунда half param: s the голова of the список Возвращает: the голова of the секунда half ***********************************************************************/ static Реф разбей (Реф s) { auto fast = s; auto slow = s; if (fast is пусто || fast.следщ is пусто) return пусто; while (fast) { fast = fast.следщ; if (fast && fast.следщ) { fast = fast.следщ; slow = slow.следщ; } } auto r = slow.следщ; slow.следщ = пусто; return r; } /*********************************************************************** Standard merge сортируй algorithm param: s the список в_ сортируй param: cmp, the сравнитель в_ use for ordering Возвращает: the голова of the sorted список ***********************************************************************/ static Реф сортируй (Реф s, Сравнитель cmp) { if (s is пусто || s.следщ is пусто) return s; else { auto right = разбей (s); auto left = s; left = сортируй (left, cmp); right = сортируй (right, cmp); return merge (left, right, cmp); } } }
D
module gui.random.hybridfractal; mixin template RandomHybrid() { GuiElementImage heightImg; float H = 0.5; float lacuna = 2; float octaves = 6; float offset = 0.7; float wavelength = 40; void initHybrid() { heightImg = new GuiElementImage(container, Rectd(0, 0, 0.6, 0.6)); auto a = new GuiElementLabeledEdit(container, Rectd(0.1, 0.7, 0.2, 0.05), "H(dimension)", to!string(H)); a.setOnEnter((string value) { H = to!float(value); renderHybrid(); }); a = new GuiElementLabeledEdit(container, Rectd(0.1, a.bottomOf, 0.2, 0.05), "lacunarity", to!string(lacuna)); a.setOnEnter((string value) { lacuna = to!float(value); renderHybrid(); }); a = new GuiElementLabeledEdit(container, Rectd(0.1, a.bottomOf, 0.2, 0.05), "octaves", to!string(octaves)); a.setOnEnter((string value) { octaves = to!float(value); renderHybrid(); }); a = new GuiElementLabeledEdit(container, Rectd(0.1, a.bottomOf, 0.2, 0.05), "offset", to!string(offset)); a.setOnEnter((string value) { offset = to!float(value); renderHybrid(); }); a = new GuiElementLabeledEdit(container, Rectd(0.1, a.bottomOf, 0.2, 0.05), "wavelength", to!string(wavelength)); a.setOnEnter((string value) { wavelength = to!float(value); renderHybrid(); }); redraw = &renderHybrid; renderHybrid(); } void renderHybrid() { auto randomField = new ValueMap2Dd; auto heightMap = new ValueMap2Dd(400, 400); auto gradient = new GradientNoise01!()(400, new RandSourceUniform(seed)); auto hybrid = new HybridMultiFractal(gradient, H, lacuna, octaves, offset); hybrid.setBaseWaveLength(wavelength); auto source = new DelegateSource((vec3d pos){ pos.x -= 200; pos.y -= 200; auto len = sqrt(pos.x^^2 + pos.y^^2) / 10; auto dir = (atan2(pos.y, pos.x)) * 50; return -(hybrid.getValue2(vec2d(len, dir)) * len / 10 + hybrid.getValue2(vec2d(pos.x, pos.y)) * 0.5); }); auto sourceA = (vec3d pos) { return source.getValue3(pos); }; auto sourceB = new DelegateSource((vec3d pos){ auto fix(string Op, T...)(T t) { alias typeof(t[0]) B; B ret = -B.infinity; foreach(val ; t) { ret = mixin(Op); } return ret; } return fix!"max(val, ret)"( sourceA(pos) * 1.0, sourceA(pos + vec3d(145, 23, 0)) * 1.3, sourceA(pos + vec3d(-78, 54, 0)) * 1.4, sourceA(pos + vec3d(2, 189, 0)) * 1.2); }); heightMap.fill(&hybrid.getValue2, 400, 400); heightMap.normalize(0, 1.0); heightImg.setImage(heightMap.toImage(0, 1, true, colorMode)); } void destroyHybrid() { container.destroy(); } }
D
module main; private import dfl.all; private import srl.MainForm; private import srl.Model; void main(string[] args) { Application.autoCollect = false; // for Drag & Drop Model model = new Model(); MainForm mainForm = new MainForm(model); if (1 < args.length) { string arg = args[1]; if (model.isAcceptableFileName(arg)) { model.fileName = arg; } } Application.run(mainForm); }
D
module lex.lexer; import lex.token; // Tango is the worst import tango.io.device.File; import tango.io.Stdout; import Text = tango.text.Util; class Lexer { private: void _error(char[] msg) { Stdout(msg).newline; //Console.forecolor = Color.Red; //Console.putln("Lexical Error: file.d @ ", _lineNumber+1, ":", _pos+1, " - ", msg); //Console.putln(); for(;;){} } // Describe the number lexer states enum LexerState : uint { Normal, String, Comment, Identifier, Integer, FloatingPoint } LexerState state; bool inEscape; int characterEscapeDigitsLeft; bool foundLeadingChar; bool foundLeadingSlash; uint nestedCommentDepth; // Describe the string lexer states enum StringType : uint { DoubleQuote, // "..." WhatYouSeeQuote, // `...` RawWhatYouSeeQuote, // r"..." Character, // '.' } StringType inStringType; // Describe the comment lexer states enum CommentType : uint { BlockComment, LineComment, NestedComment } CommentType inCommentType; char[] cur_string; char[] _line; char[] _filename = ""; size_t _lineNumber; size_t _pos; static const Token.Type[] tokenMapping = [ '!':Token.Type.Bang, ':':Token.Type.Colon, '?':Token.Type.Question, ';':Token.Type.Semicolon, '$':Token.Type.Dollar, '.':Token.Type.Dot, ',':Token.Type.Comma, '(':Token.Type.LeftParen, ')':Token.Type.RightParen, '{':Token.Type.LeftCurly, '}':Token.Type.RightCurly, '[':Token.Type.LeftBracket, ']':Token.Type.RightBracket, '<':Token.Type.LessThan, '>':Token.Type.GreaterThan, '=':Token.Type.Assign, '+':Token.Type.Add, '-':Token.Type.Sub, '~':Token.Type.Cat, '*':Token.Type.Mul, '/':Token.Type.Div, '^':Token.Type.Xor, '|':Token.Type.Or, '&':Token.Type.And, '%':Token.Type.Mod, ]; int cur_base; ulong cur_integer; bool cur_integer_signed; ulong cur_decimal; ulong cur_exponent; ulong cur_denominator; bool inDecimal; bool inExponent; bool signFound; bool positive; char[][] _lines; // Simple stack of tokens Token[] _bank; Token[] _comment_bank; void _comment_bank_push(Token token) { _comment_bank ~= token; } bool _comment_bank_empty() { return _comment_bank.length == 0; } Token _comment_bank_pop() { Token ret = _comment_bank[$-1]; _comment_bank = _comment_bank[0..$-1]; return ret; } void _bank_push(Token token) { _bank ~= token; } bool _bank_empty() { return _bank.length == 0; } Token _bank_pop() { Token ret = _bank[$-1]; _bank = _bank[0..$-1]; return ret; } Token _next() { Token current = new Token(Token.Type.EOF); current.line = _lineNumber; current.column = _pos + 1; // will give us a string for the line of utf8 characters. for(;;) { if (_line is null || _pos >= _line.length) { if (_lineNumber >= _lines.length) { // EOF return current; } _line = _lines[_lineNumber]; _lineNumber++; _pos = 0; current.line = current.line + 1; current.column = 1; } // now break up the line into tokens // the return for the line is whitespace, and can be ignored for(; _pos <= _line.length; _pos++) { char chr; char nextChr; if (_pos == _line.length) { chr = '\n'; nextChr = '\n'; } else { chr = _line[_pos]; if (_pos == _line.length-1) { nextChr = '\n'; } else { nextChr = _line[_pos+1]; } } switch (state) { default: // error _error("!!error!!"); return new Token(Token.Type.EOF); case LexerState.Normal: Token.Type newType = tokenMapping[chr]; // Comments if (current.type == Token.Type.Div) { if (newType == Token.Type.Add) { inEscape = false; foundLeadingSlash = false; foundLeadingChar = false; nestedCommentDepth = 1; current.type = Token.Type.EOF; state = LexerState.Comment; inCommentType = CommentType.NestedComment; cur_string = ""; continue; } else if (newType == Token.Type.Div) { cur_string = _line[_pos+1..$]; current.type = Token.Type.Comment; current.string = cur_string; current.lineEnd = _lineNumber; _pos = _line.length; return current; } else if (newType == Token.Type.Mul) { inEscape = false; foundLeadingSlash = false; foundLeadingChar = false; nestedCommentDepth = 1; current.type = Token.Type.EOF; state = LexerState.Comment; inCommentType = CommentType.BlockComment; cur_string = ""; continue; } } if (newType != Token.Type.EOF) { switch(current.type) { case Token.Type.And: // & if (newType == Token.Type.And) { // && current.type = Token.Type.LogicalAnd; } else if (newType == Token.Type.Assign) { // &= current.type = Token.Type.AndAssign; } else { goto default; } break; case Token.Type.Or: // | if (newType == Token.Type.Or) { // || current.type = Token.Type.LogicalOr; } else if (newType == Token.Type.Assign) { // |= current.type = Token.Type.OrAssign; } else { goto default; } break; case Token.Type.Add: // + if (newType == Token.Type.Assign) { // += current.type = Token.Type.AddAssign; } else if (newType == Token.Type.Add) { // ++ current.type = Token.Type.Increment; } else { goto default; } break; case Token.Type.Sub: // - if (newType == Token.Type.Assign) { // -= current.type = Token.Type.SubAssign; } else if (newType == Token.Type.Sub) { // -- current.type = Token.Type.Decrement; } else { goto default; } break; case Token.Type.Div: // / if (newType == Token.Type.Assign) { // /= current.type = Token.Type.DivAssign; } else if (newType == Token.Type.Add) { // /+ current.type = Token.Type.Comment; } else if (newType == Token.Type.Div) { // // current.type = Token.Type.Comment; } else if (newType == Token.Type.Mul) { // /* current.type = Token.Type.Comment; } else { goto default; } break; case Token.Type.Mul: // * if (newType == Token.Type.Assign) { // *= current.type = Token.Type.MulAssign; } else { goto default; } break; case Token.Type.Mod: // % if (newType == Token.Type.Assign) { // %= current.type = Token.Type.ModAssign; } else { goto default; } break; case Token.Type.Xor: // ^ if (newType == Token.Type.Assign) { // ^= current.type = Token.Type.XorAssign; } else { goto default; } break; case Token.Type.Cat: // ~ if (newType == Token.Type.Assign) { // ~= current.type = Token.Type.CatAssign; } else { goto default; } break; case Token.Type.Assign: // = if (newType == Token.Type.Assign) { // == current.type = Token.Type.Equals; } else { goto default; } break; case Token.Type.LessThan: // < if (newType == Token.Type.LessThan) { // << current.type = Token.Type.ShiftLeft; } else if (newType == Token.Type.Assign) { // <= current.type = Token.Type.LessThanEqual; } else if (newType == Token.Type.GreaterThan) { // <> current.type = Token.Type.LessThanGreaterThan; } else { goto default; } break; case Token.Type.GreaterThan: // > if (newType == Token.Type.GreaterThan) { // >> current.type = Token.Type.ShiftRight; } else if (newType == Token.Type.Assign) { // >= current.type = Token.Type.GreaterThanEqual; } else { goto default; } break; case Token.Type.ShiftLeft: // << if (newType == Token.Type.Assign) { // <<= current.type = Token.Type.ShiftLeftAssign; } else { goto default; } break; case Token.Type.ShiftRight: // >> if (newType == Token.Type.Assign) { // >>= current.type = Token.Type.ShiftRightAssign; } else if (newType == Token.Type.GreaterThan) { // >>> current.type = Token.Type.ShiftRightSigned; } else { goto default; } break; case Token.Type.ShiftRightSigned: // >>> if (newType == Token.Type.Assign) { // >>>= current.type = Token.Type.ShiftRightSignedAssign; } else { goto default; } break; case Token.Type.LessThanGreaterThan: // <> if (newType == Token.Type.Assign) { // <>= current.type = Token.Type.LessThanGreaterThanEqual; } else { goto default; } break; case Token.Type.Bang: // ! if (newType == Token.Type.LessThan) { // !< current.type = Token.Type.NotLessThan; } else if (newType == Token.Type.GreaterThan) { // !> current.type = Token.Type.NotGreaterThan; } else if (newType == Token.Type.Assign) { // != current.type = Token.Type.NotEquals; } else { goto default; } break; case Token.Type.NotLessThan: // !< if (newType == Token.Type.GreaterThan) { // !<> current.type = Token.Type.NotLessThanGreaterThan; } else if (newType == Token.Type.Assign) { // !<= current.type = Token.Type.NotLessThanEqual; } else { goto default; } break; case Token.Type.NotGreaterThan: // !> if (newType == Token.Type.Assign) { // !>= current.type = Token.Type.NotGreaterThanEqual; } else { goto default; } break; case Token.Type.NotLessThanGreaterThan: // !<> if (newType == Token.Type.Assign) { // !<>= current.type = Token.Type.NotLessThanGreaterThanEqual; } else { goto default; } break; case Token.Type.Dot: // . if (newType == Token.Type.Dot) { // .. current.type = Token.Type.Slice; } else { goto default; } break; case Token.Type.Slice: // .. if (newType == Token.Type.Dot) { // ... current.type = Token.Type.Variadic; } else { goto default; } break; case Token.Type.EOF: current.type = tokenMapping[chr]; break; default: // Token Error if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; return current; } // _error("Unknown operator."); return new Token(Token.Type.EOF); } continue; } // A character that will switch states continues // Strings if (chr == '\'') { state = LexerState.String; inStringType = StringType.Character; cur_string = ""; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; _pos++; return current; } continue; } else if (chr == '"') { state = LexerState.String; inStringType = StringType.DoubleQuote; cur_string = ""; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; _pos++; return current; } continue; } else if (chr == '`') { state = LexerState.String; inStringType = StringType.WhatYouSeeQuote; cur_string = ""; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; _pos++; return current; } continue; } // Whitespace else if (chr == ' ' || chr == '\t' || chr == '\n') { if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; _pos++; return current; } current.column = current.column + 1; continue; } // Identifiers else if ((chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || chr == '_') { state = LexerState.Identifier; cur_string = ""; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; return current; } goto case LexerState.Identifier; } // Numbers else if (chr >= '0' && chr <= '9') { // reset to invalid base cur_base = 0; cur_decimal = 0; cur_denominator = 1; cur_exponent = 0; if (current.type == Token.Type.Dot) { current.type = Token.Type.EOF; inDecimal = true; inExponent = false; cur_integer = 0; cur_base = 10; signFound = false; state = LexerState.FloatingPoint; goto case LexerState.FloatingPoint; } else { state = LexerState.Integer; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; return current; } goto case LexerState.Integer; } } break; case LexerState.String: if (inEscape) { if (characterEscapeDigitsLeft > 0) { characterEscapeDigitsLeft--; cur_integer *= 16; if (chr >= '0' && chr <= '9') { cur_integer += (chr - '0'); } else if (chr >= 'a' && chr <= 'f') { cur_integer += (chr - 'a') + 10; } else if (chr >= 'A' && chr <= 'F') { cur_integer += (chr - 'A') + 10; } if (characterEscapeDigitsLeft == 0) { cur_string ~= cast(char)cur_integer; inEscape = false; } continue; } inEscape = false; if (chr == 't') { chr = '\t'; } else if (chr == 'b') { chr = '\b'; } else if (chr == 'r') { chr = '\r'; } else if (chr == 'n') { chr = '\n'; } else if (chr == '0') { chr = '\0'; } else if (chr == 'x' || chr == 'X') { // Expect 2 digit code characterEscapeDigitsLeft = 2; cur_integer = 0; inEscape = true; } else if (chr == 'u') { // Expect 4 digit code characterEscapeDigitsLeft = 4; cur_integer = 0; inEscape = true; } else if (chr == 'U') { // Expect 8 digit code characterEscapeDigitsLeft = 8; cur_integer = 0; inEscape = true; } if (!inEscape) { cur_string ~= chr; } continue; } if (inStringType == StringType.DoubleQuote) { if (chr == '"') { state = LexerState.Normal; current.type = Token.Type.StringLiteral; current.columnEnd = _pos; current.lineEnd = _lineNumber; if (cur_string !is null) { current.string = cur_string; } _pos++; return current; } } else if (inStringType == StringType.RawWhatYouSeeQuote) { if (chr == '"') { state = LexerState.Normal; current.type = Token.Type.StringLiteral; current.columnEnd = _pos; current.lineEnd = _lineNumber; if (cur_string !is null) { current.string = cur_string; } _pos++; return current; } } else if (inStringType == StringType.WhatYouSeeQuote) { if (chr == '`') { state = LexerState.Normal; current.type = Token.Type.StringLiteral; current.columnEnd = _pos; current.lineEnd = _lineNumber; if (cur_string !is null) { current.string = cur_string; } _pos++; return current; } } else { // StringType.Character if (chr == '\'') { if (cur_string.length > 1) { // error goto default; } state = LexerState.Normal; current.type = Token.Type.CharacterLiteral; current.columnEnd = _pos; current.lineEnd = _lineNumber; if (cur_string !is null) { current.string = cur_string; } _pos++; return current; } } if ((inStringType == StringType.DoubleQuote || inStringType == StringType.Character) && (chr == '\\')) { // Escaped Characters inEscape = true; characterEscapeDigitsLeft = 0; } else { cur_string ~= chr; } continue; case LexerState.Comment: if (inEscape) { // Ignore escaped characters cur_string ~= [chr]; inEscape = false; } else if (chr == '\\') { inEscape = true; foundLeadingChar = false; foundLeadingSlash = false; } else if (chr == '/' && !foundLeadingChar && inCommentType == CommentType.NestedComment) { foundLeadingSlash = true; cur_string ~= [chr]; } else if (chr == '+' && foundLeadingSlash) { foundLeadingSlash = false; cur_string ~= [chr]; nestedCommentDepth++; } else if ((chr == '*' && inCommentType == CommentType.BlockComment) || (chr == '+' && inCommentType == CommentType.NestedComment)) { cur_string ~= [chr]; foundLeadingChar = true; foundLeadingSlash = false; } else if (foundLeadingChar && chr == '/') { nestedCommentDepth--; // Good if (nestedCommentDepth == 0) { state = LexerState.Normal; current.string = cur_string[0..$-1]; current.type = Token.Type.Comment; _pos++; return current; } cur_string ~= [chr]; foundLeadingChar = false; foundLeadingSlash = false; } else { foundLeadingChar = false; foundLeadingSlash = false; cur_string ~= [chr]; } continue; case LexerState.Identifier: // check for valid succeeding character if ((chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z') && chr != '_' && (chr < '0' || chr > '9')) { // Invalid identifier symbol static Token.Type keywordStart = Token.Type.Abstract; static const char[][] keywordList = ["abstract", "alias", "align", "asm", "assert", "auto", "body", "bool", "break", "byte", "case", "cast","catch","cdouble","cent","cfloat","char", "class","const","continue","creal","dchar","debug","default","delegate","delete","deprecated", "do","double","else","enum","export","extern","false","final","finally","float","for","foreach", "foreach_reverse","function","goto","idouble","if","ifloat","import","in","inout","int","interface", "invariant","ireal","is","lazy","long","macro","mixin","module","new","null","out","override", "package","pragma","private","protected","public","real","ref","return","scope","short","static", "struct","super","switch","synchronized","template","this","throw","true","try", "typedef","typeid","typeof","ubyte","ucent","uint","ulong","union","unittest","ushort","version", "void","volatile","wchar","while","with" ]; current.type = Token.Type.Identifier; foreach(size_t i, keyword; keywordList) { if (cur_string == keyword) { current.type = cast(Token.Type)(keywordStart + i); cur_string = null; break; } } if (cur_string !is null) { current.string = cur_string; } state = LexerState.Normal; if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; return current; } goto case LexerState.Normal; } cur_string ~= chr; continue; case LexerState.Integer: // check for valid succeeding character // we may want to switch to floating point state // may want to defer because this is a .. or ... token if (chr == '.') { if (nextChr == '.') { // 5.. implies that this token is an Integer followed by a slice token current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } if (cur_base <= 0) { cur_base = 10; } else if (cur_base == 2) { _error("Cannot have binary floating point literals"); return new Token(Token.Type.EOF); } else if (cur_base == 8) { _error("Cannot have octal floating point literals"); return new Token(Token.Type.EOF); } // Reset this just in case, it will get interpreted // in the Floating Point state inDecimal = false; inExponent = false; signFound = false; state = LexerState.FloatingPoint; goto case LexerState.FloatingPoint; } else if ((chr == 'p' || chr == 'P') && cur_base == 16) { // Reset this just in case, it will get interpreted // in the Floating Point state inDecimal = false; inExponent = false; signFound = false; state = LexerState.FloatingPoint; goto case LexerState.FloatingPoint; } else if (chr == '_') { // ignore if (cur_base == -1) { // OCTAL cur_base = 8; } } else if (cur_base == 0) { // this is the first value if (chr == '0') { // octal or 0 or 0.0, etc // use an invalid value so we can decide cur_base = -1; cur_integer = 0; } else if (chr >= '1' && chr <= '9') { cur_base = 10; cur_integer = (chr - '0'); } // Cannot be any other value else { _error("Integer literal expected."); return new Token(Token.Type.EOF); } } else if (cur_base == -1) { // this is the second value of an ambiguous base if (chr >= '0' && chr <= '7') { // OCTAL cur_base = 8; cur_integer = (chr - '0'); } else if (chr == 'x' || chr == 'X') { // HEX cur_base = 16; } else if (chr == 'b' || chr == 'B') { // BINARY cur_base = 2; } else { // 0 ? current.type = Token.Type.IntegerLiteral; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } } else if (cur_base == 16) { if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F')) { current.type = Token.Type.IntegerLiteral; current.integer = cur_integer; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else { cur_integer *= cur_base; if (chr >= 'a' && chr <= 'f') { cur_integer += 10 + (chr - 'a'); } else if (chr >= 'A' && chr <= 'F') { cur_integer += 10 + (chr - 'A'); } else { cur_integer += (chr - '0'); } } } else if (cur_base == 10) { if (chr < '0' || chr > '9') { current.type = Token.Type.IntegerLiteral; current.integer = cur_integer; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else { cur_integer *= cur_base; cur_integer += (chr - '0'); } } else if (cur_base == 8) { if (chr >= '8' && chr <= '9') { _error("Digits higher than 7 in an octal integer literal are invalid."); return new Token(Token.Type.EOF); } else if (chr < '0' || chr > '7') { current.type = Token.Type.IntegerLiteral; current.integer = cur_integer; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else { cur_integer *= cur_base; cur_integer += (chr - '0'); } } else if (cur_base == 2) { if (chr < '0' || chr > '1') { current.type = Token.Type.IntegerLiteral; current.integer = cur_integer; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else { cur_integer *= cur_base; cur_integer += (chr - '0'); } } continue; case LexerState.FloatingPoint: if (chr == '_') { continue; } else if (chr == '.' && (cur_base == 10 || cur_base == 16)) { // We are now parsing the decimal portion if (inDecimal) { _error("Only one decimal point is allowed per floating point literal."); return new Token(Token.Type.EOF); } else if (inExponent) { _error("Cannot put a decimal point after an exponent in a floating point literal."); } inDecimal = true; } else if (cur_base == 16 && (chr == 'p' || chr == 'P')) { // We are now parsing the exponential portion inDecimal = false; inExponent = true; cur_exponent = -1; } else if (cur_base == 10 && (chr == 'e' || chr == 'E')) { // We are now parsing the exponential portion inDecimal = false; inExponent = true; cur_exponent = -1; } else if (cur_base == 10) { if (chr == 'p' || chr == 'P') { _error("Cannot have a hexidecimal exponent in a non-hexidecimal floating point literal."); return new Token(Token.Type.EOF); } else if (chr == '+') { if (signFound) { _error("Exponent sign exists twice."); return new Token(Token.Type.EOF); } positive = true; signFound = true; } else if (chr == '-') { if (signFound) { _error("Exponent sign exists twice."); return new Token(Token.Type.EOF); } signFound = true; positive = false; } else if (chr < '0' || chr > '9') { if (inExponent && cur_exponent == -1) { _error("You need to specify a value for the exponent part of the floating point literal."); return new Token(Token.Type.EOF); } current.type = Token.Type.FloatingPointLiteral; double value = cast(double)cur_integer + (cast(double)cur_decimal / cast(double)cur_denominator); double exp = 1; for(size_t i = 0; i < cur_exponent; i++) { exp *= cur_base; } value *= exp; current.decimal = value; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else if (inExponent) { if (cur_exponent == -1) { cur_exponent = 0; } cur_exponent *= cur_base; cur_exponent += (chr - '0'); } else { cur_decimal *= cur_base; cur_denominator *= cur_base; cur_decimal += (chr - '0'); } } else { // cur_base == 16 if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F')) { if (inDecimal && !inExponent) { _error("You need to provide an exponent with the decimal portion of a hexidecimal floating point number. Ex: 0xff.3p2"); return new Token(Token.Type.EOF); } if (inExponent && cur_exponent == -1) { _error("You need to specify a value for the exponent part of the floating point literal."); return new Token(Token.Type.EOF); } current.type = Token.Type.FloatingPointLiteral; double value = cast(double)cur_integer + (cast(double)cur_decimal / cast(double)cur_denominator); double exp = 1; for(size_t i = 0; i < cur_exponent; i++) { exp *= 2; } value *= exp; current.decimal = value; current.columnEnd = _pos; current.lineEnd = _lineNumber; state = LexerState.Normal; return current; } else if (inExponent) { if (cur_exponent == -1) { cur_exponent = 0; } cur_exponent *= cur_base; if (chr >= 'A' && chr <= 'F') { cur_exponent += 10 + (chr - 'A'); } else if (chr >= 'a' && chr <= 'f') { cur_exponent += 10 + (chr - 'a'); } else { cur_exponent += (chr - '0'); } } else { cur_decimal *= cur_base; cur_denominator *= cur_base; if (chr >= 'A' && chr <= 'F') { cur_decimal += 10 + (chr - 'A'); } else if (chr >= 'a' && chr <= 'f') { cur_decimal += 10 + (chr - 'a'); } else { cur_decimal += (chr - '0'); } } } continue; } } if (current.type != Token.Type.EOF) { current.columnEnd = _pos; current.lineEnd = _lineNumber; return current; } current.line = current.line + 1; current.column = 1; if (state != LexerState.String && state != LexerState.Comment) { state = LexerState.Normal; } else if (state == LexerState.String) { if (inStringType == StringType.Character) { _error("Unmatched character literal."); return new Token(Token.Type.EOF); } cur_string ~= '\n'; } } return new Token(Token.Type.EOF); } public: char[] filename() { return _filename; } char[] line(uint idx) { return _lines[idx-1]; } Token commentPop() { if (!_comment_bank_empty()) { return _comment_bank_pop(); } return new Token(Token.Type.EOF); } void commentClear() { _comment_bank = []; } bool commentEmpty() { return _comment_bank_empty(); } void push(Token token) { _bank_push(token); } Token pop() { if (!_bank_empty()) { return _bank_pop(); } for(;;) { Token t = _next(); if (t.type == Token.Type.Comment) { _comment_bank_push(t); } else { return t; } } } this(char[] file) { auto content = cast(char[])File.get(file); _filename = file.dup; _lines = Text.splitLines(content); } }
D
/Users/y.imuta/pj/rust_study/todo/target/debug/build/memchr-4337b12bcb0909c7/build_script_build-4337b12bcb0909c7: /Users/y.imuta/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.4/build.rs /Users/y.imuta/pj/rust_study/todo/target/debug/build/memchr-4337b12bcb0909c7/build_script_build-4337b12bcb0909c7.d: /Users/y.imuta/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.4/build.rs /Users/y.imuta/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.4/build.rs:
D
/***********************************************************************\ * winperf.d * * * * Windows API header module * * * * Translated from MinGW Windows headers * * * * Placed into public domain * \***********************************************************************/ module win32.winperf; version(Windows): import win32.windef; import win32.winbase; // for SYSTEMTIME const PERF_DATA_VERSION=1; const PERF_DATA_REVISION=1; const PERF_NO_INSTANCES=-1; const PERF_SIZE_DWORD=0; const PERF_SIZE_LARGE=256; const PERF_SIZE_ZERO=512; const PERF_SIZE_VARIABLE_LEN=768; const PERF_TYPE_NUMBER=0; const PERF_TYPE_COUNTER=1024; const PERF_TYPE_TEXT=2048; const PERF_TYPE_ZERO=0xC00; const PERF_NUMBER_HEX=0; const PERF_NUMBER_DECIMAL=0x10000; const PERF_NUMBER_DEC_1000=0x20000; const PERF_COUNTER_VALUE=0; const PERF_COUNTER_RATE=0x10000; const PERF_COUNTER_FRACTION=0x20000; const PERF_COUNTER_BASE=0x30000; const PERF_COUNTER_ELAPSED=0x40000; const PERF_COUNTER_QUEUELEN=0x50000; const PERF_COUNTER_HISTOGRAM=0x60000; const PERF_TEXT_UNICODE=0; const PERF_TEXT_ASCII=0x10000; const PERF_TIMER_TICK=0; const PERF_TIMER_100NS=0x100000; const PERF_OBJECT_TIMER=0x200000; const PERF_DELTA_COUNTER=0x400000; const PERF_DELTA_BASE=0x800000; const PERF_INVERSE_COUNTER=0x1000000; const PERF_MULTI_COUNTER=0x2000000; const PERF_DISPLAY_NO_SUFFIX=0; const PERF_DISPLAY_PER_SEC=0x10000000; const PERF_DISPLAY_PERCENT=0x20000000; const PERF_DISPLAY_SECONDS=0x30000000; const PERF_DISPLAY_NOSHOW=0x40000000; const PERF_COUNTER_HISTOGRAM_TYPE=0x80000000; const PERF_NO_UNIQUE_ID=(-1); const PERF_DETAIL_NOVICE=100; const PERF_DETAIL_ADVANCED=200; const PERF_DETAIL_EXPERT=300; const PERF_DETAIL_WIZARD=400; const PERF_COUNTER_COUNTER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PER_SEC); const PERF_COUNTER_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PERCENT); const PERF_COUNTER_QUEUELEN_TYPE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_QUEUELEN|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_BULK_COUNT=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PER_SEC); const PERF_COUNTER_TEXT=(PERF_SIZE_VARIABLE_LEN|PERF_TYPE_TEXT|PERF_TEXT_UNICODE|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_RAWCOUNT=(PERF_SIZE_DWORD|PERF_TYPE_NUMBER|PERF_NUMBER_DECIMAL|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_LARGE_RAWCOUNT=(PERF_SIZE_LARGE|PERF_TYPE_NUMBER|PERF_NUMBER_DECIMAL|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_RAWCOUNT_HEX=(PERF_SIZE_DWORD|PERF_TYPE_NUMBER|PERF_NUMBER_HEX|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_LARGE_RAWCOUNT_HEX=(PERF_SIZE_LARGE|PERF_TYPE_NUMBER|PERF_NUMBER_HEX|PERF_DISPLAY_NO_SUFFIX); const PERF_SAMPLE_FRACTION=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DELTA_COUNTER|PERF_DELTA_BASE|PERF_DISPLAY_PERCENT); const PERF_SAMPLE_COUNTER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_NO_SUFFIX); const PERF_COUNTER_NODATA=(PERF_SIZE_ZERO|PERF_DISPLAY_NOSHOW); const PERF_COUNTER_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT); const PERF_SAMPLE_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|1); const PERF_AVERAGE_TIMER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_SECONDS); const PERF_AVERAGE_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|2); const PERF_AVERAGE_BULK=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_NOSHOW); const PERF_100NSEC_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_DELTA_COUNTER|PERF_DISPLAY_PERCENT); const PERF_100NSEC_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_DELTA_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT); const PERF_COUNTER_MULTI_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_DELTA_COUNTER|PERF_TIMER_TICK|PERF_MULTI_COUNTER|PERF_DISPLAY_PERCENT); const PERF_COUNTER_MULTI_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_DELTA_COUNTER|PERF_MULTI_COUNTER|PERF_TIMER_TICK|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT); const PERF_COUNTER_MULTI_BASE=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_MULTI_COUNTER|PERF_DISPLAY_NOSHOW); const PERF_100NSEC_MULTI_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_DELTA_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_MULTI_COUNTER|PERF_DISPLAY_PERCENT); const PERF_100NSEC_MULTI_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_DELTA_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_MULTI_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT); const PERF_RAW_FRACTION=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_PERCENT); const PERF_RAW_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|3); const PERF_ELAPSED_TIME=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_ELAPSED|PERF_OBJECT_TIMER|PERF_DISPLAY_SECONDS); struct PERF_DATA_BLOCK { WCHAR Signature[4]; DWORD LittleEndian; DWORD Version; DWORD Revision; DWORD TotalByteLength; DWORD HeaderLength; DWORD NumObjectTypes; LONG DefaultObject; SYSTEMTIME SystemTime; LARGE_INTEGER PerfTime; LARGE_INTEGER PerfFreq; LARGE_INTEGER PerfTime100nSec; DWORD SystemNameLength; DWORD SystemNameOffset; } alias PERF_DATA_BLOCK * PPERF_DATA_BLOCK; struct PERF_OBJECT_TYPE { DWORD TotalByteLength; DWORD DefinitionLength; DWORD HeaderLength; DWORD ObjectNameTitleIndex; LPWSTR ObjectNameTitle; DWORD ObjectHelpTitleIndex; LPWSTR ObjectHelpTitle; DWORD DetailLevel; DWORD NumCounters; LONG DefaultCounter; LONG NumInstances; DWORD CodePage; LARGE_INTEGER PerfTime; LARGE_INTEGER PerfFreq; } alias PERF_OBJECT_TYPE * PPERF_OBJECT_TYPE; struct PERF_COUNTER_DEFINITION { DWORD ByteLength; DWORD CounterNameTitleIndex; LPWSTR CounterNameTitle; DWORD CounterHelpTitleIndex; LPWSTR CounterHelpTitle; LONG DefaultScale; DWORD DetailLevel; DWORD CounterType; DWORD CounterSize; DWORD CounterOffset; } alias PERF_COUNTER_DEFINITION * PPERF_COUNTER_DEFINITION; struct PERF_INSTANCE_DEFINITION { DWORD ByteLength; DWORD ParentObjectTitleIndex; DWORD ParentObjectInstance; LONG UniqueID; DWORD NameOffset; DWORD NameLength; } alias PERF_INSTANCE_DEFINITION * PPERF_INSTANCE_DEFINITION; struct PERF_COUNTER_BLOCK { DWORD ByteLength; } alias PERF_COUNTER_BLOCK * PPERF_COUNTER_BLOCK; extern (Windows): alias DWORD function (LPWSTR) PM_OPEN_PROC; alias DWORD function (LPWSTR,PVOID*,PDWORD,PDWORD) PM_COLLECT_PROC; alias DWORD function () PM_CLOSE_PROC;
D
/******************************************************************************* Allows drawing of images Authors: ArcLib team, see AUTHORS file Maintainer: Clay Smith (clayasaurus at gmail dot com) License: zlib/libpng license: $(LICENSE) Copyright: ArcLib team Description: Code that will allow different ways to render an image with arc. Examples: -------------------- import arc.types; int main() { Texture t = Texture("texture.png"); Point pos, pivot; Size size; Color color; arcfl angle; while (gameloop) { drawImage(t, pos, size, color, pivot, angle); } return 0; } -------------------- *******************************************************************************/ module arc.draw.image; import arc.types, arc.texture, arc.draw.color, arc.math.point, arc.math.angle; import derelict.opengl.gl; /// simply draw image to screen with given image ID from the center with pivot points void drawImage(Texture texture, Point pos, Size size = Size(float.nan,float.nan), Point pivot = Point(0,0), Radians angle = 0, Color color = Color.White) { // if no size is specified, use texture size if(isnan(size.w) && isnan(size.h)) size = texture.getSize(); // center calculations arcfl halfWidth = size.w/2; arcfl halfHeight = size.h/2; arcfl texw = (texture.getSize.w / texture.getTextureSize.w); arcfl texh = (texture.getSize.h / texture.getTextureSize.h); // enable 2d textures and bind texture glEnable(GL_TEXTURE_2D); // bind texture ID to this tex glBindTexture(GL_TEXTURE_2D, texture.getID); // set color to one given color.setGLColor(); glPushMatrix(); // rotate and translate glTranslatef(pos.x,pos.y,0); glRotatef(radiansToDegrees(angle), 0, 0, 1); // draw image at given coords, binding texture appropriately glBegin(GL_QUADS); // -halfWidth and -halfHeight act as ancors to rotate from the center glTexCoord2d(0,0); glVertex2f(-halfWidth + pivot.x, -halfHeight + pivot.y); glTexCoord2d(0,texh); glVertex2f( -halfWidth + pivot.x, -halfHeight + size.h + pivot.y); glTexCoord2d(texw,texh); glVertex2f( -halfWidth + size.w + pivot.x, -halfHeight + size.h + pivot.y); glTexCoord2d(texw,0); glVertex2f( -halfWidth + size.w + pivot.x, -halfHeight + pivot.y); glEnd(); glPopMatrix(); } /// draw image from the top left location void drawImageTopLeft(Texture texture, Point pos, Size size = Size(float.nan,float.nan), Color color = Color.White) { // if no size is specified, use texture size if(isnan(size.w) && isnan(size.h)) size = texture.getSize(); // enable 2d textures and bind texture glEnable(GL_TEXTURE_2D); // bind texture ID to this tex glBindTexture(GL_TEXTURE_2D, texture.getID); // set color to one given color.setGLColor(); glPushMatrix(); // rotate and translate glTranslatef(pos.x,pos.y,0); arcfl texw = texture.getSize.w / texture.getTextureSize.w; arcfl texh = texture.getSize.h / texture.getTextureSize.h; // draw image at given coords, binding texture appropriately glBegin(GL_QUADS); // -halfWidth and -halfHeight act as ancors to rotate from the center glTexCoord2d(0,0); glVertex2f(0 , 0); glTexCoord2d(0,texh); glVertex2f(0, size.h); glTexCoord2d(texw,texh); glVertex2f(size.w , size.h); glTexCoord2d(texw,0); glVertex2f(size.w , 0); glEnd(); glPopMatrix(); } /// draw a subsection of an image with the top-left at 0,0 void drawImageSubsection(Texture texture, Point topLeft, Point rightBottom, Color color = Color.White) { // enable 2d textures and bind texture glEnable(GL_TEXTURE_2D); // bind texture ID to this tex glBindTexture(GL_TEXTURE_2D, texture.getID); // set color color.setGLColor(); // draw image at given coords, binding texture appropriately glBegin(GL_QUADS); arcfl width = texture.getTextureSize.w; arcfl height = texture.getTextureSize.h; arcfl tLeft = topLeft.x / width, tTop = topLeft.y / height, tRight = rightBottom.x / width, tBottom = rightBottom.y / height; glTexCoord2d(tLeft, tTop); glVertex2f(0, 0); glTexCoord2d(tLeft, tBottom); glVertex2f(0, rightBottom.y - topLeft.y); glTexCoord2d(tRight, tBottom); glVertex2f(rightBottom.x - topLeft.x , rightBottom.y - topLeft.y); glTexCoord2d(tRight, tTop); glVertex2f(rightBottom.x - topLeft.x , 0); glEnd(); }
D
/** * The semaphore module provides a general use semaphore for synchronization. * * Copyright: Copyright Sean Kelly 2005 - 2009. * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Authors: Sean Kelly * Source: $(DRUNTIMESRC core/sync/_semaphore.d) */ /* Copyright Sean Kelly 2005 - 2009. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ module core.sync.semaphore; public import core.sync.exception; public import core.time; version (OSX) version = Darwin; else version (iOS) version = Darwin; else version (TVOS) version = Darwin; else version (WatchOS) version = Darwin; version (Windows) { import core.sys.windows.basetsd /+: HANDLE+/; import core.sys.windows.winbase /+: CloseHandle, CreateSemaphoreA, INFINITE, ReleaseSemaphore, WAIT_OBJECT_0, WaitForSingleObject+/; import core.sys.windows.windef /+: BOOL, DWORD+/; import core.sys.windows.winerror /+: WAIT_TIMEOUT+/; } else version (Darwin) { import core.sync.config; import core.stdc.errno; import core.sys.posix.time; import core.sys.darwin.mach.semaphore; } else version (Posix) { import core.sync.config; import core.stdc.errno; import core.sys.posix.pthread; import core.sys.posix.semaphore; } else { static assert(false, "Platform not supported"); } //////////////////////////////////////////////////////////////////////////////// // Semaphore // // void wait(); // void notify(); // bool tryWait(); //////////////////////////////////////////////////////////////////////////////// /** * This class represents a general counting semaphore as concieved by Edsger * Dijkstra. As per Mesa type monitors however, "signal" has been replaced * with "notify" to indicate that control is not transferred to the waiter when * a notification is sent. */ class Semaphore { //////////////////////////////////////////////////////////////////////////// // Initialization //////////////////////////////////////////////////////////////////////////// /** * Initializes a semaphore object with the specified initial count. * * Params: * count = The initial count for the semaphore. * * Throws: * SyncError on error. */ this( uint count = 0 ) { version (Windows) { m_hndl = CreateSemaphoreA( null, count, int.max, null ); if ( m_hndl == m_hndl.init ) throw new SyncError( "Unable to create semaphore" ); } else version (Darwin) { auto rc = semaphore_create( mach_task_self(), &m_hndl, SYNC_POLICY_FIFO, count ); if ( rc ) throw new SyncError( "Unable to create semaphore" ); } else version (Posix) { int rc = sem_init( &m_hndl, 0, count ); if ( rc ) throw new SyncError( "Unable to create semaphore" ); } } ~this() { version (Windows) { BOOL rc = CloseHandle( m_hndl ); assert( rc, "Unable to destroy semaphore" ); } else version (Darwin) { auto rc = semaphore_destroy( mach_task_self(), m_hndl ); assert( !rc, "Unable to destroy semaphore" ); } else version (Posix) { int rc = sem_destroy( &m_hndl ); assert( !rc, "Unable to destroy semaphore" ); } } //////////////////////////////////////////////////////////////////////////// // General Actions //////////////////////////////////////////////////////////////////////////// /** * Wait until the current count is above zero, then atomically decrement * the count by one and return. * * Throws: * SyncError on error. */ void wait() { version (Windows) { DWORD rc = WaitForSingleObject( m_hndl, INFINITE ); if ( rc != WAIT_OBJECT_0 ) throw new SyncError( "Unable to wait for semaphore" ); } else version (Darwin) { while ( true ) { auto rc = semaphore_wait( m_hndl ); if ( !rc ) return; if ( rc == KERN_ABORTED && errno == EINTR ) continue; throw new SyncError( "Unable to wait for semaphore" ); } } else version (Posix) { while ( true ) { if ( !sem_wait( &m_hndl ) ) return; if ( errno != EINTR ) throw new SyncError( "Unable to wait for semaphore" ); } } } /** * Suspends the calling thread until the current count moves above zero or * until the supplied time period has elapsed. If the count moves above * zero in this interval, then atomically decrement the count by one and * return true. Otherwise, return false. * * Params: * period = The time to wait. * * In: * period must be non-negative. * * Throws: * SyncError on error. * * Returns: * true if notified before the timeout and false if not. */ bool wait( Duration period ) in { assert( !period.isNegative ); } do { version (Windows) { auto maxWaitMillis = dur!("msecs")( uint.max - 1 ); while ( period > maxWaitMillis ) { auto rc = WaitForSingleObject( m_hndl, cast(uint) maxWaitMillis.total!"msecs" ); switch ( rc ) { case WAIT_OBJECT_0: return true; case WAIT_TIMEOUT: period -= maxWaitMillis; continue; default: throw new SyncError( "Unable to wait for semaphore" ); } } switch ( WaitForSingleObject( m_hndl, cast(uint) period.total!"msecs" ) ) { case WAIT_OBJECT_0: return true; case WAIT_TIMEOUT: return false; default: throw new SyncError( "Unable to wait for semaphore" ); } } else version (Darwin) { mach_timespec_t t = void; (cast(byte*) &t)[0 .. t.sizeof] = 0; if ( period.total!"seconds" > t.tv_sec.max ) { t.tv_sec = t.tv_sec.max; t.tv_nsec = cast(typeof(t.tv_nsec)) period.split!("seconds", "nsecs")().nsecs; } else period.split!("seconds", "nsecs")(t.tv_sec, t.tv_nsec); while ( true ) { auto rc = semaphore_timedwait( m_hndl, t ); if ( !rc ) return true; if ( rc == KERN_OPERATION_TIMED_OUT ) return false; if ( rc != KERN_ABORTED || errno != EINTR ) throw new SyncError( "Unable to wait for semaphore" ); } } else version (Posix) { import core.sys.posix.time : clock_gettime, CLOCK_REALTIME; timespec t = void; clock_gettime( CLOCK_REALTIME, &t ); mvtspec( t, period ); while ( true ) { if ( !sem_timedwait( &m_hndl, &t ) ) return true; if ( errno == ETIMEDOUT ) return false; if ( errno != EINTR ) throw new SyncError( "Unable to wait for semaphore" ); } } } /** * Atomically increment the current count by one. This will notify one * waiter, if there are any in the queue. * * Throws: * SyncError on error. */ void notify() { version (Windows) { if ( !ReleaseSemaphore( m_hndl, 1, null ) ) throw new SyncError( "Unable to notify semaphore" ); } else version (Darwin) { auto rc = semaphore_signal( m_hndl ); if ( rc ) throw new SyncError( "Unable to notify semaphore" ); } else version (Posix) { int rc = sem_post( &m_hndl ); if ( rc ) throw new SyncError( "Unable to notify semaphore" ); } } /** * If the current count is equal to zero, return. Otherwise, atomically * decrement the count by one and return true. * * Throws: * SyncError on error. * * Returns: * true if the count was above zero and false if not. */ bool tryWait() { version (Windows) { switch ( WaitForSingleObject( m_hndl, 0 ) ) { case WAIT_OBJECT_0: return true; case WAIT_TIMEOUT: return false; default: throw new SyncError( "Unable to wait for semaphore" ); } } else version (Darwin) { return wait( dur!"hnsecs"(0) ); } else version (Posix) { while ( true ) { if ( !sem_trywait( &m_hndl ) ) return true; if ( errno == EAGAIN ) return false; if ( errno != EINTR ) throw new SyncError( "Unable to wait for semaphore" ); } } } protected: /// Aliases the operating-system-specific semaphore type. version (Windows) alias Handle = HANDLE; /// ditto else version (Darwin) alias Handle = semaphore_t; /// ditto else version (Posix) alias Handle = sem_t; /// Handle to the system-specific semaphore. Handle m_hndl; } //////////////////////////////////////////////////////////////////////////////// // Unit Tests //////////////////////////////////////////////////////////////////////////////// unittest { import core.thread, core.atomic; void testWait() { auto semaphore = new Semaphore; shared bool stopConsumption = false; immutable numToProduce = 20; immutable numConsumers = 10; shared size_t numConsumed; shared size_t numComplete; void consumer() { while (true) { semaphore.wait(); if (atomicLoad(stopConsumption)) break; atomicOp!"+="(numConsumed, 1); } atomicOp!"+="(numComplete, 1); } void producer() { assert(!semaphore.tryWait()); foreach (_; 0 .. numToProduce) semaphore.notify(); // wait until all items are consumed while (atomicLoad(numConsumed) != numToProduce) Thread.yield(); // mark consumption as finished atomicStore(stopConsumption, true); // wake all consumers foreach (_; 0 .. numConsumers) semaphore.notify(); // wait until all consumers completed while (atomicLoad(numComplete) != numConsumers) Thread.yield(); assert(!semaphore.tryWait()); semaphore.notify(); assert(semaphore.tryWait()); assert(!semaphore.tryWait()); } auto group = new ThreadGroup; for ( int i = 0; i < numConsumers; ++i ) group.create(&consumer); group.create(&producer); group.joinAll(); } void testWaitTimeout() { auto sem = new Semaphore; shared bool semReady; bool alertedOne, alertedTwo; void waiter() { while (!atomicLoad(semReady)) Thread.yield(); alertedOne = sem.wait(dur!"msecs"(1)); alertedTwo = sem.wait(dur!"msecs"(1)); assert(alertedOne && !alertedTwo); } auto thread = new Thread(&waiter); thread.start(); sem.notify(); atomicStore(semReady, true); thread.join(); assert(alertedOne && !alertedTwo); } testWait(); testWaitTimeout(); }
D
/Users/zyang/SNGithub/Cosmos/Build/Intermediates/Cosmos.build/Debug-iphonesimulator/Cosmos.build/Objects-normal/x86_64/Math.o : /Users/zyang/SNGithub/Cosmos/Cosmos/Curve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape+Creation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Wedge.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Checkerboard.swift /Users/zyang/SNGithub/Cosmos/Cosmos/RegularPolygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/EventSource.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Bloom.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rectangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AstrologicalSignProvider.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ScreenRecorder.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ImageLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/HueAdjust.swift /Users/zyang/SNGithub/Cosmos/Cosmos/QuadCurve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Vector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AppDelegate.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Stars.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBig.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Shadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBackground.swift /Users/zyang/SNGithub/Cosmos/Cosmos/PlayerLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sepia.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsSmall.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Transform.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Pixel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Line.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Arc.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIGestureRecognizer+Closure.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuShadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GradientLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StoredAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuIcons.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Ellipse.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Foundation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Border.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rect.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIViewController+C4View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Size.swift /Users/zyang/SNGithub/Cosmos/Cosmos/TextShape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Crop.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Star.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Circle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/LinearGradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Font.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Movie.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Point.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sharpen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/DotScreen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Timer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Path.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfiniteScrollView.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIView+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuSelector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ViewAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/CanvasController.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+KeyValues.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Render.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfoPanel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ColorBurn.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Gradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Triangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Twirl.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Menu.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Math.swift /Users/zyang/SNGithub/Cosmos/Cosmos/SignLines.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Polygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Layer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ShapeLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GaussianBlur.swift /Users/zyang/SNGithub/Cosmos/Cosmos/WorkSpace.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AudioPlayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuRings.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Users/zyang/SNGithub/Cosmos/Build/Intermediates/Cosmos.build/Debug-iphonesimulator/Cosmos.build/Objects-normal/x86_64/Math~partial.swiftmodule : /Users/zyang/SNGithub/Cosmos/Cosmos/Curve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape+Creation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Wedge.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Checkerboard.swift /Users/zyang/SNGithub/Cosmos/Cosmos/RegularPolygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/EventSource.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Bloom.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rectangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AstrologicalSignProvider.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ScreenRecorder.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ImageLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/HueAdjust.swift /Users/zyang/SNGithub/Cosmos/Cosmos/QuadCurve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Vector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AppDelegate.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Stars.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBig.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Shadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBackground.swift /Users/zyang/SNGithub/Cosmos/Cosmos/PlayerLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sepia.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsSmall.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Transform.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Pixel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Line.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Arc.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIGestureRecognizer+Closure.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuShadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GradientLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StoredAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuIcons.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Ellipse.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Foundation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Border.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rect.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIViewController+C4View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Size.swift /Users/zyang/SNGithub/Cosmos/Cosmos/TextShape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Crop.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Star.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Circle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/LinearGradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Font.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Movie.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Point.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sharpen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/DotScreen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Timer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Path.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfiniteScrollView.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIView+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuSelector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ViewAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/CanvasController.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+KeyValues.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Render.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfoPanel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ColorBurn.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Gradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Triangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Twirl.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Menu.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Math.swift /Users/zyang/SNGithub/Cosmos/Cosmos/SignLines.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Polygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Layer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ShapeLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GaussianBlur.swift /Users/zyang/SNGithub/Cosmos/Cosmos/WorkSpace.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AudioPlayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuRings.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Users/zyang/SNGithub/Cosmos/Build/Intermediates/Cosmos.build/Debug-iphonesimulator/Cosmos.build/Objects-normal/x86_64/Math~partial.swiftdoc : /Users/zyang/SNGithub/Cosmos/Cosmos/Curve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape+Creation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Wedge.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Checkerboard.swift /Users/zyang/SNGithub/Cosmos/Cosmos/RegularPolygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/EventSource.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Bloom.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rectangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AstrologicalSignProvider.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ScreenRecorder.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ImageLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/HueAdjust.swift /Users/zyang/SNGithub/Cosmos/Cosmos/QuadCurve.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Vector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AppDelegate.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Stars.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBig.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Shadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsBackground.swift /Users/zyang/SNGithub/Cosmos/Cosmos/PlayerLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sepia.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StarsSmall.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Transform.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Pixel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Shape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Line.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Arc.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIGestureRecognizer+Closure.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuShadow.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GradientLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/StoredAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuIcons.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Ellipse.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Foundation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Border.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Rect.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIViewController+C4View.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Size.swift /Users/zyang/SNGithub/Cosmos/Cosmos/TextShape.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Crop.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Star.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Circle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/LinearGradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Font.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Movie.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Point.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Sharpen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/DotScreen.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Filter.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Timer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Path.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfiniteScrollView.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIView+AddRemove.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuSelector.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ViewAnimation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/CanvasController.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Animation.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+KeyValues.swift /Users/zyang/SNGithub/Cosmos/Cosmos/View+Render.swift /Users/zyang/SNGithub/Cosmos/Cosmos/InfoPanel.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ColorBurn.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Gradient.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Triangle.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Twirl.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Menu.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Math.swift /Users/zyang/SNGithub/Cosmos/Cosmos/SignLines.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Polygon.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Layer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/ShapeLayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/Image+Generator.swift /Users/zyang/SNGithub/Cosmos/Cosmos/GaussianBlur.swift /Users/zyang/SNGithub/Cosmos/Cosmos/WorkSpace.swift /Users/zyang/SNGithub/Cosmos/Cosmos/UIImage+Color.swift /Users/zyang/SNGithub/Cosmos/Cosmos/AudioPlayer.swift /Users/zyang/SNGithub/Cosmos/Cosmos/MenuRings.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule
D
/*aivar Funcs * ... * Ok, to na poczatek kilka słów nt. funkcjonalnosci tutaj zawartej i jej przeznaczenia. * Jak zauwazyłem (choc dopiero po uprzątnieciu AI_Constants.d) wieleaivarów nakladalo sie * na siebie pozycjami w tablicyaivars co skutkowało takimi atrakcjami jak chocby nagłe * Od-uczenie sie kregów magii oraz wieloma innymi może nie odnotowanymi ale napewno teoretycznie * możliwymi. * * Dlatego wymagane było natychmiastowe ogarniecie tego problemu, dlatego obecneaivary musialy zostac * "skompresowane" w czesci do mask bitowych. Wiąże sie to z jakimis utrudnieniami, choc nie są one * ogromne, to jednak wymagają przyswojenia, w skrócie, uproszczeniu i bez wnikania w szczegóły teraz * Zamiast czytac/zapisywacaivary w ten sposób: * ------------------------------------------ * aivar[AIV_PARTYMEMBER] = TRUE; * * if(aivar[AIV_PARTYMEMBER] == TRUE) * { Print("Jestes w party!"); }; * ------------------------------------------ * Robimy to przy użyciu tutaj znajdujących sie funkcji o tak: * ------------------------------------------ * Npc_SetAivar(self,AIV_PARTYMEMBER,TRUE); * * if(Npc_GetAivar(self,AIV_PARTYMEMBER) == TRUE) * { Print("Jestes w party!"); }; * ------------------------------------------ * Tym czy danyaivar jest faktycznieaivarem, czy może jedynie flagą waivarze rozwazą już same funkcje. * Ork, 14:13 2012-10-19 *******************************************************************************************************/ /*************************************** * A I V A R R E G I O N S * * 0-3 -> Reserved for bitFlags (Giving ability to have up to 128 boolean(true/false)aivars * 4-49 -> "Normal"aivars, that will have more states than just two * 50-178 -> Booleanaivars virtually positions needed 100 is the first bit onaivar[0], 228 is last(32) bit onaivar[3] **************************************/ const int MIN_AIVAR = 0; const int MAX_AIVAR = 49; const int MIN_BITFLAG = 50; const int MAX_BITFLAG = 178; const int MIN_NORMALAIVAR = 4; // // Internal ("private" funcs) // DO NOT USE THEM!!! // --------------------------------- func void __Npc_SetAivar (var C_NPC slf, var int offset, var int value) { if (offset == 0 ) { slf._aivar[ 0 ] = value; } else if (offset == 1 ) { slf._aivar[ 1 ] = value; } else if (offset == 2 ) { slf._aivar[ 2 ] = value; } else if (offset == 3 ) { slf._aivar[ 3 ] = value; } else if (offset == 4 ) { slf._aivar[ 4 ] = value; } else if (offset == 5 ) { slf._aivar[ 5 ] = value; } else if (offset == 6 ) { slf._aivar[ 6 ] = value; } else if (offset == 7 ) { slf._aivar[ 7 ] = value; } else if (offset == 8 ) { slf._aivar[ 8 ] = value; } else if (offset == 9 ) { slf._aivar[ 9 ] = value; } else if (offset == 10 ) { slf._aivar[ 10 ] = value; } else if (offset == 11 ) { slf._aivar[ 11 ] = value; } else if (offset == 12 ) { slf._aivar[ 12 ] = value; } else if (offset == 13 ) { slf._aivar[ 13 ] = value; } else if (offset == 14 ) { slf._aivar[ 14 ] = value; } else if (offset == 15 ) { slf._aivar[ 15 ] = value; } else if (offset == 16 ) { slf._aivar[ 16 ] = value; } else if (offset == 17 ) { slf._aivar[ 17 ] = value; } else if (offset == 18 ) { slf._aivar[ 18 ] = value; } else if (offset == 19 ) { slf._aivar[ 19 ] = value; } else if (offset == 20 ) { slf._aivar[ 20 ] = value; } else if (offset == 21 ) { slf._aivar[ 21 ] = value; } else if (offset == 22 ) { slf._aivar[ 22 ] = value; } else if (offset == 23 ) { slf._aivar[ 23 ] = value; } else if (offset == 24 ) { slf._aivar[ 24 ] = value; } else if (offset == 25 ) { slf._aivar[ 25 ] = value; } else if (offset == 26 ) { slf._aivar[ 26 ] = value; } else if (offset == 27 ) { slf._aivar[ 27 ] = value; } else if (offset == 28 ) { slf._aivar[ 28 ] = value; } else if (offset == 29 ) { slf._aivar[ 29 ] = value; } else if (offset == 30 ) { slf._aivar[ 30 ] = value; } else if (offset == 31 ) { slf._aivar[ 31 ] = value; } else if (offset == 32 ) { slf._aivar[ 32 ] = value; } else if (offset == 33 ) { slf._aivar[ 33 ] = value; } else if (offset == 34 ) { slf._aivar[ 34 ] = value; } else if (offset == 35 ) { slf._aivar[ 35 ] = value; } else if (offset == 36 ) { slf._aivar[ 36 ] = value; } else if (offset == 37 ) { slf._aivar[ 37 ] = value; } else if (offset == 38 ) { slf._aivar[ 38 ] = value; } else if (offset == 39 ) { slf._aivar[ 39 ] = value; } else if (offset == 40 ) { slf._aivar[ 40 ] = value; } else if (offset == 41 ) { slf._aivar[ 41 ] = value; } else if (offset == 42 ) { slf._aivar[ 42 ] = value; } else if (offset == 43 ) { slf._aivar[ 43 ] = value; } else if (offset == 44 ) { slf._aivar[ 44 ] = value; } else if (offset == 45 ) { slf._aivar[ 45 ] = value; } else if (offset == 46 ) { slf._aivar[ 46 ] = value; } else if (offset == 47 ) { slf._aivar[ 47 ] = value; } else if (offset == 48 ) { slf._aivar[ 48 ] = value; } else if (offset == 49 ) { slf._aivar[ 49 ] = value; }; }; func int __Npc_GetAivar (var C_NPC slf, var int offset) { if (offset == 0 ) { return slf._aivar[ 0 ]; } else if (offset == 1 ) { return slf._aivar[ 1 ]; } else if (offset == 2 ) { return slf._aivar[ 2 ]; } else if (offset == 3 ) { return slf._aivar[ 3 ]; } else if (offset == 4 ) { return slf._aivar[ 4 ]; } else if (offset == 5 ) { return slf._aivar[ 5 ]; } else if (offset == 6 ) { return slf._aivar[ 6 ]; } else if (offset == 7 ) { return slf._aivar[ 7 ]; } else if (offset == 8 ) { return slf._aivar[ 8 ]; } else if (offset == 9 ) { return slf._aivar[ 9 ]; } else if (offset == 10 ) { return slf._aivar[ 10 ]; } else if (offset == 11 ) { return slf._aivar[ 11 ]; } else if (offset == 12 ) { return slf._aivar[ 12 ]; } else if (offset == 13 ) { return slf._aivar[ 13 ]; } else if (offset == 14 ) { return slf._aivar[ 14 ]; } else if (offset == 15 ) { return slf._aivar[ 15 ]; } else if (offset == 16 ) { return slf._aivar[ 16 ]; } else if (offset == 17 ) { return slf._aivar[ 17 ]; } else if (offset == 18 ) { return slf._aivar[ 18 ]; } else if (offset == 19 ) { return slf._aivar[ 19 ]; } else if (offset == 20 ) { return slf._aivar[ 20 ]; } else if (offset == 21 ) { return slf._aivar[ 21 ]; } else if (offset == 22 ) { return slf._aivar[ 22 ]; } else if (offset == 23 ) { return slf._aivar[ 23 ]; } else if (offset == 24 ) { return slf._aivar[ 24 ]; } else if (offset == 25 ) { return slf._aivar[ 25 ]; } else if (offset == 26 ) { return slf._aivar[ 26 ]; } else if (offset == 27 ) { return slf._aivar[ 27 ]; } else if (offset == 28 ) { return slf._aivar[ 28 ]; } else if (offset == 29 ) { return slf._aivar[ 29 ]; } else if (offset == 30 ) { return slf._aivar[ 30 ]; } else if (offset == 31 ) { return slf._aivar[ 31 ]; } else if (offset == 32 ) { return slf._aivar[ 32 ]; } else if (offset == 33 ) { return slf._aivar[ 33 ]; } else if (offset == 34 ) { return slf._aivar[ 34 ]; } else if (offset == 35 ) { return slf._aivar[ 35 ]; } else if (offset == 36 ) { return slf._aivar[ 36 ]; } else if (offset == 37 ) { return slf._aivar[ 37 ]; } else if (offset == 38 ) { return slf._aivar[ 38 ]; } else if (offset == 39 ) { return slf._aivar[ 39 ]; } else if (offset == 40 ) { return slf._aivar[ 40 ]; } else if (offset == 41 ) { return slf._aivar[ 41 ]; } else if (offset == 42 ) { return slf._aivar[ 42 ]; } else if (offset == 43 ) { return slf._aivar[ 43 ]; } else if (offset == 44 ) { return slf._aivar[ 44 ]; } else if (offset == 45 ) { return slf._aivar[ 45 ]; } else if (offset == 46 ) { return slf._aivar[ 46 ]; } else if (offset == 47 ) { return slf._aivar[ 47 ]; } else if (offset == 48 ) { return slf._aivar[ 48 ]; } else if (offset == 49 ) { return slf._aivar[ 49 ]; }; }; // "Public" funcs: // --------------------------------- func void Npc_SetAivar(var C_NPC slf, var int offset, var int value) { var int val; var int oldVal; if((offset>=MIN_NORMALAIVAR)&&(offset<=MAX_AIVAR)) {//setting normalaivar: __Npc_SetAivar(slf,offset,value); } else if((offset>=MIN_BITFLAG)&&(offset<=MAX_BITFLAG)) { var int bitAivOffset; bitAivOffset = (offset-MIN_BITFLAG)/32;//32-bits per variable var int bitOffset; bitOffset = (offset-MIN_BITFLAG)%32; val = value; if(value!=0){value=TRUE;};//We need to be sure its 0/1 val = 1 << bitOffset; //bit-shifter value oldVal = __Npc_GetAivar(slf,bitAivOffset); //the "magic" formula(s): __Npc_SetAivar(slf, bitAivOffset, (oldVal & (~val)) | (!!value << bitOffset)); // Debug stuff: PrintDebug_s_i_s_i("Npc_SetAivar: passed offset: ",offset,", val: ",value); PrintDebug_s_i_s_i("Npc_SetAivar: it's aiv num: ",bitAivOffset,", bitOff: ",bitOffset); PrintDebug_s_i_s_i("Npc_SetAivar: it's old val: ",oldVal,", newVal: ",__Npc_GetAivar(slf,bitOffset) ); } /*else {//Passed wrong offset! Print_s_i_s_i("WARN:Npc_SetAivar, offset: ",offset," is out of range, can't set value: ",value); }*/; }; func int Npc_GetAivar(var C_NPC slf, var int offset) { if ((offset >= MIN_AIVAR) && (offset<MIN_NORMALAIVAR)) { return ((__Npc_GetAivar(slf,offset) & (1 << 0)) >> 0); } else if((offset>=MIN_NORMALAIVAR)&&(offset<=MAX_AIVAR)) {//setting normalaivar: return __Npc_GetAivar(slf,offset); } else if((offset>=MIN_BITFLAG)&&(offset<=MAX_BITFLAG)) { var int bitAivOffset; bitAivOffset = (offset-MIN_BITFLAG)/32;//32-bits per variable var int bitOffset; bitOffset = (offset-MIN_BITFLAG)%32; var int val; //the "magic" formula: val = (__Npc_GetAivar(slf,bitAivOffset) & (1 << bitOffset)) >> bitOffset; // Debug stuff: PrintDebug_s_i_s_i("Npc_GetAivar: passed offset: ",offset,", returned val: ",val); return val; } else {//Passed wrong offset! // Hmm to jest sposob ktorym poradziliscie sobie z blednymi offsetami? :D // mam nadzieje ze nie :P //Print_s_i_s("WARN:Npc_GetAivar, offset: ",offset," is out of range, can't get value."); PrintDebug_s_i_s("WARN:Npc_GetAivar, offset: ",offset," is out of range, can't get value."); return -1; }; }; // [NEW] Ork: Doda rekursywnie wartosć do obecnej wartosci aivaru: func void Npc_AddToAivarValue(var C_NPC slf, var int offset, var int valPlus) { Npc_SetAivar(slf,offset,Npc_GetAivar(slf,offset) + valPlus); };
D
module elasticsearch.api.actions.nodes.all;
D
module sigod.codeforces.p285B; import std.conv; import std.stdio; import std.string; void main() { int n, s, t; stdin.readf("%s %s %s", &n, &s, &t); if (s == t) { stdout.write("0"); return; } stdin.readln(); int[] p = read_array!(int)(); --s; --t; int result = 0; int position = s; while (position != t && p[position] != -1) { auto tmp = position; position = p[position] - 1; p[tmp] = -1; ++result; } if (position != t) result = -1; stdout.write(result); } private T[] read_array(T)() { auto input = stdin.readln().strip().split(); T[] result = new T[input.length]; foreach (index, ref element; input) { result[index] = element.to!T(); } return result; }
D
version (Win32) { import std.c.windows.windows; } extern(System): /* Please use this code with old D compiler. version (Win32) { extern(Windows): } else { extern(C): } */ alias uint GLenum; alias ubyte GLboolean; alias uint GLbitfield; alias byte GLbyte; alias short GLshort; alias int GLint; alias int GLsizei; alias ubyte GLubyte; alias ushort GLushort; alias uint GLuint; alias float GLfloat; alias float GLclampf; alias double GLdouble; alias double GLclampd; alias void GLvoid; /*************************************************************/ /* Version */ const uint GL_VERSION_1_1 = 1; /* AccumOp */ const uint GL_ACCUM = 0x0100; const uint GL_LOAD = 0x0101; const uint GL_RETURN = 0x0102; const uint GL_MULT = 0x0103; const uint GL_ADD = 0x0104; /* AlphaFunction */ const uint GL_NEVER = 0x0200; const uint GL_LESS = 0x0201; const uint GL_EQUAL = 0x0202; const uint GL_LEQUAL = 0x0203; const uint GL_GREATER = 0x0204; const uint GL_NOTEQUAL = 0x0205; const uint GL_GEQUAL = 0x0206; const uint GL_ALWAYS = 0x0207; /* AttribMask */ const uint GL_CURRENT_BIT = 0x00000001; const uint GL_POINT_BIT = 0x00000002; const uint GL_LINE_BIT = 0x00000004; const uint GL_POLYGON_BIT = 0x00000008; const uint GL_POLYGON_STIPPLE_BIT = 0x00000010; const uint GL_PIXEL_MODE_BIT = 0x00000020; const uint GL_LIGHTING_BIT = 0x00000040; const uint GL_FOG_BIT = 0x00000080; const uint GL_DEPTH_BUFFER_BIT = 0x00000100; const uint GL_ACCUM_BUFFER_BIT = 0x00000200; const uint GL_STENCIL_BUFFER_BIT = 0x00000400; const uint GL_VIEWPORT_BIT = 0x00000800; const uint GL_TRANSFORM_BIT = 0x00001000; const uint GL_ENABLE_BIT = 0x00002000; const uint GL_COLOR_BUFFER_BIT = 0x00004000; const uint GL_HINT_BIT = 0x00008000; const uint GL_EVAL_BIT = 0x00010000; const uint GL_LIST_BIT = 0x00020000; const uint GL_TEXTURE_BIT = 0x00040000; const uint GL_SCISSOR_BIT = 0x00080000; const uint GL_ALL_ATTRIB_BITS = 0x000fffff; /* BeginMode */ const uint GL_POINTS = 0x0000; const uint GL_LINES = 0x0001; const uint GL_LINE_LOOP = 0x0002; const uint GL_LINE_STRIP = 0x0003; const uint GL_TRIANGLES = 0x0004; const uint GL_TRIANGLE_STRIP = 0x0005; const uint GL_TRIANGLE_FAN = 0x0006; const uint GL_QUADS = 0x0007; const uint GL_QUAD_STRIP = 0x0008; const uint GL_POLYGON = 0x0009; /* BlendingFactorDest */ const uint GL_ZERO = 0; const uint GL_ONE = 1; const uint GL_SRC_COLOR = 0x0300; const uint GL_ONE_MINUS_SRC_COLOR = 0x0301; const uint GL_SRC_ALPHA = 0x0302; const uint GL_ONE_MINUS_SRC_ALPHA = 0x0303; const uint GL_DST_ALPHA = 0x0304; const uint GL_ONE_MINUS_DST_ALPHA = 0x0305; /* BlendingFactorSrc */ /* GL_ZERO */ /* GL_ONE */ const uint GL_DST_COLOR = 0x0306; const uint GL_ONE_MINUS_DST_COLOR = 0x0307; const uint GL_SRC_ALPHA_SATURATE = 0x0308; /* GL_SRC_ALPHA */ /* GL_ONE_MINUS_SRC_ALPHA */ /* GL_DST_ALPHA */ /* GL_ONE_MINUS_DST_ALPHA */ /* Boolean */ const uint GL_TRUE = 1; const uint GL_FALSE = 0; /* ClearBufferMask */ /* GL_COLOR_BUFFER_BIT */ /* GL_ACCUM_BUFFER_BIT */ /* GL_STENCIL_BUFFER_BIT */ /* GL_DEPTH_BUFFER_BIT */ /* ClientArrayType */ /* GL_VERTEX_ARRAY */ /* GL_NORMAL_ARRAY */ /* GL_COLOR_ARRAY */ /* GL_INDEX_ARRAY */ /* GL_TEXTURE_COORD_ARRAY */ /* GL_EDGE_FLAG_ARRAY */ /* ClipPlaneName */ const uint GL_CLIP_PLANE0 = 0x3000; const uint GL_CLIP_PLANE1 = 0x3001; const uint GL_CLIP_PLANE2 = 0x3002; const uint GL_CLIP_PLANE3 = 0x3003; const uint GL_CLIP_PLANE4 = 0x3004; const uint GL_CLIP_PLANE5 = 0x3005; /* ColorMaterialFace */ /* GL_FRONT */ /* GL_BACK */ /* GL_FRONT_AND_BACK */ /* ColorMaterialParameter */ /* GL_AMBIENT */ /* GL_DIFFUSE */ /* GL_SPECULAR */ /* GL_EMISSION */ /* GL_AMBIENT_AND_DIFFUSE */ /* ColorPointerType */ /* GL_BYTE */ /* GL_UNSIGNED_BYTE */ /* GL_SHORT */ /* GL_UNSIGNED_SHORT */ /* GL_INT */ /* GL_UNSIGNED_INT */ /* GL_FLOAT */ /* GL_DOUBLE */ /* CullFaceMode */ /* GL_FRONT */ /* GL_BACK */ /* GL_FRONT_AND_BACK */ /* DataType */ const uint GL_BYTE = 0x1400; const uint GL_UNSIGNED_BYTE = 0x1401; const uint GL_SHORT = 0x1402; const uint GL_UNSIGNED_SHORT = 0x1403; const uint GL_INT = 0x1404; const uint GL_UNSIGNED_INT = 0x1405; const uint GL_FLOAT = 0x1406; const uint GL_2_BYTES = 0x1407; const uint GL_3_BYTES = 0x1408; const uint GL_4_BYTES = 0x1409; const uint GL_DOUBLE = 0x140A; /* DepthFunction */ /* GL_NEVER */ /* GL_LESS */ /* GL_EQUAL */ /* GL_LEQUAL */ /* GL_GREATER */ /* GL_NOTEQUAL */ /* GL_GEQUAL */ /* GL_ALWAYS */ /* DrawBufferMode */ const uint GL_NONE = 0; const uint GL_FRONT_LEFT = 0x0400; const uint GL_FRONT_RIGHT = 0x0401; const uint GL_BACK_LEFT = 0x0402; const uint GL_BACK_RIGHT = 0x0403; const uint GL_FRONT = 0x0404; const uint GL_BACK = 0x0405; const uint GL_LEFT = 0x0406; const uint GL_RIGHT = 0x0407; const uint GL_FRONT_AND_BACK = 0x0408; const uint GL_AUX0 = 0x0409; const uint GL_AUX1 = 0x040A; const uint GL_AUX2 = 0x040B; const uint GL_AUX3 = 0x040C; /* Enable */ /* GL_FOG */ /* GL_LIGHTING */ /* GL_TEXTURE_1D */ /* GL_TEXTURE_2D */ /* GL_LINE_STIPPLE */ /* GL_POLYGON_STIPPLE */ /* GL_CULL_FACE */ /* GL_ALPHA_TEST */ /* GL_BLEND */ /* GL_INDEX_LOGIC_OP */ /* GL_COLOR_LOGIC_OP */ /* GL_DITHER */ /* GL_STENCIL_TEST */ /* GL_DEPTH_TEST */ /* GL_CLIP_PLANE0 */ /* GL_CLIP_PLANE1 */ /* GL_CLIP_PLANE2 */ /* GL_CLIP_PLANE3 */ /* GL_CLIP_PLANE4 */ /* GL_CLIP_PLANE5 */ /* GL_LIGHT0 */ /* GL_LIGHT1 */ /* GL_LIGHT2 */ /* GL_LIGHT3 */ /* GL_LIGHT4 */ /* GL_LIGHT5 */ /* GL_LIGHT6 */ /* GL_LIGHT7 */ /* GL_TEXTURE_GEN_S */ /* GL_TEXTURE_GEN_T */ /* GL_TEXTURE_GEN_R */ /* GL_TEXTURE_GEN_Q */ /* GL_MAP1_VERTEX_3 */ /* GL_MAP1_VERTEX_4 */ /* GL_MAP1_COLOR_4 */ /* GL_MAP1_INDEX */ /* GL_MAP1_NORMAL */ /* GL_MAP1_TEXTURE_COORD_1 */ /* GL_MAP1_TEXTURE_COORD_2 */ /* GL_MAP1_TEXTURE_COORD_3 */ /* GL_MAP1_TEXTURE_COORD_4 */ /* GL_MAP2_VERTEX_3 */ /* GL_MAP2_VERTEX_4 */ /* GL_MAP2_COLOR_4 */ /* GL_MAP2_INDEX */ /* GL_MAP2_NORMAL */ /* GL_MAP2_TEXTURE_COORD_1 */ /* GL_MAP2_TEXTURE_COORD_2 */ /* GL_MAP2_TEXTURE_COORD_3 */ /* GL_MAP2_TEXTURE_COORD_4 */ /* GL_POINT_SMOOTH */ /* GL_LINE_SMOOTH */ /* GL_POLYGON_SMOOTH */ /* GL_SCISSOR_TEST */ /* GL_COLOR_MATERIAL */ /* GL_NORMALIZE */ /* GL_AUTO_NORMAL */ /* GL_VERTEX_ARRAY */ /* GL_NORMAL_ARRAY */ /* GL_COLOR_ARRAY */ /* GL_INDEX_ARRAY */ /* GL_TEXTURE_COORD_ARRAY */ /* GL_EDGE_FLAG_ARRAY */ /* GL_POLYGON_OFFSET_POINT */ /* GL_POLYGON_OFFSET_LINE */ /* GL_POLYGON_OFFSET_FILL */ /* ErrorCode */ const uint GL_NO_ERROR = 0; const uint GL_INVALID_ENUM = 0x0500; const uint GL_INVALID_VALUE = 0x0501; const uint GL_INVALID_OPERATION = 0x0502; const uint GL_STACK_OVERFLOW = 0x0503; const uint GL_STACK_UNDERFLOW = 0x0504; const uint GL_OUT_OF_MEMORY = 0x0505; /* FeedBackMode */ const uint GL_2D = 0x0600; const uint GL_3D = 0x0601; const uint GL_3D_COLOR = 0x0602; const uint GL_3D_COLOR_TEXTURE = 0x0603; const uint GL_4D_COLOR_TEXTURE = 0x0604; /* FeedBackToken */ const uint GL_PASS_THROUGH_TOKEN = 0x0700; const uint GL_POINT_TOKEN = 0x0701; const uint GL_LINE_TOKEN = 0x0702; const uint GL_POLYGON_TOKEN = 0x0703; const uint GL_BITMAP_TOKEN = 0x0704; const uint GL_DRAW_PIXEL_TOKEN = 0x0705; const uint GL_COPY_PIXEL_TOKEN = 0x0706; const uint GL_LINE_RESET_TOKEN = 0x0707; /* FogMode */ /* GL_LINEAR */ const uint GL_EXP = 0x0800; const uint GL_EXP2 = 0x0801; /* FogParameter */ /* GL_FOG_COLOR */ /* GL_FOG_DENSITY */ /* GL_FOG_END */ /* GL_FOG_INDEX */ /* GL_FOG_MODE */ /* GL_FOG_START */ /* FrontFaceDirection */ const uint GL_CW = 0x0900; const uint GL_CCW = 0x0901; /* GetMapTarget */ const uint GL_COEFF = 0x0A00; const uint GL_ORDER = 0x0A01; const uint GL_DOMAIN = 0x0A02; /* GetPixelMap */ /* GL_PIXEL_MAP_I_TO_I */ /* GL_PIXEL_MAP_S_TO_S */ /* GL_PIXEL_MAP_I_TO_R */ /* GL_PIXEL_MAP_I_TO_G */ /* GL_PIXEL_MAP_I_TO_B */ /* GL_PIXEL_MAP_I_TO_A */ /* GL_PIXEL_MAP_R_TO_R */ /* GL_PIXEL_MAP_G_TO_G */ /* GL_PIXEL_MAP_B_TO_B */ /* GL_PIXEL_MAP_A_TO_A */ /* GetPointerTarget */ /* GL_VERTEX_ARRAY_POINTER */ /* GL_NORMAL_ARRAY_POINTER */ /* GL_COLOR_ARRAY_POINTER */ /* GL_INDEX_ARRAY_POINTER */ /* GL_TEXTURE_COORD_ARRAY_POINTER */ /* GL_EDGE_FLAG_ARRAY_POINTER */ /* GetTarget */ const uint GL_CURRENT_COLOR = 0x0B00; const uint GL_CURRENT_INDEX = 0x0B01; const uint GL_CURRENT_NORMAL = 0x0B02; const uint GL_CURRENT_TEXTURE_COORDS = 0x0B03; const uint GL_CURRENT_RASTER_COLOR = 0x0B04; const uint GL_CURRENT_RASTER_INDEX = 0x0B05; const uint GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06; const uint GL_CURRENT_RASTER_POSITION = 0x0B07; const uint GL_CURRENT_RASTER_POSITION_VALID = 0x0B08; const uint GL_CURRENT_RASTER_DISTANCE = 0x0B09; const uint GL_POINT_SMOOTH = 0x0B10; const uint GL_POINT_SIZE = 0x0B11; const uint GL_POINT_SIZE_RANGE = 0x0B12; const uint GL_POINT_SIZE_GRANULARITY = 0x0B13; const uint GL_LINE_SMOOTH = 0x0B20; const uint GL_LINE_WIDTH = 0x0B21; const uint GL_LINE_WIDTH_RANGE = 0x0B22; const uint GL_LINE_WIDTH_GRANULARITY = 0x0B23; const uint GL_LINE_STIPPLE = 0x0B24; const uint GL_LINE_STIPPLE_PATTERN = 0x0B25; const uint GL_LINE_STIPPLE_REPEAT = 0x0B26; const uint GL_LIST_MODE = 0x0B30; const uint GL_MAX_LIST_NESTING = 0x0B31; const uint GL_LIST_BASE = 0x0B32; const uint GL_LIST_INDEX = 0x0B33; const uint GL_POLYGON_MODE = 0x0B40; const uint GL_POLYGON_SMOOTH = 0x0B41; const uint GL_POLYGON_STIPPLE = 0x0B42; const uint GL_EDGE_FLAG = 0x0B43; const uint GL_CULL_FACE = 0x0B44; const uint GL_CULL_FACE_MODE = 0x0B45; const uint GL_FRONT_FACE = 0x0B46; const uint GL_LIGHTING = 0x0B50; const uint GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51; const uint GL_LIGHT_MODEL_TWO_SIDE = 0x0B52; const uint GL_LIGHT_MODEL_AMBIENT = 0x0B53; const uint GL_SHADE_MODEL = 0x0B54; const uint GL_COLOR_MATERIAL_FACE = 0x0B55; const uint GL_COLOR_MATERIAL_PARAMETER = 0x0B56; const uint GL_COLOR_MATERIAL = 0x0B57; const uint GL_FOG = 0x0B60; const uint GL_FOG_INDEX = 0x0B61; const uint GL_FOG_DENSITY = 0x0B62; const uint GL_FOG_START = 0x0B63; const uint GL_FOG_END = 0x0B64; const uint GL_FOG_MODE = 0x0B65; const uint GL_FOG_COLOR = 0x0B66; const uint GL_DEPTH_RANGE = 0x0B70; const uint GL_DEPTH_TEST = 0x0B71; const uint GL_DEPTH_WRITEMASK = 0x0B72; const uint GL_DEPTH_CLEAR_VALUE = 0x0B73; const uint GL_DEPTH_FUNC = 0x0B74; const uint GL_ACCUM_CLEAR_VALUE = 0x0B80; const uint GL_STENCIL_TEST = 0x0B90; const uint GL_STENCIL_CLEAR_VALUE = 0x0B91; const uint GL_STENCIL_FUNC = 0x0B92; const uint GL_STENCIL_VALUE_MASK = 0x0B93; const uint GL_STENCIL_FAIL = 0x0B94; const uint GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95; const uint GL_STENCIL_PASS_DEPTH_PASS = 0x0B96; const uint GL_STENCIL_REF = 0x0B97; const uint GL_STENCIL_WRITEMASK = 0x0B98; const uint GL_MATRIX_MODE = 0x0BA0; const uint GL_NORMALIZE = 0x0BA1; const uint GL_VIEWPORT = 0x0BA2; const uint GL_MODELVIEW_STACK_DEPTH = 0x0BA3; const uint GL_PROJECTION_STACK_DEPTH = 0x0BA4; const uint GL_TEXTURE_STACK_DEPTH = 0x0BA5; const uint GL_MODELVIEW_MATRIX = 0x0BA6; const uint GL_PROJECTION_MATRIX = 0x0BA7; const uint GL_TEXTURE_MATRIX = 0x0BA8; const uint GL_ATTRIB_STACK_DEPTH = 0x0BB0; const uint GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1; const uint GL_ALPHA_TEST = 0x0BC0; const uint GL_ALPHA_TEST_FUNC = 0x0BC1; const uint GL_ALPHA_TEST_REF = 0x0BC2; const uint GL_DITHER = 0x0BD0; const uint GL_BLEND_DST = 0x0BE0; const uint GL_BLEND_SRC = 0x0BE1; const uint GL_BLEND = 0x0BE2; const uint GL_LOGIC_OP_MODE = 0x0BF0; const uint GL_INDEX_LOGIC_OP = 0x0BF1; const uint GL_COLOR_LOGIC_OP = 0x0BF2; const uint GL_AUX_BUFFERS = 0x0C00; const uint GL_DRAW_BUFFER = 0x0C01; const uint GL_READ_BUFFER = 0x0C02; const uint GL_SCISSOR_BOX = 0x0C10; const uint GL_SCISSOR_TEST = 0x0C11; const uint GL_INDEX_CLEAR_VALUE = 0x0C20; const uint GL_INDEX_WRITEMASK = 0x0C21; const uint GL_COLOR_CLEAR_VALUE = 0x0C22; const uint GL_COLOR_WRITEMASK = 0x0C23; const uint GL_INDEX_MODE = 0x0C30; const uint GL_RGBA_MODE = 0x0C31; const uint GL_DOUBLEBUFFER = 0x0C32; const uint GL_STEREO = 0x0C33; const uint GL_RENDER_MODE = 0x0C40; const uint GL_PERSPECTIVE_CORRECTION_HINT= 0x0C50; const uint GL_POINT_SMOOTH_HINT = 0x0C51; const uint GL_LINE_SMOOTH_HINT = 0x0C52; const uint GL_POLYGON_SMOOTH_HINT = 0x0C53; const uint GL_FOG_HINT = 0x0C54; const uint GL_TEXTURE_GEN_S = 0x0C60; const uint GL_TEXTURE_GEN_T = 0x0C61; const uint GL_TEXTURE_GEN_R = 0x0C62; const uint GL_TEXTURE_GEN_Q = 0x0C63; const uint GL_PIXEL_MAP_I_TO_I = 0x0C70; const uint GL_PIXEL_MAP_S_TO_S = 0x0C71; const uint GL_PIXEL_MAP_I_TO_R = 0x0C72; const uint GL_PIXEL_MAP_I_TO_G = 0x0C73; const uint GL_PIXEL_MAP_I_TO_B = 0x0C74; const uint GL_PIXEL_MAP_I_TO_A = 0x0C75; const uint GL_PIXEL_MAP_R_TO_R = 0x0C76; const uint GL_PIXEL_MAP_G_TO_G = 0x0C77; const uint GL_PIXEL_MAP_B_TO_B = 0x0C78; const uint GL_PIXEL_MAP_A_TO_A = 0x0C79; const uint GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0; const uint GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1; const uint GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2; const uint GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3; const uint GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4; const uint GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5; const uint GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6; const uint GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7; const uint GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8; const uint GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9; const uint GL_UNPACK_SWAP_BYTES = 0x0CF0; const uint GL_UNPACK_LSB_FIRST = 0x0CF1; const uint GL_UNPACK_ROW_LENGTH = 0x0CF2; const uint GL_UNPACK_SKIP_ROWS = 0x0CF3; const uint GL_UNPACK_SKIP_PIXELS = 0x0CF4; const uint GL_UNPACK_ALIGNMENT = 0x0CF5; const uint GL_PACK_SWAP_BYTES = 0x0D00; const uint GL_PACK_LSB_FIRST = 0x0D01; const uint GL_PACK_ROW_LENGTH = 0x0D02; const uint GL_PACK_SKIP_ROWS = 0x0D03; const uint GL_PACK_SKIP_PIXELS = 0x0D04; const uint GL_PACK_ALIGNMENT = 0x0D05; const uint GL_MAP_COLOR = 0x0D10; const uint GL_MAP_STENCIL = 0x0D11; const uint GL_INDEX_SHIFT = 0x0D12; const uint GL_INDEX_OFFSET = 0x0D13; const uint GL_RED_SCALE = 0x0D14; const uint GL_RED_BIAS = 0x0D15; const uint GL_ZOOM_X = 0x0D16; const uint GL_ZOOM_Y = 0x0D17; const uint GL_GREEN_SCALE = 0x0D18; const uint GL_GREEN_BIAS = 0x0D19; const uint GL_BLUE_SCALE = 0x0D1A; const uint GL_BLUE_BIAS = 0x0D1B; const uint GL_ALPHA_SCALE = 0x0D1C; const uint GL_ALPHA_BIAS = 0x0D1D; const uint GL_DEPTH_SCALE = 0x0D1E; const uint GL_DEPTH_BIAS = 0x0D1F; const uint GL_MAX_EVAL_ORDER = 0x0D30; const uint GL_MAX_LIGHTS = 0x0D31; const uint GL_MAX_CLIP_PLANES = 0x0D32; const uint GL_MAX_TEXTURE_SIZE = 0x0D33; const uint GL_MAX_PIXEL_MAP_TABLE = 0x0D34; const uint GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35; const uint GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36; const uint GL_MAX_NAME_STACK_DEPTH = 0x0D37; const uint GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38; const uint GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39; const uint GL_MAX_VIEWPORT_DIMS = 0x0D3A; const uint GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0x0D3B; const uint GL_SUBPIXEL_BITS = 0x0D50; const uint GL_INDEX_BITS = 0x0D51; const uint GL_RED_BITS = 0x0D52; const uint GL_GREEN_BITS = 0x0D53; const uint GL_BLUE_BITS = 0x0D54; const uint GL_ALPHA_BITS = 0x0D55; const uint GL_DEPTH_BITS = 0x0D56; const uint GL_STENCIL_BITS = 0x0D57; const uint GL_ACCUM_RED_BITS = 0x0D58; const uint GL_ACCUM_GREEN_BITS = 0x0D59; const uint GL_ACCUM_BLUE_BITS = 0x0D5A; const uint GL_ACCUM_ALPHA_BITS = 0x0D5B; const uint GL_NAME_STACK_DEPTH = 0x0D70; const uint GL_AUTO_NORMAL = 0x0D80; const uint GL_MAP1_COLOR_4 = 0x0D90; const uint GL_MAP1_INDEX = 0x0D91; const uint GL_MAP1_NORMAL = 0x0D92; const uint GL_MAP1_TEXTURE_COORD_1 = 0x0D93; const uint GL_MAP1_TEXTURE_COORD_2 = 0x0D94; const uint GL_MAP1_TEXTURE_COORD_3 = 0x0D95; const uint GL_MAP1_TEXTURE_COORD_4 = 0x0D96; const uint GL_MAP1_VERTEX_3 = 0x0D97; const uint GL_MAP1_VERTEX_4 = 0x0D98; const uint GL_MAP2_COLOR_4 = 0x0DB0; const uint GL_MAP2_INDEX = 0x0DB1; const uint GL_MAP2_NORMAL = 0x0DB2; const uint GL_MAP2_TEXTURE_COORD_1 = 0x0DB3; const uint GL_MAP2_TEXTURE_COORD_2 = 0x0DB4; const uint GL_MAP2_TEXTURE_COORD_3 = 0x0DB5; const uint GL_MAP2_TEXTURE_COORD_4 = 0x0DB6; const uint GL_MAP2_VERTEX_3 = 0x0DB7; const uint GL_MAP2_VERTEX_4 = 0x0DB8; const uint GL_MAP1_GRID_DOMAIN = 0x0DD0; const uint GL_MAP1_GRID_SEGMENTS = 0x0DD1; const uint GL_MAP2_GRID_DOMAIN = 0x0DD2; const uint GL_MAP2_GRID_SEGMENTS = 0x0DD3; const uint GL_TEXTURE_1D = 0x0DE0; const uint GL_TEXTURE_2D = 0x0DE1; const uint GL_FEEDBACK_BUFFER_POINTER = 0x0DF0; const uint GL_FEEDBACK_BUFFER_SIZE = 0x0DF1; const uint GL_FEEDBACK_BUFFER_TYPE = 0x0DF2; const uint GL_SELECTION_BUFFER_POINTER = 0x0DF3; const uint GL_SELECTION_BUFFER_SIZE = 0x0DF4; /* GL_TEXTURE_BINDING_1D */ /* GL_TEXTURE_BINDING_2D */ /* GL_VERTEX_ARRAY */ /* GL_NORMAL_ARRAY */ /* GL_COLOR_ARRAY */ /* GL_INDEX_ARRAY */ /* GL_TEXTURE_COORD_ARRAY */ /* GL_EDGE_FLAG_ARRAY */ /* GL_VERTEX_ARRAY_SIZE */ /* GL_VERTEX_ARRAY_TYPE */ /* GL_VERTEX_ARRAY_STRIDE */ /* GL_NORMAL_ARRAY_TYPE */ /* GL_NORMAL_ARRAY_STRIDE */ /* GL_COLOR_ARRAY_SIZE */ /* GL_COLOR_ARRAY_TYPE */ /* GL_COLOR_ARRAY_STRIDE */ /* GL_INDEX_ARRAY_TYPE */ /* GL_INDEX_ARRAY_STRIDE */ /* GL_TEXTURE_COORD_ARRAY_SIZE */ /* GL_TEXTURE_COORD_ARRAY_TYPE */ /* GL_TEXTURE_COORD_ARRAY_STRIDE */ /* GL_EDGE_FLAG_ARRAY_STRIDE */ /* GL_POLYGON_OFFSET_FACTOR */ /* GL_POLYGON_OFFSET_UNITS */ /* GetTextureParameter */ /* GL_TEXTURE_MAG_FILTER */ /* GL_TEXTURE_MIN_FILTER */ /* GL_TEXTURE_WRAP_S */ /* GL_TEXTURE_WRAP_T */ const uint GL_TEXTURE_WIDTH = 0x1000; const uint GL_TEXTURE_HEIGHT = 0x1001; const uint GL_TEXTURE_INTERNAL_FORMAT = 0x1003; const uint GL_TEXTURE_BORDER_COLOR = 0x1004; const uint GL_TEXTURE_BORDER = 0x1005; /* GL_TEXTURE_RED_SIZE */ /* GL_TEXTURE_GREEN_SIZE */ /* GL_TEXTURE_BLUE_SIZE */ /* GL_TEXTURE_ALPHA_SIZE */ /* GL_TEXTURE_LUMINANCE_SIZE */ /* GL_TEXTURE_INTENSITY_SIZE */ /* GL_TEXTURE_PRIORITY */ /* GL_TEXTURE_RESIDENT */ /* HintMode */ const uint GL_DONT_CARE = 0x1100; const uint GL_FASTEST = 0x1101; const uint GL_NICEST = 0x1102; /* HintTarget */ /* GL_PERSPECTIVE_CORRECTION_HINT */ /* GL_POINT_SMOOTH_HINT */ /* GL_LINE_SMOOTH_HINT */ /* GL_POLYGON_SMOOTH_HINT */ /* GL_FOG_HINT */ /* GL_PHONG_HINT */ /* IndexPointerType */ /* GL_SHORT */ /* GL_INT */ /* GL_FLOAT */ /* GL_DOUBLE */ /* LightModelParameter */ /* GL_LIGHT_MODEL_AMBIENT */ /* GL_LIGHT_MODEL_LOCAL_VIEWER */ /* GL_LIGHT_MODEL_TWO_SIDE */ /* LightName */ const uint GL_LIGHT0 = 0x4000; const uint GL_LIGHT1 = 0x4001; const uint GL_LIGHT2 = 0x4002; const uint GL_LIGHT3 = 0x4003; const uint GL_LIGHT4 = 0x4004; const uint GL_LIGHT5 = 0x4005; const uint GL_LIGHT6 = 0x4006; const uint GL_LIGHT7 = 0x4007; /* LightParameter */ const uint GL_AMBIENT = 0x1200; const uint GL_DIFFUSE = 0x1201; const uint GL_SPECULAR = 0x1202; const uint GL_POSITION = 0x1203; const uint GL_SPOT_DIRECTION = 0x1204; const uint GL_SPOT_EXPONENT = 0x1205; const uint GL_SPOT_CUTOFF = 0x1206; const uint GL_CONSTANT_ATTENUATION = 0x1207; const uint GL_LINEAR_ATTENUATION = 0x1208; const uint GL_QUADRATIC_ATTENUATION = 0x1209; /* InterleavedArrays */ /* GL_V2F */ /* GL_V3F */ /* GL_C4UB_V2F */ /* GL_C4UB_V3F */ /* GL_C3F_V3F */ /* GL_N3F_V3F */ /* GL_C4F_N3F_V3F */ /* GL_T2F_V3F */ /* GL_T4F_V4F */ /* GL_T2F_C4UB_V3F */ /* GL_T2F_C3F_V3F */ /* GL_T2F_N3F_V3F */ /* GL_T2F_C4F_N3F_V3F */ /* GL_T4F_C4F_N3F_V4F */ /* ListMode */ const uint GL_COMPILE = 0x1300; const uint GL_COMPILE_AND_EXECUTE = 0x1301; /* ListNameType */ /* GL_BYTE */ /* GL_UNSIGNED_BYTE */ /* GL_SHORT */ /* GL_UNSIGNED_SHORT */ /* GL_INT */ /* GL_UNSIGNED_INT */ /* GL_FLOAT */ /* GL_2_BYTES */ /* GL_3_BYTES */ /* GL_4_BYTES */ /* LogicOp */ const uint GL_CLEAR = 0x1500; const uint GL_AND = 0x1501; const uint GL_AND_REVERSE = 0x1502; const uint GL_COPY = 0x1503; const uint GL_AND_INVERTED = 0x1504; const uint GL_NOOP = 0x1505; const uint GL_XOR = 0x1506; const uint GL_OR = 0x1507; const uint GL_NOR = 0x1508; const uint GL_EQUIV = 0x1509; const uint GL_INVERT = 0x150A; const uint GL_OR_REVERSE = 0x150B; const uint GL_COPY_INVERTED = 0x150C; const uint GL_OR_INVERTED = 0x150D; const uint GL_NAND = 0x150E; const uint GL_SET = 0x150F; /* MapTarget */ /* GL_MAP1_COLOR_4 */ /* GL_MAP1_INDEX */ /* GL_MAP1_NORMAL */ /* GL_MAP1_TEXTURE_COORD_1 */ /* GL_MAP1_TEXTURE_COORD_2 */ /* GL_MAP1_TEXTURE_COORD_3 */ /* GL_MAP1_TEXTURE_COORD_4 */ /* GL_MAP1_VERTEX_3 */ /* GL_MAP1_VERTEX_4 */ /* GL_MAP2_COLOR_4 */ /* GL_MAP2_INDEX */ /* GL_MAP2_NORMAL */ /* GL_MAP2_TEXTURE_COORD_1 */ /* GL_MAP2_TEXTURE_COORD_2 */ /* GL_MAP2_TEXTURE_COORD_3 */ /* GL_MAP2_TEXTURE_COORD_4 */ /* GL_MAP2_VERTEX_3 */ /* GL_MAP2_VERTEX_4 */ /* MaterialFace */ /* GL_FRONT */ /* GL_BACK */ /* GL_FRONT_AND_BACK */ /* MaterialParameter */ const uint GL_EMISSION = 0x1600; const uint GL_SHININESS = 0x1601; const uint GL_AMBIENT_AND_DIFFUSE = 0x1602; const uint GL_COLOR_INDEXES = 0x1603; /* GL_AMBIENT */ /* GL_DIFFUSE */ /* GL_SPECULAR */ /* MatrixMode */ const uint GL_MODELVIEW = 0x1700; const uint GL_PROJECTION = 0x1701; const uint GL_TEXTURE = 0x1702; /* MeshMode1 */ /* GL_POINT */ /* GL_LINE */ /* MeshMode2 */ /* GL_POINT */ /* GL_LINE */ /* GL_FILL */ /* NormalPointerType */ /* GL_BYTE */ /* GL_SHORT */ /* GL_INT */ /* GL_FLOAT */ /* GL_DOUBLE */ /* PixelCopyType */ const uint GL_COLOR = 0x1800; const uint GL_DEPTH = 0x1801; const uint GL_STENCIL = 0x1802; /* PixelFormat */ const uint GL_COLOR_INDEX = 0x1900; const uint GL_STENCIL_INDEX = 0x1901; const uint GL_DEPTH_COMPONENT = 0x1902; const uint GL_RED = 0x1903; const uint GL_GREEN = 0x1904; const uint GL_BLUE = 0x1905; const uint GL_ALPHA = 0x1906; const uint GL_RGB = 0x1907; const uint GL_RGBA = 0x1908; const uint GL_LUMINANCE = 0x1909; const uint GL_LUMINANCE_ALPHA = 0x190A; /* PixelMap */ /* GL_PIXEL_MAP_I_TO_I */ /* GL_PIXEL_MAP_S_TO_S */ /* GL_PIXEL_MAP_I_TO_R */ /* GL_PIXEL_MAP_I_TO_G */ /* GL_PIXEL_MAP_I_TO_B */ /* GL_PIXEL_MAP_I_TO_A */ /* GL_PIXEL_MAP_R_TO_R */ /* GL_PIXEL_MAP_G_TO_G */ /* GL_PIXEL_MAP_B_TO_B */ /* GL_PIXEL_MAP_A_TO_A */ /* PixelStore */ /* GL_UNPACK_SWAP_BYTES */ /* GL_UNPACK_LSB_FIRST */ /* GL_UNPACK_ROW_LENGTH */ /* GL_UNPACK_SKIP_ROWS */ /* GL_UNPACK_SKIP_PIXELS */ /* GL_UNPACK_ALIGNMENT */ /* GL_PACK_SWAP_BYTES */ /* GL_PACK_LSB_FIRST */ /* GL_PACK_ROW_LENGTH */ /* GL_PACK_SKIP_ROWS */ /* GL_PACK_SKIP_PIXELS */ /* GL_PACK_ALIGNMENT */ /* PixelTransfer */ /* GL_MAP_COLOR */ /* GL_MAP_STENCIL */ /* GL_INDEX_SHIFT */ /* GL_INDEX_OFFSET */ /* GL_RED_SCALE */ /* GL_RED_BIAS */ /* GL_GREEN_SCALE */ /* GL_GREEN_BIAS */ /* GL_BLUE_SCALE */ /* GL_BLUE_BIAS */ /* GL_ALPHA_SCALE */ /* GL_ALPHA_BIAS */ /* GL_DEPTH_SCALE */ /* GL_DEPTH_BIAS */ /* PixelType */ const uint GL_BITMAP = 0x1A00; /* GL_BYTE */ /* GL_UNSIGNED_BYTE */ /* GL_SHORT */ /* GL_UNSIGNED_SHORT */ /* GL_INT */ /* GL_UNSIGNED_INT */ /* GL_FLOAT */ /* PolygonMode */ const uint GL_POINT = 0x1B00; const uint GL_LINE = 0x1B01; const uint GL_FILL = 0x1B02; /* ReadBufferMode */ /* GL_FRONT_LEFT */ /* GL_FRONT_RIGHT */ /* GL_BACK_LEFT */ /* GL_BACK_RIGHT */ /* GL_FRONT */ /* GL_BACK */ /* GL_LEFT */ /* GL_RIGHT */ /* GL_AUX0 */ /* GL_AUX1 */ /* GL_AUX2 */ /* GL_AUX3 */ /* RenderingMode */ const uint GL_RENDER = 0x1C00; const uint GL_FEEDBACK = 0x1C01; const uint GL_SELECT = 0x1C02; /* ShadingModel */ const uint GL_FLAT = 0x1D00; const uint GL_SMOOTH = 0x1D01; /* StencilFunction */ /* GL_NEVER */ /* GL_LESS */ /* GL_EQUAL */ /* GL_LEQUAL */ /* GL_GREATER */ /* GL_NOTEQUAL */ /* GL_GEQUAL */ /* GL_ALWAYS */ /* StencilOp */ /* GL_ZERO */ const uint GL_KEEP = 0x1E00; const uint GL_REPLACE = 0x1E01; const uint GL_INCR = 0x1E02; const uint GL_DECR = 0x1E03; /* GL_INVERT */ /* StringName */ const uint GL_VENDOR = 0x1F00; const uint GL_RENDERER = 0x1F01; const uint GL_VERSION = 0x1F02; const uint GL_EXTENSIONS = 0x1F03; /* TextureCoordName */ const uint GL_S = 0x2000; const uint GL_T = 0x2001; const uint GL_R = 0x2002; const uint GL_Q = 0x2003; /* TexCoordPointerType */ /* GL_SHORT */ /* GL_INT */ /* GL_FLOAT */ /* GL_DOUBLE */ /* TextureEnvMode */ const uint GL_MODULATE = 0x2100; const uint GL_DECAL = 0x2101; /* GL_BLEND */ /* GL_REPLACE */ /* TextureEnvParameter */ const uint GL_TEXTURE_ENV_MODE = 0x2200; const uint GL_TEXTURE_ENV_COLOR = 0x2201; /* TextureEnvTarget */ const uint GL_TEXTURE_ENV = 0x2300; /* TextureGenMode */ const uint GL_EYE_LINEAR = 0x2400; const uint GL_OBJECT_LINEAR = 0x2401; const uint GL_SPHERE_MAP = 0x2402; /* TextureGenParameter */ const uint GL_TEXTURE_GEN_MODE = 0x2500; const uint GL_OBJECT_PLANE = 0x2501; const uint GL_EYE_PLANE = 0x2502; /* TextureMagFilter */ const uint GL_NEAREST = 0x2600; const uint GL_LINEAR = 0x2601; /* TextureMinFilter */ /* GL_NEAREST */ /* GL_LINEAR */ const uint GL_NEAREST_MIPMAP_NEAREST = 0x2700; const uint GL_LINEAR_MIPMAP_NEAREST = 0x2701; const uint GL_NEAREST_MIPMAP_LINEAR = 0x2702; const uint GL_LINEAR_MIPMAP_LINEAR = 0x2703; /* TextureParameterName */ const uint GL_TEXTURE_MAG_FILTER = 0x2800; const uint GL_TEXTURE_MIN_FILTER = 0x2801; const uint GL_TEXTURE_WRAP_S = 0x2802; const uint GL_TEXTURE_WRAP_T = 0x2803; /* GL_TEXTURE_BORDER_COLOR */ /* GL_TEXTURE_PRIORITY */ /* TextureTarget */ /* GL_TEXTURE_1D */ /* GL_TEXTURE_2D */ /* GL_PROXY_TEXTURE_1D */ /* GL_PROXY_TEXTURE_2D */ /* TextureWrapMode */ const uint GL_CLAMP = 0x2900; const uint GL_REPEAT = 0x2901; /* VertexPointerType */ /* GL_SHORT */ /* GL_INT */ /* GL_FLOAT */ /* GL_DOUBLE */ /* ClientAttribMask */ const uint GL_CLIENT_PIXEL_STORE_BIT = 0x00000001; const uint GL_CLIENT_VERTEX_ARRAY_BIT = 0x00000002; const uint GL_CLIENT_ALL_ATTRIB_BITS = 0xffffffff; /* polygon_offset */ const uint GL_POLYGON_OFFSET_FACTOR = 0x8038; const uint GL_POLYGON_OFFSET_UNITS = 0x2A00; const uint GL_POLYGON_OFFSET_POINT = 0x2A01; const uint GL_POLYGON_OFFSET_LINE = 0x2A02; const uint GL_POLYGON_OFFSET_FILL = 0x8037; /* texture */ const uint GL_ALPHA4 = 0x803B; const uint GL_ALPHA8 = 0x803C; const uint GL_ALPHA12 = 0x803D; const uint GL_ALPHA16 = 0x803E; const uint GL_LUMINANCE4 = 0x803F; const uint GL_LUMINANCE8 = 0x8040; const uint GL_LUMINANCE12 = 0x8041; const uint GL_LUMINANCE16 = 0x8042; const uint GL_LUMINANCE4_ALPHA4 = 0x8043; const uint GL_LUMINANCE6_ALPHA2 = 0x8044; const uint GL_LUMINANCE8_ALPHA8 = 0x8045; const uint GL_LUMINANCE12_ALPHA4 = 0x8046; const uint GL_LUMINANCE12_ALPHA12 = 0x8047; const uint GL_LUMINANCE16_ALPHA16 = 0x8048; const uint GL_INTENSITY = 0x8049; const uint GL_INTENSITY4 = 0x804A; const uint GL_INTENSITY8 = 0x804B; const uint GL_INTENSITY12 = 0x804C; const uint GL_INTENSITY16 = 0x804D; const uint GL_R3_G3_B2 = 0x2A10; const uint GL_RGB4 = 0x804F; const uint GL_RGB5 = 0x8050; const uint GL_RGB8 = 0x8051; const uint GL_RGB10 = 0x8052; const uint GL_RGB12 = 0x8053; const uint GL_RGB16 = 0x8054; const uint GL_RGBA2 = 0x8055; const uint GL_RGBA4 = 0x8056; const uint GL_RGB5_A1 = 0x8057; const uint GL_RGBA8 = 0x8058; const uint GL_RGB10_A2 = 0x8059; const uint GL_RGBA12 = 0x805A; const uint GL_RGBA16 = 0x805B; const uint GL_TEXTURE_RED_SIZE = 0x805C; const uint GL_TEXTURE_GREEN_SIZE = 0x805D; const uint GL_TEXTURE_BLUE_SIZE = 0x805E; const uint GL_TEXTURE_ALPHA_SIZE = 0x805F; const uint GL_TEXTURE_LUMINANCE_SIZE = 0x8060; const uint GL_TEXTURE_INTENSITY_SIZE = 0x8061; const uint GL_PROXY_TEXTURE_1D = 0x8063; const uint GL_PROXY_TEXTURE_2D = 0x8064; /* texture_object */ const uint GL_TEXTURE_PRIORITY = 0x8066; const uint GL_TEXTURE_RESIDENT = 0x8067; const uint GL_TEXTURE_BINDING_1D = 0x8068; const uint GL_TEXTURE_BINDING_2D = 0x8069; /* vertex_array */ const uint GL_VERTEX_ARRAY = 0x8074; const uint GL_NORMAL_ARRAY = 0x8075; const uint GL_COLOR_ARRAY = 0x8076; const uint GL_INDEX_ARRAY = 0x8077; const uint GL_TEXTURE_COORD_ARRAY = 0x8078; const uint GL_EDGE_FLAG_ARRAY = 0x8079; const uint GL_VERTEX_ARRAY_SIZE = 0x807A; const uint GL_VERTEX_ARRAY_TYPE = 0x807B; const uint GL_VERTEX_ARRAY_STRIDE = 0x807C; const uint GL_NORMAL_ARRAY_TYPE = 0x807E; const uint GL_NORMAL_ARRAY_STRIDE = 0x807F; const uint GL_COLOR_ARRAY_SIZE = 0x8081; const uint GL_COLOR_ARRAY_TYPE = 0x8082; const uint GL_COLOR_ARRAY_STRIDE = 0x8083; const uint GL_INDEX_ARRAY_TYPE = 0x8085; const uint GL_INDEX_ARRAY_STRIDE = 0x8086; const uint GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088; const uint GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089; const uint GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A; const uint GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C; const uint GL_VERTEX_ARRAY_POINTER = 0x808E; const uint GL_NORMAL_ARRAY_POINTER = 0x808F; const uint GL_COLOR_ARRAY_POINTER = 0x8090; const uint GL_INDEX_ARRAY_POINTER = 0x8091; const uint GL_TEXTURE_COORD_ARRAY_POINTER= 0x8092; const uint GL_EDGE_FLAG_ARRAY_POINTER = 0x8093; const uint GL_V2F = 0x2A20; const uint GL_V3F = 0x2A21; const uint GL_C4UB_V2F = 0x2A22; const uint GL_C4UB_V3F = 0x2A23; const uint GL_C3F_V3F = 0x2A24; const uint GL_N3F_V3F = 0x2A25; const uint GL_C4F_N3F_V3F = 0x2A26; const uint GL_T2F_V3F = 0x2A27; const uint GL_T4F_V4F = 0x2A28; const uint GL_T2F_C4UB_V3F = 0x2A29; const uint GL_T2F_C3F_V3F = 0x2A2A; const uint GL_T2F_N3F_V3F = 0x2A2B; const uint GL_T2F_C4F_N3F_V3F = 0x2A2C; const uint GL_T4F_C4F_N3F_V4F = 0x2A2D; /* Extensions */ const uint GL_EXT_vertex_array = 1; const uint GL_EXT_bgra = 1; const uint GL_EXT_paletted_texture = 1; const uint GL_WIN_swap_hint = 1; const uint GL_WIN_draw_range_elements = 1; // const uint GL_WIN_phong_shading 1 // const uint GL_WIN_specular_fog 1 /* EXT_vertex_array */ const uint GL_VERTEX_ARRAY_EXT = 0x8074; const uint GL_NORMAL_ARRAY_EXT = 0x8075; const uint GL_COLOR_ARRAY_EXT = 0x8076; const uint GL_INDEX_ARRAY_EXT = 0x8077; const uint GL_TEXTURE_COORD_ARRAY_EXT = 0x8078; const uint GL_EDGE_FLAG_ARRAY_EXT = 0x8079; const uint GL_VERTEX_ARRAY_SIZE_EXT = 0x807A; const uint GL_VERTEX_ARRAY_TYPE_EXT = 0x807B; const uint GL_VERTEX_ARRAY_STRIDE_EXT = 0x807C; const uint GL_VERTEX_ARRAY_COUNT_EXT = 0x807D; const uint GL_NORMAL_ARRAY_TYPE_EXT = 0x807E; const uint GL_NORMAL_ARRAY_STRIDE_EXT = 0x807F; const uint GL_NORMAL_ARRAY_COUNT_EXT = 0x8080; const uint GL_COLOR_ARRAY_SIZE_EXT = 0x8081; const uint GL_COLOR_ARRAY_TYPE_EXT = 0x8082; const uint GL_COLOR_ARRAY_STRIDE_EXT = 0x8083; const uint GL_COLOR_ARRAY_COUNT_EXT = 0x8084; const uint GL_INDEX_ARRAY_TYPE_EXT = 0x8085; const uint GL_INDEX_ARRAY_STRIDE_EXT = 0x8086; const uint GL_INDEX_ARRAY_COUNT_EXT = 0x8087; const uint GL_TEXTURE_COORD_ARRAY_SIZE_EXT = 0x8088; const uint GL_TEXTURE_COORD_ARRAY_TYPE_EXT = 0x8089; const uint GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = 0x808A; const uint GL_TEXTURE_COORD_ARRAY_COUNT_EXT = 0x808B; const uint GL_EDGE_FLAG_ARRAY_STRIDE_EXT = 0x808C; const uint GL_EDGE_FLAG_ARRAY_COUNT_EXT = 0x808D; const uint GL_VERTEX_ARRAY_POINTER_EXT = 0x808E; const uint GL_NORMAL_ARRAY_POINTER_EXT = 0x808F; const uint GL_COLOR_ARRAY_POINTER_EXT = 0x8090; const uint GL_INDEX_ARRAY_POINTER_EXT = 0x8091; const uint GL_TEXTURE_COORD_ARRAY_POINTER_EXT = 0x8092; const uint GL_EDGE_FLAG_ARRAY_POINTER_EXT = 0x8093; const uint GL_DOUBLE_EXT = GL_DOUBLE; /* EXT_bgra */ const uint GL_BGR_EXT = 0x80E0; const uint GL_BGRA_EXT = 0x80E1; /* EXT_paletted_texture */ /* These must match the GL_COLOR_TABLE_*_SGI enumerants */ const uint GL_COLOR_TABLE_FORMAT_EXT = 0x80D8; const uint GL_COLOR_TABLE_WIDTH_EXT = 0x80D9; const uint GL_COLOR_TABLE_RED_SIZE_EXT = 0x80DA; const uint GL_COLOR_TABLE_GREEN_SIZE_EXT = 0x80DB; const uint GL_COLOR_TABLE_BLUE_SIZE_EXT = 0x80DC; const uint GL_COLOR_TABLE_ALPHA_SIZE_EXT = 0x80DD; const uint GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE; const uint GL_COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF; const uint GL_COLOR_INDEX1_EXT = 0x80E2; const uint GL_COLOR_INDEX2_EXT = 0x80E3; const uint GL_COLOR_INDEX4_EXT = 0x80E4; const uint GL_COLOR_INDEX8_EXT = 0x80E5; const uint GL_COLOR_INDEX12_EXT = 0x80E6; const uint GL_COLOR_INDEX16_EXT = 0x80E7; /* WIN_draw_range_elements */ const uint GL_MAX_ELEMENTS_VERTICES_WIN = 0x80E8; const uint GL_MAX_ELEMENTS_INDICES_WIN = 0x80E9; /* WIN_phong_shading */ const uint GL_PHONG_WIN = 0x80EA; const uint GL_PHONG_HINT_WIN = 0x80EB; /* WIN_specular_fog */ const uint GL_FOG_SPECULAR_TEXTURE_WIN = 0x80EC; /* For compatibility with OpenGL v1.0 */ const uint GL_LOGIC_OP = GL_INDEX_LOGIC_OP; const uint GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT; /*************************************************************/ void /*APIENTRY*/glAccum (GLenum op, GLfloat value); void /*APIENTRY*/glAlphaFunc (GLenum func, GLclampf cref); GLboolean /*APIENTRY*/glAreTexturesResident (GLsizei n, GLuint *textures, GLboolean *residences); void /*APIENTRY*/glArrayElement (GLint i); void /*APIENTRY*/glBegin (GLenum mode); void /*APIENTRY*/glBindTexture (GLenum target, GLuint texture); void /*APIENTRY*/glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte *bitmap); void /*APIENTRY*/glBlendFunc (GLenum sfactor, GLenum dfactor); void /*APIENTRY*/glCallList (GLuint list); void /*APIENTRY*/glCallLists (GLsizei n, GLenum type, GLvoid *lists); void /*APIENTRY*/glClear (GLbitfield mask); void /*APIENTRY*/glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void /*APIENTRY*/glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void /*APIENTRY*/glClearDepth (GLclampd depth); void /*APIENTRY*/glClearIndex (GLfloat c); void /*APIENTRY*/glClearStencil (GLint s); void /*APIENTRY*/glClipPlane (GLenum plane, GLdouble *equation); void /*APIENTRY*/glColor3b (GLbyte red, GLbyte green, GLbyte blue); void /*APIENTRY*/glColor3bv (GLbyte *v); void /*APIENTRY*/glColor3d (GLdouble red, GLdouble green, GLdouble blue); void /*APIENTRY*/glColor3dv (GLdouble *v); void /*APIENTRY*/glColor3f (GLfloat red, GLfloat green, GLfloat blue); void /*APIENTRY*/glColor3fv (GLfloat *v); void /*APIENTRY*/glColor3i (GLint red, GLint green, GLint blue); void /*APIENTRY*/glColor3iv (GLint *v); void /*APIENTRY*/glColor3s (GLshort red, GLshort green, GLshort blue); void /*APIENTRY*/glColor3sv (GLshort *v); void /*APIENTRY*/glColor3ub (GLubyte red, GLubyte green, GLubyte blue); void /*APIENTRY*/glColor3ubv (GLubyte *v); void /*APIENTRY*/glColor3ui (GLuint red, GLuint green, GLuint blue); void /*APIENTRY*/glColor3uiv (GLuint *v); void /*APIENTRY*/glColor3us (GLushort red, GLushort green, GLushort blue); void /*APIENTRY*/glColor3usv (GLushort *v); void /*APIENTRY*/glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); void /*APIENTRY*/glColor4bv (GLbyte *v); void /*APIENTRY*/glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); void /*APIENTRY*/glColor4dv (GLdouble *v); void /*APIENTRY*/glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void /*APIENTRY*/glColor4fv (GLfloat *v); void /*APIENTRY*/glColor4i (GLint red, GLint green, GLint blue, GLint alpha); void /*APIENTRY*/glColor4iv (GLint *v); void /*APIENTRY*/glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); void /*APIENTRY*/glColor4sv (GLshort *v); void /*APIENTRY*/glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); void /*APIENTRY*/glColor4ubv (GLubyte *v); void /*APIENTRY*/glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); void /*APIENTRY*/glColor4uiv (GLuint *v); void /*APIENTRY*/glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); void /*APIENTRY*/glColor4usv (GLushort *v); void /*APIENTRY*/glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); void /*APIENTRY*/glColorMaterial (GLenum face, GLenum mode); void /*APIENTRY*/glColorPointer (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); void /*APIENTRY*/glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); void /*APIENTRY*/glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); void /*APIENTRY*/glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); void /*APIENTRY*/glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); void /*APIENTRY*/glCullFace (GLenum mode); void /*APIENTRY*/glDeleteLists (GLuint list, GLsizei range); void /*APIENTRY*/glDeleteTextures (GLsizei n, GLuint *textures); void /*APIENTRY*/glDepthFunc (GLenum func); void /*APIENTRY*/glDepthMask (GLboolean flag); void /*APIENTRY*/glDepthRange (GLclampd zNear, GLclampd zFar); void /*APIENTRY*/glDisable (GLenum cap); void /*APIENTRY*/glDisableClientState (GLenum array); void /*APIENTRY*/glDrawArrays (GLenum mode, GLint first, GLsizei count); void /*APIENTRY*/glDrawBuffer (GLenum mode); void /*APIENTRY*/glDrawElements (GLenum mode, GLsizei count, GLenum type, GLvoid *indices); void /*APIENTRY*/glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glEdgeFlag (GLboolean flag); void /*APIENTRY*/glEdgeFlagPointer (GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glEdgeFlagv (GLboolean *flag); void /*APIENTRY*/glEnable (GLenum cap); void /*APIENTRY*/glEnableClientState (GLenum array); void /*APIENTRY*/glEnd (); void /*APIENTRY*/glEndList (); void /*APIENTRY*/glEvalCoord1d (GLdouble u); void /*APIENTRY*/glEvalCoord1dv (GLdouble *u); void /*APIENTRY*/glEvalCoord1f (GLfloat u); void /*APIENTRY*/glEvalCoord1fv (GLfloat *u); void /*APIENTRY*/glEvalCoord2d (GLdouble u, GLdouble v); void /*APIENTRY*/glEvalCoord2dv (GLdouble *u); void /*APIENTRY*/glEvalCoord2f (GLfloat u, GLfloat v); void /*APIENTRY*/glEvalCoord2fv (GLfloat *u); void /*APIENTRY*/glEvalMesh1 (GLenum mode, GLint i1, GLint i2); void /*APIENTRY*/glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); void /*APIENTRY*/glEvalPoint1 (GLint i); void /*APIENTRY*/glEvalPoint2 (GLint i, GLint j); void /*APIENTRY*/glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); void /*APIENTRY*/glFinish (); void /*APIENTRY*/glFlush (); void /*APIENTRY*/glFogf (GLenum pname, GLfloat param); void /*APIENTRY*/glFogfv (GLenum pname, GLfloat *params); void /*APIENTRY*/glFogi (GLenum pname, GLint param); void /*APIENTRY*/glFogiv (GLenum pname, GLint *params); void /*APIENTRY*/glFrontFace (GLenum mode); void /*APIENTRY*/glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLuint /*APIENTRY*/glGenLists (GLsizei range); void /*APIENTRY*/glGenTextures (GLsizei n, GLuint *textures); void /*APIENTRY*/glGetBooleanv (GLenum pname, GLboolean *params); void /*APIENTRY*/glGetClipPlane (GLenum plane, GLdouble *equation); void /*APIENTRY*/glGetDoublev (GLenum pname, GLdouble *params); GLenum /*APIENTRY*/glGetError (); void /*APIENTRY*/glGetFloatv (GLenum pname, GLfloat *params); void /*APIENTRY*/glGetIntegerv (GLenum pname, GLint *params); void /*APIENTRY*/glGetLightfv (GLenum light, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetLightiv (GLenum light, GLenum pname, GLint *params); void /*APIENTRY*/glGetMapdv (GLenum target, GLenum query, GLdouble *v); void /*APIENTRY*/glGetMapfv (GLenum target, GLenum query, GLfloat *v); void /*APIENTRY*/glGetMapiv (GLenum target, GLenum query, GLint *v); void /*APIENTRY*/glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetMaterialiv (GLenum face, GLenum pname, GLint *params); void /*APIENTRY*/glGetPixelMapfv (GLenum map, GLfloat *values); void /*APIENTRY*/glGetPixelMapuiv (GLenum map, GLuint *values); void /*APIENTRY*/glGetPixelMapusv (GLenum map, GLushort *values); void /*APIENTRY*/glGetPointerv (GLenum pname, GLvoid* *params); void /*APIENTRY*/glGetPolygonStipple (GLubyte *mask); GLubyte * /*APIENTRY*/glGetString (GLenum name); void /*APIENTRY*/glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetTexEnviv (GLenum target, GLenum pname, GLint *params); void /*APIENTRY*/glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); void /*APIENTRY*/glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); void /*APIENTRY*/glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); void /*APIENTRY*/glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); void /*APIENTRY*/glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); void /*APIENTRY*/glHint (GLenum target, GLenum mode); void /*APIENTRY*/glIndexMask (GLuint mask); void /*APIENTRY*/glIndexPointer (GLenum type, GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glIndexd (GLdouble c); void /*APIENTRY*/glIndexdv (GLdouble *c); void /*APIENTRY*/glIndexf (GLfloat c); void /*APIENTRY*/glIndexfv (GLfloat *c); void /*APIENTRY*/glIndexi (GLint c); void /*APIENTRY*/glIndexiv (GLint *c); void /*APIENTRY*/glIndexs (GLshort c); void /*APIENTRY*/glIndexsv (GLshort *c); void /*APIENTRY*/glIndexub (GLubyte c); void /*APIENTRY*/glIndexubv (GLubyte *c); void /*APIENTRY*/glInitNames (); void /*APIENTRY*/glInterleavedArrays (GLenum format, GLsizei stride, GLvoid *pointer); GLboolean /*APIENTRY*/glIsEnabled (GLenum cap); GLboolean /*APIENTRY*/glIsList (GLuint list); GLboolean /*APIENTRY*/glIsTexture (GLuint texture); void /*APIENTRY*/glLightModelf (GLenum pname, GLfloat param); void /*APIENTRY*/glLightModelfv (GLenum pname, GLfloat *params); void /*APIENTRY*/glLightModeli (GLenum pname, GLint param); void /*APIENTRY*/glLightModeliv (GLenum pname, GLint *params); void /*APIENTRY*/glLightf (GLenum light, GLenum pname, GLfloat param); void /*APIENTRY*/glLightfv (GLenum light, GLenum pname, GLfloat *params); void /*APIENTRY*/glLighti (GLenum light, GLenum pname, GLint param); void /*APIENTRY*/glLightiv (GLenum light, GLenum pname, GLint *params); void /*APIENTRY*/glLineStipple (GLint factor, GLushort pattern); void /*APIENTRY*/glLineWidth (GLfloat width); void /*APIENTRY*/glListBase (GLuint base); void /*APIENTRY*/glLoadIdentity (); void /*APIENTRY*/glLoadMatrixd (GLdouble *m); void /*APIENTRY*/glLoadMatrixf (GLfloat *m); void /*APIENTRY*/glLoadName (GLuint name); void /*APIENTRY*/glLogicOp (GLenum opcode); void /*APIENTRY*/glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, GLdouble *points); void /*APIENTRY*/glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, GLfloat *points); void /*APIENTRY*/glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble *points); void /*APIENTRY*/glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat *points); void /*APIENTRY*/glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); void /*APIENTRY*/glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); void /*APIENTRY*/glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); void /*APIENTRY*/glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); void /*APIENTRY*/glMaterialf (GLenum face, GLenum pname, GLfloat param); void /*APIENTRY*/glMaterialfv (GLenum face, GLenum pname, GLfloat *params); void /*APIENTRY*/glMateriali (GLenum face, GLenum pname, GLint param); void /*APIENTRY*/glMaterialiv (GLenum face, GLenum pname, GLint *params); void /*APIENTRY*/glMatrixMode (GLenum mode); void /*APIENTRY*/glMultMatrixd (GLdouble *m); void /*APIENTRY*/glMultMatrixf (GLfloat *m); void /*APIENTRY*/glNewList (GLuint list, GLenum mode); void /*APIENTRY*/glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); void /*APIENTRY*/glNormal3bv (GLbyte *v); void /*APIENTRY*/glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); void /*APIENTRY*/glNormal3dv (GLdouble *v); void /*APIENTRY*/glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); void /*APIENTRY*/glNormal3fv (GLfloat *v); void /*APIENTRY*/glNormal3i (GLint nx, GLint ny, GLint nz); void /*APIENTRY*/glNormal3iv (GLint *v); void /*APIENTRY*/glNormal3s (GLshort nx, GLshort ny, GLshort nz); void /*APIENTRY*/glNormal3sv (GLshort *v); void /*APIENTRY*/glNormalPointer (GLenum type, GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); void /*APIENTRY*/glPassThrough (GLfloat token); void /*APIENTRY*/glPixelMapfv (GLenum map, GLsizei mapsize, GLfloat *values); void /*APIENTRY*/glPixelMapuiv (GLenum map, GLsizei mapsize, GLuint *values); void /*APIENTRY*/glPixelMapusv (GLenum map, GLsizei mapsize, GLushort *values); void /*APIENTRY*/glPixelStoref (GLenum pname, GLfloat param); void /*APIENTRY*/glPixelStorei (GLenum pname, GLint param); void /*APIENTRY*/glPixelTransferf (GLenum pname, GLfloat param); void /*APIENTRY*/glPixelTransferi (GLenum pname, GLint param); void /*APIENTRY*/glPixelZoom (GLfloat xfactor, GLfloat yfactor); void /*APIENTRY*/glPointSize (GLfloat size); void /*APIENTRY*/glPolygonMode (GLenum face, GLenum mode); void /*APIENTRY*/glPolygonOffset (GLfloat factor, GLfloat units); void /*APIENTRY*/glPolygonStipple (GLubyte *mask); void /*APIENTRY*/glPopAttrib (); void /*APIENTRY*/glPopClientAttrib (); void /*APIENTRY*/glPopMatrix (); void /*APIENTRY*/glPopName (); void /*APIENTRY*/glPrioritizeTextures (GLsizei n, GLuint *textures, GLclampf *priorities); void /*APIENTRY*/glPushAttrib (GLbitfield mask); void /*APIENTRY*/glPushClientAttrib (GLbitfield mask); void /*APIENTRY*/glPushMatrix (); void /*APIENTRY*/glPushName (GLuint name); void /*APIENTRY*/glRasterPos2d (GLdouble x, GLdouble y); void /*APIENTRY*/glRasterPos2dv (GLdouble *v); void /*APIENTRY*/glRasterPos2f (GLfloat x, GLfloat y); void /*APIENTRY*/glRasterPos2fv (GLfloat *v); void /*APIENTRY*/glRasterPos2i (GLint x, GLint y); void /*APIENTRY*/glRasterPos2iv (GLint *v); void /*APIENTRY*/glRasterPos2s (GLshort x, GLshort y); void /*APIENTRY*/glRasterPos2sv (GLshort *v); void /*APIENTRY*/glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); void /*APIENTRY*/glRasterPos3dv (GLdouble *v); void /*APIENTRY*/glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); void /*APIENTRY*/glRasterPos3fv (GLfloat *v); void /*APIENTRY*/glRasterPos3i (GLint x, GLint y, GLint z); void /*APIENTRY*/glRasterPos3iv (GLint *v); void /*APIENTRY*/glRasterPos3s (GLshort x, GLshort y, GLshort z); void /*APIENTRY*/glRasterPos3sv (GLshort *v); void /*APIENTRY*/glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); void /*APIENTRY*/glRasterPos4dv (GLdouble *v); void /*APIENTRY*/glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); void /*APIENTRY*/glRasterPos4fv (GLfloat *v); void /*APIENTRY*/glRasterPos4i (GLint x, GLint y, GLint z, GLint w); void /*APIENTRY*/glRasterPos4iv (GLint *v); void /*APIENTRY*/glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); void /*APIENTRY*/glRasterPos4sv (GLshort *v); void /*APIENTRY*/glReadBuffer (GLenum mode); void /*APIENTRY*/glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); void /*APIENTRY*/glRectdv (GLdouble *v1, GLdouble *v2); void /*APIENTRY*/glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); void /*APIENTRY*/glRectfv (GLfloat *v1, GLfloat *v2); void /*APIENTRY*/glRecti (GLint x1, GLint y1, GLint x2, GLint y2); void /*APIENTRY*/glRectiv (GLint *v1, GLint *v2); void /*APIENTRY*/glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); void /*APIENTRY*/glRectsv (GLshort *v1, GLshort *v2); GLint /*APIENTRY*/glRenderMode (GLenum mode); void /*APIENTRY*/glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); void /*APIENTRY*/glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); void /*APIENTRY*/glScaled (GLdouble x, GLdouble y, GLdouble z); void /*APIENTRY*/glScalef (GLfloat x, GLfloat y, GLfloat z); void /*APIENTRY*/glScissor (GLint x, GLint y, GLsizei width, GLsizei height); void /*APIENTRY*/glSelectBuffer (GLsizei size, GLuint *buffer); void /*APIENTRY*/glShadeModel (GLenum mode); void /*APIENTRY*/glStencilFunc (GLenum func, GLint cref, GLuint mask); void /*APIENTRY*/glStencilMask (GLuint mask); void /*APIENTRY*/glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); void /*APIENTRY*/glTexCoord1d (GLdouble s); void /*APIENTRY*/glTexCoord1dv (GLdouble *v); void /*APIENTRY*/glTexCoord1f (GLfloat s); void /*APIENTRY*/glTexCoord1fv (GLfloat *v); void /*APIENTRY*/glTexCoord1i (GLint s); void /*APIENTRY*/glTexCoord1iv (GLint *v); void /*APIENTRY*/glTexCoord1s (GLshort s); void /*APIENTRY*/glTexCoord1sv (GLshort *v); void /*APIENTRY*/glTexCoord2d (GLdouble s, GLdouble t); void /*APIENTRY*/glTexCoord2dv (GLdouble *v); void /*APIENTRY*/glTexCoord2f (GLfloat s, GLfloat t); void /*APIENTRY*/glTexCoord2fv (GLfloat *v); void /*APIENTRY*/glTexCoord2i (GLint s, GLint t); void /*APIENTRY*/glTexCoord2iv (GLint *v); void /*APIENTRY*/glTexCoord2s (GLshort s, GLshort t); void /*APIENTRY*/glTexCoord2sv (GLshort *v); void /*APIENTRY*/glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); void /*APIENTRY*/glTexCoord3dv (GLdouble *v); void /*APIENTRY*/glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); void /*APIENTRY*/glTexCoord3fv (GLfloat *v); void /*APIENTRY*/glTexCoord3i (GLint s, GLint t, GLint r); void /*APIENTRY*/glTexCoord3iv (GLint *v); void /*APIENTRY*/glTexCoord3s (GLshort s, GLshort t, GLshort r); void /*APIENTRY*/glTexCoord3sv (GLshort *v); void /*APIENTRY*/glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); void /*APIENTRY*/glTexCoord4dv (GLdouble *v); void /*APIENTRY*/glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); void /*APIENTRY*/glTexCoord4fv (GLfloat *v); void /*APIENTRY*/glTexCoord4i (GLint s, GLint t, GLint r, GLint q); void /*APIENTRY*/glTexCoord4iv (GLint *v); void /*APIENTRY*/glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); void /*APIENTRY*/glTexCoord4sv (GLshort *v); void /*APIENTRY*/glTexCoordPointer (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glTexEnvf (GLenum target, GLenum pname, GLfloat param); void /*APIENTRY*/glTexEnvfv (GLenum target, GLenum pname, GLfloat *params); void /*APIENTRY*/glTexEnvi (GLenum target, GLenum pname, GLint param); void /*APIENTRY*/glTexEnviv (GLenum target, GLenum pname, GLint *params); void /*APIENTRY*/glTexGend (GLenum coord, GLenum pname, GLdouble param); void /*APIENTRY*/glTexGendv (GLenum coord, GLenum pname, GLdouble *params); void /*APIENTRY*/glTexGenf (GLenum coord, GLenum pname, GLfloat param); void /*APIENTRY*/glTexGenfv (GLenum coord, GLenum pname, GLfloat *params); void /*APIENTRY*/glTexGeni (GLenum coord, GLenum pname, GLint param); void /*APIENTRY*/glTexGeniv (GLenum coord, GLenum pname, GLint *params); void /*APIENTRY*/glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glTexParameterf (GLenum target, GLenum pname, GLfloat param); void /*APIENTRY*/glTexParameterfv (GLenum target, GLenum pname, GLfloat *params); void /*APIENTRY*/glTexParameteri (GLenum target, GLenum pname, GLint param); void /*APIENTRY*/glTexParameteriv (GLenum target, GLenum pname, GLint *params); void /*APIENTRY*/glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void /*APIENTRY*/glTranslated (GLdouble x, GLdouble y, GLdouble z); void /*APIENTRY*/glTranslatef (GLfloat x, GLfloat y, GLfloat z); void /*APIENTRY*/glVertex2d (GLdouble x, GLdouble y); void /*APIENTRY*/glVertex2dv (GLdouble *v); void /*APIENTRY*/glVertex2f (GLfloat x, GLfloat y); void /*APIENTRY*/glVertex2fv (GLfloat *v); void /*APIENTRY*/glVertex2i (GLint x, GLint y); void /*APIENTRY*/glVertex2iv (GLint *v); void /*APIENTRY*/glVertex2s (GLshort x, GLshort y); void /*APIENTRY*/glVertex2sv (GLshort *v); void /*APIENTRY*/glVertex3d (GLdouble x, GLdouble y, GLdouble z); void /*APIENTRY*/glVertex3dv (GLdouble *v); void /*APIENTRY*/glVertex3f (GLfloat x, GLfloat y, GLfloat z); void /*APIENTRY*/glVertex3fv (GLfloat *v); void /*APIENTRY*/glVertex3i (GLint x, GLint y, GLint z); void /*APIENTRY*/glVertex3iv (GLint *v); void /*APIENTRY*/glVertex3s (GLshort x, GLshort y, GLshort z); void /*APIENTRY*/glVertex3sv (GLshort *v); void /*APIENTRY*/glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); void /*APIENTRY*/glVertex4dv (GLdouble *v); void /*APIENTRY*/glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); void /*APIENTRY*/glVertex4fv (GLfloat *v); void /*APIENTRY*/glVertex4i (GLint x, GLint y, GLint z, GLint w); void /*APIENTRY*/glVertex4iv (GLint *v); void /*APIENTRY*/glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); void /*APIENTRY*/glVertex4sv (GLshort *v); void /*APIENTRY*/glVertexPointer (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); void /*APIENTRY*/glViewport (GLint x, GLint y, GLsizei width, GLsizei height); /* EXT_vertex_array */ typedef void (* PFNGLARRAYELEMENTEXTPROC) (GLint i); typedef void (* PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); typedef void (* PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, GLvoid *pointer); typedef void (* PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, GLvoid *pointer); typedef void (* PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, GLvoid *pointer); typedef void (* PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, GLvoid *pointer); typedef void (* PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, GLvoid *pointer); typedef void (* PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, GLboolean *pointer); typedef void (* PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); typedef void (* PFNGLARRAYELEMENTARRAYEXTPROC)(GLenum mode, GLsizei count, GLvoid* pi); /* WIN_draw_range_elements */ typedef void (* PFNGLDRAWRANGEELEMENTSWINPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLvoid *indices); /* WIN_swap_hint */ typedef void (* PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); /* EXT_paletted_texture */ typedef void (* PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, GLvoid *data); typedef void (* PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, GLvoid *data); typedef void (* PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); typedef void (* PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (* PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); //import openglu;
D
module rund.file; import std.typecons : Flag, Yes, No; version (Posix) { enum objExt = ".o"; enum binExt = ""; enum libExt = ".a"; enum dirSeparators = "/"; } else version (Windows) { enum objExt = ".obj"; enum binExt = ".exe"; enum libExt = ".lib"; enum dirSeparators = "/\\"; } else { static assert(0, "Unsupported operating system."); } struct FileAttributes { private uint attributes; private bool _exists; bool exists() const { return _exists; } bool isFile() const { import std.file : attrIsFile; return _exists && attrIsFile(attributes); } bool isDir() const { import std.file : attrIsDir; return _exists && attrIsDir(attributes); } bool isSymlink() const { version (Windows) return false; else { import std.file : attrIsSymlink; return _exists && attrIsSymlink(attributes); } } } FileAttributes getFileAttributes(const(char)[] name, Flag!"resolveLink" resolveLink = Yes.resolveLink) { import std.internal.cstring : tempCString; import std.format : format; import std.file : FileException; version(Windows) { import core.sys.windows.windows : GetFileAttributesW, GetLastError, ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND; auto attributes = GetFileAttributesW(name.tempCString!wchar()); if(attributes == 0xFFFFFFFF) { auto lastError = GetLastError(); if (lastError == ERROR_FILE_NOT_FOUND || lastError == ERROR_PATH_NOT_FOUND) return FileAttributes(0, false); throw new FileException(name, format("GetFileAttributesW failed (e=%d)", lastError)); } return FileAttributes(attributes, true); } else version(Posix) { import core.stdc.errno : errno, ENOENT; import core.sys.posix.sys.stat : stat_t, stat, lstat; stat_t statbuf = void; int result; if (resolveLink) result = stat(name.tempCString!char(), &statbuf); else result = lstat(name.tempCString!char(), &statbuf); if(result != 0) { if (errno == ENOENT) return FileAttributes(0, false); throw new FileException(name, format("stat function failed (e=%d)", errno)); } return FileAttributes(statbuf.st_mode, true); } else static assert(0); } string which(string path) { import std.algorithm : findAmong, splitter; import std.string : split; import std.process : environment; import std.path : pathSeparator, buildPath, extension; if (findAmong(path, dirSeparators).length || getFileAttributes(path).isFile) { return path; } string[] extensions = [""]; version(Windows) { // TODO: add a test that verifies this works correctly on windows if (path.extension is null) { extensions ~= environment["PATHEXT"].split(pathSeparator); // TODO: remove duplicate entries in extensions } } foreach (envPath; environment["PATH"].splitter(pathSeparator)) { foreach (ext; extensions) { string absPath = buildPath(envPath, path ~ ext); if (getFileAttributes(absPath).isFile) { return absPath; } } } return null; }
D
/home/brs/Documents/Projects/AdventOfCode/day_2/target/debug/deps/day_2-0cd2c2b57f35633c.rmeta: src/main.rs /home/brs/Documents/Projects/AdventOfCode/day_2/target/debug/deps/day_2-0cd2c2b57f35633c.d: src/main.rs src/main.rs:
D
crude outline/sillouette of a horses head
D
/++ This module contains summation algorithms. License: $(HTTP www.apache.org/licenses/LICENSE-2.0, Apache-2.0) Authors: Ilia Ki Copyright: 2020 Ilia Ki, Kaleidic Associates Advisory Limited, Symmetry Investments +/ module mir.math.sum; /// version(mir_test) unittest { import mir.ndslice.slice: sliced; import mir.ndslice.topology: map; auto ar = [1, 1e100, 1, -1e100].sliced.map!"a * 10_000"; const r = 20_000; assert(r == ar.sum!"kbn"); assert(r == ar.sum!"kb2"); assert(r == ar.sum!"precise"); assert(r == ar.sum!"decimal"); } /// Decimal precise summation version(mir_test) unittest { auto ar = [777.7, -777]; assert(ar.sum!"decimal" == 0.7); assert(sum!"decimal"(777.7, -777) == 0.7); // The exact binary reuslt is 0.7000000000000455 assert(ar[0] + ar[1] == 0.7000000000000455); assert(ar.sum!"fast" == 0.7000000000000455); assert(ar.sum!"kahan" == 0.7000000000000455); assert(ar.sum!"kbn" == 0.7000000000000455); assert(ar.sum!"kb2" == 0.7000000000000455); assert(ar.sum!"precise" == 0.7000000000000455); assert([1e-20, 1].sum!"decimal" == 1); } /// version(mir_test) unittest { import mir.ndslice.slice: sliced, slicedField; import mir.ndslice.topology: map, iota, retro; import mir.ndslice.concatenation: concatenation; import mir.math.common; auto ar = 1000 .iota .map!(n => 1.7L.pow(n+1) - 1.7L.pow(n)) ; real d = 1.7L.pow(1000); assert(sum!"precise"(concatenation(ar, [-d].sliced).slicedField) == -1); assert(sum!"precise"(ar.retro, -d) == -1); } /++ `Naive`, `Pairwise` and `Kahan` algorithms can be used for user defined types. +/ version(mir_test) unittest { import mir.internal.utility: isFloatingPoint; static struct Quaternion(F) if (isFloatingPoint!F) { F[4] rijk; /// + and - operator overloading Quaternion opBinary(string op)(auto ref const Quaternion rhs) const if (op == "+" || op == "-") { Quaternion ret ; foreach (i, ref e; ret.rijk) mixin("e = rijk[i] "~op~" rhs.rijk[i];"); return ret; } /// += and -= operator overloading Quaternion opOpAssign(string op)(auto ref const Quaternion rhs) if (op == "+" || op == "-") { foreach (i, ref e; rijk) mixin("e "~op~"= rhs.rijk[i];"); return this; } ///constructor with single FP argument this(F f) { rijk[] = f; } ///assigment with single FP argument void opAssign(F f) { rijk[] = f; } } Quaternion!double q, p, r; q.rijk = [0, 1, 2, 4]; p.rijk = [3, 4, 5, 9]; r.rijk = [3, 5, 7, 13]; assert(r == [p, q].sum!"naive"); assert(r == [p, q].sum!"pairwise"); assert(r == [p, q].sum!"kahan"); } /++ All summation algorithms available for complex numbers. +/ version(mir_test) unittest { import mir.complex: Complex; auto ar = [Complex!double(1.0, 2), Complex!double(2.0, 3), Complex!double(3.0, 4), Complex!double(4.0, 5)]; Complex!double r = Complex!double(10.0, 14); assert(r == ar.sum!"fast"); assert(r == ar.sum!"naive"); assert(r == ar.sum!"pairwise"); assert(r == ar.sum!"kahan"); version(LDC) // DMD Internal error: backend/cgxmm.c 628 { assert(r == ar.sum!"kbn"); assert(r == ar.sum!"kb2"); } assert(r == ar.sum!"precise"); assert(r == ar.sum!"decimal"); } /// version(mir_test) @safe pure nothrow unittest { import mir.ndslice.topology: repeat, iota; //simple integral summation assert(sum([ 1, 2, 3, 4]) == 10); //with initial value assert(sum([ 1, 2, 3, 4], 5) == 15); //with integral promotion assert(sum([false, true, true, false, true]) == 3); assert(sum(ubyte.max.repeat(100)) == 25_500); //The result may overflow assert(uint.max.repeat(3).sum == 4_294_967_293U ); //But a seed can be used to change the summation primitive assert(uint.max.repeat(3).sum(ulong.init) == 12_884_901_885UL); //Floating point summation assert(sum([1.0, 2.0, 3.0, 4.0]) == 10); //Type overriding static assert(is(typeof(sum!double([1F, 2F, 3F, 4F])) == double)); static assert(is(typeof(sum!double([1F, 2F, 3F, 4F], 5F)) == double)); assert(sum([1F, 2, 3, 4]) == 10); assert(sum([1F, 2, 3, 4], 5F) == 15); //Force pair-wise floating point summation on large integers import mir.math : approxEqual; assert(iota!long([4096], uint.max / 2).sum(0.0) .approxEqual((uint.max / 2) * 4096.0 + 4096.0 * 4096.0 / 2)); } /// Precise summation version(mir_test) nothrow @nogc unittest { import mir.ndslice.topology: iota, map; import core.stdc.tgmath: pow; assert(iota(1000).map!(n => 1.7L.pow(real(n)+1) - 1.7L.pow(real(n))) .sum!"precise" == -1 + 1.7L.pow(1000.0L)); } /// Precise summation with output range version(mir_test) nothrow @nogc unittest { import mir.ndslice.topology: iota, map; import mir.math.common; auto r = iota(1000).map!(n => 1.7L.pow(n+1) - 1.7L.pow(n)); Summator!(real, Summation.precise) s = 0.0; s.put(r); s -= 1.7L.pow(1000); assert(s.sum == -1); } /// Precise summation with output range version(mir_test) nothrow @nogc unittest { import mir.math.common; float M = 2.0f ^^ (float.max_exp-1); double N = 2.0 ^^ (float.max_exp-1); auto s = Summator!(float, Summation.precise)(0); s += M; s += M; assert(float.infinity == s.sum); //infinity auto e = cast(Summator!(double, Summation.precise)) s; assert(e.sum < double.infinity); assert(N+N == e.sum()); //finite number } /// Moving mean version(mir_test) @safe pure nothrow @nogc unittest { import mir.internal.utility: isFloatingPoint; import mir.math.sum; import mir.ndslice.topology: linspace; import mir.rc.array: rcarray; struct MovingAverage(T) if (isFloatingPoint!T) { import mir.math.stat: MeanAccumulator; MeanAccumulator!(T, Summation.precise) meanAccumulator; double[] circularBuffer; size_t frontIndex; @disable this(this); auto avg() @property const { return meanAccumulator.mean; } this(double[] buffer) { assert(buffer.length); circularBuffer = buffer; meanAccumulator.put(buffer); } ///operation without rounding void put(T x) { import mir.utility: swap; meanAccumulator.summator += x; swap(circularBuffer[frontIndex++], x); frontIndex = frontIndex == circularBuffer.length ? 0 : frontIndex; meanAccumulator.summator -= x; } } /// ma always keeps precise average of last 1000 elements auto x = linspace!double([1000], [0.0, 999]).rcarray; auto ma = MovingAverage!double(x[]); assert(ma.avg == (1000 * 999 / 2) / 1000.0); /// move by 10 elements foreach(e; linspace!double([10], [1000.0, 1009.0])) ma.put(e); assert(ma.avg == (1010 * 1009 / 2 - 10 * 9 / 2) / 1000.0); } /// Arbitrary sum version(mir_test) @safe pure nothrow unittest { import mir.complex; alias C = Complex!double; assert(sum(1, 2, 3, 4) == 10); assert(sum!float(1, 2, 3, 4) == 10f); assert(sum(1f, 2, 3, 4) == 10f); assert(sum(C(1.0, 2), C(2, 3), C(3, 4), C(4, 5)) == C(10, 14)); } version(X86) version = X86_Any; version(X86_64) version = X86_Any; /++ SIMD Vectors Bugs: ICE 1662 (dmd only) +/ version(LDC) version(X86_Any) version(mir_test) unittest { import core.simd; import std.meta : AliasSeq; double2 a = 1, b = 2, c = 3, d = 6; with(Summation) { foreach (algo; AliasSeq!(naive, fast, pairwise, kahan)) { assert([a, b, c].sum!algo.array == d.array); assert([a, b].sum!algo(c).array == d.array); } } } import std.traits; private alias AliasSeq(T...) = T; import mir.internal.utility: Iota, isComplex; import mir.math.common: fabs; private alias isNaN = x => x != x; private alias isFinite = x => x.fabs < x.infinity; private alias isInfinity = x => x.fabs == x.infinity; private template chainSeq(size_t n) { static if (n) alias chainSeq = AliasSeq!(n, chainSeq!(n / 2)); else alias chainSeq = AliasSeq!(); } /++ Summation algorithms. +/ enum Summation { /++ Performs `pairwise` summation for floating point based types and `fast` summation for integral based types. +/ appropriate, /++ $(WEB en.wikipedia.org/wiki/Pairwise_summation, Pairwise summation) algorithm. +/ pairwise, /++ Precise summation algorithm. The value of the sum is rounded to the nearest representable floating-point number using the $(LUCKY round-half-to-even rule). The result can differ from the exact value on 32bit `x86`, `nextDown(proir) <= result && result <= nextUp(proir)`. The current implementation re-establish special value semantics across iterations (i.e. handling ±inf). References: $(LINK2 http://www.cs.cmu.edu/afs/cs/project/quake/public/papers/robust-arithmetic.ps, "Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates", Jonathan Richard Shewchuk), $(LINK2 http://bugs.python.org/file10357/msum4.py, Mark Dickinson's post at bugs.python.org). +/ /+ Precise summation function as msum() by Raymond Hettinger in <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/393090>, enhanced with the exact partials sum and roundoff from Mark Dickinson's post at <http://bugs.python.org/file10357/msum4.py>. See those links for more details, proofs and other references. IEEE 754R floating point semantics are assumed. +/ precise, /++ Precise decimal summation algorithm. The elements of the sum are converted to a shortest decimal representation that being converted back would result the same floating-point number. The resulting decimal elements are summed without rounding. The decimal sum is converted back to a binary floating point representation using round-half-to-even rule. See_also: The $(HTTPS github.com/ulfjack/ryu, Ryu algorithm) +/ decimal, /++ $(WEB en.wikipedia.org/wiki/Kahan_summation, Kahan summation) algorithm. +/ /+ --------------------- s := x[1] c := 0 FOR k := 2 TO n DO y := x[k] - c t := s + y c := (t - s) - y s := t END DO --------------------- +/ kahan, /++ $(LUCKY Kahan-Babuška-Neumaier summation algorithm). `KBN` gives more accurate results then `Kahan`. +/ /+ --------------------- s := x[1] c := 0 FOR i := 2 TO n DO t := s + x[i] IF ABS(s) >= ABS(x[i]) THEN c := c + ((s-t)+x[i]) ELSE c := c + ((x[i]-t)+s) END IF s := t END DO s := s + c --------------------- +/ kbn, /++ $(LUCKY Generalized Kahan-Babuška summation algorithm), order 2. `KB2` gives more accurate results then `Kahan` and `KBN`. +/ /+ --------------------- s := 0 ; cs := 0 ; ccs := 0 FOR j := 1 TO n DO t := s + x[i] IF ABS(s) >= ABS(x[i]) THEN c := (s-t) + x[i] ELSE c := (x[i]-t) + s END IF s := t t := cs + c IF ABS(cs) >= ABS(c) THEN cc := (cs-t) + c ELSE cc := (c-t) + cs END IF cs := t ccs := ccs + cc END FOR RETURN s+cs+ccs --------------------- +/ kb2, /++ Naive algorithm (one by one). +/ naive, /++ SIMD optimized summation algorithm. +/ fast, } /++ Output range for summation. +/ struct Summator(T, Summation summation) if (isMutable!T) { import mir.internal.utility: isComplex; static if (is(T == class) || is(T == interface) || hasElaborateAssign!T && !isComplex!T) static assert (summation == Summation.naive, "Classes, interfaces, and structures with " ~ "elaborate constructor support only naive summation."); static if (summation == Summation.fast) { version (LDC) { import ldc.attributes: fastmath; alias attr = fastmath; } else { alias attr = AliasSeq!(); } } else { alias attr = AliasSeq!(); } @attr: static if (summation == Summation.pairwise) { private enum bool fastPairwise = is(F == float) || is(F == double) || (isComplex!F && F.sizeof <= 16) || is(F : __vector(W[N]), W, size_t N); //false; } alias F = T; static if (summation == Summation.precise) { import std.internal.scopebuffer; import mir.appender; import mir.math.ieee: signbit; private: enum F M = (cast(F)(2)) ^^ (T.max_exp - 1); auto partials = scopedBuffer!(F, 8 * T.sizeof); //sum for NaN and infinity. F s = summationInitValue!F; //Overflow Degree. Count of 2^^F.max_exp minus count of -(2^^F.max_exp) sizediff_t o; /++ Compute the sum of a list of nonoverlapping floats. On input, partials is a list of nonzero, nonspecial, nonoverlapping floats, strictly increasing in magnitude, but possibly not all having the same sign. On output, the sum of partials gives the error in the returned result, which is correctly rounded (using the round-half-to-even rule). Two floating point values x and y are non-overlapping if the least significant nonzero bit of x is more significant than the most significant nonzero bit of y, or vice-versa. +/ static F partialsReduce(F s, in F[] partials) in { debug(numeric) assert(!partials.length || .isFinite(s)); } do { bool _break; foreach_reverse (i, y; partials) { s = partialsReducePred(s, y, i ? partials[i-1] : 0, _break); if (_break) break; debug(numeric) assert(.isFinite(s)); } return s; } static F partialsReducePred(F s, F y, F z, out bool _break) out(result) { debug(numeric) assert(.isFinite(result)); } do { F x = s; s = x + y; F d = s - x; F l = y - d; debug(numeric) { assert(.isFinite(x)); assert(.isFinite(y)); assert(.isFinite(s)); assert(fabs(y) < fabs(x)); } if (l) { //Make half-even rounding work across multiple partials. //Needed so that sum([1e-16, 1, 1e16]) will round-up the last //digit to two instead of down to zero (the 1e-16 makes the 1 //slightly closer to two). Can guarantee commutativity. if (z && !signbit(l * z)) { l *= 2; x = s + l; F t = x - s; if (l == t) s = x; } _break = true; } return s; } //Returns corresponding infinity if is overflow and 0 otherwise. F overflow()() const { if (o == 0) return 0; if (partials.length && (o == -1 || o == 1) && signbit(o * partials.data[$-1])) { // problem case: decide whether result is representable F x = o * M; F y = partials.data[$-1] / 2; F h = x + y; F d = h - x; F l = (y - d) * 2; y = h * 2; d = h + l; F t = d - h; version(X86) { if (!.isInfinity(cast(T)y) || !.isInfinity(sum())) return 0; } else { if (!.isInfinity(cast(T)y) || ((partials.length > 1 && !signbit(l * partials.data[$-2])) && t == l)) return 0; } } return F.infinity * o; } } else static if (summation == Summation.kb2) { F s = summationInitValue!F; F cs = summationInitValue!F; F ccs = summationInitValue!F; } else static if (summation == Summation.kbn) { F s = summationInitValue!F; F c = summationInitValue!F; } else static if (summation == Summation.kahan) { F s = summationInitValue!F; F c = summationInitValue!F; F y = summationInitValue!F; // do not declare in the loop/put (algo can be used for matrixes and etc) F t = summationInitValue!F; // ditto } else static if (summation == Summation.pairwise) { package size_t counter; size_t index; static if (fastPairwise) { enum registersCount= 16; F[size_t.sizeof * 8] partials; } else { F[size_t.sizeof * 8] partials; } } else static if (summation == Summation.naive) { F s = summationInitValue!F; } else static if (summation == Summation.fast) { F s = summationInitValue!F; } else static if (summation == Summation.decimal) { import mir.bignum.decimal; Decimal!128 s; T ss = 0; } else static assert(0, "Unsupported summation type for std.numeric.Summator."); public: /// this()(T n) { static if (summation == Summation.precise) { s = 0.0; o = 0; if (n) put(n); } else static if (summation == Summation.kb2) { s = n; static if (isComplex!T) { cs = Complex!float(0, 0); ccs = Complex!float(0, 0); } else { cs = 0.0; ccs = 0.0; } } else static if (summation == Summation.kbn) { s = n; static if (isComplex!T) c = Complex!float(0, 0); else c = 0.0; } else static if (summation == Summation.kahan) { s = n; static if (isComplex!T) c = Complex!float(0, 0); else c = 0.0; } else static if (summation == Summation.pairwise) { counter = index = 1; partials[0] = n; } else static if (summation == Summation.naive) { s = n; } else static if (summation == Summation.fast) { s = n; } else static if (summation == Summation.decimal) { ss = 0; if (!(-n.infinity < n && n < n.infinity)) { ss = n; n = 0; } s = n; } else static assert(0); } ///Adds `n` to the internal partial sums. void put(N)(N n) if (__traits(compiles, {T a = n; a = n; a += n;})) { static if (isCompesatorAlgorithm!summation) F x = n; static if (summation == Summation.precise) { if (.isFinite(x)) { size_t i; auto partials_data = partials.data; foreach (y; partials_data[]) { F h = x + y; if (.isInfinity(cast(T)h)) { if (fabs(x) < fabs(y)) { F t = x; x = y; y = t; } //h == -F.infinity if (signbit(h)) { x += M; x += M; o--; } //h == +F.infinity else { x -= M; x -= M; o++; } debug(numeric) assert(x.isFinite); h = x + y; } debug(numeric) assert(h.isFinite); F l; if (fabs(x) < fabs(y)) { F t = h - y; l = x - t; } else { F t = h - x; l = y - t; } debug(numeric) assert(l.isFinite); if (l) { partials_data[i++] = l; } x = h; } partials.shrinkTo(i); if (x) { partials.put(x); } } else { s += x; } } else static if (summation == Summation.kb2) { static if (isFloatingPoint!F) { F t = s + x; F c = 0; if (fabs(s) >= fabs(x)) { F d = s - t; c = d + x; } else { F d = x - t; c = d + s; } s = t; t = cs + c; if (fabs(cs) >= fabs(c)) { F d = cs - t; d += c; ccs += d; } else { F d = c - t; d += cs; ccs += d; } cs = t; } else { F t = s + x; if (fabs(s.re) < fabs(x.re)) { auto s_re = s.re; auto x_re = x.re; s = F(x_re, s.im); x = F(s_re, x.im); } if (fabs(s.im) < fabs(x.im)) { auto s_im = s.im; auto x_im = x.im; s = F(s.re, x_im); x = F(x.re, s_im); } F c = (s-t)+x; s = t; if (fabs(cs.re) < fabs(c.re)) { auto c_re = c.re; auto cs_re = cs.re; c = F(cs_re, c.im); cs = F(c_re, cs.im); } if (fabs(cs.im) < fabs(c.im)) { auto c_im = c.im; auto cs_im = cs.im; c = F(c.re, cs_im); cs = F(cs.re, c_im); } F d = cs - t; d += c; ccs += d; cs = t; } } else static if (summation == Summation.kbn) { static if (isFloatingPoint!F) { F t = s + x; if (fabs(s) >= fabs(x)) { F d = s - t; d += x; c += d; } else { F d = x - t; d += s; c += d; } s = t; } else { F t = s + x; if (fabs(s.re) < fabs(x.re)) { auto s_re = s.re; auto x_re = x.re; s = F(x_re, s.im); x = F(s_re, x.im); } if (fabs(s.im) < fabs(x.im)) { auto s_im = s.im; auto x_im = x.im; s = F(s.re, x_im); x = F(x.re, s_im); } F d = s - t; d += x; c += d; s = t; } } else static if (summation == Summation.kahan) { y = x - c; t = s + y; c = t - s; c -= y; s = t; } else static if (summation == Summation.pairwise) { import mir.bitop: cttz; ++counter; partials[index] = n; foreach (_; 0 .. cttz(counter)) { immutable newIndex = index - 1; partials[newIndex] += partials[index]; index = newIndex; } ++index; } else static if (summation == Summation.naive) { s += n; } else static if (summation == Summation.fast) { s += n; } else static if (summation == summation.decimal) { import mir.bignum.internal.ryu.generic_128: genericBinaryToDecimal; if (-n.infinity < n && n < n.infinity) { auto decimal = genericBinaryToDecimal(n); s += decimal; } else { ss += n; } } else static assert(0); } ///ditto void put(Range)(Range r) if (isIterable!Range && !is(Range : __vector(V[N]), V, size_t N)) { static if (summation == Summation.pairwise && fastPairwise && isDynamicArray!Range) { F[registersCount] v; foreach (i, n; chainSeq!registersCount) { if (r.length >= n * 2) do { foreach (j; Iota!n) v[j] = cast(F) r[j]; foreach (j; Iota!n) v[j] += cast(F) r[n + j]; foreach (m; chainSeq!(n / 2)) foreach (j; Iota!m) v[j] += v[m + j]; put(v[0]); r = r[n * 2 .. $]; } while (!i && r.length >= n * 2); } if (r.length) { put(cast(F) r[0]); r = r[1 .. $]; } assert(r.length == 0); } else static if (summation == Summation.fast) { static if (isComplex!F) F s0 = F(0, 0f); else F s0 = 0; foreach (ref elem; r) s0 += elem; s += s0; } else { foreach (ref elem; r) put(elem); } } import mir.ndslice.slice; /// ditto void put(Range: Slice!(Iterator, N, kind), Iterator, size_t N, SliceKind kind)(Range r) { static if (N > 1 && kind == Contiguous) { import mir.ndslice.topology: flattened; this.put(r.flattened); } else static if (isPointer!Iterator && kind == Contiguous) { this.put(r.field); } else static if (summation == Summation.fast && N == 1) { static if (isComplex!F) F s0 = F(0, 0f); else F s0 = 0; import mir.algorithm.iteration: reduce; s0 = s0.reduce!"a + b"(r); s += s0; } else { foreach(elem; r) this.put(elem); } } /+ Adds `x` to the internal partial sums. This operation doesn't re-establish special value semantics across iterations (i.e. handling ±inf). Preconditions: `isFinite(x)`. +/ version(none) static if (summation == Summation.precise) package void unsafePut()(F x) in { assert(.isFinite(x)); } do { size_t i; foreach (y; partials.data[]) { F h = x + y; debug(numeric) assert(.isFinite(h)); F l; if (fabs(x) < fabs(y)) { F t = h - y; l = x - t; } else { F t = h - x; l = y - t; } debug(numeric) assert(.isFinite(l)); if (l) { partials.data[i++] = l; } x = h; } partials.length = i; if (x) { partials.put(x); } } ///Returns the value of the sum. T sum()() scope const { /++ Returns the value of the sum, rounded to the nearest representable floating-point number using the round-half-to-even rule. The result can differ from the exact value on `X86`, `nextDown`proir) <= result && result <= nextUp(proir)). +/ static if (summation == Summation.precise) { debug(mir_sum) { foreach (y; partials.data[]) { assert(y); assert(y.isFinite); } //TODO: Add Non-Overlapping check to std.math import mir.ndslice.slice: sliced; import mir.ndslice.sorting: isSorted; import mir.ndslice.topology: map; assert(partials.data[].sliced.map!fabs.isSorted); } if (s) return s; auto parts = partials.data[]; F y = 0.0; //pick last if (parts.length) { y = parts[$-1]; parts = parts[0..$-1]; } if (o) { immutable F of = o; if (y && (o == -1 || o == 1) && signbit(of * y)) { // problem case: decide whether result is representable y /= 2; F x = of * M; immutable F h = x + y; F t = h - x; F l = (y - t) * 2; y = h * 2; if (.isInfinity(cast(T)y)) { // overflow, except in edge case... x = h + l; t = x - h; y = parts.length && t == l && !signbit(l*parts[$-1]) ? x * 2 : F.infinity * of; parts = null; } else if (l) { bool _break; y = partialsReducePred(y, l, parts.length ? parts[$-1] : 0, _break); if (_break) parts = null; } } else { y = F.infinity * of; parts = null; } } return partialsReduce(y, parts); } else static if (summation == Summation.kb2) { return s + (cs + ccs); } else static if (summation == Summation.kbn) { return s + c; } else static if (summation == Summation.kahan) { return s; } else static if (summation == Summation.pairwise) { F s = summationInitValue!T; assert((counter == 0) == (index == 0)); foreach_reverse (ref e; partials[0 .. index]) { static if (is(F : __vector(W[N]), W, size_t N)) s += cast(Unqual!F) e; //DMD bug workaround else s += e; } return s; } else static if (summation == Summation.naive) { return s; } else static if (summation == Summation.fast) { return s; } else static if (summation == Summation.decimal) { return cast(T) s + ss; } else static assert(0); } version(none) static if (summation == Summation.precise) F partialsSum()() const { debug(numeric) partialsDebug; auto parts = partials.data[]; F y = 0.0; //pick last if (parts.length) { y = parts[$-1]; parts = parts[0..$-1]; } return partialsReduce(y, parts); } ///Returns `Summator` with extended internal partial sums. C opCast(C : Summator!(P, _summation), P, Summation _summation)() const if ( _summation == summation && isMutable!C && P.max_exp >= T.max_exp && P.mant_dig >= T.mant_dig ) { static if (is(P == T)) return this; else static if (summation == Summation.precise) { auto ret = typeof(return).init; ret.s = s; ret.o = o; foreach (p; partials.data[]) { ret.partials.put(p); } enum exp_diff = P.max_exp / T.max_exp; static if (exp_diff) { if (ret.o) { immutable f = ret.o / exp_diff; immutable t = cast(int)(ret.o % exp_diff); ret.o = f; ret.put((P(2) ^^ T.max_exp) * t); } } return ret; } else static if (summation == Summation.kb2) { auto ret = typeof(return).init; ret.s = s; ret.cs = cs; ret.ccs = ccs; return ret; } else static if (summation == Summation.kbn) { auto ret = typeof(return).init; ret.s = s; ret.c = c; return ret; } else static if (summation == Summation.kahan) { auto ret = typeof(return).init; ret.s = s; ret.c = c; return ret; } else static if (summation == Summation.pairwise) { auto ret = typeof(return).init; ret.counter = counter; ret.index = index; foreach (i; 0 .. index) ret.partials[i] = partials[i]; return ret; } else static if (summation == Summation.naive) { auto ret = typeof(return).init; ret.s = s; return ret; } else static if (summation == Summation.fast) { auto ret = typeof(return).init; ret.s = s; return ret; } else static assert(0); } /++ `cast(C)` operator overloading. Returns `cast(C)sum()`. See also: `cast` +/ C opCast(C)() const if (is(Unqual!C == T)) { return cast(C)sum(); } ///Operator overloading. // opAssign should initialize partials. void opAssign(T rhs) { static if (summation == Summation.precise) { partials.reset; s = 0.0; o = 0; if (rhs) put(rhs); } else static if (summation == Summation.kb2) { s = rhs; static if (isComplex!T) { cs = T(0, 0f); ccs = T(0.0, 0f); } else { cs = 0.0; ccs = 0.0; } } else static if (summation == Summation.kbn) { s = rhs; static if (isComplex!T) c = T(0, 0f); else c = 0.0; } else static if (summation == Summation.kahan) { s = rhs; static if (isComplex!T) c = T(0, 0f); else c = 0.0; } else static if (summation == Summation.pairwise) { counter = 1; index = 1; partials[0] = rhs; } else static if (summation == Summation.naive) { s = rhs; } else static if (summation == Summation.fast) { s = rhs; } else static if (summation == summation.decimal) { __ctor(rhs); } else static assert(0); } ///ditto void opOpAssign(string op : "+")(T rhs) { put(rhs); } ///ditto void opOpAssign(string op : "+")(ref const Summator rhs) { static if (summation == Summation.precise) { s += rhs.s; o += rhs.o; foreach (f; rhs.partials.data[]) put(f); } else static if (summation == Summation.kb2) { put(rhs.ccs); put(rhs.cs); put(rhs.s); } else static if (summation == Summation.kbn) { put(rhs.c); put(rhs.s); } else static if (summation == Summation.kahan) { put(rhs.s); } else static if (summation == Summation.pairwise) { foreach_reverse (e; rhs.partials[0 .. rhs.index]) put(e); counter -= rhs.index; counter += rhs.counter; } else static if (summation == Summation.naive) { put(rhs.s); } else static if (summation == Summation.fast) { put(rhs.s); } else static assert(0); } ///ditto void opOpAssign(string op : "-")(T rhs) { static if (summation == Summation.precise) { put(-rhs); } else static if (summation == Summation.kb2) { put(-rhs); } else static if (summation == Summation.kbn) { put(-rhs); } else static if (summation == Summation.kahan) { y = 0.0; y -= rhs; y -= c; t = s + y; c = t - s; c -= y; s = t; } else static if (summation == Summation.pairwise) { put(-rhs); } else static if (summation == Summation.naive) { s -= rhs; } else static if (summation == Summation.fast) { s -= rhs; } else static assert(0); } ///ditto void opOpAssign(string op : "-")(ref const Summator rhs) { static if (summation == Summation.precise) { s -= rhs.s; o -= rhs.o; foreach (f; rhs.partials.data[]) put(-f); } else static if (summation == Summation.kb2) { put(-rhs.ccs); put(-rhs.cs); put(-rhs.s); } else static if (summation == Summation.kbn) { put(-rhs.c); put(-rhs.s); } else static if (summation == Summation.kahan) { this -= rhs.s; } else static if (summation == Summation.pairwise) { foreach_reverse (e; rhs.partials[0 .. rhs.index]) put(-e); counter -= rhs.index; counter += rhs.counter; } else static if (summation == Summation.naive) { s -= rhs.s; } else static if (summation == Summation.fast) { s -= rhs.s; } else static assert(0); } /// version(mir_test) @nogc nothrow unittest { import mir.math.common; import mir.ndslice.topology: iota, map; auto r1 = iota(500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); auto r2 = iota([500], 500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); Summator!(real, Summation.precise) s1 = 0, s2 = 0.0; foreach (e; r1) s1 += e; foreach (e; r2) s2 -= e; s1 -= s2; s1 -= 1.7L.pow(1000); assert(s1.sum == -1); } version(mir_test) @nogc nothrow unittest { with(Summation) foreach (summation; AliasSeq!(kahan, kbn, kb2, precise, pairwise)) foreach (T; AliasSeq!(float, double, real)) { Summator!(T, summation) sum = 1; sum += 3; assert(sum.sum == 4); sum -= 10; assert(sum.sum == -6); Summator!(T, summation) sum2 = 3; sum -= sum2; assert(sum.sum == -9); sum2 = 100; sum += 100; assert(sum.sum == 91); auto sum3 = cast(Summator!(real, summation))sum; assert(sum3.sum == 91); sum = sum2; } } version(mir_test) @nogc nothrow unittest { import mir.math.common: approxEqual; with(Summation) foreach (summation; AliasSeq!(naive, fast)) foreach (T; AliasSeq!(float, double, real)) { Summator!(T, summation) sum = 1; sum += 3.5; assert(sum.sum.approxEqual(4.5)); sum = 2; assert(sum.sum == 2); sum -= 4; assert(sum.sum.approxEqual(-2)); } } static if (summation == Summation.precise) { ///Returns `true` if current sum is a NaN. bool isNaN()() const { return .isNaN(s); } ///Returns `true` if current sum is finite (not infinite or NaN). bool isFinite()() const { if (s) return false; return !overflow; } ///Returns `true` if current sum is ±∞. bool isInfinity()() const { return .isInfinity(s) || overflow(); } } else static if (isFloatingPoint!F) { ///Returns `true` if current sum is a NaN. bool isNaN()() const { return .isNaN(sum()); } ///Returns `true` if current sum is finite (not infinite or NaN). bool isFinite()() const { return .isFinite(sum()); } ///Returns `true` if current sum is ±∞. bool isInfinity()() const { return .isInfinity(sum()); } } else { //User defined types } } version(mir_test) unittest { import mir.functional: Tuple, tuple; import mir.ndslice.topology: map, iota, retro; import mir.array.allocation: array; import std.math: isInfinity, isFinite, isNaN; Summator!(double, Summation.precise) summator = 0.0; enum double M = (cast(double)2) ^^ (double.max_exp - 1); Tuple!(double[], double)[] tests = [ tuple(new double[0], 0.0), tuple([0.0], 0.0), tuple([1e100, 1.0, -1e100, 1e-100, 1e50, -1, -1e50], 1e-100), tuple([1e308, 1e308, -1e308], 1e308), tuple([-1e308, 1e308, 1e308], 1e308), tuple([1e308, -1e308, 1e308], 1e308), tuple([M, M, -2.0^^1000], 1.7976930277114552e+308), tuple([M, M, M, M, -M, -M, -M], 8.9884656743115795e+307), tuple([2.0^^53, -0.5, -2.0^^-54], 2.0^^53-1.0), tuple([2.0^^53, 1.0, 2.0^^-100], 2.0^^53+2.0), tuple([2.0^^53+10.0, 1.0, 2.0^^-100], 2.0^^53+12.0), tuple([2.0^^53-4.0, 0.5, 2.0^^-54], 2.0^^53-3.0), tuple([M-2.0^^970, -1, M], 1.7976931348623157e+308), tuple([double.max, double.max*2.^^-54], double.max), tuple([double.max, double.max*2.^^-53], double.infinity), tuple(iota([1000], 1).map!(a => 1.0/a).array , 7.4854708605503451), tuple(iota([1000], 1).map!(a => (-1.0)^^a/a).array, -0.69264743055982025), //0.693147180559945309417232121458176568075500134360255254120680... tuple(iota([1000], 1).map!(a => 1.0/a).retro.array , 7.4854708605503451), tuple(iota([1000], 1).map!(a => (-1.0)^^a/a).retro.array, -0.69264743055982025), tuple([double.infinity, -double.infinity, double.nan], double.nan), tuple([double.nan, double.infinity, -double.infinity], double.nan), tuple([double.infinity, double.nan, double.infinity], double.nan), tuple([double.infinity, double.infinity], double.infinity), tuple([double.infinity, -double.infinity], double.nan), tuple([-double.infinity, 1e308, 1e308, -double.infinity], -double.infinity), tuple([M-2.0^^970, 0.0, M], double.infinity), tuple([M-2.0^^970, 1.0, M], double.infinity), tuple([M, M], double.infinity), tuple([M, M, -1], double.infinity), tuple([M, M, M, M, -M, -M], double.infinity), tuple([M, M, M, M, -M, M], double.infinity), tuple([-M, -M, -M, -M], -double.infinity), tuple([M, M, -2.^^971], double.max), tuple([M, M, -2.^^970], double.infinity), tuple([-2.^^970, M, M, -0X0.0000000000001P-0 * 2.^^-1022], double.max), tuple([M, M, -2.^^970, 0X0.0000000000001P-0 * 2.^^-1022], double.infinity), tuple([-M, 2.^^971, -M], -double.max), tuple([-M, -M, 2.^^970], -double.infinity), tuple([-M, -M, 2.^^970, 0X0.0000000000001P-0 * 2.^^-1022], -double.max), tuple([-0X0.0000000000001P-0 * 2.^^-1022, -M, -M, 2.^^970], -double.infinity), tuple([2.^^930, -2.^^980, M, M, M, -M], 1.7976931348622137e+308), tuple([M, M, -1e307], 1.6976931348623159e+308), tuple([1e16, 1., 1e-16], 10_000_000_000_000_002.0), ]; foreach (i, test; tests) { summator = 0.0; foreach (t; test.a) summator.put(t); auto r = test.b; auto s = summator.sum; assert(summator.isNaN() == r.isNaN()); assert(summator.isFinite() == r.isFinite()); assert(summator.isInfinity() == r.isInfinity()); assert(s == r || s.isNaN && r.isNaN); } } /++ Sums elements of `r`, which must be a finite iterable. A seed may be passed to `sum`. Not only will this seed be used as an initial value, but its type will be used if it is not specified. Note that these specialized summing algorithms execute more primitive operations than vanilla summation. Therefore, if in certain cases maximum speed is required at expense of precision, one can use $(LREF Summation.fast). Returns: The sum of all the elements in the range r. +/ template sum(F, Summation summation = Summation.appropriate) if (isMutable!F) { /// template sum(Range) if (isIterable!Range && isMutable!Range) { import core.lifetime: move; /// F sum(Range r) { static if (isComplex!F && (summation == Summation.precise || summation == Summation.decimal)) { return sum(r, summationInitValue!F); } else { static if (summation == Summation.decimal) { Summator!(F, summation) sum = void; sum = 0; } else { Summator!(F, ResolveSummationType!(summation, Range, sumType!Range)) sum; } sum.put(r.move); return sum.sum; } } /// F sum(Range r, F seed) { static if (isComplex!F && (summation == Summation.precise || summation == Summation.decimal)) { alias T = typeof(F.init.re); static if (summation == Summation.decimal) { Summator!(T, summation) sumRe = void; sumRe = seed.re; Summator!(T, summation) sumIm = void; sumIm = seed.im; } else { auto sumRe = Summator!(T, Summation.precise)(seed.re); auto sumIm = Summator!(T, Summation.precise)(seed.im); } import mir.ndslice.slice: isSlice; static if (isSlice!Range) { import mir.algorithm.iteration: each; r.each!((auto ref elem) { sumRe.put(elem.re); sumIm.put(elem.im); }); } else { foreach (ref elem; r) { sumRe.put(elem.re); sumIm.put(elem.im); } } return F(sumRe.sum, sumIm.sum); } else { static if (summation == Summation.decimal) { Summator!(F, summation) sum = void; sum = seed; } else { auto sum = Summator!(F, ResolveSummationType!(summation, Range, F))(seed); } sum.put(r.move); return sum.sum; } } } /// template sum(Range) if (isIterable!Range && !isMutable!Range) { /// F sum(Range r) { return .sum!(F, summation)(r.lightConst); } /// F sum(Range r, F seed) { return .sum!(F, summation)(r.lightConst, seed); } } /// F sum(scope const F[] r...) { static if (isComplex!F && (summation == Summation.precise || summation == Summation.decimal)) { return sum(r, summationInitValue!F); } else { Summator!(F, ResolveSummationType!(summation, const(F)[], F)) sum; sum.put(r); return sum.sum; } } } ///ditto template sum(Summation summation = Summation.appropriate) { /// sumType!Range sum(Range)(Range r) if (isIterable!Range && isMutable!Range) { import core.lifetime: move; alias F = typeof(return); alias s = .sum!(F, ResolveSummationType!(summation, Range, F)); return s(r.move); } /// F sum(Range, F)(Range r, F seed) if (isIterable!Range && isMutable!Range) { import core.lifetime: move; alias s = .sum!(F, ResolveSummationType!(summation, Range, F)); return s(r.move, seed); } /// sumType!Range sum(Range)(Range r) if (isIterable!Range && !isMutable!Range) { return .sum!(typeof(return), summation)(r.lightConst); } /// F sum(Range, F)(Range r, F seed) if (isIterable!Range && !isMutable!Range) { return .sum!(F, summation)(r.lightConst, seed); } /// sumType!T sum(T)(scope const T[] ar...) { alias F = typeof(return); return .sum!(F, ResolveSummationType!(summation, F[], F))(ar); } } ///ditto template sum(F, string summation) if (isMutable!F) { mixin("alias sum = .sum!(F, Summation." ~ summation ~ ");"); } ///ditto template sum(string summation) { mixin("alias sum = .sum!(Summation." ~ summation ~ ");"); } private static immutable jaggedMsg = "sum: each slice should have the same length"; version(D_Exceptions) static immutable jaggedException = new Exception(jaggedMsg); /++ Sum slices with a naive algorithm. +/ template sumSlices() { import mir.primitives: DeepElementType; import mir.ndslice.slice: Slice, SliceKind, isSlice; /// auto sumSlices(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) sliceOfSlices) if (isSlice!(DeepElementType!(Slice!(Iterator, 1, kind)))) { import mir.ndslice.topology: as; import mir.ndslice.allocation: slice; alias T = Unqual!(DeepElementType!(DeepElementType!(Slice!(Iterator, 1, kind)))); import mir.ndslice: slice; if (sliceOfSlices.length == 0) return typeof(slice(as!T(sliceOfSlices.front))).init; auto ret = slice(as!T(sliceOfSlices.front)); sliceOfSlices.popFront; foreach (sl; sliceOfSlices) { if (sl.length != ret.length) { version (D_Exceptions) throw jaggedException; else assert(0); } ret[] += sl[]; } return ret; } } /// version(mir_test) unittest { import mir.ndslice.topology: map, byDim; import mir.ndslice.slice: sliced; auto ar = [[1, 2, 3], [10, 20, 30]]; assert(ar.map!sliced.sumSlices == [11, 22, 33]); import mir.ndslice.fuse: fuse; auto a = [[[1.2], [2.1]], [[4.1], [5.2]]].fuse; auto s = a.byDim!0.sumSlices; assert(s == [[5.3], [7.300000000000001]]); } version(mir_test) @safe pure nothrow unittest { static assert(is(typeof(sum([cast( byte)1])) == int)); static assert(is(typeof(sum([cast(ubyte)1])) == int)); static assert(is(typeof(sum([ 1, 2, 3, 4])) == int)); static assert(is(typeof(sum([ 1U, 2U, 3U, 4U])) == uint)); static assert(is(typeof(sum([ 1L, 2L, 3L, 4L])) == long)); static assert(is(typeof(sum([1UL, 2UL, 3UL, 4UL])) == ulong)); int[] empty; assert(sum(empty) == 0); assert(sum([42]) == 42); assert(sum([42, 43]) == 42 + 43); assert(sum([42, 43, 44]) == 42 + 43 + 44); assert(sum([42, 43, 44, 45]) == 42 + 43 + 44 + 45); } version(mir_test) @safe pure nothrow unittest { static assert(is(typeof(sum([1.0, 2.0, 3.0, 4.0])) == double)); static assert(is(typeof(sum!double([ 1F, 2F, 3F, 4F])) == double)); const(float[]) a = [1F, 2F, 3F, 4F]; static assert(is(typeof(sum!double(a)) == double)); const(float)[] b = [1F, 2F, 3F, 4F]; static assert(is(typeof(sum!double(a)) == double)); double[] empty; assert(sum(empty) == 0); assert(sum([42.]) == 42); assert(sum([42., 43.]) == 42 + 43); assert(sum([42., 43., 44.]) == 42 + 43 + 44); assert(sum([42., 43., 44., 45.5]) == 42 + 43 + 44 + 45.5); } version(mir_test) @safe pure nothrow unittest { import mir.ndslice.topology: iota; assert(iota(2, 3).sum == 15); } version(mir_test) @safe pure nothrow unittest { import std.container; static assert(is(typeof(sum!double(SList!float()[])) == double)); static assert(is(typeof(sum(SList!double()[])) == double)); static assert(is(typeof(sum(SList!real()[])) == real)); assert(sum(SList!double()[]) == 0); assert(sum(SList!double(1)[]) == 1); assert(sum(SList!double(1, 2)[]) == 1 + 2); assert(sum(SList!double(1, 2, 3)[]) == 1 + 2 + 3); assert(sum(SList!double(1, 2, 3, 4)[]) == 10); } version(mir_test) pure nothrow unittest // 12434 { import mir.ndslice.slice: sliced; import mir.ndslice.topology: map; immutable a = [10, 20]; auto s = a.sliced; auto s1 = sum(a); // Error auto s2 = s.map!(x => x).sum; // Error } version(mir_test) unittest { import std.bigint; import mir.ndslice.topology: repeat; auto a = BigInt("1_000_000_000_000_000_000").repeat(10); auto b = (ulong.max/2).repeat(10); auto sa = a.sum(); auto sb = b.sum(BigInt(0)); //reduce ulongs into bigint assert(sa == BigInt("10_000_000_000_000_000_000")); assert(sb == (BigInt(ulong.max/2) * 10)); } version(mir_test) unittest { with(Summation) foreach (F; AliasSeq!(float, double, real)) { F[] ar = [1, 2, 3, 4]; F r = 10; assert(r == ar.sum!fast()); assert(r == ar.sum!pairwise()); assert(r == ar.sum!kahan()); assert(r == ar.sum!kbn()); assert(r == ar.sum!kb2()); } } version(mir_test) unittest { assert(sum(1) == 1); assert(sum(1, 2, 3) == 6); assert(sum(1.0, 2.0, 3.0) == 6); } version(mir_test) unittest { assert(sum!float(1) == 1f); assert(sum!float(1, 2, 3) == 6f); assert(sum!float(1.0, 2.0, 3.0) == 6f); } version(mir_test) unittest { import mir.complex: Complex; assert(sum(Complex!float(1.0, 1.0), Complex!float(2.0, 2.0), Complex!float(3.0, 3.0)) == Complex!float(6.0, 6.0)); assert(sum!(Complex!float)(Complex!float(1.0, 1.0), Complex!float(2.0, 2.0), Complex!float(3.0, 3.0)) == Complex!float(6.0, 6.0)); } version(LDC) version(X86_Any) version(mir_test) unittest { import core.simd; static if (__traits(compiles, double2.init + double2.init)) { alias S = Summation; alias sums = AliasSeq!(S.kahan, S.pairwise, S.naive, S.fast); double2[] ar = [double2([1.0, 2]), double2([2, 3]), double2([3, 4]), double2([4, 6])]; double2 c = double2([10, 15]); foreach (sumType; sums) { double2 s = ar.sum!(sumType); assert(s.array == c.array); } } } version(LDC) version(X86_Any) version(mir_test) unittest { import core.simd; import mir.ndslice.topology: iota, as; alias S = Summation; alias sums = AliasSeq!(S.kahan, S.pairwise, S.naive, S.fast, S.precise, S.kbn, S.kb2); int[2] ns = [9, 101]; foreach (n; ns) { foreach (sumType; sums) { auto ar = iota(n).as!double; double c = n * (n - 1) / 2; // gauss for n=100 double s = ar.sum!(sumType); assert(s == c); } } } // Confirm sum works for Slice!(const(double)*, 1)) version(mir_test) @safe pure nothrow unittest { import mir.ndslice.slice: sliced; double[] x = [1.0, 2, 3]; auto y = x.sliced; auto z = y.toConst; assert(z.sum == 6); assert(z.sum(0.0) == 6); assert(z.sum!double == 6); assert(z.sum!double(0.0) == 6); } // Confirm sum works for const(Slice!(double*, 1)) version(mir_test) @safe pure nothrow unittest { import mir.ndslice.slice: sliced; double[] x = [1.0, 2, 3]; auto y = x.sliced; const z = y; assert(z.sum == 6); assert(z.sum(0.0) == 6); assert(z.sum!double == 6); assert(z.sum!double(0.0) == 6); } // Confirm sum works for const(Slice!(const(double)*, 1)) version(mir_test) @safe pure nothrow unittest { import mir.ndslice.slice: sliced; double[] x = [1.0, 2, 3]; auto y = x.sliced; const z = y.toConst; assert(z.sum == 6); assert(z.sum(0.0) == 6); assert(z.sum!double == 6); assert(z.sum!double(0.0) == 6); } package(mir) template ResolveSummationType(Summation summation, Range, F) { static if (summation == Summation.appropriate) { static if (isSummable!(Range, F)) enum ResolveSummationType = Summation.pairwise; else static if (is(F == class) || is(F == struct) || is(F == interface)) enum ResolveSummationType = Summation.naive; else enum ResolveSummationType = Summation.fast; } else { enum ResolveSummationType = summation; } } private T summationInitValue(T)() { static if (__traits(compiles, {T a = 0.0;})) { T a = 0.0; return a; } else static if (__traits(compiles, {T a = 0;})) { T a = 0; return a; } else static if (__traits(compiles, {T a = 0 + 0fi;})) { T a = 0 + 0fi; return a; } else { return T.init; } } package(mir) template elementType(T) { import mir.ndslice.slice: isSlice, DeepElementType; import std.traits: Unqual, ForeachType; static if (isIterable!T) { static if (isSlice!T) alias elementType = Unqual!(DeepElementType!(T.This)); else alias elementType = Unqual!(ForeachType!T); } else { alias elementType = Unqual!T; } } package(mir) template sumType(Range) { alias T = elementType!Range; static if (__traits(compiles, { auto a = T.init + T.init; a += T.init; })) alias sumType = typeof(T.init + T.init); else static assert(0, "sumType: Can't sum elements of type " ~ T.stringof); } /++ +/ template fillCollapseSums(Summation summation, alias combineParts, combineElements...) { import mir.ndslice.slice: Slice, SliceKind; /++ +/ auto ref fillCollapseSums(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) data) @property { import mir.algorithm.iteration; import mir.functional: naryFun; import mir.ndslice.topology: iota, triplets; foreach (triplet; data.length.iota.triplets) with(triplet) { auto ref ce(size_t i)() { static if (summation == Summation.fast) { return sum!summation(naryFun!(combineElements[i])(center, left )) + sum!summation(naryFun!(combineElements[i])(center, right)); } else { Summator!summation summator = 0; summator.put(naryFun!(combineElements[i])(center, left)); summator.put(naryFun!(combineElements[i])(center, right)); return summator.sum; } } alias sums = staticMap!(ce, Iota!(combineElements.length)); data[center] = naryFun!combineParts(center, sums); } } } package: template isSummable(F) { enum bool isSummable = __traits(compiles, { F a = 0.1, b, c; b = 2.3; c = a + b; c = a - b; a += b; a -= b; }); } template isSummable(Range, F) { enum bool isSummable = isIterable!Range && isImplicitlyConvertible!(sumType!Range, F) && isSummable!F; } version(mir_test) unittest { import mir.ndslice.topology: iota; static assert(isSummable!(typeof(iota([size_t.init])), double)); } private enum bool isCompesatorAlgorithm(Summation summation) = summation == Summation.precise || summation == Summation.kb2 || summation == Summation.kbn || summation == Summation.kahan; version(mir_test) unittest { import mir.ndslice; auto p = iota([2, 3, 4, 5]); auto a = p.as!double; auto b = a.flattened; auto c = a.slice; auto d = c.flattened; auto s = p.flattened.sum; assert(a.sum == s); assert(b.sum == s); assert(c.sum == s); assert(d.sum == s); assert(a.canonical.sum == s); assert(b.canonical.sum == s); assert(c.canonical.sum == s); assert(d.canonical.sum == s); assert(a.universal.transposed!3.sum == s); assert(b.universal.sum == s); assert(c.universal.transposed!3.sum == s); assert(d.universal.sum == s); assert(a.sum!"fast" == s); assert(b.sum!"fast" == s); assert(c.sum!(float, "fast") == s); assert(d.sum!"fast" == s); assert(a.canonical.sum!"fast" == s); assert(b.canonical.sum!"fast" == s); assert(c.canonical.sum!"fast" == s); assert(d.canonical.sum!"fast" == s); assert(a.universal.transposed!3.sum!"fast" == s); assert(b.universal.sum!"fast" == s); assert(c.universal.transposed!3.sum!"fast" == s); assert(d.universal.sum!"fast" == s); }
D
/Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/Protocol/MySQLComStmtPrepare.swift.o : /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeV10.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeResponse41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLColumnDefinition41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+OK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepareOK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/ByteBuffer+MySQL.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLData.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Metadata.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLGeneric.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Deprecated.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBind.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLAlterTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataTypeStaticRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataType.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepare.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabase.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketState.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtExecute.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabaseConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+TransportConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Data/MySQLData+Decimal.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBoolLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDefaultLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLColumn.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFractionalSecondsPrecision.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLCollation.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFunction.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLNullBitmap.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLProvider.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLLogger.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLIdentifier.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnectionHandler.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/MySQLError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCapabilities.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLStatusFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLDataFormat.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Connect.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCharacterSet.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLEOFPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLErrorPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLPrimaryKeyDefault.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLInsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLUpsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+SSLRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLResultSetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryResultsetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDropIndex.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Query.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+SimpleQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentMySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/Protocol/MySQLComStmtPrepare~partial.swiftmodule : /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeV10.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeResponse41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLColumnDefinition41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+OK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepareOK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/ByteBuffer+MySQL.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLData.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Metadata.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLGeneric.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Deprecated.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBind.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLAlterTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataTypeStaticRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataType.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepare.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabase.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketState.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtExecute.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabaseConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+TransportConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Data/MySQLData+Decimal.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBoolLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDefaultLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLColumn.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFractionalSecondsPrecision.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLCollation.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFunction.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLNullBitmap.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLProvider.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLLogger.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLIdentifier.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnectionHandler.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/MySQLError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCapabilities.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLStatusFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLDataFormat.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Connect.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCharacterSet.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLEOFPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLErrorPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLPrimaryKeyDefault.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLInsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLUpsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+SSLRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLResultSetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryResultsetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDropIndex.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Query.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+SimpleQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentMySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/Protocol/MySQLComStmtPrepare~partial.swiftdoc : /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeV10.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeResponse41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLColumnDefinition41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+OK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepareOK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/ByteBuffer+MySQL.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLData.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Metadata.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLGeneric.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Deprecated.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBind.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLAlterTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataTypeStaticRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataType.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepare.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabase.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketState.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtExecute.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabaseConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+TransportConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Data/MySQLData+Decimal.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBoolLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDefaultLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLColumn.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFractionalSecondsPrecision.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLCollation.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFunction.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLNullBitmap.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLProvider.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLLogger.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLIdentifier.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnectionHandler.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/MySQLError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCapabilities.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLStatusFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLDataFormat.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Connect.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCharacterSet.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLEOFPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLErrorPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLPrimaryKeyDefault.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLInsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLUpsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+SSLRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLResultSetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryResultsetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDropIndex.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Query.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+SimpleQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentMySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/Protocol/MySQLComStmtPrepare~partial.swiftsourceinfo : /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeV10.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+HandshakeResponse41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLColumnDefinition41.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+OK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepareOK.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/ByteBuffer+MySQL.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLData.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Metadata.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLGeneric.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Deprecated.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBind.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLAlterTable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataTypeStaticRepresentable.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDataType.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtPrepare.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabase.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketState.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComStmtExecute.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryValue.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLDatabaseConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+TransportConfig.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Data/MySQLData+Decimal.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLBoolLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDefaultLiteral.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLColumn.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFractionalSecondsPrecision.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLCollation.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLFunction.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLNullBitmap.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLProvider.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowDecoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Codable/MySQLDataEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Pipeline/MySQLPacketEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/OldMySQLRowEncoder.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Database/MySQLLogger.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLIdentifier.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnectionHandler.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/MySQLError.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCapabilities.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLStatusFlags.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Utilities/Exports.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLDataFormat.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Connect.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLCharacterSet.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLEOFPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLErrorPacket.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLPrimaryKeyDefault.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLInsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLUpsert.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLPacket+SSLRequest.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLResultSetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLBinaryResultsetRow.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLDropIndex.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+Query.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/SQL/MySQLQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Connection/MySQLConnection+SimpleQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/mysql/Sources/MySQL/Protocol/MySQLComQuery.swift /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/XPC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/ObjectiveC.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Combine.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Dispatch.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Darwin.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Foundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreFoundation.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/CoreGraphics.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/Swift.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/IOKit.swiftmodule/x86_64-apple-macos.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.swiftmodule /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.swiftmodule /usr/local/Cellar/libressl/3.0.2/include/openssl/asn1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/tls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dtls1.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs12.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem2.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl23.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509v3.h /usr/local/Cellar/libressl/3.0.2/include/openssl/md5.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pkcs7.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509.h /usr/local/Cellar/libressl/3.0.2/include/openssl/sha.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rsa.h /usr/local/Cellar/libressl/3.0.2/include/openssl/obj_mac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/hmac.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ec.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/cpp_magic.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/ifaddrs-android.h /usr/local/Cellar/libressl/3.0.2/include/openssl/rand.h /usr/local/Cellar/libressl/3.0.2/include/openssl/conf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslconf.h /usr/local/Cellar/libressl/3.0.2/include/openssl/dh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ecdh.h /usr/local/Cellar/libressl/3.0.2/include/openssl/lhash.h /usr/local/Cellar/libressl/3.0.2/include/openssl/stack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/safestack.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl/Sources/CNIOOpenSSL/include/c_nio_openssl.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CCryptoOpenSSL/include/c_crypto_openssl.h /usr/local/Cellar/libressl/3.0.2/include/openssl/pem.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bn.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIODarwin/include/CNIODarwin.h /usr/local/Cellar/libressl/3.0.2/include/openssl/bio.h /usr/local/Cellar/libressl/3.0.2/include/openssl/crypto.h /usr/local/Cellar/libressl/3.0.2/include/openssl/srtp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/evp.h /usr/local/Cellar/libressl/3.0.2/include/openssl/ossl_typ.h /usr/local/Cellar/libressl/3.0.2/include/openssl/buffer.h /usr/local/Cellar/libressl/3.0.2/include/openssl/err.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOAtomics/include/CNIOAtomics.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslfeatures.h /usr/local/Cellar/libressl/3.0.2/include/openssl/objects.h /usr/local/Cellar/libressl/3.0.2/include/openssl/opensslv.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio/Sources/CNIOLinux/include/CNIOLinux.h /usr/local/Cellar/libressl/3.0.2/include/openssl/x509_vfy.h /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOSHA1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOHTTP1.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/MySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentMySQL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CCryptoOpenSSL.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIO.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/HTTP.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOTLS.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOZlib.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Async.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Command.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Service.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Console.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Core.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentSQLite.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOPriorityQueue.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Logging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Debugging.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Routing.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/SQLBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/FluentBenchmark.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/COperatingSystem.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Random.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/URLEncodedForm.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIODarwin.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Authentication.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Validation.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Crypto.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/App.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOHTTPParser.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Vapor.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOAtomics.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOConcurrencyHelpers.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Bits.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOFoundationCompat.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/WebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/NIOWebSocket.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/DatabaseKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/TemplateKit.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Fluent.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/Multipart.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/x86_64-apple-macosx/debug/CNIOLinux.build/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBase32/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/crypto/Sources/CBcrypt/include/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-zlib-support/module.modulemap /Users/panartem/Developer/Study/Microservices-vapor/TILAppAcronyms/.build/checkouts/swift-nio-ssl-support/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/xpc/XPC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
/* glut.h */ module opengl.glutextern; /* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ /* This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ version (Windows) extern (Windows): else extern (C): /* Stroke font opaque addresses (use constants instead in source code). */ void *glutStrokeRoman; void *glutStrokeMonoRoman; /* Bitmap font opaque addresses (use constants instead in source code). */ void *glutBitmap9By15; void *glutBitmap8By13; void *glutBitmapTimesRoman10; void *glutBitmapTimesRoman24; void *glutBitmapHelvetica10 ; void *glutBitmapHelvetica12; void *glutBitmapHelvetica18;
D
module game.core.speed; static import basics.globals; import basics.alleg5; import net.repdata; // Phyu import basics.user; // replayAfterFrameBack import game.core.game; import game.core.active; // findAgainHighlitLixAfterPhyu import game.panel.base; import hardware.mouse; import hardware.sound; package: void updatePhysicsAccordingToSpeedButtons(Game game) { with (game) { import game.model.cache : DuringTurbo; void upd(in int howmany = 1, in DuringTurbo duringTurbo = DuringTurbo.no) { immutable before = nurse.upd; // Don't send undispatched via network, we did that earlier already. // Some from undispatchedAssignments have even come from the net. nurse.addReplayDataMaybeGoBack(undispatchedAssignments); undispatchedAssignments = null; nurse.updateTo(Phyu(before + howmany), duringTurbo); game.findAgainHighlitLixAfterPhyu(); game.setLastPhyuToNow(); } if (pan.framestepBackOne) { game.framestepBackBy(1); } else if (pan.framestepBackMany) { game.framestepBackBy(Game.updatesBackMany); } else if (pan.restart) { game.restartLevel(); } else if (pan.saveState) { nurse.saveUserState(); hardware.sound.playLoud(Sound.DISKSAVE); } else if (pan.loadState) { if (! nurse.userStateExists) hardware.sound.playLoud(Sound.PANEL_EMPTY); else with (LoadStateRAII(game)) if (nurse.loadUserStateDoesItMismatch) hardware.sound.playLoud(Sound.SCISSORS); } else if (pan.framestepAheadOne) { upd(); } else if (pan.framestepAheadMany) { upd(updatesAheadMany); } else if (pan.paused && ! pan.isMouseHere && mouseClickLeft) { // Clicking into the non-panel screen advances physics once. // This happens both when we unpause on assignment and when we // merely advance 1 frame, but keep the game paused, on assignment. // This happens either because you've assigned something, or because // you have cancelled the replay. upd(); } else if (! pan.paused) { if (pan.speedIsNormal) { if (game.shallWeUpdateAtAdjustedNormalSpeed()) upd(); } else if (pan.speedIsTurbo) upd(updatesDuringTurbo, DuringTurbo.yes); else { assert (pan.speedIsFast); upd(); } } }} // end with (game), end function updatePhysicsAccordingToSpeedButtons void restartLevel(Game game) { game.pan.setSpeedNormal(); with (LoadStateRAII(game)) game.nurse.restartLevel(); } void framestepBackBy(Game game, in int by) { with (LoadStateRAII(game)) { game.nurse.framestepBackBy(by); if (! replayAfterFrameBack.value) game.cancelReplay(); } } // The server tells us the milliseconds since game start, and the net client // has added our lag. We think in Phyus or Allegro ticks, not in millis, // therefore convert millis to Phyus. void adjustToMatchMillisecondsSinceGameStart(Game game, in int suggMillis) { with (game) with (game.nurse) { // How many ticks have elapsed since game start? This is the number of // completed Phyus converted to ticks, plus leftover ticks that didn't // yet make a complete Phyu. immutable ourTicks = updatesSinceZero * ticksNormalSpeed + (timerTicks - altickLastPhyu); immutable suggTicks = suggMillis * basics.globals.ticksPerSecond / 1000; game._alticksToAdjust = suggTicks - ourTicks; }} private: struct LoadStateRAII { private Game _game; this(Game g) { _game = g; _game.saveTrophy(); } ~this() { _game.setLastPhyuToNow(); } } // Combat the network time-lag, affect _alticksToAdjust. // _alticksToAdjust is < 0 if we have to slow down, > 0 if we have to speed up. bool shallWeUpdateAtAdjustedNormalSpeed(Game game) { with (game) { immutable long updAgo = timerTicks - game.altickLastPhyu; immutable long adjust = _alticksToAdjust < -20 ? 2 : _alticksToAdjust < 0 ? 1 : _alticksToAdjust > 20 ? -2 : _alticksToAdjust > 0 ? -1 : 0; if (updAgo >= ticksNormalSpeed + adjust) { _alticksToAdjust += adjust; return true; } return false; }}
D
module perfontain.meshholder; import std, perfontain; final class MeshHolder : RCounted { this(ref in HolderData v) { _iv = PE.render.drawAlloc[v.type].iv; texs = v .textures .map!(a => new Texture(a)) .array; meshes = v.meshes; reg = _iv.alloc(v.data); } ~this() { _iv.dealloc(reg); } const { RegionIV reg; HolderMesh[] meshes; RCArray!Texture texs; } const size() { assert(texs.length == 1); return texs[0].size; } private: IndexVertex _iv; }
D
/Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ICandleChartDataSet.o : /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Legend.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Description.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform+Accessibility.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxAtomic/RxAtomic.modulemap /Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxSwift/RxSwift.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ICandleChartDataSet~partial.swiftmodule : /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Legend.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Description.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform+Accessibility.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxAtomic/RxAtomic.modulemap /Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxSwift/RxSwift.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ICandleChartDataSet~partial.swiftdoc : /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Legend.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/Description.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Charts/Source/Charts/Utils/Platform+Accessibility.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mli/Desktop/Develope/Swift/LBE_Demo/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxAtomic/RxAtomic.modulemap /Users/mli/Desktop/Develope/Swift/LBE_Demo/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Users/mli/Desktop/Develope/VLogVideo/Pods/Headers/Public/RxSwift/RxSwift.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
// REQUIRED_ARGS: import std.math: poly; import core.stdc.stdarg; extern(C) { int printf(const char*, ...); version(Windows) { int _snprintf(char*, size_t, const char*, ...); alias _snprintf snprintf; } else int snprintf(char*, size_t, const char*, ...); } version (LDC) static if (real.mant_dig != 64) version = LDC_NoX87; /*************************************/ // http://www.digitalmars.com/d/archives/digitalmars/D/bugs/4766.html // Only with -O real randx() { return 1.2; } void test1() { float x10=randx(); float x11=randx(); float x20=randx(); float x21=randx(); float y10=randx(); float y11=randx(); float y20=randx(); float y21=randx(); float tmp=( x20*x21 + y10*y10 + y10*y11 + y11*y11 + y11*y20 + y20*y20 + y10*y21 + y11*y21 + y21*y21); assert(tmp > 0); } /*************************************/ void test2() { double x10=randx(); double x11=randx(); double x20=randx(); double x21=randx(); double y10=randx(); double y11=randx(); double y20=randx(); double y21=randx(); double tmp=( x20*x21 + y10*y10 + y10*y11 + y11*y11 + y11*y20 + y20*y20 + y10*y21 + y11*y21 + y21*y21); assert(tmp > 0); } /*************************************/ void test3() { real x10=randx(); real x11=randx(); real x20=randx(); real x21=randx(); real y10=randx(); real y11=randx(); real y20=randx(); real y21=randx(); real tmp=( x20*x21 + y10*y10 + y10*y11 + y11*y11 + y11*y20 + y20*y20 + y10*y21 + y11*y21 + y21*y21); assert(tmp > 0); } /*************************************/ void test4() { printf("main() : (-128 >= 0)=%s, (-128 <= 0)=%s\n", cast(char*)(-128 >= 0 ? "true" : "false"), cast(char*)(-128 <= 0 ? "true" : "false")); printf("main() : (128 >= 0)=%s, (128 <= 0)=%s\n", cast(char*)(128 >= 0 ? "true" : "false"), cast(char*)(128 <= 0 ? "true" : "false")); assert((-128 >= 0 ? "true" : "false") == "false"), assert((-128 <= 0 ? "true" : "false") == "true"); assert((+128 >= 0 ? "true" : "false") == "true"), assert((+128 <= 0 ? "true" : "false") == "false"); } /*************************************/ int foo5() { assert(0); } // No return. int abc5() { printf("foo = %d\n", foo5()); return 0; } void test5() { } /*************************************/ void test6() { ireal a = 6.5i % 3i; printf("%Lfi %Lfi\n", a, a - .5i); assert(a == .5i); a = 6.5i % 3; printf("%Lfi %Lfi\n", a, a - .5i); assert(a == .5i); real b = 6.5 % 3i; printf("%Lf %Lf\n", b, b - .5); assert(b == .5); b = 6.5 % 3; printf("%Lf %Lf\n", b, b - .5); assert(b == .5); } /*************************************/ void test7() { cfloat f = 1+0i; f %= 2fi; printf("%f + %fi\n", f.re, f.im); assert(f == 1 + 0i); cdouble d = 1+0i; d %= 2i; printf("%f + %fi\n", d.re, d.im); assert(d == 1 + 0i); creal r = 1+0i; r %= 2i; printf("%Lf + %Lfi\n", r.re, r.im); assert(r == 1 + 0i); } /*************************************/ void test8() { cfloat f = 1+0i; f %= 2i; printf("%f + %fi\n", f.re, f.im); assert(f == 1); cdouble d = 1+0i; d = d % 2i; printf("%f + %fi\n", d.re, d.im); assert(d == 1); creal r = 1+0i; r = r % 2i; printf("%Lf + %Lfi\n", r.re, r.im); assert(r == 1); } /*************************************/ class A9 { this(int[] params ...) { for (int i = 0; i < params.length; i++) { assert(params[i] == i + 1); } } } class B9 { this() { init(); } private void init() { A9 test1 = new A9(1, 2, 3); A9 test2 = new A9(1, 2, 3, 4); int[3] arg; A9 test3 = new A9((arg[0]=1, arg[1]=2, arg[2]=3, arg)); } } void test9() { B9 test2 = new B9(); } /*************************************/ void test10() { auto i = 5u; auto s = typeid(typeof(i)).toString; printf("%.*s\n", s.length, s.ptr); assert(typeid(typeof(i)) == typeid(uint)); } /*************************************/ void test11() { printf("%d\n", 3); printf("xhello world!\n"); } /*************************************/ void assertEqual(real* a, real* b, string file = __FILE__, size_t line = __LINE__) { auto x = cast(ubyte*)a; auto y = cast(ubyte*)b; // Only compare the 10 value bytes, the padding bytes are of undefined // value. version (LDC_NoX87) enum count = real.sizeof; else version (X86) enum count = 10; else version (X86_64) enum count = 10; else enum count = real.sizeof; for (size_t i = 0; i < count; i++) { if (x[i] != y[i]) { printf("%02d: %02x %02x\n", i, x[i], y[i]); import core.exception; throw new AssertError(file, line); } } } void assertEqual(creal* a, creal* b, string file = __FILE__, size_t line = __LINE__) { assertEqual(cast(real*)a, cast(real*)b, file, line); assertEqual(cast(real*)a + 1, cast(real*)b + 1, file, line); } void test12() { creal a = creal.nan; creal b = real.nan + ireal.nan; assertEqual(&a, &b); real c= real.nan; real d=a.re; assertEqual(&c, &d); d=a.im; assertEqual(&c, &d); } /*************************************/ void test13() { creal a = creal.infinity; creal b = real.infinity + ireal.infinity; assertEqual(&a, &b); real c = real.infinity; real d=a.re; assertEqual(&c, &d); d=a.im; assertEqual(&c, &d); } /*************************************/ void test14() { creal a = creal.nan; creal b = creal.nan; b = real.nan + ireal.nan; assertEqual(&a, &b); real c = real.nan; real d=a.re; assertEqual(&c, &d); d=a.im; assertEqual(&c, &d); } /*************************************/ ireal x15; void foo15() { x15 = -x15; } void bar15() { return foo15(); } void test15() { x15=2i; bar15(); assert(x15==-2i); } /*************************************/ real x16; void foo16() { x16 = -x16; } void bar16() { return foo16(); } void test16() { x16=2; bar16(); assert(x16==-2); } /*************************************/ class Bar17 { this(...) {} } class Foo17 { void opAdd (Bar17 b) {} } void test17() { auto f = new Foo17; f + new Bar17; } /*************************************/ template u18(int n) { static if (n==1) { int a = 1; } else int b = 4; } void test18() { mixin u18!(2); assert(b == 4); } /*************************************/ class DP { private: void I(char[] p) { I(p[1..p.length]); } } void test19() { } /*************************************/ struct Struct20 { int i; } void test20() { auto s = new Struct20; s.i = 7; } /*************************************/ class C21(float f) { float ff = f; } void test21() { auto a = new C21!(1.2); C21!(1.2) b = new C21!(1.2); } /*************************************/ void test22() { static creal[] params = [1+0i, 3+0i, 5+0i]; printf("params[0] = %Lf + %Lfi\n", params[0].re, params[0].im); printf("params[1] = %Lf + %Lfi\n", params[1].re, params[1].im); printf("params[2] = %Lf + %Lfi\n", params[2].re, params[2].im); creal[] sums = new creal[3]; sums[] = 0+0i; foreach(creal d; params) { creal prod = d; printf("prod = %Lf + %Lfi\n", prod.re, prod.im); for(int i; i<2; i++) { sums[i] += prod; prod *= d; } sums[2] += prod; } printf("sums[0] = %Lf + %Lfi", sums[0].re, sums[0].im); assert(sums[0].re==9); assert(sums[0].im==0); assert(sums[1].re==35); assert(sums[1].im==0); assert(sums[2].re==153); assert(sums[2].im==0); } /*************************************/ const int c23 = b23 * b23; const int a23 = 1; const int b23 = a23 * 3; template T23(int n) { int[n] x23; } mixin T23!(c23); void test23() { assert(x23.length==9); } /*************************************/ ifloat func_24_1(ifloat f, double d) { // f /= cast(cdouble)d; return f; } ifloat func_24_2(ifloat f, double d) { f = cast(ifloat)(f / cast(cdouble)d); return f; } float func_24_3(float f, double d) { // f /= cast(cdouble)d; return f; } float func_24_4(float f, double d) { f = cast(float)(f / cast(cdouble)d); return f; } void test24() { ifloat f = func_24_1(10i, 8); printf("%fi\n", f); // assert(f == 1.25i); f = func_24_2(10i, 8); printf("%fi\n", f); assert(f == 1.25i); float g = func_24_3(10, 8); printf("%f\n", g); // assert(g == 1.25); g = func_24_4(10, 8); printf("%f\n", g); assert(g == 1.25); } /*************************************/ template cat(int n) { const int dog = n; } const char [] bird = "canary"; const int sheep = cat!(bird.length).dog; void test25() { assert(sheep == 6); } /*************************************/ string toString26(cdouble z) { char[ulong.sizeof*8] buf; auto len = snprintf(buf.ptr, buf.sizeof, "%f+%fi", z.re, z.im); return buf[0 .. len].idup; } void test26() { static cdouble[] A = [1+0i, 0+1i, 1+1i]; string s; foreach( cdouble z; A ) { s = toString26(z); printf("%.*s ", s.length, s.ptr); } printf("\n"); for(int ii=0; ii<A.length; ii++ ) A[ii] += -1i*A[ii]; assert(A[0] == 1 - 1i); assert(A[1] == 1 + 1i); assert(A[2] == 2); foreach( cdouble z; A ) { s = toString26(z); printf("%.*s ", s.length, s.ptr); } printf("\n"); } /*************************************/ void test27() { int x; string s = (int*function(int ...)[]).mangleof; printf("%.*s\n", s.length, s.ptr); assert((int*function(int ...)[]).mangleof == "APFiXPi"); assert(typeof(x).mangleof == "i"); assert(x.mangleof == "_D6test226test27FZ1xi"); } /*************************************/ void test28() { alias cdouble X; X four = cast(X) (4.0i + 0.4); } /*************************************/ void test29() { ulong a = 10_000_000_000_000_000, b = 1_000_000_000_000_000; printf("test29\n%lx\n%lx\n%lx\n", a, b, a / b); assert((a / b) == 10); } static assert((10_000_000_000_000_000 / 1_000_000_000_000_000) == 10); /*************************************/ template chook(int n) { const int chook = 3; } template dog(alias f) { const int dog = chook!(f.mangleof.length); } class pig {} const int goose = dog!(pig); void test30() { printf("%d\n", goose); assert(goose == 3); } /*************************************/ template dog31(string sheep) { immutable string dog31 = "daschund"; } void test31() { string duck = dog31!("bird"[1..3]); assert(duck == "daschund"); } /*************************************/ struct particle { int active; /* Active (Yes/No) */ float life; /* Particle Life */ float fade; /* Fade Speed */ float r; /* Red Value */ float g; /* Green Value */ float b; /* Blue Value */ float x; /* X Position */ float y; /* Y Position */ float xi; /* X Direction */ float yi; /* Y Direction */ float xg; /* X Gravity */ float yg; /* Y Gravity */ } particle particles[10000]; void test32() { } /*************************************/ class Foo33 { template foo() { int foo() { return 6; } } } void test33() { Foo33 f = new Foo33; assert(f.foo!()() == 6); with (f) assert(foo!()() == 6); } /*************************************/ template dog34(string duck) { const int dog34 = 2; } void test34() { int aardvark = dog34!("cat" ~ "pig"); assert(aardvark == 2); } /*************************************/ class A35 { private bool quit; void halt() {quit = true;} bool isHalted() {return quit;} } void test35() { auto a = new A35; a.halt; // error here a.halt(); a.isHalted; // error here bool done = a.isHalted; if (a.isHalted) { } } /*************************************/ void test36() { bool q = (0.9 + 3.5L == 0.9L + 3.5L); assert(q); static assert(0.9 + 3.5L == 0.9L + 3.5L); assert(0.9 + 3.5L == 0.9L + 3.5L); } /*************************************/ abstract class Foo37(T) { void bar () { } } class Bar37 : Foo37!(int) { } void test37() { auto f = new Bar37; } /*************************************/ void test38() { auto s=`hello`; assert(s.length==5); assert(s[0]=='h'); assert(s[1]=='e'); assert(s[2]=='l'); assert(s[3]=='l'); assert(s[4]=='o'); } /*************************************/ void test39() { int value=1; string key = "eins"; int[char[]] array; array[key]=value; int* ptr = key in array; assert(value == *ptr); } /*************************************/ void test40() { auto s=r"hello"; assert(s.length==5); assert(s[0]=='h'); assert(s[1]=='e'); assert(s[2]=='l'); assert(s[3]=='l'); assert(s[4]=='o'); } /*************************************/ void test41() { version (Windows) { version(D_InlineAsm){ double a = 1.2; double b = 0.2; double c = 1.4; asm{ movq XMM0, a; movq XMM1, b; addsd XMM1, XMM0; movq c, XMM1; } a += b; b = a-c; b = (b>0) ? b : (-1 * b); assert(b < b.epsilon*4); } } } /*************************************/ const char[] tapir = "some horned animal"; const byte[] antelope = cast(byte []) tapir; void test42() { } /*************************************/ void test43() { string armadillo = "abc" ~ 'a'; assert(armadillo == "abca"); string armadillo2 = 'b' ~ "abc"; assert(armadillo2 == "babc"); } /*************************************/ const uint baboon44 = 3; const int monkey44 = 4; const ape44 = monkey44 * baboon44; void test44() { assert(ape44 == 12); } /*************************************/ class A45 { this() { b = new B(); b.x = 5; // illegal } class B { protected int x; } B b; } void test45() { } /*************************************/ class C46(T) { private T i; // or protected or package } void test46() { C46!(int) c = new C46!(int); // class t4.C46!(int).C46 member i is not accessible c.i = 10; } /*************************************/ void bug5809() { ushort[2] x = void; x[0] = 0; x[1] = 0x1234; ushort *px = &x[0]; uint b = px[0]; assert(px[0] == 0); } /*************************************/ void bug7546() { double p = -0.0; assert(p == 0); } /*************************************/ real poly_asm(real x, real[] A) in { assert(A.length > 0); } body { version (LDC_NoX87) { return 0; } else version (D_InlineAsm_X86) { version (linux) { asm // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX][ECX*8] ; add EDX,ECX ; add EDX,ECX ; add EDX,ECX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (OSX) { asm // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; add EDX,EDX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -16[EDX] ; sub EDX,16 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (FreeBSD) { asm // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX][ECX*8] ; add EDX,ECX ; add EDX,ECX ; add EDX,ECX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else { asm // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX][ECX*8] ; add EDX,ECX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -10[EDX] ; sub EDX,10 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } } else { printf("Sorry, you don't seem to have InlineAsm_X86\n"); return 0; } } real poly_c(real x, real[] A) in { assert(A.length > 0); } body { ptrdiff_t i = A.length - 1; real r = A[i]; while (--i >= 0) { r *= x; r += A[i]; } return r; } void test47() { real x = 3.1; static real pp[] = [56.1, 32.7, 6]; real r; printf("The result should be %Lf\n",(56.1L + (32.7L + 6L * x) * x)); printf("The C version outputs %Lf\n", poly_c(x, pp)); printf("The asm version outputs %Lf\n", poly_asm(x, pp)); printf("The std.math version outputs %Lf\n", poly(x, pp)); r = (56.1L + (32.7L + 6L * x) * x); assert(r == poly_c(x, pp)); version (LDC_NoX87) {} else version (D_InlineAsm_X86) assert(r == poly_asm(x, pp)); assert(r == poly(x, pp)); } /*************************************/ const c48 = 1uL-1; void test48() { assert(c48 == 0); } /*************************************/ template cat49() { static assert(1); // OK static if (1) { static assert(1); // doesn't work static if (1) { static assert(1); // OK const int cat49 = 3; } } } void test49() { const int a = cat49!(); assert(a == 3); } /*************************************/ void test50() { if (auto x = 1) { assert(typeid(typeof(x)) == typeid(int)); assert(x == 1); } else assert(0); if (int x = 1) { assert(typeid(typeof(x)) == typeid(int)); assert(x == 1); } else assert(0); if (1) { } else assert(0); } /*************************************/ void test51() { bool b; assert(b == false); b &= 1; assert(b == false); b |= 1; assert(b == true); b ^= 1; assert(b == false); b = b | true; assert(b == true); b = b & false; assert(b == false); b = b ^ true; assert(b == true); b = !b; assert(b == false); } /*************************************/ alias int function (int) x52; template T52(string str){ const int T52 = 1; } static assert(T52!(x52.mangleof)); void test52() { } /*************************************/ import std.stdio; import core.stdc.stdarg; void myfunc(int a1, ...) { va_list argument_list; TypeInfo argument_type; string sa; int ia; double da; writefln("%d variable arguments", _arguments.length); writefln("argument types %s", _arguments); va_start(argument_list, a1); for (int i = 0; i < _arguments.length; ) { if ((argument_type=_arguments[i++]) == typeid(string)) { va_arg(argument_list, sa); writefln("%d) string arg = '%s', length %d", i+1, sa.length<=20? sa : "?", sa.length); } else if (argument_type == typeid(int)) { va_arg(argument_list, ia); writefln("%d) int arg = %d", i+1, ia); } else if (argument_type == typeid(double)) { va_arg(argument_list, da); writefln("%d) double arg = %f", i+1, da); } else { throw new Exception("invalid argument type"); } } va_end(argument_list); } void test6758() { myfunc(1, 2, 3, 4, 5, 6, 7, 8, "9", "10"); // Fails. myfunc(1, 2.0, 3, 4, 5, 6, 7, 8, "9", "10"); // Works OK. myfunc(1, 2, 3, 4, 5, 6, 7, "8", "9", "10"); // Works OK. myfunc(1, "2", 3, 4, 5, 6, 7, 8, "9", "10"); // Works OK. } /*************************************/ int main() { test1(); test2(); test3(); test4(); test5(); test6(); test7(); test8(); test9(); test10(); test11(); test12(); test13(); test14(); test15(); test16(); test17(); test18(); test19(); test20(); test21(); test22(); test23(); test24(); test25(); test26(); test27(); test28(); test29(); test30(); test31(); test32(); test33(); test34(); test35(); test36(); test37(); test38(); test39(); test40(); test41(); test42(); test43(); test44(); test45(); test46(); bug5809(); bug7546(); test47(); test48(); test49(); test50(); test51(); test52(); test6758(); printf("Success\n"); return 0; }
D
module mach.text.json.json; private: import mach.text.parse.numeric : WriteFloatSettings; import mach.text.json.exceptions; import mach.text.json.attributes; import mach.text.json.parse; import mach.text.json.serialize; import mach.text.json.value; public: struct Json{ /// Type which stores information for a json value. static alias Value = JsonValue; static enum FloatSettings{ Default = JsonValue.EncodeFloatSettingsDefault, Extended = JsonValue.EncodeFloatSettingsExtended, Standard = JsonValue.EncodeFloatSettingsStandard } /// Given a value of an arbitrary type, generate a `Json.Value` object. static alias serialize = jsonserialize; /// Given a json string, parse json values. static auto parse( WriteFloatSettings floatsettings = FloatSettings.Default )(in string json){ return json.parsejson!floatsettings; } /// Given a json string, parse a value of the given type. static auto parse( T, WriteFloatSettings floatsettings = FloatSettings.Default )(in string json){ return json.parsejson!floatsettings.jsondeserialize!T; } /// Given a value of an arbitrary type, serialize to compact json. static auto encode( WriteFloatSettings floatsettings = FloatSettings.Default, T )(auto ref T value){ return value.jsonserialize.encode!floatsettings; } /// Given a value of an arbitrary type, serialize to pretty-printable json. static auto pretty( string indent = " ", WriteFloatSettings floatsettings = FloatSettings.Default, T )(auto ref T value){ return value.jsonserialize.pretty!(indent, floatsettings); } /// UDA which indicates a field should be ignored when serializing json /// for a type. static alias Skip = JsonSerializeSkip; // Aliases to common exception classes follow: /// Base class for json exceptions. static alias Exception = JsonException; /// Exception thrown when attempting to perform an unsupported operation /// on a `Json.Value` object. static alias InvalidOperationException = JsonInvalidOperationException; /// Exception thrown when failing to parse a json string. static alias ParseException = JsonParseException; /// Exception thrown when failing to serialize an object to json. static alias SerializationException = JsonSerializationException; /// Exception thrown when failing to deserialize an object from json. static alias DeserializationException = JsonDeserializationException; }
D
/* * Copyright (c) 2017-2019 sel-project * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ /** * Copyright: Copyright (c) 2017-2019 sel-project * License: MIT * Authors: Kripth * Source: $(HTTP github.com/sel-project/selery/source/selery/event/world/world.d, selery/event/world/world.d) */ module selery.event.world.world; import selery.about : tick_t; import selery.entity.entity : Entity; import selery.event.event : Event, Cancellable; import selery.math.vector : EntityPosition; import selery.world.world : World; /** * Generic event related to the world. */ interface WorldEvent : Event { /** * Gets the world where the event has happened. */ public pure nothrow @property @safe @nogc World world(); public static mixin template Implementation() { private World n_world; public final override pure nothrow @property @safe @nogc World world() { return this.n_world; } } } /** * Called it starts to rain or snow in the world. */ final class StartRainEvent : WorldEvent, Cancellable { mixin Cancellable.Implementation; mixin WorldEvent.Implementation; private tick_t m_duration; public pure nothrow @safe @nogc this(World world, tick_t duration) { this.n_world = world; this.m_duration = duration; } /** * Gets the duration of the precipitations is ticks. */ public pure nothrow @property @safe @nogc tick_t duration() { return this.m_duration; } /** * Sets the duration of the precipitation in ticks. * Example: * --- * event.duration = 1; * --- */ public pure nothrow @property @safe @nogc tick_t duration(tick_t duration) { return this.m_duration = duration; } } /// ditto alias StartSnowEvent = StartRainEvent; /** * Event called when it stops to rain or snow in the world. */ final class StopRainEvent : WorldEvent { mixin WorldEvent.Implementation; public pure nothrow @safe @nogc this(World world) { this.n_world = world; } } /// ditto alias StopSnowEvent = StopRainEvent; /** * Event called when a lighting strikes in the world. */ final class LightningStrikeEvent : WorldEvent, Cancellable { mixin Cancellable.Implementation; mixin WorldEvent.Implementation; private EntityPosition n_position; private Entity n_target; public pure nothrow @safe @nogc this(World world, EntityPosition position) { this.n_world = world; this.n_position = position; } public pure nothrow @safe @nogc this(World world, Entity target) { this(world, target.position); this.n_target = target; } /** * Gets the position where the lightning has struck. */ public pure nothrow @property @safe @nogc EntityPosition position() { return this.n_position; } /** * Gets the target of the lightning, it may be null if the lightning * struck randomly. */ public pure nothrow @property @safe @nogc Entity target() { return this.n_target; } } interface ExplosionEvent : WorldEvent, Cancellable { public pure nothrow @property @safe @nogc float power(); public pure nothrow @property @safe @nogc float power(float power); mixin template Implementation() { mixin Cancellable.Implementation; private float m_power; public override pure nothrow @property @safe @nogc float power() { return this.m_power; } public override pure nothrow @property @safe @nogc float power(float power) { return this.m_power = power; } } }
D
/******************************************************************************* Turtle application-specific exception classes Copyright: Copyright (c) 2015-2017 sociomantic labs GmbH. All rights reserved License: Boost Software License Version 1.0. See LICENSE for details. *******************************************************************************/ module turtle.Exception; import ocean.transition; /******************************************************************************* Thrown if any of turtle utilities fail before getting to actual test cases. *******************************************************************************/ class TurtleException : Exception { /*************************************************************************** Constructor Params: msg = exception message ***************************************************************************/ this ( istring msg, istring file = __FILE__, long line = __LINE__ ) { super(msg, file, line, null); } }
D
/home/pi/Veilige_soft_test/test_project/test_project/target/release/deps/libcfg_if-9db7b6e92b363072.rlib: /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.7/src/lib.rs /home/pi/Veilige_soft_test/test_project/test_project/target/release/deps/cfg_if-9db7b6e92b363072.d: /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.7/src/lib.rs /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.7/src/lib.rs:
D
// Written in the D programming language. /++ $(P The $(D std.uni) module provides an implementation of fundamental Unicode algorithms and data structures. This doesn't include UTF encoding and decoding primitives, see $(XREF _utf, decode) and $(XREF _utf, encode) in std.utf for this functionality. ) $(P All primitives listed operate on Unicode characters and sets of characters. For functions which operate on ASCII characters and ignore Unicode $(CHARACTERS), see $(LINK2 std_ascii.html, std.ascii). For definitions of Unicode $(CHARACTER), $(CODEPOINT) and other terms used throughout this module see the $(S_LINK Terminology, terminology) section below. ) $(P The focus of this module is the core needs of developing Unicode-aware applications. To that effect it provides the following optimized primitives: ) $(UL $(LI Character classification by category and common properties: $(LREF isAlpha), $(LREF isWhite) and others. ) $(LI Case-insensitive string comparison ($(LREF sicmp), $(LREF icmp)). ) $(LI Converting text to any of the four normalization forms via $(LREF normalize). ) $(LI Decoding ($(LREF decodeGrapheme)) and iteration ($(LREF byGrapheme), $(LREF graphemeStride)) by user-perceived characters, that is by $(LREF Grapheme) clusters. ) $(LI Decomposing and composing of individual character(s) according to canonical or compatibility rules, see $(LREF compose) and $(LREF decompose), including the specific version for Hangul syllables $(LREF composeJamo) and $(LREF decomposeHangul). ) ) $(P It's recognized that an application may need further enhancements and extensions, such as less commonly known algorithms, or tailoring existing ones for region specific needs. To help users with building any extra functionality beyond the core primitives, the module provides: ) $(UL $(LI $(LREF CodepointSet), a type for easy manipulation of sets of characters. Besides the typical set algebra it provides an unusual feature: a D source code generator for detection of $(CODEPOINTS) in this set. This is a boon for meta-programming parser frameworks, and is used internally to power classification in small sets like $(LREF isWhite). ) $(LI A way to construct optimal packed multi-stage tables also known as a special case of $(LUCKY Trie). The functions $(LREF codepointTrie), $(LREF codepointSetTrie) construct custom tries that map dchar to value. The end result is a fast and predictable $(BIGOH 1) lookup that powers functions like $(LREF isAlpha) and $(LREF combiningClass), but for user-defined data sets. ) $(LI A useful technique for Unicode-aware parsers that perform character classification of encoded $(CODEPOINTS) is to avoid unnecassary decoding at all costs. $(LREF utfMatcher) provides an improvement over the usual workflow of decode-classify-process, combining the decoding and classification steps. By extracting necessary bits directly from encoded $(S_LINK Code unit, code units) matchers achieve significant performance improvements. See $(LREF MatcherConcept) for the common interface of UTF matchers. ) $(LI Generally useful building blocks for customized normalization: $(LREF combiningClass) for querying combining class and $(LREF allowedIn) for testing the Quick_Check property of a given normalization form. ) $(LI Access to a large selection of commonly used sets of $(CODEPOINTS). $(S_LINK Unicode properties, Supported sets) include Script, Block and General Category. The exact contents of a set can be observed in the CLDR utility, on the $(WEB www.unicode.org/cldr/utility/properties.jsp, property index) page of the Unicode website. See $(LREF unicode) for easy and (optionally) compile-time checked set queries. ) ) $(SECTION Synopsis) --- import std.uni; void main() { // initialize code point sets using script/block or property name // now 'set' contains code points from both scripts. auto set = unicode("Cyrillic") | unicode("Armenian"); // same thing but simpler and checked at compile-time auto ascii = unicode.ASCII; auto currency = unicode.Currency_Symbol; // easy set ops auto a = set & ascii; assert(a.empty); // as it has no intersection with ascii a = set | ascii; auto b = currency - a; // subtract all ASCII, Cyrillic and Armenian // some properties of code point sets assert(b.length > 45); // 46 items in Unicode 6.1, even more in 6.2 // testing presence of a code point in a set // is just fine, it is O(logN) assert(!b['$']); assert(!b['\u058F']); // Armenian dram sign assert(b['¥']); // building fast lookup tables, these guarantee O(1) complexity // 1-level Trie lookup table essentially a huge bit-set ~262Kb auto oneTrie = toTrie!1(b); // 2-level far more compact but typically slightly slower auto twoTrie = toTrie!2(b); // 3-level even smaller, and a bit slower yet auto threeTrie = toTrie!3(b); assert(oneTrie['£']); assert(twoTrie['£']); assert(threeTrie['£']); // build the trie with the most sensible trie level // and bind it as a functor auto cyrillicOrArmenian = toDelegate(set); auto balance = find!(cyrillicOrArmenian)("Hello ընկեր!"); assert(balance == "ընկեր!"); // compatible with bool delegate(dchar) bool delegate(dchar) bindIt = cyrillicOrArmenian; // Normalization string s = "Plain ascii (and not only), is always normalized!"; assert(s is normalize(s));// is the same string string nonS = "A\u0308ffin"; // A ligature auto nS = normalize(nonS); // to NFC, the W3C endorsed standard assert(nS == "Äffin"); assert(nS != nonS); string composed = "Äffin"; assert(normalize!NFD(composed) == "A\u0308ffin"); // to NFKD, compatibility decomposition useful for fuzzy matching/searching assert(normalize!NFKD("2¹⁰") == "210"); } --- $(SECTION Terminology) $(P The following is a list of important Unicode notions and definitions. Any conventions used specifically in this module alone are marked as such. The descriptions are based on the formal definition as found in $(WEB www.unicode.org/versions/Unicode6.2.0/ch03.pdf, chapter three of The Unicode Standard Core Specification.) ) $(P $(DEF Abstract character) A unit of information used for the organization, control, or representation of textual data. Note that: $(UL $(LI When representing data, the nature of that data is generally symbolic as opposed to some other kind of data (for example, visual).) $(LI An abstract character has no concrete form and should not be confused with a $(S_LINK Glyph, glyph).) $(LI An abstract character does not necessarily correspond to what a user thinks of as a “character” and should not be confused with a $(LREF Grapheme).) $(LI The abstract characters encoded (see Encoded character) are known as Unicode abstract characters.) $(LI Abstract characters not directly encoded by the Unicode Standard can often be represented by the use of combining character sequences.) ) ) $(P $(DEF Canonical decomposition) The decomposition of a character or character sequence that results from recursively applying the canonical mappings found in the Unicode Character Database and these described in Conjoining Jamo Behavior (section 12 of $(WEB www.unicode.org/uni2book/ch03.pdf, Unicode Conformance)). ) $(P $(DEF Canonical composition) The precise definition of the Canonical composition is the algorithm as specified in $(WEB www.unicode.org/uni2book/ch03.pdf, Unicode Conformance) section 11. Informally it's the process that does the reverse of the canonical decomposition with the addition of certain rules that e.g. prevent legacy characters from appearing in the composed result. ) $(P $(DEF Canonical equivalent) Two character sequences are said to be canonical equivalents if their full canonical decompositions are identical. ) $(P $(DEF Character) Typically differs by context. For the purpose of this documentation the term $(I character) implies $(I encoded character), that is, a code point having an assigned abstract character (a symbolic meaning). ) $(P $(DEF Code point) Any value in the Unicode codespace; that is, the range of integers from 0 to 10FFFF (hex). Not all code points are assigned to encoded characters. ) $(P $(DEF Code unit) The minimal bit combination that can represent a unit of encoded text for processing or interchange. Depending on the encoding this could be: 8-bit code units in the UTF-8 ($(D char)), 16-bit code units in the UTF-16 ($(D wchar)), and 32-bit code units in the UTF-32 ($(D dchar)). $(I Note that in UTF-32, a code unit is a code point and is represented by the D $(D dchar) type.) ) $(P $(DEF Combining character) A character with the General Category of Combining Mark(M). $(UL $(LI All characters with non-zero canonical combining class are combining characters, but the reverse is not the case: there are combining characters with a zero combining class. ) $(LI These characters are not normally used in isolation unless they are being described. They include such characters as accents, diacritics, Hebrew points, Arabic vowel signs, and Indic matras. ) ) ) $(P $(DEF Combining class) A numerical value used by the Unicode Canonical Ordering Algorithm to determine which sequences of combining marks are to be considered canonically equivalent and which are not. ) $(P $(DEF Compatibility decomposition) The decomposition of a character or character sequence that results from recursively applying both the compatibility mappings and the canonical mappings found in the Unicode Character Database, and those described in Conjoining Jamo Behavior no characters can be further decomposed. ) $(P $(DEF Compatibility equivalent) Two character sequences are said to be compatibility equivalents if their full compatibility decompositions are identical. ) $(P $(DEF Encoded character) An association (or mapping) between an abstract character and a code point. ) $(P $(DEF Glyph) The actual, concrete image of a glyph representation having been rasterized or otherwise imaged onto some display surface. ) $(P $(DEF Grapheme base) A character with the property Grapheme_Base, or any standard Korean syllable block. ) $(P $(DEF Grapheme cluster) Defined as the text between grapheme boundaries as specified by Unicode Standard Annex #29, $(WEB www.unicode.org/reports/tr29/, Unicode text segmentation). Important general properties of a grapheme: $(UL $(LI The grapheme cluster represents a horizontally segmentable unit of text, consisting of some grapheme base (which may consist of a Korean syllable) together with any number of nonspacing marks applied to it. ) $(LI A grapheme cluster typically starts with a grapheme base and then extends across any subsequent sequence of nonspacing marks. A grapheme cluster is most directly relevant to text rendering and processes such as cursor placement and text selection in editing, but may also be relevant to comparison and searching. ) $(LI For many processes, a grapheme cluster behaves as if it was a single character with the same properties as its grapheme base. Effectively, nonspacing marks apply $(I graphically) to the base, but do not change its properties. ) ) $(P This module defines a number of primitives that work with graphemes: $(LREF Grapheme), $(LREF decodeGrapheme) and $(LREF graphemeStride). All of them are using $(I extended grapheme) boundaries as defined in the aforementioned standard annex. ) ) $(P $(DEF Nonspacing mark) A combining character with the General Category of Nonspacing Mark (Mn) or Enclosing Mark (Me). ) $(P $(DEF Spacing mark) A combining character that is not a nonspacing mark.) $(SECTION Normalization) $(P The concepts of $(S_LINK Canonical equivalent, canonical equivalent) or $(S_LINK Compatibility equivalent, compatibility equivalent) characters in the Unicode Standard make it necessary to have a full, formal definition of equivalence for Unicode strings. String equivalence is determined by a process called normalization, whereby strings are converted into forms which are compared directly for identity. This is the primary goal of the normalization process, see the function $(LREF normalize) to convert into any of the four defined forms. ) $(P A very important attribute of the Unicode Normalization Forms is that they must remain stable between versions of the Unicode Standard. A Unicode string normalized to a particular Unicode Normalization Form in one version of the standard is guaranteed to remain in that Normalization Form for implementations of future versions of the standard. ) $(P The Unicode Standard specifies four normalization forms. Informally, two of these forms are defined by maximal decomposition of equivalent sequences, and two of these forms are defined by maximal $(I composition) of equivalent sequences. $(UL $(LI Normalization Form D (NFD): The $(S_LINK Canonical decomposition, canonical decomposition) of a character sequence.) $(LI Normalization Form KD (NFKD): The $(S_LINK Compatibility decomposition, compatibility decomposition) of a character sequence.) $(LI Normalization Form C (NFC): The canonical composition of the $(S_LINK Canonical decomposition, canonical decomposition) of a coded character sequence.) $(LI Normalization Form KC (NFKC): The canonical composition of the $(S_LINK Compatibility decomposition, compatibility decomposition) of a character sequence) ) ) $(P The choice of the normalization form depends on the particular use case. NFC is the best form for general text, since it's more compatible with strings converted from legacy encodings. NFKC is the preferred form for identifiers, especially where there are security concerns. NFD and NFKD are the most useful for internal processing. ) $(SECTION Construction of lookup tables) $(P The Unicode standard describes a set of algorithms that depend on having the ability to quickly look up various properties of a code point. Given the the codespace of about 1 million $(CODEPOINTS), it is not a trivial task to provide a space-efficient solution for the multitude of properties.) $(P Common approaches such as hash-tables or binary search over sorted code point intervals (as in $(LREF InversionList)) are insufficient. Hash-tables have enormous memory footprint and binary search over intervals is not fast enough for some heavy-duty algorithms. ) $(P The recommended solution (see Unicode Implementation Guidelines) is using multi-stage tables that are an implementation of the $(WEB en.wikipedia.org/wiki/Trie, Trie) data structure with integer keys and a fixed number of stages. For the remainder of the section this will be called a fixed trie. The following describes a particular implementation that is aimed for the speed of access at the expense of ideal size savings. ) $(P Taking a 2-level Trie as an example the principle of operation is as follows. Split the number of bits in a key (code point, 21 bits) into 2 components (e.g. 15 and 8). The first is the number of bits in the index of the trie and the other is number of bits in each page of the trie. The layout of the trie is then an array of size 2^^bits-of-index followed an array of memory chunks of size 2^^bits-of-page/bits-per-element. ) $(P The number of pages is variable (but not less then 1) unlike the number of entries in the index. The slots of the index all have to contain a number of a page that is present. The lookup is then just a couple of operations - slice the upper bits, lookup an index for these, take a page at this index and use the lower bits as an offset within this page. Assuming that pages are laid out consequently in one array at $(D pages), the pseudo-code is: ) --- auto elemsPerPage = (2 ^^ bits_per_page) / Value.sizeOfInBits; pages[index[n >> bits_per_page]][n & (elemsPerPage - 1)]; --- $(P Where if $(D elemsPerPage) is a power of 2 the whole process is a handful of simple instructions and 2 array reads. Subsequent levels of the trie are introduced by recursing on this notion - the index array is treated as values. The number of bits in index is then again split into 2 parts, with pages over 'current-index' and the new 'upper-index'. ) $(P For completeness a level 1 trie is simply an array. The current implementation takes advantage of bit-packing values when the range is known to be limited in advance (such as $(D bool)). See also $(LREF BitPacked) for enforcing it manually. The major size advantage however comes from the fact that multiple $(B identical pages on every level are merged) by construction. ) $(P The process of constructing a trie is more involved and is hidden from the user in a form of the convenience functions $(LREF codepointTrie), $(LREF codepointSetTrie) and the even more convenient $(LREF toTrie). In general a set or built-in AA with $(D dchar) type can be turned into a trie. The trie object in this module is read-only (immutable); it's effectively frozen after construction. ) $(SECTION Unicode properties) $(P This is a full list of Unicode properties accessible through $(LREF unicode) with specific helpers per category nested within. Consult the $(WEB www.unicode.org/cldr/utility/properties.jsp, CLDR utility) when in doubt about the contents of a particular set.) $(P General category sets listed below are only accessible with the $(LREF unicode) shorthand accessor.) $(BOOKTABLE $(B General category ), $(TR $(TH Abb.) $(TH Long form) $(TH Abb.) $(TH Long form)$(TH Abb.) $(TH Long form)) $(TR $(TD L) $(TD Letter) $(TD Cn) $(TD Unassigned) $(TD Po) $(TD Other_Punctuation)) $(TR $(TD Ll) $(TD Lowercase_Letter) $(TD Co) $(TD Private_Use) $(TD Ps) $(TD Open_Punctuation)) $(TR $(TD Lm) $(TD Modifier_Letter) $(TD Cs) $(TD Surrogate) $(TD S) $(TD Symbol)) $(TR $(TD Lo) $(TD Other_Letter) $(TD N) $(TD Number) $(TD Sc) $(TD Currency_Symbol)) $(TR $(TD Lt) $(TD Titlecase_Letter) $(TD Nd) $(TD Decimal_Number) $(TD Sk) $(TD Modifier_Symbol)) $(TR $(TD Lu) $(TD Uppercase_Letter) $(TD Nl) $(TD Letter_Number) $(TD Sm) $(TD Math_Symbol)) $(TR $(TD M) $(TD Mark) $(TD No) $(TD Other_Number) $(TD So) $(TD Other_Symbol)) $(TR $(TD Mc) $(TD Spacing_Mark) $(TD P) $(TD Punctuation) $(TD Z) $(TD Separator)) $(TR $(TD Me) $(TD Enclosing_Mark) $(TD Pc) $(TD Connector_Punctuation) $(TD Zl) $(TD Line_Separator)) $(TR $(TD Mn) $(TD Nonspacing_Mark) $(TD Pd) $(TD Dash_Punctuation) $(TD Zp) $(TD Paragraph_Separator)) $(TR $(TD C) $(TD Other) $(TD Pe) $(TD Close_Punctuation) $(TD Zs) $(TD Space_Separator)) $(TR $(TD Cc) $(TD Control) $(TD Pf) $(TD Final_Punctuation) $(TD -) $(TD Any)) $(TR $(TD Cf) $(TD Format) $(TD Pi) $(TD Initial_Punctuation) $(TD -) $(TD ASCII)) ) $(P Sets for other commonly useful properties that are accessible with $(LREF unicode):) $(BOOKTABLE $(B Common binary properties), $(TR $(TH Name) $(TH Name) $(TH Name)) $(TR $(TD Alphabetic) $(TD Ideographic) $(TD Other_Uppercase)) $(TR $(TD ASCII_Hex_Digit) $(TD IDS_Binary_Operator) $(TD Pattern_Syntax)) $(TR $(TD Bidi_Control) $(TD ID_Start) $(TD Pattern_White_Space)) $(TR $(TD Cased) $(TD IDS_Trinary_Operator) $(TD Quotation_Mark)) $(TR $(TD Case_Ignorable) $(TD Join_Control) $(TD Radical)) $(TR $(TD Dash) $(TD Logical_Order_Exception) $(TD Soft_Dotted)) $(TR $(TD Default_Ignorable_Code_Point) $(TD Lowercase) $(TD STerm)) $(TR $(TD Deprecated) $(TD Math) $(TD Terminal_Punctuation)) $(TR $(TD Diacritic) $(TD Noncharacter_Code_Point) $(TD Unified_Ideograph)) $(TR $(TD Extender) $(TD Other_Alphabetic) $(TD Uppercase)) $(TR $(TD Grapheme_Base) $(TD Other_Default_Ignorable_Code_Point) $(TD Variation_Selector)) $(TR $(TD Grapheme_Extend) $(TD Other_Grapheme_Extend) $(TD White_Space)) $(TR $(TD Grapheme_Link) $(TD Other_ID_Continue) $(TD XID_Continue)) $(TR $(TD Hex_Digit) $(TD Other_ID_Start) $(TD XID_Start)) $(TR $(TD Hyphen) $(TD Other_Lowercase) ) $(TR $(TD ID_Continue) $(TD Other_Math) ) ) $(P Bellow is the table with block names accepted by $(LREF unicode.block). Note that the shorthand version $(LREF unicode) requires "In" to be prepended to the names of blocks so as to disambiguate scripts and blocks.) $(BOOKTABLE $(B Blocks), $(TR $(TD Aegean Numbers) $(TD Ethiopic Extended) $(TD Mongolian)) $(TR $(TD Alchemical Symbols) $(TD Ethiopic Extended-A) $(TD Musical Symbols)) $(TR $(TD Alphabetic Presentation Forms) $(TD Ethiopic Supplement) $(TD Myanmar)) $(TR $(TD Ancient Greek Musical Notation) $(TD General Punctuation) $(TD Myanmar Extended-A)) $(TR $(TD Ancient Greek Numbers) $(TD Geometric Shapes) $(TD New Tai Lue)) $(TR $(TD Ancient Symbols) $(TD Georgian) $(TD NKo)) $(TR $(TD Arabic) $(TD Georgian Supplement) $(TD Number Forms)) $(TR $(TD Arabic Extended-A) $(TD Glagolitic) $(TD Ogham)) $(TR $(TD Arabic Mathematical Alphabetic Symbols) $(TD Gothic) $(TD Ol Chiki)) $(TR $(TD Arabic Presentation Forms-A) $(TD Greek and Coptic) $(TD Old Italic)) $(TR $(TD Arabic Presentation Forms-B) $(TD Greek Extended) $(TD Old Persian)) $(TR $(TD Arabic Supplement) $(TD Gujarati) $(TD Old South Arabian)) $(TR $(TD Armenian) $(TD Gurmukhi) $(TD Old Turkic)) $(TR $(TD Arrows) $(TD Halfwidth and Fullwidth Forms) $(TD Optical Character Recognition)) $(TR $(TD Avestan) $(TD Hangul Compatibility Jamo) $(TD Oriya)) $(TR $(TD Balinese) $(TD Hangul Jamo) $(TD Osmanya)) $(TR $(TD Bamum) $(TD Hangul Jamo Extended-A) $(TD Phags-pa)) $(TR $(TD Bamum Supplement) $(TD Hangul Jamo Extended-B) $(TD Phaistos Disc)) $(TR $(TD Basic Latin) $(TD Hangul Syllables) $(TD Phoenician)) $(TR $(TD Batak) $(TD Hanunoo) $(TD Phonetic Extensions)) $(TR $(TD Bengali) $(TD Hebrew) $(TD Phonetic Extensions Supplement)) $(TR $(TD Block Elements) $(TD High Private Use Surrogates) $(TD Playing Cards)) $(TR $(TD Bopomofo) $(TD High Surrogates) $(TD Private Use Area)) $(TR $(TD Bopomofo Extended) $(TD Hiragana) $(TD Rejang)) $(TR $(TD Box Drawing) $(TD Ideographic Description Characters) $(TD Rumi Numeral Symbols)) $(TR $(TD Brahmi) $(TD Imperial Aramaic) $(TD Runic)) $(TR $(TD Braille Patterns) $(TD Inscriptional Pahlavi) $(TD Samaritan)) $(TR $(TD Buginese) $(TD Inscriptional Parthian) $(TD Saurashtra)) $(TR $(TD Buhid) $(TD IPA Extensions) $(TD Sharada)) $(TR $(TD Byzantine Musical Symbols) $(TD Javanese) $(TD Shavian)) $(TR $(TD Carian) $(TD Kaithi) $(TD Sinhala)) $(TR $(TD Chakma) $(TD Kana Supplement) $(TD Small Form Variants)) $(TR $(TD Cham) $(TD Kanbun) $(TD Sora Sompeng)) $(TR $(TD Cherokee) $(TD Kangxi Radicals) $(TD Spacing Modifier Letters)) $(TR $(TD CJK Compatibility) $(TD Kannada) $(TD Specials)) $(TR $(TD CJK Compatibility Forms) $(TD Katakana) $(TD Sundanese)) $(TR $(TD CJK Compatibility Ideographs) $(TD Katakana Phonetic Extensions) $(TD Sundanese Supplement)) $(TR $(TD CJK Compatibility Ideographs Supplement) $(TD Kayah Li) $(TD Superscripts and Subscripts)) $(TR $(TD CJK Radicals Supplement) $(TD Kharoshthi) $(TD Supplemental Arrows-A)) $(TR $(TD CJK Strokes) $(TD Khmer) $(TD Supplemental Arrows-B)) $(TR $(TD CJK Symbols and Punctuation) $(TD Khmer Symbols) $(TD Supplemental Mathematical Operators)) $(TR $(TD CJK Unified Ideographs) $(TD Lao) $(TD Supplemental Punctuation)) $(TR $(TD CJK Unified Ideographs Extension A) $(TD Latin-1 Supplement) $(TD Supplementary Private Use Area-A)) $(TR $(TD CJK Unified Ideographs Extension B) $(TD Latin Extended-A) $(TD Supplementary Private Use Area-B)) $(TR $(TD CJK Unified Ideographs Extension C) $(TD Latin Extended Additional) $(TD Syloti Nagri)) $(TR $(TD CJK Unified Ideographs Extension D) $(TD Latin Extended-B) $(TD Syriac)) $(TR $(TD Combining Diacritical Marks) $(TD Latin Extended-C) $(TD Tagalog)) $(TR $(TD Combining Diacritical Marks for Symbols) $(TD Latin Extended-D) $(TD Tagbanwa)) $(TR $(TD Combining Diacritical Marks Supplement) $(TD Lepcha) $(TD Tags)) $(TR $(TD Combining Half Marks) $(TD Letterlike Symbols) $(TD Tai Le)) $(TR $(TD Common Indic Number Forms) $(TD Limbu) $(TD Tai Tham)) $(TR $(TD Control Pictures) $(TD Linear B Ideograms) $(TD Tai Viet)) $(TR $(TD Coptic) $(TD Linear B Syllabary) $(TD Tai Xuan Jing Symbols)) $(TR $(TD Counting Rod Numerals) $(TD Lisu) $(TD Takri)) $(TR $(TD Cuneiform) $(TD Low Surrogates) $(TD Tamil)) $(TR $(TD Cuneiform Numbers and Punctuation) $(TD Lycian) $(TD Telugu)) $(TR $(TD Currency Symbols) $(TD Lydian) $(TD Thaana)) $(TR $(TD Cypriot Syllabary) $(TD Mahjong Tiles) $(TD Thai)) $(TR $(TD Cyrillic) $(TD Malayalam) $(TD Tibetan)) $(TR $(TD Cyrillic Extended-A) $(TD Mandaic) $(TD Tifinagh)) $(TR $(TD Cyrillic Extended-B) $(TD Mathematical Alphanumeric Symbols) $(TD Transport And Map Symbols)) $(TR $(TD Cyrillic Supplement) $(TD Mathematical Operators) $(TD Ugaritic)) $(TR $(TD Deseret) $(TD Meetei Mayek) $(TD Unified Canadian Aboriginal Syllabics)) $(TR $(TD Devanagari) $(TD Meetei Mayek Extensions) $(TD Unified Canadian Aboriginal Syllabics Extended)) $(TR $(TD Devanagari Extended) $(TD Meroitic Cursive) $(TD Vai)) $(TR $(TD Dingbats) $(TD Meroitic Hieroglyphs) $(TD Variation Selectors)) $(TR $(TD Domino Tiles) $(TD Miao) $(TD Variation Selectors Supplement)) $(TR $(TD Egyptian Hieroglyphs) $(TD Miscellaneous Mathematical Symbols-A) $(TD Vedic Extensions)) $(TR $(TD Emoticons) $(TD Miscellaneous Mathematical Symbols-B) $(TD Vertical Forms)) $(TR $(TD Enclosed Alphanumerics) $(TD Miscellaneous Symbols) $(TD Yijing Hexagram Symbols)) $(TR $(TD Enclosed Alphanumeric Supplement) $(TD Miscellaneous Symbols and Arrows) $(TD Yi Radicals)) $(TR $(TD Enclosed CJK Letters and Months) $(TD Miscellaneous Symbols And Pictographs) $(TD Yi Syllables)) $(TR $(TD Enclosed Ideographic Supplement) $(TD Miscellaneous Technical) ) $(TR $(TD Ethiopic) $(TD Modifier Tone Letters) ) ) $(P Bellow is the table with script names accepted by $(LREF unicode.script) and by the shorthand version $(LREF unicode):) $(BOOKTABLE $(B Scripts), $(TR $(TD Arabic) $(TD Hanunoo) $(TD Old_Italic)) $(TR $(TD Armenian) $(TD Hebrew) $(TD Old_Persian)) $(TR $(TD Avestan) $(TD Hiragana) $(TD Old_South_Arabian)) $(TR $(TD Balinese) $(TD Imperial_Aramaic) $(TD Old_Turkic)) $(TR $(TD Bamum) $(TD Inherited) $(TD Oriya)) $(TR $(TD Batak) $(TD Inscriptional_Pahlavi) $(TD Osmanya)) $(TR $(TD Bengali) $(TD Inscriptional_Parthian) $(TD Phags_Pa)) $(TR $(TD Bopomofo) $(TD Javanese) $(TD Phoenician)) $(TR $(TD Brahmi) $(TD Kaithi) $(TD Rejang)) $(TR $(TD Braille) $(TD Kannada) $(TD Runic)) $(TR $(TD Buginese) $(TD Katakana) $(TD Samaritan)) $(TR $(TD Buhid) $(TD Kayah_Li) $(TD Saurashtra)) $(TR $(TD Canadian_Aboriginal) $(TD Kharoshthi) $(TD Sharada)) $(TR $(TD Carian) $(TD Khmer) $(TD Shavian)) $(TR $(TD Chakma) $(TD Lao) $(TD Sinhala)) $(TR $(TD Cham) $(TD Latin) $(TD Sora_Sompeng)) $(TR $(TD Cherokee) $(TD Lepcha) $(TD Sundanese)) $(TR $(TD Common) $(TD Limbu) $(TD Syloti_Nagri)) $(TR $(TD Coptic) $(TD Linear_B) $(TD Syriac)) $(TR $(TD Cuneiform) $(TD Lisu) $(TD Tagalog)) $(TR $(TD Cypriot) $(TD Lycian) $(TD Tagbanwa)) $(TR $(TD Cyrillic) $(TD Lydian) $(TD Tai_Le)) $(TR $(TD Deseret) $(TD Malayalam) $(TD Tai_Tham)) $(TR $(TD Devanagari) $(TD Mandaic) $(TD Tai_Viet)) $(TR $(TD Egyptian_Hieroglyphs) $(TD Meetei_Mayek) $(TD Takri)) $(TR $(TD Ethiopic) $(TD Meroitic_Cursive) $(TD Tamil)) $(TR $(TD Georgian) $(TD Meroitic_Hieroglyphs) $(TD Telugu)) $(TR $(TD Glagolitic) $(TD Miao) $(TD Thaana)) $(TR $(TD Gothic) $(TD Mongolian) $(TD Thai)) $(TR $(TD Greek) $(TD Myanmar) $(TD Tibetan)) $(TR $(TD Gujarati) $(TD New_Tai_Lue) $(TD Tifinagh)) $(TR $(TD Gurmukhi) $(TD Nko) $(TD Ugaritic)) $(TR $(TD Han) $(TD Ogham) $(TD Vai)) $(TR $(TD Hangul) $(TD Ol_Chiki) $(TD Yi)) ) $(P Bellow is the table of names accepted by $(LREF unicode.hangulSyllableType).) $(BOOKTABLE $(B Hangul syllable type), $(TR $(TH Abb.) $(TH Long form)) $(TR $(TD L) $(TD Leading_Jamo)) $(TR $(TD LV) $(TD LV_Syllable)) $(TR $(TD LVT) $(TD LVT_Syllable) ) $(TR $(TD T) $(TD Trailing_Jamo)) $(TR $(TD V) $(TD Vowel_Jamo)) ) References: $(WEB www.digitalmars.com/d/ascii-table.html, ASCII Table), $(WEB en.wikipedia.org/wiki/Unicode, Wikipedia), $(WEB www.unicode.org, The Unicode Consortium), $(WEB www.unicode.org/reports/tr15/, Unicode normalization forms), $(WEB www.unicode.org/reports/tr29/, Unicode text segmentation) $(WEB www.unicode.org/uni2book/ch05.pdf, Unicode Implementation Guidelines) $(WEB www.unicode.org/uni2book/ch03.pdf, Unicode Conformance) Trademarks: Unicode(tm) is a trademark of Unicode, Inc. Macros: WIKI=Phobos/StdUni Copyright: Copyright 2013 - License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). Authors: Dmitry Olshansky Source: $(PHOBOSSRC std/_uni.d) Standards: $(WEB www.unicode.org/versions/Unicode6.2.0/, Unicode v6.2) Macros: SECTION = <h3><a id="$1">$0</a></h3> DEF = <div><a id="$1"><i>$0</i></a></div> S_LINK = <a href="#$1">$+</a> CODEPOINT = $(S_LINK Code point, code point) CODEPOINTS = $(S_LINK Code point, code points) CHARACTER = $(S_LINK Character, character) CHARACTERS = $(S_LINK Character, characters) CLUSTER = $(S_LINK Grapheme cluster, grapheme cluster) +/ module std.uni; import core.stdc.stdlib; import std.meta, std.traits; import std.range.primitives; // debug = std_uni; debug(std_uni) import std.stdio; private: version (unittest) { private: struct TestAliasedString { string get() @safe @nogc pure nothrow { return _s; } alias get this; @disable this(this); string _s; } bool testAliasedString(alias func, Args...)(string s, Args args) { return func(TestAliasedString(s), args) == func(s, args); } } version(std_uni_bootstrap){} else { import std.internal.unicode_tables; // generated file } void copyBackwards(T,U)(T[] src, U[] dest) { assert(src.length == dest.length); for(size_t i=src.length; i-- > 0; ) dest[i] = src[i]; } void copyForward(T,U)(T[] src, U[] dest) { assert(src.length == dest.length); for(size_t i=0; i<src.length; i++) dest[i] = src[i]; } // TODO: update to reflect all major CPUs supporting unaligned reads version(X86) enum hasUnalignedReads = true; else version(X86_64) enum hasUnalignedReads = true; else enum hasUnalignedReads = false; // better be safe then sorry public enum dchar lineSep = '\u2028'; /// Constant $(CODEPOINT) (0x2028) - line separator. public enum dchar paraSep = '\u2029'; /// Constant $(CODEPOINT) (0x2029) - paragraph separator. public enum dchar nelSep = '\u0085'; /// Constant $(CODEPOINT) (0x0085) - next line. // test the intro example @safe unittest { import std.algorithm : find; // initialize code point sets using script/block or property name // set contains code points from both scripts. auto set = unicode("Cyrillic") | unicode("Armenian"); // or simpler and statically-checked look auto ascii = unicode.ASCII; auto currency = unicode.Currency_Symbol; // easy set ops auto a = set & ascii; assert(a.empty); // as it has no intersection with ascii a = set | ascii; auto b = currency - a; // subtract all ASCII, Cyrillic and Armenian // some properties of code point sets assert(b.length > 45); // 46 items in Unicode 6.1, even more in 6.2 // testing presence of a code point in a set // is just fine, it is O(logN) assert(!b['$']); assert(!b['\u058F']); // Armenian dram sign assert(b['¥']); // building fast lookup tables, these guarantee O(1) complexity // 1-level Trie lookup table essentially a huge bit-set ~262Kb auto oneTrie = toTrie!1(b); // 2-level far more compact but typically slightly slower auto twoTrie = toTrie!2(b); // 3-level even smaller, and a bit slower yet auto threeTrie = toTrie!3(b); assert(oneTrie['£']); assert(twoTrie['£']); assert(threeTrie['£']); // build the trie with the most sensible trie level // and bind it as a functor auto cyrillicOrArmenian = toDelegate(set); auto balance = find!(cyrillicOrArmenian)("Hello ընկեր!"); assert(balance == "ընկեր!"); // compatible with bool delegate(dchar) bool delegate(dchar) bindIt = cyrillicOrArmenian; // Normalization string s = "Plain ascii (and not only), is always normalized!"; assert(s is normalize(s));// is the same string string nonS = "A\u0308ffin"; // A ligature auto nS = normalize(nonS); // to NFC, the W3C endorsed standard assert(nS == "Äffin"); assert(nS != nonS); string composed = "Äffin"; assert(normalize!NFD(composed) == "A\u0308ffin"); // to NFKD, compatibility decomposition useful for fuzzy matching/searching assert(normalize!NFKD("2¹⁰") == "210"); } enum lastDchar = 0x10FFFF; auto force(T, F)(F from) if(isIntegral!T && !is(T == F)) { assert(from <= T.max && from >= T.min); return cast(T)from; } auto force(T, F)(F from) if(isBitPacked!T && !is(T == F)) { assert(from <= 2^^bitSizeOf!T-1); return T(cast(TypeOfBitPacked!T)from); } auto force(T, F)(F from) if(is(T == F)) { return from; } // repeat X times the bit-pattern in val assuming it's length is 'bits' size_t replicateBits(size_t times, size_t bits)(size_t val) @safe pure nothrow @nogc { static if(times == 1) return val; else static if(bits == 1) { static if(times == size_t.sizeof*8) return val ? size_t.max : 0; else return val ? (1<<times)-1 : 0; } else static if(times % 2) return (replicateBits!(times-1, bits)(val)<<bits) | val; else return replicateBits!(times/2, bits*2)((val<<bits) | val); } @safe pure nothrow @nogc unittest // for replicate { import std.algorithm : sum, map; import std.range : iota; size_t m = 0b111; size_t m2 = 0b01; foreach(i; AliasSeq!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) { assert(replicateBits!(i, 3)(m)+1 == (1<<(3*i))); assert(replicateBits!(i, 2)(m2) == iota(0, i).map!"2^^(2*a)"().sum()); } } // multiple arrays squashed into one memory block struct MultiArray(Types...) { this(size_t[] sizes...) @safe pure nothrow { assert(dim == sizes.length); size_t full_size; foreach(i, v; Types) { full_size += spaceFor!(bitSizeOf!v)(sizes[i]); sz[i] = sizes[i]; static if(i >= 1) offsets[i] = offsets[i-1] + spaceFor!(bitSizeOf!(Types[i-1]))(sizes[i-1]); } storage = new size_t[full_size]; } this(const(size_t)[] raw_offsets, const(size_t)[] raw_sizes, const(size_t)[] data)const @safe pure nothrow @nogc { offsets[] = raw_offsets[]; sz[] = raw_sizes[]; storage = data; } @property auto slice(size_t n)()inout pure nothrow @nogc { auto ptr = raw_ptr!n; return packedArrayView!(Types[n])(ptr, sz[n]); } @property auto ptr(size_t n)()inout pure nothrow @nogc { auto ptr = raw_ptr!n; return inout(PackedPtr!(Types[n]))(ptr); } template length(size_t n) { @property size_t length()const @safe pure nothrow @nogc{ return sz[n]; } @property void length(size_t new_size) { if(new_size > sz[n]) {// extend size_t delta = (new_size - sz[n]); sz[n] += delta; delta = spaceFor!(bitSizeOf!(Types[n]))(delta); storage.length += delta;// extend space at end // raw_slice!x must follow resize as it could be moved! // next stmts move all data past this array, last-one-goes-first static if(n != dim-1) { auto start = raw_ptr!(n+1); // len includes delta size_t len = (storage.ptr+storage.length-start); copyBackwards(start[0..len-delta], start[delta..len]); start[0..delta] = 0; // offsets are used for raw_slice, ptr etc. foreach(i; n+1..dim) offsets[i] += delta; } } else if(new_size < sz[n]) {// shrink size_t delta = (sz[n] - new_size); sz[n] -= delta; delta = spaceFor!(bitSizeOf!(Types[n]))(delta); // move all data past this array, forward direction static if(n != dim-1) { auto start = raw_ptr!(n+1); size_t len = (storage.ptr+storage.length-start); copyForward(start[0..len-delta], start[delta..len]); // adjust offsets last, they affect raw_slice foreach(i; n+1..dim) offsets[i] -= delta; } storage.length -= delta; } // else - NOP } } @property size_t bytes(size_t n=size_t.max)() const { static if(n == size_t.max) return storage.length*size_t.sizeof; else static if(n != Types.length-1) return (raw_ptr!(n+1)-raw_ptr!n)*size_t.sizeof; else return (storage.ptr+storage.length - raw_ptr!n)*size_t.sizeof; } void store(OutRange)(scope OutRange sink) const if(isOutputRange!(OutRange, char)) { import std.format; formattedWrite(sink, "[%( 0x%x, %)]", offsets[]); formattedWrite(sink, ", [%( 0x%x, %)]", sz[]); formattedWrite(sink, ", [%( 0x%x, %)]", storage); } private: @property auto raw_ptr(size_t n)()inout pure nothrow @nogc { static if(n == 0) return storage.ptr; else { return storage.ptr+offsets[n]; } } enum dim = Types.length; size_t[dim] offsets;// offset for level x size_t[dim] sz;// size of level x alias bitWidth = staticMap!(bitSizeOf, Types); size_t[] storage; } unittest { import std.conv; enum dg = (){ // sizes are: // lvl0: 3, lvl1 : 2, lvl2: 1 auto m = MultiArray!(int, ubyte, int)(3,2,1); static void check(size_t k, T)(ref T m, int n) { foreach(i; 0..n) assert(m.slice!(k)[i] == i+1, text("level:",i," : ",m.slice!(k)[0..n])); } static void checkB(size_t k, T)(ref T m, int n) { foreach(i; 0..n) assert(m.slice!(k)[i] == n-i, text("level:",i," : ",m.slice!(k)[0..n])); } static void fill(size_t k, T)(ref T m, int n) { foreach(i; 0..n) m.slice!(k)[i] = force!ubyte(i+1); } static void fillB(size_t k, T)(ref T m, int n) { foreach(i; 0..n) m.slice!(k)[i] = force!ubyte(n-i); } m.length!1 = 100; fill!1(m, 100); check!1(m, 100); m.length!0 = 220; fill!0(m, 220); check!1(m, 100); check!0(m, 220); m.length!2 = 17; fillB!2(m, 17); checkB!2(m, 17); check!0(m, 220); check!1(m, 100); m.length!2 = 33; checkB!2(m, 17); fillB!2(m, 33); checkB!2(m, 33); check!0(m, 220); check!1(m, 100); m.length!1 = 195; fillB!1(m, 195); checkB!1(m, 195); checkB!2(m, 33); check!0(m, 220); auto marr = MultiArray!(BitPacked!(uint, 4), BitPacked!(uint, 6))(20, 10); marr.length!0 = 15; marr.length!1 = 30; fill!1(marr, 30); fill!0(marr, 15); check!1(marr, 30); check!0(marr, 15); return 0; }; enum ct = dg(); auto rt = dg(); } unittest {// more bitpacking tests import std.conv; alias Bitty = MultiArray!(BitPacked!(size_t, 3) , BitPacked!(size_t, 4) , BitPacked!(size_t, 3) , BitPacked!(size_t, 6) , bool); alias fn1 = sliceBits!(13, 16); alias fn2 = sliceBits!( 9, 13); alias fn3 = sliceBits!( 6, 9); alias fn4 = sliceBits!( 0, 6); static void check(size_t lvl, MA)(ref MA arr){ for(size_t i = 0; i< arr.length!lvl; i++) assert(arr.slice!(lvl)[i] == i, text("Mismatch on lvl ", lvl, " idx ", i, " value: ", arr.slice!(lvl)[i])); } static void fillIdx(size_t lvl, MA)(ref MA arr){ for(size_t i = 0; i< arr.length!lvl; i++) arr.slice!(lvl)[i] = i; } Bitty m1; m1.length!4 = 10; m1.length!3 = 2^^6; m1.length!2 = 2^^3; m1.length!1 = 2^^4; m1.length!0 = 2^^3; m1.length!4 = 2^^16; for(size_t i = 0; i< m1.length!4; i++) m1.slice!(4)[i] = i % 2; fillIdx!1(m1); check!1(m1); fillIdx!2(m1); check!2(m1); fillIdx!3(m1); check!3(m1); fillIdx!0(m1); check!0(m1); check!3(m1); check!2(m1); check!1(m1); for(size_t i=0; i < 2^^16; i++) { m1.slice!(4)[i] = i % 2; m1.slice!(0)[fn1(i)] = fn1(i); m1.slice!(1)[fn2(i)] = fn2(i); m1.slice!(2)[fn3(i)] = fn3(i); m1.slice!(3)[fn4(i)] = fn4(i); } for(size_t i=0; i < 2^^16; i++) { assert(m1.slice!(4)[i] == i % 2); assert(m1.slice!(0)[fn1(i)] == fn1(i)); assert(m1.slice!(1)[fn2(i)] == fn2(i)); assert(m1.slice!(2)[fn3(i)] == fn3(i)); assert(m1.slice!(3)[fn4(i)] == fn4(i)); } } size_t spaceFor(size_t _bits)(size_t new_len) @safe pure nothrow @nogc { enum bits = _bits == 1 ? 1 : ceilPowerOf2(_bits);// see PackedArrayView static if(bits > 8*size_t.sizeof) { static assert(bits % (size_t.sizeof*8) == 0); return new_len * bits/(8*size_t.sizeof); } else { enum factor = size_t.sizeof*8/bits; return (new_len+factor-1)/factor; // rounded up } } template isBitPackableType(T) { enum isBitPackableType = isBitPacked!T || isIntegral!T || is(T == bool) || isSomeChar!T; } //============================================================================ template PackedArrayView(T) if((is(T dummy == BitPacked!(U, sz), U, size_t sz) && isBitPackableType!U) || isBitPackableType!T) { private enum bits = bitSizeOf!T; alias PackedArrayView = PackedArrayViewImpl!(T, bits > 1 ? ceilPowerOf2(bits) : 1); } //unsafe and fast access to a chunk of RAM as if it contains packed values template PackedPtr(T) if((is(T dummy == BitPacked!(U, sz), U, size_t sz) && isBitPackableType!U) || isBitPackableType!T) { private enum bits = bitSizeOf!T; alias PackedPtr = PackedPtrImpl!(T, bits > 1 ? ceilPowerOf2(bits) : 1); } @trusted struct PackedPtrImpl(T, size_t bits) { pure nothrow: static assert(isPowerOf2(bits)); this(inout(size_t)* ptr)inout @safe @nogc { origin = ptr; } private T simpleIndex(size_t n) inout { auto q = n / factor; auto r = n % factor; return cast(T)((origin[q] >> bits*r) & mask); } private void simpleWrite(TypeOfBitPacked!T val, size_t n) in { static if(isIntegral!T) assert(val <= mask); } body { auto q = n / factor; auto r = n % factor; size_t tgt_shift = bits*r; size_t word = origin[q]; origin[q] = (word & ~(mask<<tgt_shift)) | (cast(size_t)val << tgt_shift); } static if(factor == bytesPerWord// can safely pack by byte || factor == 1 // a whole word at a time || ((factor == bytesPerWord/2 || factor == bytesPerWord/4) && hasUnalignedReads)) // this needs unaligned reads { static if(factor == bytesPerWord) alias U = ubyte; else static if(factor == bytesPerWord/2) alias U = ushort; else static if(factor == bytesPerWord/4) alias U = uint; else static if(size_t.sizeof == 8 && factor == bytesPerWord/8) alias U = ulong; T opIndex(size_t idx) inout { return __ctfe ? simpleIndex(idx) : cast(inout(T))(cast(U*)origin)[idx]; } static if(isBitPacked!T) // lack of user-defined implicit conversion { void opIndexAssign(T val, size_t idx) { return opIndexAssign(cast(TypeOfBitPacked!T)val, idx); } } void opIndexAssign(TypeOfBitPacked!T val, size_t idx) { if(__ctfe) simpleWrite(val, idx); else (cast(U*)origin)[idx] = cast(U)val; } } else { T opIndex(size_t n) inout { return simpleIndex(n); } static if(isBitPacked!T) // lack of user-defined implicit conversion { void opIndexAssign(T val, size_t idx) { return opIndexAssign(cast(TypeOfBitPacked!T)val, idx); } } void opIndexAssign(TypeOfBitPacked!T val, size_t n) { return simpleWrite(val, n); } } private: // factor - number of elements in one machine word enum factor = size_t.sizeof*8/bits, mask = 2^^bits-1; enum bytesPerWord = size_t.sizeof; size_t* origin; } // data is packed only by power of two sized packs per word, // thus avoiding mul/div overhead at the cost of ultimate packing // this construct doesn't own memory, only provides access, see MultiArray for usage @trusted struct PackedArrayViewImpl(T, size_t bits) { pure nothrow: this(inout(size_t)* origin, size_t offset, size_t items) inout { ptr = inout(PackedPtr!(T))(origin); ofs = offset; limit = items; } bool zeros(size_t s, size_t e) in { assert(s <= e); } body { s += ofs; e += ofs; size_t pad_s = roundUp(s); if ( s >= e) { foreach (i; s..e) if(ptr[i]) return false; return true; } size_t pad_e = roundDown(e); size_t i; for(i=s; i<pad_s; i++) if(ptr[i]) return false; // all in between is x*factor elements for(size_t j=i/factor; i<pad_e; i+=factor, j++) if(ptr.origin[j]) return false; for(; i<e; i++) if(ptr[i]) return false; return true; } T opIndex(size_t idx) inout in { assert(idx < limit); } body { return ptr[ofs + idx]; } static if(isBitPacked!T) // lack of user-defined implicit conversion { void opIndexAssign(T val, size_t idx) { return opIndexAssign(cast(TypeOfBitPacked!T)val, idx); } } void opIndexAssign(TypeOfBitPacked!T val, size_t idx) in { assert(idx < limit); } body { ptr[ofs + idx] = val; } static if(isBitPacked!T) // lack of user-defined implicit conversions { void opSliceAssign(T val, size_t start, size_t end) { opSliceAssign(cast(TypeOfBitPacked!T)val, start, end); } } void opSliceAssign(TypeOfBitPacked!T val, size_t start, size_t end) in { assert(start <= end); assert(end <= limit); } body { // account for ofsetted view start += ofs; end += ofs; // rounded to factor granularity size_t pad_start = roundUp(start);// rounded up if(pad_start >= end) //rounded up >= then end of slice { //nothing to gain, use per element assignment foreach(i; start..end) ptr[i] = val; return; } size_t pad_end = roundDown(end); // rounded down size_t i; for(i=start; i<pad_start; i++) ptr[i] = val; // all in between is x*factor elements if(pad_start != pad_end) { size_t repval = replicateBits!(factor, bits)(val); for(size_t j=i/factor; i<pad_end; i+=factor, j++) ptr.origin[j] = repval;// so speed it up by factor } for(; i<end; i++) ptr[i] = val; } auto opSlice(size_t from, size_t to)inout in { assert(from <= to); assert(ofs + to <= limit); } body { return typeof(this)(ptr.origin, ofs + from, to - from); } auto opSlice(){ return opSlice(0, length); } bool opEquals(T)(auto ref T arr) const { if(limit != arr.limit) return false; size_t s1 = ofs, s2 = arr.ofs; size_t e1 = s1 + limit, e2 = s2 + limit; if(s1 % factor == 0 && s2 % factor == 0 && length % factor == 0) { return ptr.origin[s1/factor .. e1/factor] == arr.ptr.origin[s2/factor .. e2/factor]; } for(size_t i=0;i<limit; i++) if(this[i] != arr[i]) return false; return true; } @property size_t length()const{ return limit; } private: auto roundUp()(size_t val){ return (val+factor-1)/factor*factor; } auto roundDown()(size_t val){ return val/factor*factor; } // factor - number of elements in one machine word enum factor = size_t.sizeof*8/bits; PackedPtr!(T) ptr; size_t ofs, limit; } private struct SliceOverIndexed(T) { enum assignableIndex = is(typeof((){ T.init[0] = Item.init; })); enum assignableSlice = is(typeof((){ T.init[0..0] = Item.init; })); auto opIndex(size_t idx)const in { assert(idx < to - from); } body { return (*arr)[from+idx]; } static if(assignableIndex) void opIndexAssign(Item val, size_t idx) in { assert(idx < to - from); } body { (*arr)[from+idx] = val; } auto opSlice(size_t a, size_t b) { return typeof(this)(from+a, from+b, arr); } // static if(assignableSlice) void opSliceAssign(T)(T val, size_t start, size_t end) { (*arr)[start+from .. end+from] = val; } auto opSlice() { return typeof(this)(from, to, arr); } @property size_t length()const { return to-from;} auto opDollar()const { return length; } @property bool empty()const { return from == to; } @property auto front()const { return (*arr)[from]; } static if(assignableIndex) @property void front(Item val) { (*arr)[from] = val; } @property auto back()const { return (*arr)[to-1]; } static if(assignableIndex) @property void back(Item val) { (*arr)[to-1] = val; } @property auto save() inout { return this; } void popFront() { from++; } void popBack() { to--; } bool opEquals(T)(auto ref T arr) const { if(arr.length != length) return false; for(size_t i=0; i <length; i++) if(this[i] != arr[i]) return false; return true; } private: alias Item = typeof(T.init[0]); size_t from, to; T* arr; } static assert(isRandomAccessRange!(SliceOverIndexed!(int[]))); // BUG? forward reference to return type of sliceOverIndexed!Grapheme SliceOverIndexed!(const(T)) sliceOverIndexed(T)(size_t a, size_t b, const(T)* x) if(is(Unqual!T == T)) { return SliceOverIndexed!(const(T))(a, b, x); } // BUG? inout is out of reach //...SliceOverIndexed.arr only parameters or stack based variables can be inout SliceOverIndexed!T sliceOverIndexed(T)(size_t a, size_t b, T* x) if(is(Unqual!T == T)) { return SliceOverIndexed!T(a, b, x); } unittest { int[] idxArray = [2, 3, 5, 8, 13]; auto sliced = sliceOverIndexed(0, idxArray.length, &idxArray); assert(!sliced.empty); assert(sliced.front == 2); sliced.front = 1; assert(sliced.front == 1); assert(sliced.back == 13); sliced.popFront(); assert(sliced.front == 3); assert(sliced.back == 13); sliced.back = 11; assert(sliced.back == 11); sliced.popBack(); assert(sliced.front == 3); assert(sliced[$-1] == 8); sliced = sliced[]; assert(sliced[0] == 3); assert(sliced.back == 8); sliced = sliced[1..$]; assert(sliced.front == 5); sliced = sliced[0..$-1]; assert(sliced[$-1] == 5); int[] other = [2, 5]; assert(sliced[] == sliceOverIndexed(1, 2, &other)); sliceOverIndexed(0, 2, &idxArray)[0..2] = -1; assert(idxArray[0..2] == [-1, -1]); uint[] nullArr = null; auto nullSlice = sliceOverIndexed(0, 0, &idxArray); assert(nullSlice.empty); } private auto packedArrayView(T)(inout(size_t)* ptr, size_t items) @trusted pure nothrow { return inout(PackedArrayView!T)(ptr, 0, items); } //============================================================================ // Partially unrolled binary search using Shar's method //============================================================================ string genUnrolledSwitchSearch(size_t size) { import std.conv : to; import core.bitop : bsr; import std.array : replace; assert(isPowerOf2(size)); string code = ` import core.bitop : bsr; auto power = bsr(m)+1; switch(power){`; size_t i = bsr(size); foreach_reverse(val; 0..bsr(size)) { auto v = 2^^val; code ~= ` case pow: if(pred(range[idx+m], needle)) idx += m; goto case; `.replace("m", to!string(v)) .replace("pow", to!string(i)); i--; } code ~= ` case 0: if(pred(range[idx], needle)) idx += 1; goto default; `; code ~= ` default: }`; return code; } bool isPowerOf2(size_t sz) @safe pure nothrow @nogc { return (sz & (sz-1)) == 0; } size_t uniformLowerBound(alias pred, Range, T)(Range range, T needle) if(is(T : ElementType!Range)) { assert(isPowerOf2(range.length)); size_t idx = 0, m = range.length/2; while(m != 0) { if(pred(range[idx+m], needle)) idx += m; m /= 2; } if(pred(range[idx], needle)) idx += 1; return idx; } size_t switchUniformLowerBound(alias pred, Range, T)(Range range, T needle) if(is(T : ElementType!Range)) { assert(isPowerOf2(range.length)); size_t idx = 0, m = range.length/2; enum max = 1<<10; while(m >= max) { if(pred(range[idx+m], needle)) idx += m; m /= 2; } mixin(genUnrolledSwitchSearch(max)); return idx; } // size_t floorPowerOf2(size_t arg) @safe pure nothrow @nogc { import core.bitop : bsr; assert(arg > 1); // else bsr is undefined return 1<<bsr(arg-1); } size_t ceilPowerOf2(size_t arg) @safe pure nothrow @nogc { import core.bitop : bsr; assert(arg > 1); // else bsr is undefined return 1<<bsr(arg-1)+1; } template sharMethod(alias uniLowerBound) { size_t sharMethod(alias _pred="a<b", Range, T)(Range range, T needle) if(is(T : ElementType!Range)) { import std.functional; alias pred = binaryFun!_pred; if(range.length == 0) return 0; if(isPowerOf2(range.length)) return uniLowerBound!pred(range, needle); size_t n = floorPowerOf2(range.length); if(pred(range[n-1], needle)) {// search in another 2^^k area that fully covers the tail of range size_t k = ceilPowerOf2(range.length - n + 1); return range.length - k + uniLowerBound!pred(range[$-k..$], needle); } else return uniLowerBound!pred(range[0..n], needle); } } alias sharLowerBound = sharMethod!uniformLowerBound; alias sharSwitchLowerBound = sharMethod!switchUniformLowerBound; unittest { import std.range; auto stdLowerBound(T)(T[] range, T needle) { return assumeSorted(range).lowerBound(needle).length; } immutable MAX = 5*1173; auto arr = array(iota(5, MAX, 5)); assert(arr.length == MAX/5-1); foreach(i; 0..MAX+5) { auto st = stdLowerBound(arr, i); assert(st == sharLowerBound(arr, i)); assert(st == sharSwitchLowerBound(arr, i)); } arr = []; auto st = stdLowerBound(arr, 33); assert(st == sharLowerBound(arr, 33)); assert(st == sharSwitchLowerBound(arr, 33)); } //============================================================================ @safe { // hope to see simillar stuff in public interface... once Allocators are out //@@@BUG moveFront and friends? dunno, for now it's POD-only @trusted size_t genericReplace(Policy=void, T, Range) (ref T dest, size_t from, size_t to, Range stuff) { import std.algorithm : copy; size_t delta = to - from; size_t stuff_end = from+stuff.length; if(stuff.length > delta) {// replace increases length delta = stuff.length - delta;// now, new is > old by delta static if(is(Policy == void)) dest.length = dest.length+delta;//@@@BUG lame @property else dest = Policy.realloc(dest, dest.length+delta); copyBackwards(dest[to..dest.length-delta], dest[to+delta..dest.length]); copyForward(stuff, dest[from..stuff_end]); } else if(stuff.length == delta) { copy(stuff, dest[from..to]); } else {// replace decreases length by delta delta = delta - stuff.length; copy(stuff, dest[from..stuff_end]); copyForward(dest[to..dest.length], dest[stuff_end..dest.length-delta]); static if(is(Policy == void)) dest.length = dest.length - delta;//@@@BUG lame @property else dest = Policy.realloc(dest, dest.length-delta); } return stuff_end; } // Simple storage manipulation policy @trusted public struct GcPolicy { static T[] dup(T)(const T[] arr) { return arr.dup; } static T[] alloc(T)(size_t size) { return new T[size]; } static T[] realloc(T)(T[] arr, size_t sz) { arr.length = sz; return arr; } static void replaceImpl(T, Range)(ref T[] dest, size_t from, size_t to, Range stuff) { replaceInPlace(dest, from, to, stuff); } static void append(T, V)(ref T[] arr, V value) if(!isInputRange!V) { arr ~= force!T(value); } static void append(T, V)(ref T[] arr, V value) if(isInputRange!V) { insertInPlace(arr, arr.length, value); } static void destroy(T)(ref T arr) if(isDynamicArray!T && is(Unqual!T == T)) { debug { arr[] = cast(typeof(T.init[0]))(0xdead_beef); } arr = null; } static void destroy(T)(ref T arr) if(isDynamicArray!T && !is(Unqual!T == T)) { arr = null; } } // ditto @trusted struct ReallocPolicy { static T[] dup(T)(const T[] arr) { auto result = alloc!T(arr.length); result[] = arr[]; return result; } static T[] alloc(T)(size_t size) { import std.exception : enforce; auto ptr = cast(T*)enforce(malloc(T.sizeof*size), "out of memory on C heap"); return ptr[0..size]; } static T[] realloc(T)(T[] arr, size_t size) { import std.exception : enforce; if(!size) { destroy(arr); return null; } auto ptr = cast(T*)enforce(core.stdc.stdlib.realloc( arr.ptr, T.sizeof*size), "out of memory on C heap"); return ptr[0..size]; } static void replaceImpl(T, Range)(ref T[] dest, size_t from, size_t to, Range stuff) { genericReplace!(ReallocPolicy)(dest, from, to, stuff); } static void append(T, V)(ref T[] arr, V value) if(!isInputRange!V) { arr = realloc(arr, arr.length+1); arr[$-1] = force!T(value); } static void append(T, V)(ref T[] arr, V value) if(isInputRange!V && hasLength!V) { arr = realloc(arr, arr.length+value.length); copy(value, arr[$-value.length..$]); } static void destroy(T)(ref T[] arr) { if(arr.ptr) free(arr.ptr); arr = null; } } //build hack alias _RealArray = CowArray!ReallocPolicy; unittest { with(ReallocPolicy) { bool test(T, U, V)(T orig, size_t from, size_t to, U toReplace, V result, string file = __FILE__, size_t line = __LINE__) { { replaceImpl(orig, from, to, toReplace); scope(exit) destroy(orig); if(!equalS(orig, result)) return false; } return true; } static T[] arr(T)(T[] args... ) { return dup(args); } assert(test(arr([1, 2, 3, 4]), 0, 0, [5, 6, 7], [5, 6, 7, 1, 2, 3, 4])); assert(test(arr([1, 2, 3, 4]), 0, 2, cast(int[])[], [3, 4])); assert(test(arr([1, 2, 3, 4]), 0, 4, [5, 6, 7], [5, 6, 7])); assert(test(arr([1, 2, 3, 4]), 0, 2, [5, 6, 7], [5, 6, 7, 3, 4])); assert(test(arr([1, 2, 3, 4]), 2, 3, [5, 6, 7], [1, 2, 5, 6, 7, 4])); } } /** Tests if T is some kind a set of code points. Intended for template constraints. */ public template isCodepointSet(T) { static if(is(T dummy == InversionList!(Args), Args...)) enum isCodepointSet = true; else enum isCodepointSet = false; } /** Tests if $(D T) is a pair of integers that implicitly convert to $(D V). The following code must compile for any pair $(D T): --- (T x){ V a = x[0]; V b = x[1];} --- The following must not compile: --- (T x){ V c = x[2];} --- */ public template isIntegralPair(T, V=uint) { enum isIntegralPair = is(typeof((T x){ V a = x[0]; V b = x[1];})) && !is(typeof((T x){ V c = x[2]; })); } /** The recommended default type for set of $(CODEPOINTS). For details, see the current implementation: $(LREF InversionList). */ public alias CodepointSet = InversionList!GcPolicy; //@@@BUG: std.typecons tuples depend on std.format to produce fields mixin // which relies on std.uni.isGraphical and this chain blows up with Forward reference error // hence below doesn't seem to work // public alias CodepointInterval = Tuple!(uint, "a", uint, "b"); /** The recommended type of $(XREF _typecons, Tuple) to represent [a, b$(RPAREN) intervals of $(CODEPOINTS). As used in $(LREF InversionList). Any interval type should pass $(LREF isIntegralPair) trait. */ public struct CodepointInterval { pure: uint[2] _tuple; alias _tuple this; @safe pure nothrow @nogc: this(uint low, uint high) { _tuple[0] = low; _tuple[1] = high; } bool opEquals(T)(T val) const { return this[0] == val[0] && this[1] == val[1]; } @property ref inout(uint) a() inout { return _tuple[0]; } @property ref inout(uint) b() inout { return _tuple[1]; } } //@@@BUG another forward reference workaround @trusted bool equalS(R1, R2)(R1 lhs, R2 rhs) { for(;;){ if(lhs.empty) return rhs.empty; if(rhs.empty) return false; if(lhs.front != rhs.front) return false; lhs.popFront(); rhs.popFront(); } } /** $(P $(D InversionList) is a set of $(CODEPOINTS) represented as an array of open-right [a, b$(RPAREN) intervals (see $(LREF CodepointInterval) above). The name comes from the way the representation reads left to right. For instance a set of all values [10, 50$(RPAREN), [80, 90$(RPAREN), plus a singular value 60 looks like this: ) --- 10, 50, 60, 61, 80, 90 --- $(P The way to read this is: start with negative meaning that all numbers smaller then the next one are not present in this set (and positive - the contrary). Then switch positive/negative after each number passed from left to right. ) $(P This way negative spans until 10, then positive until 50, then negative until 60, then positive until 61, and so on. As seen this provides a space-efficient storage of highly redundant data that comes in long runs. A description which Unicode $(CHARACTER) properties fit nicely. The technique itself could be seen as a variation on $(LUCKY RLE encoding). ) $(P Sets are value types (just like $(D int) is) thus they are never aliased. ) Example: --- auto a = CodepointSet('a', 'z'+1); auto b = CodepointSet('A', 'Z'+1); auto c = a; a = a | b; assert(a == CodepointSet('A', 'Z'+1, 'a', 'z'+1)); assert(a != c); --- $(P See also $(LREF unicode) for simpler construction of sets from predefined ones. ) $(P Memory usage is 8 bytes per each contiguous interval in a set. The value semantics are achieved by using the $(WEB en.wikipedia.org/wiki/Copy-on-write, COW) technique and thus it's $(RED not) safe to cast this type to $(D_KEYWORD shared). ) Note: $(P It's not recommended to rely on the template parameters or the exact type of a current $(CODEPOINT) set in $(D std.uni). The type and parameters may change when the standard allocators design is finalized. Use $(LREF isCodepointSet) with templates or just stick with the default alias $(LREF CodepointSet) throughout the whole code base. ) */ @trusted public struct InversionList(SP=GcPolicy) { import std.range : assumeSorted; public: /** Construct from another code point set of any type. */ this(Set)(Set set) pure if(isCodepointSet!Set) { uint[] arr; foreach(v; set.byInterval) { arr ~= v.a; arr ~= v.b; } data = CowArray!(SP).reuse(arr); } /** Construct a set from a forward range of code point intervals. */ this(Range)(Range intervals) pure if(isForwardRange!Range && isIntegralPair!(ElementType!Range)) { uint[] arr; foreach(v; intervals) { SP.append(arr, v.a); SP.append(arr, v.b); } data = CowArray!(SP).reuse(arr); sanitize(); //enforce invariant: sort intervals etc. } //helper function that avoids sanity check to be CTFE-friendly private static fromIntervals(Range)(Range intervals) pure { import std.algorithm : map; import std.range : roundRobin; auto flattened = roundRobin(intervals.save.map!"a[0]"(), intervals.save.map!"a[1]"()); InversionList set; set.data = CowArray!(SP)(flattened); return set; } //ditto untill sort is CTFE-able private static fromIntervals()(uint[] intervals...) pure in { import std.conv : text; assert(intervals.length % 2 == 0, "Odd number of interval bounds [a, b)!"); for (uint i = 0; i < intervals.length; i += 2) { auto a = intervals[i], b = intervals[i+1]; assert(a < b, text("illegal interval [a, b): ", a, " > ", b)); } } body { InversionList set; set.data = CowArray!(SP)(intervals); return set; } /** Construct a set from plain values of code point intervals. */ this()(uint[] intervals...) in { import std.conv : text; assert(intervals.length % 2 == 0, "Odd number of interval bounds [a, b)!"); for (uint i = 0; i < intervals.length; i += 2) { auto a = intervals[i], b = intervals[i+1]; assert(a < b, text("illegal interval [a, b): ", a, " > ", b)); } } body { data = CowArray!(SP)(intervals); sanitize(); //enforce invariant: sort intervals etc. } /// unittest { import std.algorithm.comparison : equal; auto set = CodepointSet('a', 'z'+1, 'а', 'я'+1); foreach(v; 'a'..'z'+1) assert(set[v]); // Cyrillic lowercase interval foreach(v; 'а'..'я'+1) assert(set[v]); //specific order is not required, intervals may interesect auto set2 = CodepointSet('а', 'я'+1, 'a', 'd', 'b', 'z'+1); //the same end result assert(set2.byInterval.equal(set.byInterval)); } /** Get range that spans all of the $(CODEPOINT) intervals in this $(LREF InversionList). Example: ----------- import std.algorithm.comparison : equal; import std.typecons : tuple; auto set = CodepointSet('A', 'D'+1, 'a', 'd'+1); assert(set.byInterval.equal([tuple('A','E'), tuple('a','e')])); ----------- */ @property auto byInterval() { return Intervals!(typeof(data))(data); } /** Tests the presence of code point $(D val) in this set. */ bool opIndex(uint val) const { // the <= ensures that searching in interval of [a, b) for 'a' you get .length == 1 // return assumeSorted!((a,b) => a<=b)(data[]).lowerBound(val).length & 1; return sharSwitchLowerBound!"a<=b"(data[], val) & 1; } /// unittest { auto gothic = unicode.Gothic; // Gothic letter ahsa assert(gothic['\U00010330']); // no ascii in Gothic obviously assert(!gothic['$']); } // Linear scan for $(D ch). Useful only for small sets. // TODO: // used internally in std.regex // should be properly exposed in a public API ? package auto scanFor()(dchar ch) const { immutable len = data.length; for(size_t i = 0; i < len; i++) if(ch < data[i]) return i & 1; return 0; } /// Number of $(CODEPOINTS) in this set @property size_t length() { size_t sum = 0; foreach(iv; byInterval) { sum += iv.b - iv.a; } return sum; } // bootstrap full set operations from 4 primitives (suitable as a template mixin): // addInterval, skipUpTo, dropUpTo & byInterval iteration //============================================================================ public: /** $(P Sets support natural syntax for set algebra, namely: ) $(BOOKTABLE , $(TR $(TH Operator) $(TH Math notation) $(TH Description) ) $(TR $(TD &) $(TD a ∩ b) $(TD intersection) ) $(TR $(TD |) $(TD a ∪ b) $(TD union) ) $(TR $(TD -) $(TD a ∖ b) $(TD subtraction) ) $(TR $(TD ~) $(TD a ~ b) $(TD symmetric set difference i.e. (a ∪ b) \ (a ∩ b)) ) ) */ This opBinary(string op, U)(U rhs) if(isCodepointSet!U || is(U:dchar)) { static if(op == "&" || op == "|" || op == "~") {// symmetric ops thus can swap arguments to reuse r-value static if(is(U:dchar)) { auto tmp = this; mixin("tmp "~op~"= rhs; "); return tmp; } else { static if(is(Unqual!U == U)) { // try hard to reuse r-value mixin("rhs "~op~"= this;"); return rhs; } else { auto tmp = this; mixin("tmp "~op~"= rhs;"); return tmp; } } } else static if(op == "-") // anti-symmetric { auto tmp = this; tmp -= rhs; return tmp; } else static assert(0, "no operator "~op~" defined for Set"); } /// unittest { import std.algorithm.comparison : equal; import std.range : iota; auto lower = unicode.LowerCase; auto upper = unicode.UpperCase; auto ascii = unicode.ASCII; assert((lower & upper).empty); // no intersection auto lowerASCII = lower & ascii; assert(lowerASCII.byCodepoint.equal(iota('a', 'z'+1))); // throw away all of the lowercase ASCII assert((ascii - lower).length == 128 - 26); auto onlyOneOf = lower ~ ascii; assert(!onlyOneOf['Δ']); // not ASCII and not lowercase assert(onlyOneOf['$']); // ASCII and not lowercase assert(!onlyOneOf['a']); // ASCII and lowercase assert(onlyOneOf['я']); // not ASCII but lowercase // throw away all cased letters from ASCII auto noLetters = ascii - (lower | upper); assert(noLetters.length == 128 - 26*2); } /// The 'op=' versions of the above overloaded operators. ref This opOpAssign(string op, U)(U rhs) if(isCodepointSet!U || is(U:dchar)) { static if(op == "|") // union { static if(is(U:dchar)) { this.addInterval(rhs, rhs+1); return this; } else return this.add(rhs); } else static if(op == "&") // intersection return this.intersect(rhs);// overloaded else static if(op == "-") // set difference return this.sub(rhs);// overloaded else static if(op == "~") // symmetric set difference { auto copy = this & rhs; this |= rhs; this -= copy; return this; } else static assert(0, "no operator "~op~" defined for Set"); } /** Tests the presence of codepoint $(D ch) in this set, the same as $(LREF opIndex). */ bool opBinaryRight(string op: "in", U)(U ch) const if(is(U : dchar)) { return this[ch]; } /// unittest { assert('я' in unicode.Cyrillic); assert(!('z' in unicode.Cyrillic)); } /** * Obtains a set that is the inversion of this set. * * See_Also: $(LREF inverted) */ auto opUnary(string op: "!")() { return this.inverted; } /** A range that spans each $(CODEPOINT) in this set. */ @property auto byCodepoint() { @trusted static struct CodepointRange { this(This set) { r = set.byInterval; if(!r.empty) cur = r.front.a; } @property dchar front() const { return cast(dchar)cur; } @property bool empty() const { return r.empty; } void popFront() { cur++; while(cur >= r.front.b) { r.popFront(); if(r.empty) break; cur = r.front.a; } } private: uint cur; typeof(This.init.byInterval) r; } return CodepointRange(this); } /// unittest { import std.algorithm.comparison : equal; import std.range : iota; auto set = unicode.ASCII; set.byCodepoint.equal(iota(0, 0x80)); } /** $(P Obtain textual representation of this set in from of open-right intervals and feed it to $(D sink). ) $(P Used by various standard formatting facilities such as $(XREF _format, formattedWrite), $(XREF _stdio, write), $(XREF _stdio, writef), $(XREF _conv, to) and others. ) Example: --- import std.conv; assert(unicode.ASCII.to!string == "[0..128$(RPAREN)"); --- */ private import std.format : FormatException, FormatSpec; /*************************************** * Obtain a textual representation of this InversionList * in form of open-right intervals. * * The formatting flag is applied individually to each value, for example: * $(LI $(B %s) and $(B %d) format the intervals as a [low..high$(RPAREN) range of integrals) * $(LI $(B %x) formats the intervals as a [low..high$(RPAREN) range of lowercase hex characters) * $(LI $(B %X) formats the intervals as a [low..high$(RPAREN) range of uppercase hex characters) */ void toString(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) /* const */ { import std.format; auto range = byInterval; if(range.empty) return; while (1) { auto i = range.front; range.popFront(); put(sink, "["); formatValue(sink, i.a, fmt); put(sink, ".."); formatValue(sink, i.b, fmt); put(sink, ")"); if (range.empty) return; put(sink, " "); } } /// unittest { import std.conv : to; import std.format : format; import std.uni : unicode; assert(unicode.Cyrillic.to!string == "[1024..1157) [1159..1320) [7467..7468) [7544..7545) [11744..11776) [42560..42648) [42655..42656)"); // The specs '%s' and '%d' are equivalent to the to!string call above. assert(format("%d", unicode.Cyrillic) == unicode.Cyrillic.to!string); assert(format("%#x", unicode.Cyrillic) == "[0x400..0x485) [0x487..0x528) [0x1d2b..0x1d2c) [0x1d78..0x1d79) [0x2de0..0x2e00) [0xa640..0xa698) [0xa69f..0xa6a0)"); assert(format("%#X", unicode.Cyrillic) == "[0X400..0X485) [0X487..0X528) [0X1D2B..0X1D2C) [0X1D78..0X1D79) [0X2DE0..0X2E00) [0XA640..0XA698) [0XA69F..0XA6A0)"); } unittest { import std.exception : assertThrown; import std.format : format; assertThrown!FormatException(format("%a", unicode.ASCII)); } /** Add an interval [a, b$(RPAREN) to this set. */ ref add()(uint a, uint b) { addInterval(a, b); return this; } /// unittest { CodepointSet someSet; someSet.add('0', '5').add('A','Z'+1); someSet.add('5', '9'+1); assert(someSet['0']); assert(someSet['5']); assert(someSet['9']); assert(someSet['Z']); } private: package(std) // used from: std.regex.internal.parser ref intersect(U)(U rhs) if(isCodepointSet!U) { Marker mark; foreach( i; rhs.byInterval) { mark = this.dropUpTo(i.a, mark); mark = this.skipUpTo(i.b, mark); } this.dropUpTo(uint.max, mark); return this; } ref intersect()(dchar ch) { foreach(i; byInterval) if(i.a <= ch && ch < i.b) return this = This.init.add(ch, ch+1); this = This.init; return this; } /// unittest { assert(unicode.Cyrillic.intersect('-').byInterval.empty); } ref sub()(dchar ch) { return subChar(ch); } // same as the above except that skip & drop parts are swapped package(std) // used from: std.regex.internal.parser ref sub(U)(U rhs) if(isCodepointSet!U) { uint top; Marker mark; foreach(i; rhs.byInterval) { mark = this.skipUpTo(i.a, mark); mark = this.dropUpTo(i.b, mark); } return this; } package(std) // used from: std.regex.internal.parse ref add(U)(U rhs) if(isCodepointSet!U) { Marker start; foreach(i; rhs.byInterval) { start = addInterval(i.a, i.b, start); } return this; } // end of mixin-able part //============================================================================ public: /** Obtains a set that is the inversion of this set. See the '!' $(LREF opUnary) for the same but using operators. */ @property auto inverted() { InversionList inversion = this; if(inversion.data.length == 0) { inversion.addInterval(0, lastDchar+1); return inversion; } if(inversion.data[0] != 0) genericReplace(inversion.data, 0, 0, [0]); else genericReplace(inversion.data, 0, 1, cast(uint[])null); if(data[data.length-1] != lastDchar+1) genericReplace(inversion.data, inversion.data.length, inversion.data.length, [lastDchar+1]); else genericReplace(inversion.data, inversion.data.length-1, inversion.data.length, cast(uint[])null); return inversion; } /// unittest { auto set = unicode.ASCII; // union with the inverse gets all of the code points in the Unicode assert((set | set.inverted).length == 0x110000); // no intersection with the inverse assert((set & set.inverted).empty); } /** Generates string with D source code of unary function with name of $(D funcName) taking a single $(D dchar) argument. If $(D funcName) is empty the code is adjusted to be a lambda function. The function generated tests if the $(CODEPOINT) passed belongs to this set or not. The result is to be used with string mixin. The intended usage area is aggressive optimization via meta programming in parser generators and the like. Note: Use with care for relatively small or regular sets. It could end up being slower then just using multi-staged tables. Example: --- import std.stdio; // construct set directly from [a, b$RPAREN intervals auto set = CodepointSet(10, 12, 45, 65, 100, 200); writeln(set); writeln(set.toSourceCode("func")); --- The above outputs something along the lines of: --- bool func(dchar ch) @safe pure nothrow @nogc { if(ch < 45) { if(ch == 10 || ch == 11) return true; return false; } else if (ch < 65) return true; else { if(ch < 100) return false; if(ch < 200) return true; return false; } } --- */ string toSourceCode(string funcName="") { import std.array : array; import std.format : format; import std.algorithm : countUntil; enum maxBinary = 3; static string linearScope(R)(R ivals, string indent) { string result = indent~"{\n"; string deeper = indent~" "; foreach(ival; ivals) { auto span = ival[1] - ival[0]; assert(span != 0); if(span == 1) { result ~= format("%sif(ch == %s) return true;\n", deeper, ival[0]); } else if(span == 2) { result ~= format("%sif(ch == %s || ch == %s) return true;\n", deeper, ival[0], ival[0]+1); } else { if(ival[0] != 0) // dchar is unsigned and < 0 is useless result ~= format("%sif(ch < %s) return false;\n", deeper, ival[0]); result ~= format("%sif(ch < %s) return true;\n", deeper, ival[1]); } } result ~= format("%sreturn false;\n%s}\n", deeper, indent); // including empty range of intervals return result; } static string binaryScope(R)(R ivals, string indent) { // time to do unrolled comparisons? if(ivals.length < maxBinary) return linearScope(ivals, indent); else return bisect(ivals, ivals.length/2, indent); } // not used yet if/elsebinary search is far better with DMD as of 2.061 // and GDC is doing fine job either way static string switchScope(R)(R ivals, string indent) { string result = indent~"switch(ch){\n"; string deeper = indent~" "; foreach(ival; ivals) { if(ival[0]+1 == ival[1]) { result ~= format("%scase %s: return true;\n", deeper, ival[0]); } else { result ~= format("%scase %s: .. case %s: return true;\n", deeper, ival[0], ival[1]-1); } } result ~= deeper~"default: return false;\n"~indent~"}\n"; return result; } static string bisect(R)(R range, size_t idx, string indent) { string deeper = indent ~ " "; // bisect on one [a, b) interval at idx string result = indent~"{\n"; // less branch, < a result ~= format("%sif(ch < %s)\n%s", deeper, range[idx][0], binaryScope(range[0..idx], deeper)); // middle point, >= a && < b result ~= format("%selse if (ch < %s) return true;\n", deeper, range[idx][1]); // greater or equal branch, >= b result ~= format("%selse\n%s", deeper, binaryScope(range[idx+1..$], deeper)); return result~indent~"}\n"; } string code = format("bool %s(dchar ch) @safe pure nothrow @nogc\n", funcName.empty ? "function" : funcName); auto range = byInterval.array(); // special case first bisection to be on ASCII vs beyond auto tillAscii = countUntil!"a[0] > 0x80"(range); if(tillAscii <= 0) // everything is ASCII or nothing is ascii (-1 & 0) code ~= binaryScope(range, ""); else code ~= bisect(range, tillAscii, ""); return code; } /** True if this set doesn't contain any $(CODEPOINTS). */ @property bool empty() const { return data.length == 0; } /// unittest { CodepointSet emptySet; assert(emptySet.length == 0); assert(emptySet.empty); } private: alias This = typeof(this); alias Marker = size_t; // a random-access range of integral pairs static struct Intervals(Range) { this(Range sp) { slice = sp; start = 0; end = sp.length; } this(Range sp, size_t s, size_t e) { slice = sp; start = s; end = e; } @property auto front()const { uint a = slice[start]; uint b = slice[start+1]; return CodepointInterval(a, b); } //may break sorted property - but we need std.sort to access it //hence package protection attribute package @property auto front(CodepointInterval val) { slice[start] = val.a; slice[start+1] = val.b; } @property auto back()const { uint a = slice[end-2]; uint b = slice[end-1]; return CodepointInterval(a, b); } //ditto about package package @property auto back(CodepointInterval val) { slice[end-2] = val.a; slice[end-1] = val.b; } void popFront() { start += 2; } void popBack() { end -= 2; } auto opIndex(size_t idx) const { uint a = slice[start+idx*2]; uint b = slice[start+idx*2+1]; return CodepointInterval(a, b); } //ditto about package package auto opIndexAssign(CodepointInterval val, size_t idx) { slice[start+idx*2] = val.a; slice[start+idx*2+1] = val.b; } auto opSlice(size_t s, size_t e) { return Intervals(slice, s*2+start, e*2+start); } @property size_t length()const { return slice.length/2; } @property bool empty()const { return start == end; } @property auto save(){ return this; } private: size_t start, end; Range slice; } // called after construction from intervals // to make sure invariants hold void sanitize() { import std.algorithm : sort, SwapStrategy, max; if (data.length == 0) return; alias Ival = CodepointInterval; //intervals wrapper for a _range_ over packed array auto ivals = Intervals!(typeof(data[]))(data[]); //@@@BUG@@@ can't use "a.a < b.a" see issue 12265 sort!((a,b) => a.a < b.a, SwapStrategy.stable)(ivals); // what follows is a variation on stable remove // differences: // - predicate is binary, and is tested against // the last kept element (at 'i'). // - predicate mutates lhs (merges rhs into lhs) size_t len = ivals.length; size_t i = 0; size_t j = 1; while (j < len) { if (ivals[i].b >= ivals[j].a) { ivals[i] = Ival(ivals[i].a, max(ivals[i].b, ivals[j].b)); j++; } else //unmergable { // check if there is a hole after merges // (in the best case we do 0 writes to ivals) if (j != i+1) ivals[i+1] = ivals[j]; //copy over i++; j++; } } len = i + 1; for (size_t k=0; k + 1 < len; k++) { assert(ivals[k].a < ivals[k].b); assert(ivals[k].b < ivals[k+1].a); } data.length = len * 2; } // special case for normal InversionList ref subChar(dchar ch) { auto mark = skipUpTo(ch); if(mark != data.length && data[mark] == ch && data[mark-1] == ch) { // it has split, meaning that ch happens to be in one of intervals data[mark] = data[mark]+1; } return this; } // Marker addInterval(int a, int b, Marker hint=Marker.init) in { assert(a <= b); } body { import std.range : assumeSorted, SearchPolicy; auto range = assumeSorted(data[]); size_t pos; size_t a_idx = hint + range[hint..$].lowerBound!(SearchPolicy.gallop)(a).length; if(a_idx == range.length) { // [---+++----++++----++++++] // [ a b] data.append(a, b); return data.length-1; } size_t b_idx = range[a_idx..range.length].lowerBound!(SearchPolicy.gallop)(b).length+a_idx; uint[3] buf = void; uint to_insert; debug(std_uni) { writefln("a_idx=%d; b_idx=%d;", a_idx, b_idx); } if(b_idx == range.length) { // [-------++++++++----++++++-] // [ s a b] if(a_idx & 1)// a in positive { buf[0] = b; to_insert = 1; } else// a in negative { buf[0] = a; buf[1] = b; to_insert = 2; } pos = genericReplace(data, a_idx, b_idx, buf[0..to_insert]); return pos - 1; } uint top = data[b_idx]; debug(std_uni) { writefln("a_idx=%d; b_idx=%d;", a_idx, b_idx); writefln("a=%s; b=%s; top=%s;", a, b, top); } if(a_idx & 1) {// a in positive if(b_idx & 1)// b in positive { // [-------++++++++----++++++-] // [ s a b ] buf[0] = top; to_insert = 1; } else // b in negative { // [-------++++++++----++++++-] // [ s a b ] if(top == b) { assert(b_idx+1 < data.length); buf[0] = data[b_idx+1]; pos = genericReplace(data, a_idx, b_idx+2, buf[0..1]); return pos - 1; } buf[0] = b; buf[1] = top; to_insert = 2; } } else { // a in negative if(b_idx & 1) // b in positive { // [----------+++++----++++++-] // [ a b ] buf[0] = a; buf[1] = top; to_insert = 2; } else// b in negative { // [----------+++++----++++++-] // [ a s b ] if(top == b) { assert(b_idx+1 < data.length); buf[0] = a; buf[1] = data[b_idx+1]; pos = genericReplace(data, a_idx, b_idx+2, buf[0..2]); return pos - 1; } buf[0] = a; buf[1] = b; buf[2] = top; to_insert = 3; } } pos = genericReplace(data, a_idx, b_idx+1, buf[0..to_insert]); debug(std_uni) { writefln("marker idx: %d; length=%d", pos, data[pos], data.length); writeln("inserting ", buf[0..to_insert]); } return pos - 1; } // Marker dropUpTo(uint a, Marker pos=Marker.init) in { assert(pos % 2 == 0); // at start of interval } body { auto range = assumeSorted!"a<=b"(data[pos..data.length]); if(range.empty) return pos; size_t idx = pos; idx += range.lowerBound(a).length; debug(std_uni) { writeln("dropUpTo full length=", data.length); writeln(pos,"~~~", idx); } if(idx == data.length) return genericReplace(data, pos, idx, cast(uint[])[]); if(idx & 1) { // a in positive //[--+++----++++++----+++++++------...] // |<---si s a t genericReplace(data, pos, idx, [a]); } else { // a in negative //[--+++----++++++----+++++++-------+++...] // |<---si s a t genericReplace(data, pos, idx, cast(uint[])[]); } return pos; } // Marker skipUpTo(uint a, Marker pos=Marker.init) out(result) { assert(result % 2 == 0);// always start of interval //(may be 0-width after-split) } body { assert(data.length % 2 == 0); auto range = assumeSorted!"a<=b"(data[pos..data.length]); size_t idx = pos+range.lowerBound(a).length; if(idx >= data.length) // could have Marker point to recently removed stuff return data.length; if(idx & 1)// inside of interval, check for split { uint top = data[idx]; if(top == a)// no need to split, it's end return idx+1; uint start = data[idx-1]; if(a == start) return idx-1; // split it up genericReplace(data, idx, idx+1, [a, a, top]); return idx+1; // avoid odd index } return idx; } CowArray!SP data; } @system unittest { import std.conv; assert(unicode.ASCII.to!string() == "[0..128)"); } // pedantic version for ctfe, and aligned-access only architectures @trusted uint safeRead24(const ubyte* ptr, size_t idx) pure nothrow @nogc { idx *= 3; version(LittleEndian) return ptr[idx] + (cast(uint)ptr[idx+1]<<8) + (cast(uint)ptr[idx+2]<<16); else return (cast(uint)ptr[idx]<<16) + (cast(uint)ptr[idx+1]<<8) + ptr[idx+2]; } // ditto @trusted void safeWrite24(ubyte* ptr, uint val, size_t idx) pure nothrow @nogc { idx *= 3; version(LittleEndian) { ptr[idx] = val & 0xFF; ptr[idx+1] = (val>>8) & 0xFF; ptr[idx+2] = (val>>16) & 0xFF; } else { ptr[idx] = (val>>16) & 0xFF; ptr[idx+1] = (val>>8) & 0xFF; ptr[idx+2] = val & 0xFF; } } // unaligned x86-like read/write functions @trusted uint unalignedRead24(const ubyte* ptr, size_t idx) pure nothrow @nogc { uint* src = cast(uint*)(ptr+3*idx); version(LittleEndian) return *src & 0xFF_FFFF; else return *src >> 8; } // ditto @trusted void unalignedWrite24(ubyte* ptr, uint val, size_t idx) pure nothrow @nogc { uint* dest = cast(uint*)(cast(ubyte*)ptr + 3*idx); version(LittleEndian) *dest = val | (*dest & 0xFF00_0000); else *dest = (val<<8) | (*dest & 0xFF); } uint read24(const ubyte* ptr, size_t idx) @safe pure nothrow @nogc { static if(hasUnalignedReads) return __ctfe ? safeRead24(ptr, idx) : unalignedRead24(ptr, idx); else return safeRead24(ptr, idx); } void write24(ubyte* ptr, uint val, size_t idx) @safe pure nothrow @nogc { static if(hasUnalignedReads) return __ctfe ? safeWrite24(ptr, val, idx) : unalignedWrite24(ptr, val, idx); else return safeWrite24(ptr, val, idx); } @trusted struct CowArray(SP=GcPolicy) { static auto reuse(uint[] arr) { CowArray cow; cow.data = arr; SP.append(cow.data, 1); assert(cow.refCount == 1); assert(cow.length == arr.length); return cow; } this(Range)(Range range) if(isInputRange!Range && hasLength!Range) { import std.algorithm : copy; length = range.length; copy(range, data[0..$-1]); } this(Range)(Range range) if(isForwardRange!Range && !hasLength!Range) { import std.algorithm : copy; auto len = walkLength(range.save); length = len; copy(range, data[0..$-1]); } this(this) { if(!empty) { refCount = refCount + 1; } } ~this() { if(!empty) { auto cnt = refCount; if(cnt == 1) SP.destroy(data); else refCount = cnt - 1; } } // no ref-count for empty U24 array @property bool empty() const { return data.length == 0; } // report one less then actual size @property size_t length() const { return data.length ? data.length - 1 : 0; } //+ an extra slot for ref-count @property void length(size_t len) { import std.algorithm : min, copy; if(len == 0) { if(!empty) freeThisReference(); return; } immutable total = len + 1; // including ref-count if(empty) { data = SP.alloc!uint(total); refCount = 1; return; } auto cur_cnt = refCount; if(cur_cnt != 1) // have more references to this memory { refCount = cur_cnt - 1; auto new_data = SP.alloc!uint(total); // take shrinking into account auto to_copy = min(total, data.length) - 1; copy(data[0..to_copy], new_data[0..to_copy]); data = new_data; // before setting refCount! refCount = 1; } else // 'this' is the only reference { // use the realloc (hopefully in-place operation) data = SP.realloc(data, total); refCount = 1; // setup a ref-count in the new end of the array } } alias opDollar = length; uint opIndex()(size_t idx)const { return data[idx]; } void opIndexAssign(uint val, size_t idx) { auto cnt = refCount; if(cnt != 1) dupThisReference(cnt); data[idx] = val; } // auto opSlice(size_t from, size_t to) { if(!empty) { auto cnt = refCount; if(cnt != 1) dupThisReference(cnt); } return data[from .. to]; } // auto opSlice(size_t from, size_t to) const { return data[from .. to]; } // length slices before the ref count auto opSlice() { return opSlice(0, length); } // ditto auto opSlice() const { return opSlice(0, length); } void append(Range)(Range range) if(isInputRange!Range && hasLength!Range && is(ElementType!Range : uint)) { size_t nl = length + range.length; length = nl; copy(range, this[nl-range.length..nl]); } void append()(uint[] val...) { length = length + val.length; data[$-val.length-1 .. $-1] = val[]; } bool opEquals()(auto const ref CowArray rhs)const { if(empty ^ rhs.empty) return false; // one is empty and the other isn't return empty || data[0..$-1] == rhs.data[0..$-1]; } private: // ref-count is right after the data @property uint refCount() const { return data[$-1]; } @property void refCount(uint cnt) { data[$-1] = cnt; } void freeThisReference() { auto count = refCount; if(count != 1) // have more references to this memory { // dec shared ref-count refCount = count - 1; data = []; } else SP.destroy(data); assert(!data.ptr); } void dupThisReference(uint count) in { assert(!empty && count != 1 && count == refCount); } body { import std.algorithm : copy; // dec shared ref-count refCount = count - 1; // copy to the new chunk of RAM auto new_data = SP.alloc!uint(data.length); // bit-blit old stuff except the counter copy(data[0..$-1], new_data[0..$-1]); data = new_data; // before setting refCount! refCount = 1; // so that this updates the right one } uint[] data; } @safe unittest// Uint24 tests { import std.algorithm; import std.conv; import std.range; void funcRef(T)(ref T u24) { u24.length = 2; u24[1] = 1024; T u24_c = u24; assert(u24[1] == 1024); u24.length = 0; assert(u24.empty); u24.append([1, 2]); assert(equalS(u24[], [1, 2])); u24.append(111); assert(equalS(u24[], [1, 2, 111])); assert(!u24_c.empty && u24_c[1] == 1024); u24.length = 3; copy(iota(0, 3), u24[]); assert(equalS(u24[], iota(0, 3))); assert(u24_c[1] == 1024); } void func2(T)(T u24) { T u24_2 = u24; T u24_3; u24_3 = u24_2; assert(u24_2 == u24_3); assert(equalS(u24[], u24_2[])); assert(equalS(u24_2[], u24_3[])); funcRef(u24_3); assert(equalS(u24_3[], iota(0, 3))); assert(!equalS(u24_2[], u24_3[])); assert(equalS(u24_2[], u24[])); u24_2 = u24_3; assert(equalS(u24_2[], iota(0, 3))); // to test that passed arg is intact outside // plus try out opEquals u24 = u24_3; u24 = T.init; u24_3 = T.init; assert(u24.empty); assert(u24 == u24_3); assert(u24 != u24_2); } foreach(Policy; AliasSeq!(GcPolicy, ReallocPolicy)) { alias Range = typeof(CowArray!Policy.init[]); alias U24A = CowArray!Policy; static assert(isForwardRange!Range); static assert(isBidirectionalRange!Range); static assert(isOutputRange!(Range, uint)); static assert(isRandomAccessRange!(Range)); auto arr = U24A([42u, 36, 100]); assert(arr[0] == 42); assert(arr[1] == 36); arr[0] = 72; arr[1] = 0xFE_FEFE; assert(arr[0] == 72); assert(arr[1] == 0xFE_FEFE); assert(arr[2] == 100); U24A arr2 = arr; assert(arr2[0] == 72); arr2[0] = 11; // test COW-ness assert(arr[0] == 72); assert(arr2[0] == 11); // set this to about 100M to stress-test COW memory management foreach(v; 0..10_000) func2(arr); assert(equalS(arr[], [72, 0xFE_FEFE, 100])); auto r2 = U24A(iota(0, 100)); assert(equalS(r2[], iota(0, 100)), text(r2[])); copy(iota(10, 170, 2), r2[10..90]); assert(equalS(r2[], chain(iota(0, 10), iota(10, 170, 2), iota(90, 100))) , text(r2[])); } } version(unittest) { private alias AllSets = AliasSeq!(InversionList!GcPolicy, InversionList!ReallocPolicy); } @safe unittest// core set primitives test { import std.conv; foreach(CodeList; AllSets) { CodeList a; //"plug a hole" test a.add(10, 20).add(25, 30).add(15, 27); assert(a == CodeList(10, 30), text(a)); auto x = CodeList.init; x.add(10, 20).add(30, 40).add(50, 60); a = x; a.add(20, 49);//[10, 49) [50, 60) assert(a == CodeList(10, 49, 50 ,60)); a = x; a.add(20, 50); assert(a == CodeList(10, 60), text(a)); // simple unions, mostly edge effects x = CodeList.init; x.add(10, 20).add(40, 60); a = x; a.add(10, 25); //[10, 25) [40, 60) assert(a == CodeList(10, 25, 40, 60)); a = x; a.add(5, 15); //[5, 20) [40, 60) assert(a == CodeList(5, 20, 40, 60)); a = x; a.add(0, 10); // [0, 20) [40, 60) assert(a == CodeList(0, 20, 40, 60)); a = x; a.add(0, 5); // prepand assert(a == CodeList(0, 5, 10, 20, 40, 60), text(a)); a = x; a.add(5, 20); assert(a == CodeList(5, 20, 40, 60)); a = x; a.add(3, 37); assert(a == CodeList(3, 37, 40, 60)); a = x; a.add(37, 65); assert(a == CodeList(10, 20, 37, 65)); // some tests on helpers for set intersection x = CodeList.init.add(10, 20).add(40, 60).add(100, 120); a = x; auto m = a.skipUpTo(60); a.dropUpTo(110, m); assert(a == CodeList(10, 20, 40, 60, 110, 120), text(a.data[])); a = x; a.dropUpTo(100); assert(a == CodeList(100, 120), text(a.data[])); a = x; m = a.skipUpTo(50); a.dropUpTo(140, m); assert(a == CodeList(10, 20, 40, 50), text(a.data[])); a = x; a.dropUpTo(60); assert(a == CodeList(100, 120), text(a.data[])); } } //test constructor to work with any order of intervals @safe unittest { import std.conv, std.range, std.algorithm; import std.typecons; //ensure constructor handles bad ordering and overlap auto c1 = CodepointSet('а', 'я'+1, 'А','Я'+1); foreach(ch; chain(iota('а', 'я'+1), iota('А','Я'+1))) assert(ch in c1, to!string(ch)); //contiguos assert(CodepointSet(1000, 1006, 1006, 1009) .byInterval.equal([tuple(1000, 1009)])); //contains assert(CodepointSet(900, 1200, 1000, 1100) .byInterval.equal([tuple(900, 1200)])); //intersect left assert(CodepointSet(900, 1100, 1000, 1200) .byInterval.equal([tuple(900, 1200)])); //intersect right assert(CodepointSet(1000, 1200, 900, 1100) .byInterval.equal([tuple(900, 1200)])); //ditto with extra items at end assert(CodepointSet(1000, 1200, 900, 1100, 800, 850) .byInterval.equal([tuple(800, 850), tuple(900, 1200)])); assert(CodepointSet(900, 1100, 1000, 1200, 800, 850) .byInterval.equal([tuple(800, 850), tuple(900, 1200)])); //"plug a hole" test auto c2 = CodepointSet(20, 40, 60, 80, 100, 140, 150, 200, 40, 60, 80, 100, 140, 150 ); assert(c2.byInterval.equal([tuple(20, 200)])); auto c3 = CodepointSet( 20, 40, 60, 80, 100, 140, 150, 200, 0, 10, 15, 100, 10, 20, 200, 220); assert(c3.byInterval.equal([tuple(0, 140), tuple(150, 220)])); } @safe unittest { // full set operations import std.conv; foreach(CodeList; AllSets) { CodeList a, b, c, d; //"plug a hole" a.add(20, 40).add(60, 80).add(100, 140).add(150, 200); b.add(40, 60).add(80, 100).add(140, 150); c = a | b; d = b | a; assert(c == CodeList(20, 200), text(CodeList.stringof," ", c)); assert(c == d, text(c," vs ", d)); b = CodeList.init.add(25, 45).add(65, 85).add(95,110).add(150, 210); c = a | b; //[20,45) [60, 85) [95, 140) [150, 210) d = b | a; assert(c == CodeList(20, 45, 60, 85, 95, 140, 150, 210), text(c)); assert(c == d, text(c," vs ", d)); b = CodeList.init.add(10, 20).add(30,100).add(145,200); c = a | b;//[10, 140) [145, 200) d = b | a; assert(c == CodeList(10, 140, 145, 200)); assert(c == d, text(c," vs ", d)); b = CodeList.init.add(0, 10).add(15, 100).add(10, 20).add(200, 220); c = a | b;//[0, 140) [150, 220) d = b | a; assert(c == CodeList(0, 140, 150, 220)); assert(c == d, text(c," vs ", d)); a = CodeList.init.add(20, 40).add(60, 80); b = CodeList.init.add(25, 35).add(65, 75); c = a & b; d = b & a; assert(c == CodeList(25, 35, 65, 75), text(c)); assert(c == d, text(c," vs ", d)); a = CodeList.init.add(20, 40).add(60, 80).add(100, 140).add(150, 200); b = CodeList.init.add(25, 35).add(65, 75).add(110, 130).add(160, 180); c = a & b; d = b & a; assert(c == CodeList(25, 35, 65, 75, 110, 130, 160, 180), text(c)); assert(c == d, text(c," vs ", d)); a = CodeList.init.add(20, 40).add(60, 80).add(100, 140).add(150, 200); b = CodeList.init.add(10, 30).add(60, 120).add(135, 160); c = a & b;//[20, 30)[60, 80) [100, 120) [135, 140) [150, 160) d = b & a; assert(c == CodeList(20, 30, 60, 80, 100, 120, 135, 140, 150, 160),text(c)); assert(c == d, text(c, " vs ",d)); assert((c & a) == c); assert((d & b) == d); assert((c & d) == d); b = CodeList.init.add(40, 60).add(80, 100).add(140, 200); c = a & b; d = b & a; assert(c == CodeList(150, 200), text(c)); assert(c == d, text(c, " vs ",d)); assert((c & a) == c); assert((d & b) == d); assert((c & d) == d); assert((a & a) == a); assert((b & b) == b); a = CodeList.init.add(20, 40).add(60, 80).add(100, 140).add(150, 200); b = CodeList.init.add(30, 60).add(75, 120).add(190, 300); c = a - b;// [30, 40) [60, 75) [120, 140) [150, 190) d = b - a;// [40, 60) [80, 100) [200, 300) assert(c == CodeList(20, 30, 60, 75, 120, 140, 150, 190), text(c)); assert(d == CodeList(40, 60, 80, 100, 200, 300), text(d)); assert(c - d == c, text(c-d, " vs ", c)); assert(d - c == d, text(d-c, " vs ", d)); assert(c - c == CodeList.init); assert(d - d == CodeList.init); a = CodeList.init.add(20, 40).add( 60, 80).add(100, 140).add(150, 200); b = CodeList.init.add(10, 50).add(60, 160).add(190, 300); c = a - b;// [160, 190) d = b - a;// [10, 20) [40, 50) [80, 100) [140, 150) [200, 300) assert(c == CodeList(160, 190), text(c)); assert(d == CodeList(10, 20, 40, 50, 80, 100, 140, 150, 200, 300), text(d)); assert(c - d == c, text(c-d, " vs ", c)); assert(d - c == d, text(d-c, " vs ", d)); assert(c - c == CodeList.init); assert(d - d == CodeList.init); a = CodeList.init.add(20, 40).add(60, 80).add(100, 140).add(150, 200); b = CodeList.init.add(10, 30).add(45, 100).add(130, 190); c = a ~ b; // [10, 20) [30, 40) [45, 60) [80, 130) [140, 150) [190, 200) d = b ~ a; assert(c == CodeList(10, 20, 30, 40, 45, 60, 80, 130, 140, 150, 190, 200), text(c)); assert(c == d, text(c, " vs ", d)); } } } @safe unittest// vs single dchar { import std.conv; CodepointSet a = CodepointSet(10, 100, 120, 200); assert(a - 'A' == CodepointSet(10, 65, 66, 100, 120, 200), text(a - 'A')); assert((a & 'B') == CodepointSet(66, 67)); } @safe unittest// iteration & opIndex { import std.conv; import std.typecons; foreach(CodeList; AliasSeq!(InversionList!(ReallocPolicy))) { auto arr = "ABCDEFGHIJKLMabcdefghijklm"d; auto a = CodeList('A','N','a', 'n'); assert(equalS(a.byInterval, [tuple(cast(uint)'A', cast(uint)'N'), tuple(cast(uint)'a', cast(uint)'n')] ), text(a.byInterval)); // same @@@BUG as in issue 8949 ? version(bug8949) { assert(equalS(retro(a.byInterval), [tuple(cast(uint)'a', cast(uint)'n'), tuple(cast(uint)'A', cast(uint)'N')] ), text(retro(a.byInterval))); } auto achr = a.byCodepoint; assert(equalS(achr, arr), text(a.byCodepoint)); foreach(ch; a.byCodepoint) assert(a[ch]); auto x = CodeList(100, 500, 600, 900, 1200, 1500); assert(equalS(x.byInterval, [ tuple(100, 500), tuple(600, 900), tuple(1200, 1500)]), text(x.byInterval)); foreach(ch; x.byCodepoint) assert(x[ch]); static if(is(CodeList == CodepointSet)) { auto y = CodeList(x.byInterval); assert(equalS(x.byInterval, y.byInterval)); } assert(equalS(CodepointSet.init.byInterval, cast(Tuple!(uint, uint)[])[])); assert(equalS(CodepointSet.init.byCodepoint, cast(dchar[])[])); } } //============================================================================ // Generic Trie template and various ways to build it //============================================================================ // debug helper to get a shortened array dump auto arrayRepr(T)(T x) { import std.conv : text; if(x.length > 32) { return text(x[0..16],"~...~", x[x.length-16..x.length]); } else return text(x); } /** Maps $(D Key) to a suitable integer index within the range of $(D size_t). The mapping is constructed by applying predicates from $(D Prefix) left to right and concatenating the resulting bits. The first (leftmost) predicate defines the most significant bits of the resulting index. */ template mapTrieIndex(Prefix...) { size_t mapTrieIndex(Key)(Key key) if(isValidPrefixForTrie!(Key, Prefix)) { alias p = Prefix; size_t idx; foreach(i, v; p[0..$-1]) { idx |= p[i](key); idx <<= p[i+1].bitSize; } idx |= p[$-1](key); return idx; } } /* $(D TrieBuilder) is a type used for incremental construction of $(LREF Trie)s. See $(LREF buildTrie) for generic helpers built on top of it. */ @trusted struct TrieBuilder(Value, Key, Args...) if(isBitPackableType!Value && isValidArgsForTrie!(Key, Args)) { import std.exception : enforce; private: // last index is not stored in table, it is used as an offset to values in a block. static if(is(Value == bool))// always pack bool alias V = BitPacked!(Value, 1); else alias V = Value; static auto deduceMaxIndex(Preds...)() { size_t idx = 1; foreach(v; Preds) idx *= 2^^v.bitSize; return idx; } static if(is(typeof(Args[0]) : Key)) // Args start with upper bound on Key { alias Prefix = Args[1..$]; enum lastPageSize = 2^^Prefix[$-1].bitSize; enum translatedMaxIndex = mapTrieIndex!(Prefix)(Args[0]); enum roughedMaxIndex = (translatedMaxIndex + lastPageSize-1)/lastPageSize*lastPageSize; // check warp around - if wrapped, use the default deduction rule enum maxIndex = roughedMaxIndex < translatedMaxIndex ? deduceMaxIndex!(Prefix)() : roughedMaxIndex; } else { alias Prefix = Args; enum maxIndex = deduceMaxIndex!(Prefix)(); } alias getIndex = mapTrieIndex!(Prefix); enum lastLevel = Prefix.length-1; struct ConstructState { size_t idx_zeros, idx_ones; } // iteration over levels of Trie, each indexes its own level and thus a shortened domain size_t[Prefix.length] indices; // default filler value to use Value defValue; // this is a full-width index of next item size_t curIndex; // all-zeros page index, all-ones page index (+ indicator if there is such a page) ConstructState[Prefix.length] state; // the table being constructed MultiArray!(idxTypes!(Key, fullBitSize!(Prefix), Prefix[0..$]), V) table; @disable this(); //shortcut for index variable at level 'level' @property ref idx(size_t level)(){ return indices[level]; } // this function assumes no holes in the input so // indices are going one by one void addValue(size_t level, T)(T val, size_t numVals) { alias j = idx!level; enum pageSize = 1<<Prefix[level].bitSize; if(numVals == 0) return; auto ptr = table.slice!(level); if(numVals == 1) { static if(level == Prefix.length-1) ptr[j] = val; else {// can incur narrowing conversion assert(j < ptr.length); ptr[j] = force!(typeof(ptr[j]))(val); } j++; if(j % pageSize == 0) spillToNextPage!level(ptr); return; } // longer row of values // get to the next page boundary size_t nextPB = (j + pageSize) & ~(pageSize-1); size_t n = nextPB - j;// can fill right in this page if(numVals < n) //fits in current page { ptr[j..j+numVals] = val; j += numVals; return; } static if(level != 0)//on the first level it always fits { numVals -= n; //write till the end of current page ptr[j..j+n] = val; j += n; //spill to the next page spillToNextPage!level(ptr); // page at once loop if(state[level].idx_zeros != size_t.max && val == T.init) { alias NextIdx = typeof(table.slice!(level-1)[0]); addValue!(level-1)(force!NextIdx(state[level].idx_zeros), numVals/pageSize); ptr = table.slice!level; //table structure might have changed numVals %= pageSize; } else { while(numVals >= pageSize) { numVals -= pageSize; ptr[j..j+pageSize] = val; j += pageSize; spillToNextPage!level(ptr); } } if(numVals) { // the leftovers, an incomplete page ptr[j..j+numVals] = val; j += numVals; } } } void spillToNextPage(size_t level, Slice)(ref Slice ptr) { // last level (i.e. topmost) has 1 "page" // thus it need not to add a new page on upper level static if(level != 0) spillToNextPageImpl!(level)(ptr); } // this can re-use the current page if duplicate or allocate a new one // it also makes sure that previous levels point to the correct page in this level void spillToNextPageImpl(size_t level, Slice)(ref Slice ptr) { alias NextIdx = typeof(table.slice!(level-1)[0]); NextIdx next_lvl_index; enum pageSize = 1<<Prefix[level].bitSize; assert(idx!level % pageSize == 0); auto last = idx!level-pageSize; auto slice = ptr[idx!level - pageSize..idx!level]; size_t j; for(j=0; j<last; j+=pageSize) { if(ptr[j..j+pageSize] == slice) { // get index to it, reuse ptr space for the next block next_lvl_index = force!NextIdx(j/pageSize); version(none) { writefln("LEVEL(%s) page maped idx: %s: 0..%s ---> [%s..%s]" ,level ,indices[level-1], pageSize, j, j+pageSize); writeln("LEVEL(", level , ") mapped page is: ", slice, ": ", arrayRepr(ptr[j..j+pageSize])); writeln("LEVEL(", level , ") src page is :", ptr, ": ", arrayRepr(slice[0..pageSize])); } idx!level -= pageSize; // reuse this page, it is duplicate break; } } if(j == last) { L_allocate_page: next_lvl_index = force!NextIdx(idx!level/pageSize - 1); if(state[level].idx_zeros == size_t.max && ptr.zeros(j, j+pageSize)) { state[level].idx_zeros = next_lvl_index; } // allocate next page version(none) { writefln("LEVEL(%s) page allocated: %s" , level, arrayRepr(slice[0..pageSize])); writefln("LEVEL(%s) index: %s ; page at this index %s" , level , next_lvl_index , arrayRepr( table.slice!(level) [pageSize*next_lvl_index..(next_lvl_index+1)*pageSize] )); } table.length!level = table.length!level + pageSize; } L_know_index: // for the previous level, values are indices to the pages in the current level addValue!(level-1)(next_lvl_index, 1); ptr = table.slice!level; //re-load the slice after moves } // idx - full-width index to fill with v (full-width index != key) // fills everything in the range of [curIndex, idx) with filler void putAt(size_t idx, Value v) { assert(idx >= curIndex); size_t numFillers = idx - curIndex; addValue!lastLevel(defValue, numFillers); addValue!lastLevel(v, 1); curIndex = idx + 1; } // ditto, but sets the range of [idxA, idxB) to v void putRangeAt(size_t idxA, size_t idxB, Value v) { assert(idxA >= curIndex); assert(idxB >= idxA); size_t numFillers = idxA - curIndex; addValue!lastLevel(defValue, numFillers); addValue!lastLevel(v, idxB - idxA); curIndex = idxB; // open-right } enum errMsg = "non-monotonic prefix function(s), an unsorted range or "~ "duplicate key->value mapping"; public: /** Construct a builder, where $(D filler) is a value to indicate empty slots (or "not found" condition). */ this(Value filler) { curIndex = 0; defValue = filler; // zeros-page index, ones-page index foreach(ref v; state) v = ConstructState(size_t.max, size_t.max); table = typeof(table)(indices); // one page per level is a bootstrap minimum foreach(i, Pred; Prefix) table.length!i = (1<<Pred.bitSize); } /** Put a value $(D v) into interval as mapped by keys from $(D a) to $(D b). All slots prior to $(D a) are filled with the default filler. */ void putRange(Key a, Key b, Value v) { auto idxA = getIndex(a), idxB = getIndex(b); // indexes of key should always grow enforce(idxB >= idxA && idxA >= curIndex, errMsg); putRangeAt(idxA, idxB, v); } /** Put a value $(D v) into slot mapped by $(D key). All slots prior to $(D key) are filled with the default filler. */ void putValue(Key key, Value v) { import std.conv : text; auto idx = getIndex(key); enforce(idx >= curIndex, text(errMsg, " ", idx)); putAt(idx, v); } /// Finishes construction of Trie, yielding an immutable Trie instance. auto build() { static if(maxIndex != 0) // doesn't cover full range of size_t { assert(curIndex <= maxIndex); addValue!lastLevel(defValue, maxIndex - curIndex); } else { if(curIndex != 0 // couldn't wrap around || (Prefix.length != 1 && indices[lastLevel] == 0)) // can be just empty { addValue!lastLevel(defValue, size_t.max - curIndex); addValue!lastLevel(defValue, 1); } // else curIndex already completed the full range of size_t by wrapping around } return Trie!(V, Key, maxIndex, Prefix)(table); } } /* $(P A generic Trie data-structure for a fixed number of stages. The design goal is optimal speed with smallest footprint size. ) $(P It's intentionally read-only and doesn't provide constructors. To construct one use a special builder, see $(LREF TrieBuilder) and $(LREF buildTrie). ) */ @trusted public struct Trie(Value, Key, Args...) if(isValidPrefixForTrie!(Key, Args) || (isValidPrefixForTrie!(Key, Args[1..$]) && is(typeof(Args[0]) : size_t))) { static if(is(typeof(Args[0]) : size_t)) { enum maxIndex = Args[0]; enum hasBoundsCheck = true; alias Prefix = Args[1..$]; } else { enum hasBoundsCheck = false; alias Prefix = Args; } private this()(typeof(_table) table) { _table = table; } // only for constant Tries constructed from precompiled tables private this()(const(size_t)[] offsets, const(size_t)[] sizes, const(size_t)[] data) const { _table = typeof(_table)(offsets, sizes, data); } /* $(P Lookup the $(D key) in this $(D Trie). ) $(P The lookup always succeeds if key fits the domain provided during construction. The whole domain defined is covered so instead of not found condition the sentinel (filler) value could be used. ) $(P See $(LREF buildTrie), $(LREF TrieBuilder) for how to define a domain of $(D Trie) keys and the sentinel value. ) Note: Domain range-checking is only enabled in debug builds and results in assertion failure. */ // templated to auto-detect pure, @safe and nothrow TypeOfBitPacked!Value opIndex()(Key key) const { static if(hasBoundsCheck) assert(mapTrieIndex!Prefix(key) < maxIndex); size_t idx; alias p = Prefix; idx = cast(size_t)p[0](key); foreach(i, v; p[0..$-1]) idx = cast(size_t)((_table.ptr!i[idx]<<p[i+1].bitSize) + p[i+1](key)); return _table.ptr!(p.length-1)[idx]; } @property size_t bytes(size_t n=size_t.max)() const { return _table.bytes!n; } @property size_t pages(size_t n)() const { return (bytes!n+2^^(Prefix[n].bitSize-1)) /2^^Prefix[n].bitSize; } void store(OutRange)(scope OutRange sink) const if(isOutputRange!(OutRange, char)) { _table.store(sink); } private: MultiArray!(idxTypes!(Key, fullBitSize!(Prefix), Prefix[0..$]), Value) _table; } // create a tuple of 'sliceBits' that slice the 'top' of bits into pieces of sizes 'sizes' // left-to-right, the most significant bits first template GetBitSlicing(size_t top, sizes...) { static if(sizes.length > 0) alias GetBitSlicing = AliasSeq!(sliceBits!(top - sizes[0], top), GetBitSlicing!(top - sizes[0], sizes[1..$])); else alias GetBitSlicing = AliasSeq!(); } template callableWith(T) { template callableWith(alias Pred) { static if(!is(typeof(Pred(T.init)))) enum callableWith = false; else { alias Result = typeof(Pred(T.init)); enum callableWith = isBitPackableType!(TypeOfBitPacked!(Result)); } } } /* Check if $(D Prefix) is a valid set of predicates for $(D Trie) template having $(D Key) as the type of keys. This requires all predicates to be callable, take single argument of type $(D Key) and return unsigned value. */ template isValidPrefixForTrie(Key, Prefix...) { enum isValidPrefixForTrie = allSatisfy!(callableWith!Key, Prefix); // TODO: tighten the screws } /* Check if $(D Args) is a set of maximum key value followed by valid predicates for $(D Trie) template having $(D Key) as the type of keys. */ template isValidArgsForTrie(Key, Args...) { static if(Args.length > 1) { enum isValidArgsForTrie = isValidPrefixForTrie!(Key, Args) || (isValidPrefixForTrie!(Key, Args[1..$]) && is(typeof(Args[0]) : Key)); } else enum isValidArgsForTrie = isValidPrefixForTrie!Args; } @property size_t sumOfIntegerTuple(ints...)() { size_t count=0; foreach(v; ints) count += v; return count; } /** A shorthand for creating a custom multi-level fixed Trie from a $(D CodepointSet). $(D sizes) are numbers of bits per level, with the most significant bits used first. Note: The sum of $(D sizes) must be equal 21. See_Also: $(LREF toTrie), which is even simpler. Example: --- { import std.stdio; auto set = unicode("Number"); auto trie = codepointSetTrie!(8, 5, 8)(set); writeln("Input code points to test:"); foreach(line; stdin.byLine) { int count=0; foreach(dchar ch; line) if(trie[ch])// is number count++; writefln("Contains %d number code points.", count); } } --- */ public template codepointSetTrie(sizes...) if(sumOfIntegerTuple!sizes == 21) { auto codepointSetTrie(Set)(Set set) if(isCodepointSet!Set) { auto builder = TrieBuilder!(bool, dchar, lastDchar+1, GetBitSlicing!(21, sizes))(false); foreach(ival; set.byInterval) builder.putRange(ival[0], ival[1], true); return builder.build(); } } /// Type of Trie generated by codepointSetTrie function. public template CodepointSetTrie(sizes...) if(sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); alias CodepointSetTrie = typeof(TrieBuilder!(bool, dchar, lastDchar+1, Prefix)(false).build()); } /** A slightly more general tool for building fixed $(D Trie) for the Unicode data. Specifically unlike $(D codepointSetTrie) it's allows creating mappings of $(D dchar) to an arbitrary type $(D T). Note: Overload taking $(D CodepointSet)s will naturally convert only to bool mapping $(D Trie)s. */ public template codepointTrie(T, sizes...) if(sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); static if(is(TypeOfBitPacked!T == bool)) { auto codepointTrie(Set)(in Set set) if(isCodepointSet!Set) { return codepointSetTrie(set); } } auto codepointTrie()(T[dchar] map, T defValue=T.init) { return buildTrie!(T, dchar, Prefix)(map, defValue); } // unsorted range of pairs auto codepointTrie(R)(R range, T defValue=T.init) if(isInputRange!R && is(typeof(ElementType!R.init[0]) : T) && is(typeof(ElementType!R.init[1]) : dchar)) { // build from unsorted array of pairs // TODO: expose index sorting functions for Trie return buildTrie!(T, dchar, Prefix)(range, defValue, true); } } /// pure unittest { import std.algorithm.comparison : max; import std.algorithm.searching : count; // pick characters from the Greek script auto set = unicode.Greek; // a user-defined property (or an expensive function) // that we want to look up static uint luckFactor(dchar ch) { // here we consider a character lucky // if its code point has a lot of identical hex-digits // e.g. arabic letter DDAL (\u0688) has a "luck factor" of 2 ubyte[6] nibbles; // 6 4-bit chunks of code point uint value = ch; foreach(i; 0..6) { nibbles[i] = value & 0xF; value >>= 4; } uint luck; foreach(n; nibbles) luck = cast(uint)max(luck, count(nibbles[], n)); return luck; } // only unsigned built-ins are supported at the moment alias LuckFactor = BitPacked!(uint, 3); // create a temporary associative array (AA) LuckFactor[dchar] map; foreach(ch; set.byCodepoint) map[ch] = LuckFactor(luckFactor(ch)); // bits per stage are chosen randomly, fell free to optimize auto trie = codepointTrie!(LuckFactor, 8, 5, 8)(map); // from now on the AA is not needed foreach(ch; set.byCodepoint) assert(trie[ch] == luckFactor(ch)); // verify // CJK is not Greek, thus it has the default value assert(trie['\u4444'] == 0); // and here is a couple of quite lucky Greek characters: // Greek small letter epsilon with dasia assert(trie['\u1F11'] == 3); // Ancient Greek metretes sign assert(trie['\U00010181'] == 3); } /// Type of Trie as generated by codepointTrie function. public template CodepointTrie(T, sizes...) if(sumOfIntegerTuple!sizes == 21) { alias Prefix = GetBitSlicing!(21, sizes); alias CodepointTrie = typeof(TrieBuilder!(T, dchar, lastDchar+1, Prefix)(T.init).build()); } // @@@BUG multiSort can's access private symbols from uni public template cmpK0(alias Pred) { import std.typecons; static bool cmpK0(Value, Key) (Tuple!(Value, Key) a, Tuple!(Value, Key) b) { return Pred(a[1]) < Pred(b[1]); } } /* The most general utility for construction of $(D Trie)s short of using $(D TrieBuilder) directly. Provides a number of convenience overloads. $(D Args) is tuple of maximum key value followed by predicates to construct index from key. Alternatively if the first argument is not a value convertible to $(D Key) then the whole tuple of $(D Args) is treated as predicates and the maximum Key is deduced from predicates. */ public template buildTrie(Value, Key, Args...) if(isValidArgsForTrie!(Key, Args)) { static if(is(typeof(Args[0]) : Key)) // prefix starts with upper bound on Key { alias Prefix = Args[1..$]; } else alias Prefix = Args; alias getIndex = mapTrieIndex!(Prefix); // for multi-sort template GetComparators(size_t n) { static if(n > 0) alias GetComparators = AliasSeq!(GetComparators!(n-1), cmpK0!(Prefix[n-1])); else alias GetComparators = AliasSeq!(); } /* Build $(D Trie) from a range of a Key-Value pairs, assuming it is sorted by Key as defined by the following lambda: ------ (a, b) => mapTrieIndex!(Prefix)(a) < mapTrieIndex!(Prefix)(b) ------ Exception is thrown if it's detected that the above order doesn't hold. In other words $(LREF mapTrieIndex) should be a monotonically increasing function that maps $(D Key) to an integer. See_Also: $(XREF _algorithm, sort), $(XREF _range, SortedRange), $(XREF _algorithm, setUnion). */ auto buildTrie(Range)(Range range, Value filler=Value.init) if(isInputRange!Range && is(typeof(Range.init.front[0]) : Value) && is(typeof(Range.init.front[1]) : Key)) { auto builder = TrieBuilder!(Value, Key, Prefix)(filler); foreach(v; range) builder.putValue(v[1], v[0]); return builder.build(); } /* If $(D Value) is bool (or BitPacked!(bool, x)) then it's possible to build $(D Trie) from a range of open-right intervals of $(D Key)s. The requirement on the ordering of keys (and the behavior on the violation of it) is the same as for Key-Value range overload. Intervals denote ranges of !$(D filler) i.e. the opposite of filler. If no filler provided keys inside of the intervals map to true, and $(D filler) is false. */ auto buildTrie(Range)(Range range, Value filler=Value.init) if(is(TypeOfBitPacked!Value == bool) && isInputRange!Range && is(typeof(Range.init.front[0]) : Key) && is(typeof(Range.init.front[1]) : Key)) { auto builder = TrieBuilder!(Value, Key, Prefix)(filler); foreach(ival; range) builder.putRange(ival[0], ival[1], !filler); return builder.build(); } auto buildTrie(Range)(Range range, Value filler, bool unsorted) if(isInputRange!Range && is(typeof(Range.init.front[0]) : Value) && is(typeof(Range.init.front[1]) : Key)) { import std.algorithm : multiSort; alias Comps = GetComparators!(Prefix.length); if(unsorted) multiSort!(Comps)(range); return buildTrie(range, filler); } /* If $(D Value) is bool (or BitPacked!(bool, x)) then it's possible to build $(D Trie) simply from an input range of $(D Key)s. The requirement on the ordering of keys (and the behavior on the violation of it) is the same as for Key-Value range overload. Keys found in range denote !$(D filler) i.e. the opposite of filler. If no filler provided keys map to true, and $(D filler) is false. */ auto buildTrie(Range)(Range range, Value filler=Value.init) if(is(TypeOfBitPacked!Value == bool) && isInputRange!Range && is(typeof(Range.init.front) : Key)) { auto builder = TrieBuilder!(Value, Key, Prefix)(filler); foreach(v; range) builder.putValue(v, !filler); return builder.build(); } /* If $(D Key) is unsigned integer $(D Trie) could be constructed from array of values where array index serves as key. */ auto buildTrie()(Value[] array, Value filler=Value.init) if(isUnsigned!Key) { auto builder = TrieBuilder!(Value, Key, Prefix)(filler); foreach(idx, v; array) builder.putValue(idx, v); return builder.build(); } /* Builds $(D Trie) from associative array. */ auto buildTrie(Key, Value)(Value[Key] map, Value filler=Value.init) { import std.range : zip, array; auto range = array(zip(map.values, map.keys)); return buildTrie(range, filler, true); // sort it } } // helper in place of assumeSize to //reduce mangled name & help DMD inline Trie functors struct clamp(size_t bits) { static size_t opCall(T)(T arg){ return arg; } enum bitSize = bits; } struct clampIdx(size_t idx, size_t bits) { static size_t opCall(T)(T arg){ return arg[idx]; } enum bitSize = bits; } /** Conceptual type that outlines the common properties of all UTF Matchers. Note: For illustration purposes only, every method call results in assertion failure. Use $(LREF utfMatcher) to obtain a concrete matcher for UTF-8 or UTF-16 encodings. */ public struct MatcherConcept { /** $(P Perform a semantic equivalent 2 operations: decoding a $(CODEPOINT) at front of $(D inp) and testing if it belongs to the set of $(CODEPOINTS) of this matcher. ) $(P The effect on $(D inp) depends on the kind of function called:) $(P Match. If the codepoint is found in the set then range $(D inp) is advanced by its size in $(S_LINK Code unit, code units), otherwise the range is not modifed.) $(P Skip. The range is always advanced by the size of the tested $(CODEPOINT) regardless of the result of test.) $(P Test. The range is left unaffected regardless of the result of test.) */ public bool match(Range)(ref Range inp) if(isRandomAccessRange!Range && is(ElementType!Range : char)) { assert(false); } ///ditto public bool skip(Range)(ref Range inp) if(isRandomAccessRange!Range && is(ElementType!Range : char)) { assert(false); } ///ditto public bool test(Range)(ref Range inp) if(isRandomAccessRange!Range && is(ElementType!Range : char)) { assert(false); } /// @safe unittest { string truth = "2² = 4"; auto m = utfMatcher!char(unicode.Number); assert(m.match(truth)); // '2' is a number all right assert(truth == "² = 4"); // skips on match assert(m.match(truth)); // so is the superscript '2' assert(!m.match(truth)); // space is not a number assert(truth == " = 4"); // unaffected on no match assert(!m.skip(truth)); // same test ... assert(truth == "= 4"); // but skips a codepoint regardless assert(!m.test(truth)); // '=' is not a number assert(truth == "= 4"); // test never affects argument } /* Advanced feature - provide direct access to a subset of matcher based a set of known encoding lengths. Lengths are provided in $(S_LINK Code unit, code units). The sub-matcher then may do less operations per any $(D test)/$(D match). Use with care as the sub-matcher won't match any $(CODEPOINTS) that have encoded length that doesn't belong to the selected set of lengths. Also the sub-matcher object references the parent matcher and must not be used past the liftetime of the latter. Another caveat of using sub-matcher is that skip is not available preciesly because sub-matcher doesn't detect all lengths. */ @property auto subMatcher(Lengths...)() { assert(0); return this; } /// @safe unittest { auto m = utfMatcher!char(unicode.Number); string square = "2²"; // about sub-matchers assert(!m.subMatcher!(2,3,4).test(square)); // ASCII no covered assert(m.subMatcher!1.match(square)); // ASCII-only, works assert(!m.subMatcher!1.test(square)); // unicode '²' assert(m.subMatcher!(2,3,4).match(square)); // assert(square == ""); wstring wsquare = "2²"; auto m16 = utfMatcher!wchar(unicode.Number); // may keep ref, but the orignal (m16) must be kept alive auto bmp = m16.subMatcher!1; assert(bmp.match(wsquare)); // Okay, in basic multilingual plan assert(bmp.match(wsquare)); // And '²' too } } /** Test if $(D M) is an UTF Matcher for ranges of $(D Char). */ public enum isUtfMatcher(M, C) = __traits(compiles, (){ C[] s; auto d = s.decoder; M m; assert(is(typeof(m.match(d)) == bool)); assert(is(typeof(m.test(d)) == bool)); static if(is(typeof(m.skip(d)))) { assert(is(typeof(m.skip(d)) == bool)); assert(is(typeof(m.skip(s)) == bool)); } assert(is(typeof(m.match(s)) == bool)); assert(is(typeof(m.test(s)) == bool)); }); unittest { alias CharMatcher = typeof(utfMatcher!char(CodepointSet.init)); alias WcharMatcher = typeof(utfMatcher!wchar(CodepointSet.init)); static assert(isUtfMatcher!(CharMatcher, char)); static assert(isUtfMatcher!(CharMatcher, immutable(char))); static assert(isUtfMatcher!(WcharMatcher, wchar)); static assert(isUtfMatcher!(WcharMatcher, immutable(wchar))); } enum Mode { alwaysSkip, neverSkip, skipOnMatch } mixin template ForwardStrings() { private bool fwdStr(string fn, C)(ref C[] str) const pure { alias type = typeof(units(str)); return mixin(fn~"(*cast(type*)&str)"); } } template Utf8Matcher() { enum validSize(int sz) = sz >= 1 && sz <=4; void badEncoding() pure @safe { import std.utf; throw new UTFException("Invalid UTF-8 sequence"); } //for 1-stage ASCII alias AsciiSpec = AliasSeq!(bool, char, clamp!7); //for 2-stage lookup of 2 byte UTF-8 sequences alias Utf8Spec2 = AliasSeq!(bool, char[2], clampIdx!(0, 5), clampIdx!(1, 6)); //ditto for 3 byte alias Utf8Spec3 = AliasSeq!(bool, char[3], clampIdx!(0, 4), clampIdx!(1, 6), clampIdx!(2, 6) ); //ditto for 4 byte alias Utf8Spec4 = AliasSeq!(bool, char[4], clampIdx!(0, 3), clampIdx!(1, 6), clampIdx!(2, 6), clampIdx!(3, 6) ); alias Tables = AliasSeq!( typeof(TrieBuilder!(AsciiSpec)(false).build()), typeof(TrieBuilder!(Utf8Spec2)(false).build()), typeof(TrieBuilder!(Utf8Spec3)(false).build()), typeof(TrieBuilder!(Utf8Spec4)(false).build()) ); alias Table(int size) = Tables[size-1]; enum leadMask(size_t size) = (cast(size_t)1<<(7 - size))-1; enum encMask(size_t size) = ((1<<size)-1)<<(8-size); char truncate()(char ch) pure @safe { ch -= 0x80; if (ch < 0x40) { return ch; } else { badEncoding(); return cast(char)0; } } static auto encode(size_t sz)(dchar ch) if(sz > 1) { import std.utf : encode; char[4] buf; std.utf.encode(buf, ch); char[sz] ret; buf[0] &= leadMask!sz; foreach(n; 1..sz) buf[n] = buf[n] & 0x3f; //keep 6 lower bits ret[] = buf[0..sz]; return ret; } auto build(Set)(Set set) { import std.algorithm : map; auto ascii = set & unicode.ASCII; auto utf8_2 = set & CodepointSet(0x80, 0x800); auto utf8_3 = set & CodepointSet(0x800, 0x1_0000); auto utf8_4 = set & CodepointSet(0x1_0000, lastDchar+1); auto asciiT = ascii.byCodepoint.map!(x=>cast(char)x).buildTrie!(AsciiSpec); auto utf8_2T = utf8_2.byCodepoint.map!(x=>encode!2(x)).buildTrie!(Utf8Spec2); auto utf8_3T = utf8_3.byCodepoint.map!(x=>encode!3(x)).buildTrie!(Utf8Spec3); auto utf8_4T = utf8_4.byCodepoint.map!(x=>encode!4(x)).buildTrie!(Utf8Spec4); alias Ret = Impl!(1,2,3,4); return Ret(asciiT, utf8_2T, utf8_3T, utf8_4T); } // Bootstrap UTF-8 static matcher interface // from 3 primitives: tab!(size), lookup and Sizes mixin template DefMatcher() { import std.format : format; enum hasASCII = staticIndexOf!(1, Sizes) >= 0; alias UniSizes = Erase!(1, Sizes); //generate dispatch code sequence for unicode parts static auto genDispatch() { string code; foreach(size; UniSizes) code ~= format(q{ if ((ch & ~leadMask!%d) == encMask!(%d)) return lookup!(%d, mode)(inp); else }, size, size, size); static if (Sizes.length == 4) //covers all code unit cases code ~= "{ badEncoding(); return false; }"; else code ~= "return false;"; //may be just fine but not covered return code; } enum dispatch = genDispatch(); public bool match(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : char)) { enum mode = Mode.skipOnMatch; assert(!inp.empty); auto ch = inp[0]; static if(hasASCII) { if (ch < 0x80) { bool r = tab!1[ch]; if(r) inp.popFront(); return r; } else mixin(dispatch); } else mixin(dispatch); } static if(Sizes.length == 4) // can skip iff can detect all encodings { public bool skip(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : char)) { enum mode = Mode.alwaysSkip; assert(!inp.empty); auto ch = inp[0]; static if(hasASCII) { if (ch < 0x80) { inp.popFront(); return tab!1[ch]; } else mixin(dispatch); } else mixin(dispatch); } } public bool test(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : char)) { enum mode = Mode.neverSkip; assert(!inp.empty); auto ch = inp[0]; static if(hasASCII) { if (ch < 0x80) return tab!1[ch]; else mixin(dispatch); } else mixin(dispatch); } bool match(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"match"(str); } bool skip(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"skip"(str); } bool test(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"test"(str); } mixin ForwardStrings; } struct Impl(Sizes...) { static assert(allSatisfy!(validSize, Sizes), "Only lengths of 1, 2, 3 and 4 code unit are possible for UTF-8"); private: //pick tables for chosen sizes alias OurTabs = staticMap!(Table, Sizes); OurTabs tables; mixin DefMatcher; //static disptach helper UTF size ==> table alias tab(int i) = tables[i - 1]; package @property auto subMatcher(SizesToPick...)() @trusted { return CherryPick!(Impl, SizesToPick)(&this); } bool lookup(int size, Mode mode, Range)(ref Range inp) const pure @trusted { import std.typecons; if(inp.length < size) { badEncoding(); return false; } char[size] needle = void; needle[0] = leadMask!size & inp[0]; foreach(i; staticIota!(1, size)) { needle[i] = truncate(inp[i]); } //overlong encoding checks static if(size == 2) { //0x80-0x7FF //got 6 bits in needle[1], must use at least 8 bits //must use at least 2 bits in needle[1] if(needle[0] < 2) badEncoding(); } else static if(size == 3) { //0x800-0xFFFF //got 6 bits in needle[2], must use at least 12bits //must use 6 bits in needle[1] or anything in needle[0] if(needle[0] == 0 && needle[1] < 0x20) badEncoding(); } else static if(size == 4) { //0x800-0xFFFF //got 2x6=12 bits in needle[2..3] must use at least 17bits //must use 5 bits (or above) in needle[1] or anything in needle[0] if(needle[0] == 0 && needle[1] < 0x10) badEncoding(); } static if(mode == Mode.alwaysSkip) { inp.popFrontN(size); return tab!size[needle]; } else static if(mode == Mode.neverSkip) { return tab!size[needle]; } else { static assert(mode == Mode.skipOnMatch); if (tab!size[needle]) { inp.popFrontN(size); return true; } else return false; } } } struct CherryPick(I, Sizes...) { static assert(allSatisfy!(validSize, Sizes), "Only lengths of 1, 2, 3 and 4 code unit are possible for UTF-8"); private: I* m; @property ref tab(int i)() const pure { return m.tables[i - 1]; } bool lookup(int size, Mode mode, Range)(ref Range inp) const pure { return m.lookup!(size, mode)(inp); } mixin DefMatcher; } } template Utf16Matcher() { enum validSize(int sz) = sz >= 1 && sz <=2; void badEncoding() pure { import std.utf; throw new UTFException("Invalid UTF-16 sequence"); } // 1-stage ASCII alias AsciiSpec = AliasSeq!(bool, wchar, clamp!7); //2-stage BMP alias BmpSpec = AliasSeq!(bool, wchar, sliceBits!(7, 16), sliceBits!(0, 7)); //4-stage - full Unicode //assume that 0xD800 & 0xDC00 bits are cleared //thus leaving 10 bit per wchar to worry about alias UniSpec = AliasSeq!(bool, wchar[2], assumeSize!(x=>x[0]>>4, 6), assumeSize!(x=>x[0]&0xf, 4), assumeSize!(x=>x[1]>>6, 4), assumeSize!(x=>x[1]&0x3f, 6), ); alias Ascii = typeof(TrieBuilder!(AsciiSpec)(false).build()); alias Bmp = typeof(TrieBuilder!(BmpSpec)(false).build()); alias Uni = typeof(TrieBuilder!(UniSpec)(false).build()); auto encode2(dchar ch) { ch -= 0x1_0000; assert(ch <= 0xF_FFFF); wchar[2] ret; //do not put surrogate bits, they are sliced off ret[0] = cast(wchar)(ch>>10); ret[1] = (ch & 0xFFF); return ret; } auto build(Set)(Set set) { import std.algorithm : map; auto ascii = set & unicode.ASCII; auto bmp = (set & CodepointSet.fromIntervals(0x80, 0xFFFF+1)) - CodepointSet.fromIntervals(0xD800, 0xDFFF+1); auto other = set - (bmp | ascii); auto asciiT = ascii.byCodepoint.map!(x=>cast(char)x).buildTrie!(AsciiSpec); auto bmpT = bmp.byCodepoint.map!(x=>cast(wchar)x).buildTrie!(BmpSpec); auto otherT = other.byCodepoint.map!(x=>encode2(x)).buildTrie!(UniSpec); alias Ret = Impl!(1,2); return Ret(asciiT, bmpT, otherT); } //bootstrap full UTF-16 matcher interace from //sizeFlags, lookupUni and ascii mixin template DefMatcher() { public bool match(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : wchar)) { enum mode = Mode.skipOnMatch; assert(!inp.empty); auto ch = inp[0]; static if(sizeFlags & 1) { if (ch < 0x80) { if (ascii[ch]) { inp.popFront(); return true; } else return false; } return lookupUni!mode(inp); } else return lookupUni!mode(inp); } static if(Sizes.length == 2) { public bool skip(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : wchar)) { enum mode = Mode.alwaysSkip; assert(!inp.empty); auto ch = inp[0]; static if(sizeFlags & 1) { if (ch < 0x80) { inp.popFront(); return ascii[ch]; } else return lookupUni!mode(inp); } else return lookupUni!mode(inp); } } public bool test(Range)(ref Range inp) const pure @trusted if(isRandomAccessRange!Range && is(ElementType!Range : wchar)) { enum mode = Mode.neverSkip; assert(!inp.empty); auto ch = inp[0]; static if(sizeFlags & 1) return ch < 0x80 ? ascii[ch] : lookupUni!mode(inp); else return lookupUni!mode(inp); } bool match(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"match"(str); } bool skip(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"skip"(str); } bool test(C)(ref C[] str) const pure @trusted if(isSomeChar!C) { return fwdStr!"test"(str); } mixin ForwardStrings; //dispatch strings to range versions } struct Impl(Sizes...) if(Sizes.length >= 1 && Sizes.length <= 2) { private: static assert(allSatisfy!(validSize, Sizes), "Only lengths of 1 and 2 code units are possible in UTF-16"); static if(Sizes.length > 1) enum sizeFlags = Sizes[0] | Sizes[1]; else enum sizeFlags = Sizes[0]; static if(sizeFlags & 1) { Ascii ascii; Bmp bmp; } static if(sizeFlags & 2) { Uni uni; } mixin DefMatcher; package @property auto subMatcher(SizesToPick...)() @trusted { return CherryPick!(Impl, SizesToPick)(&this); } bool lookupUni(Mode mode, Range)(ref Range inp) const pure { wchar x = cast(wchar)(inp[0] - 0xD800); //not a high surrogate if(x > 0x3FF) { //low surrogate if(x <= 0x7FF) badEncoding(); static if(sizeFlags & 1) { auto ch = inp[0]; static if(mode == Mode.alwaysSkip) inp.popFront(); static if(mode == Mode.skipOnMatch) { if (bmp[ch]) { inp.popFront(); return true; } else return false; } else return bmp[ch]; } else //skip is not available for sub-matchers, so just false return false; } else { static if(sizeFlags & 2) { if(inp.length < 2) badEncoding(); wchar y = cast(wchar)(inp[1] - 0xDC00); //not a low surrogate if(y > 0x3FF) badEncoding(); wchar[2] needle = [inp[0] & 0x3ff, inp[1] & 0x3ff]; static if(mode == Mode.alwaysSkip) inp.popFrontN(2); static if(mode == Mode.skipOnMatch) { if (uni[needle]) { inp.popFrontN(2); return true; } else return false; } else return uni[needle]; } else //ditto return false; } } } struct CherryPick(I, Sizes...) if(Sizes.length >= 1 && Sizes.length <= 2) { private: I* m; enum sizeFlags = I.sizeFlags; static if(sizeFlags & 1) { @property ref ascii()() const pure{ return m.ascii; } } bool lookupUni(Mode mode, Range)(ref Range inp) const pure { return m.lookupUni!mode(inp); } mixin DefMatcher; static assert(allSatisfy!(validSize, Sizes), "Only lengths of 1 and 2 code units are possible in UTF-16"); } } private auto utf8Matcher(Set)(Set set) @trusted { return Utf8Matcher!().build(set); } private auto utf16Matcher(Set)(Set set) @trusted { return Utf16Matcher!().build(set); } /** Constructs a matcher object to classify $(CODEPOINTS) from the $(D set) for encoding that has $(D Char) as code unit. See $(LREF MatcherConcept) for API outline. */ public auto utfMatcher(Char, Set)(Set set) @trusted if(isCodepointSet!Set) { static if(is(Char : char)) return utf8Matcher(set); else static if(is(Char : wchar)) return utf16Matcher(set); else static if(is(Char : dchar)) static assert(false, "UTF-32 needs no decoding, and thus not supported by utfMatcher"); else static assert(false, "Only character types 'char' and 'wchar' are allowed"); } //a range of code units, packed with index to speed up forward iteration package auto decoder(C)(C[] s, size_t offset=0) @safe pure nothrow @nogc if(is(C : wchar) || is(C : char)) { static struct Decoder { pure nothrow: C[] str; size_t idx; @property C front(){ return str[idx]; } @property C back(){ return str[$-1]; } void popFront(){ idx++; } void popBack(){ str = str[0..$-1]; } void popFrontN(size_t n){ idx += n; } @property bool empty(){ return idx == str.length; } @property auto save(){ return this; } auto opIndex(size_t i){ return str[idx+i]; } @property size_t length(){ return str.length - idx; } alias opDollar = length; auto opSlice(size_t a, size_t b){ return Decoder(str[0..idx+b], idx+a); } } static assert(isRandomAccessRange!Decoder); static assert(is(ElementType!Decoder : C)); return Decoder(s, offset); } /* Expose UTF string $(D s) as a random-access range of $(S_LINK Code unit, code units). */ package auto units(C)(C[] s) @safe pure nothrow @nogc if(is(C : wchar) || is(C : char)) { static struct Units { pure nothrow: C[] str; @property C front(){ return str[0]; } @property C back(){ return str[$-1]; } void popFront(){ str = str[1..$]; } void popBack(){ str = str[0..$-1]; } void popFrontN(size_t n){ str = str[n..$]; } @property bool empty(){ return 0 == str.length; } @property auto save(){ return this; } auto opIndex(size_t i){ return str[i]; } @property size_t length(){ return str.length; } alias opDollar = length; auto opSlice(size_t a, size_t b){ return Units(str[a..b]); } } static assert(isRandomAccessRange!Units); static assert(is(ElementType!Units : C)); return Units(s); } @safe unittest { import std.range; string rs = "hi! ネемног砀 текста"; auto codec = rs.decoder; auto utf8 = utf8Matcher(unicode.Letter); auto asc = utf8.subMatcher!(1); auto uni = utf8.subMatcher!(2,3,4); assert(asc.test(codec)); assert(!uni.match(codec)); assert(utf8.skip(codec)); assert(codec.idx == 1); assert(!uni.match(codec)); assert(asc.test(codec)); assert(utf8.skip(codec)); assert(codec.idx == 2); assert(!asc.match(codec)); assert(!utf8.test(codec)); assert(!utf8.skip(codec)); assert(!asc.test(codec)); assert(!utf8.test(codec)); assert(!utf8.skip(codec)); assert(utf8.test(codec)); foreach(i; 0..7) { assert(!asc.test(codec)); assert(uni.test(codec)); assert(utf8.skip(codec)); } assert(!utf8.test(codec)); assert(!utf8.skip(codec)); //the same with match where applicable codec = rs.decoder; assert(utf8.match(codec)); assert(codec.idx == 1); assert(utf8.match(codec)); assert(codec.idx == 2); assert(!utf8.match(codec)); assert(codec.idx == 2); assert(!utf8.skip(codec)); assert(!utf8.skip(codec)); foreach(i; 0..7) { assert(!asc.test(codec)); assert(utf8.test(codec)); assert(utf8.match(codec)); } auto i = codec.idx; assert(!utf8.match(codec)); assert(codec.idx == i); } @safe unittest { import std.range; static bool testAll(Matcher, Range)(ref Matcher m, ref Range r) { bool t = m.test(r); auto save = r.idx; assert(t == m.match(r)); assert(r.idx == save || t); //ether no change or was match r.idx = save; static if(is(typeof(m.skip(r)))) { assert(t == m.skip(r)); assert(r.idx != save); //always changed r.idx = save; } return t; } auto utf16 = utfMatcher!wchar(unicode.L); auto bmp = utf16.subMatcher!1; auto nonBmp = utf16.subMatcher!1; auto utf8 = utfMatcher!char(unicode.L); auto ascii = utf8.subMatcher!1; auto uni2 = utf8.subMatcher!2; auto uni3 = utf8.subMatcher!3; auto uni24 = utf8.subMatcher!(2,4); foreach(ch; unicode.L.byCodepoint.stride(3)) { import std.utf : encode; char[4] buf; wchar[2] buf16; auto len = std.utf.encode(buf, ch); auto len16 = std.utf.encode(buf16, ch); auto c8 = buf[0..len].decoder; auto c16 = buf16[0..len16].decoder; assert(testAll(utf16, c16)); assert(testAll(bmp, c16) || len16 != 1); assert(testAll(nonBmp, c16) || len16 != 2); assert(testAll(utf8, c8)); //submatchers return false on out of their domain assert(testAll(ascii, c8) || len != 1); assert(testAll(uni2, c8) || len != 2); assert(testAll(uni3, c8) || len != 3); assert(testAll(uni24, c8) || (len != 2 && len !=4)); } } // cover decode fail cases of Matcher unittest { import std.exception : collectException; import std.format : format; import std.algorithm; auto utf16 = utfMatcher!wchar(unicode.L); auto utf8 = utfMatcher!char(unicode.L); //decode failure cases UTF-8 alias fails8 = AliasSeq!("\xC1", "\x80\x00","\xC0\x00", "\xCF\x79", "\xFF\x00\0x00\0x00\x00", "\xC0\0x80\0x80\x80", "\x80\0x00\0x00\x00", "\xCF\x00\0x00\0x00\x00"); foreach(msg; fails8){ assert(collectException((){ auto s = msg; import std.utf; size_t idx = 0; //decode(s, idx); utf8.test(s); }()), format("%( %2x %)", cast(ubyte[])msg)); } //decode failure cases UTF-16 alias fails16 = AliasSeq!([0xD811], [0xDC02]); foreach(msg; fails16){ assert(collectException((){ auto s = msg.map!(x => cast(wchar)x); utf16.test(s); }())); } } /++ Convenience function to construct optimal configurations for packed Trie from any $(D set) of $(CODEPOINTS). The parameter $(D level) indicates the number of trie levels to use, allowed values are: 1, 2, 3 or 4. Levels represent different trade-offs speed-size wise. $(P Level 1 is fastest and the most memory hungry (a bit array). ) $(P Level 4 is the slowest and has the smallest footprint. ) See the $(S_LINK Synopsis, Synopsis) section for example. Note: Level 4 stays very practical (being faster and more predictable) compared to using direct lookup on the $(D set) itself. +/ public auto toTrie(size_t level, Set)(Set set) if(isCodepointSet!Set) { static if(level == 1) return codepointSetTrie!(21)(set); else static if(level == 2) return codepointSetTrie!(10, 11)(set); else static if(level == 3) return codepointSetTrie!(8, 5, 8)(set); else static if(level == 4) return codepointSetTrie!(6, 4, 4, 7)(set); else static assert(false, "Sorry, toTrie doesn't support levels > 4, use codepointSetTrie directly"); } /** $(P Builds a $(D Trie) with typically optimal speed-size trade-off and wraps it into a delegate of the following type: $(D bool delegate(dchar ch)). ) $(P Effectively this creates a 'tester' lambda suitable for algorithms like std.algorithm.find that take unary predicates. ) See the $(S_LINK Synopsis, Synopsis) section for example. */ public auto toDelegate(Set)(Set set) if(isCodepointSet!Set) { // 3 is very small and is almost as fast as 2-level (due to CPU caches?) auto t = toTrie!3(set); return (dchar ch) => t[ch]; } /** $(P Opaque wrapper around unsigned built-in integers and code unit (char/wchar/dchar) types. Parameter $(D sz) indicates that the value is confined to the range of [0, 2^^sz$(RPAREN). With this knowledge it can be packed more tightly when stored in certain data-structures like trie. ) Note: $(P The $(D BitPacked!(T, sz)) is implicitly convertible to $(D T) but not vise-versa. Users have to ensure the value fits in the range required and use the $(D cast) operator to perform the conversion.) */ struct BitPacked(T, size_t sz) if(isIntegral!T || is(T:dchar)) { enum bitSize = sz; T _value; alias _value this; } /* Depending on the form of the passed argument $(D bitSizeOf) returns the amount of bits required to represent a given type or a return type of a given functor. */ template bitSizeOf(Args...) if(Args.length == 1) { alias T = Args[0]; static if(__traits(compiles, { size_t val = T.bitSize; })) //(is(typeof(T.bitSize) : size_t)) { enum bitSizeOf = T.bitSize; } else static if(is(ReturnType!T dummy == BitPacked!(U, bits), U, size_t bits)) { enum bitSizeOf = bitSizeOf!(ReturnType!T); } else { enum bitSizeOf = T.sizeof*8; } } /** Tests if $(D T) is some instantiation of $(LREF BitPacked)!(U, x) and thus suitable for packing. */ template isBitPacked(T) { static if(is(T dummy == BitPacked!(U, bits), U, size_t bits)) enum isBitPacked = true; else enum isBitPacked = false; } /** Gives the type $(D U) from $(LREF BitPacked)!(U, x) or $(D T) itself for every other type. */ template TypeOfBitPacked(T) { static if(is(T dummy == BitPacked!(U, bits), U, size_t bits)) alias TypeOfBitPacked = U; else alias TypeOfBitPacked = T; } /* Wrapper, used in definition of custom data structures from $(D Trie) template. Applying it to a unary lambda function indicates that the returned value always fits within $(D bits) of bits. */ struct assumeSize(alias Fn, size_t bits) { enum bitSize = bits; static auto ref opCall(T)(auto ref T arg) { return Fn(arg); } } /* A helper for defining lambda function that yields a slice of certain bits from an unsigned integral value. The resulting lambda is wrapped in assumeSize and can be used directly with $(D Trie) template. */ struct sliceBits(size_t from, size_t to) { //for now bypass assumeSize, DMD has trouble inlining it enum bitSize = to-from; static auto opCall(T)(T x) out(result) { assert(result < (1<<to-from)); } body { static assert(from < to); static if(from == 0) return x & ((1<<to)-1); else return (x >> from) & ((1<<(to-from))-1); } } @safe pure nothrow @nogc uint low_8(uint x) { return x&0xFF; } @safe pure nothrow @nogc uint midlow_8(uint x){ return (x&0xFF00)>>8; } alias lo8 = assumeSize!(low_8, 8); alias mlo8 = assumeSize!(midlow_8, 8); static assert(bitSizeOf!lo8 == 8); static assert(bitSizeOf!(sliceBits!(4, 7)) == 3); static assert(bitSizeOf!(BitPacked!(uint, 2)) == 2); template Sequence(size_t start, size_t end) { static if(start < end) alias Sequence = AliasSeq!(start, Sequence!(start+1, end)); else alias Sequence = AliasSeq!(); } //---- TRIE TESTS ---- unittest { import std.conv; import std.algorithm; import std.range; static trieStats(TRIE)(TRIE t) { version(std_uni_stats) { import std.stdio; writeln("---TRIE FOOTPRINT STATS---"); foreach(i; staticIota!(0, t.table.dim) ) { writefln("lvl%s = %s bytes; %s pages" , i, t.bytes!i, t.pages!i); } writefln("TOTAL: %s bytes", t.bytes); version(none) { writeln("INDEX (excluding value level):"); foreach(i; staticIota!(0, t.table.dim-1) ) writeln(t.table.slice!(i)[0..t.table.length!i]); } writeln("---------------------------"); } } //@@@BUG link failure, lambdas not found by linker somehow (in case of trie2) // alias lo8 = assumeSize!(8, function (uint x) { return x&0xFF; }); // alias next8 = assumeSize!(7, function (uint x) { return (x&0x7F00)>>8; }); alias Set = CodepointSet; auto set = Set('A','Z','a','z'); auto trie = buildTrie!(bool, uint, 256, lo8)(set.byInterval);// simple bool array for(int a='a'; a<'z';a++) assert(trie[a]); for(int a='A'; a<'Z';a++) assert(trie[a]); for(int a=0; a<'A'; a++) assert(!trie[a]); for(int a ='Z'; a<'a'; a++) assert(!trie[a]); trieStats(trie); auto redundant2 = Set( 1, 18, 256+2, 256+111, 512+1, 512+18, 768+2, 768+111); auto trie2 = buildTrie!(bool, uint, 1024, mlo8, lo8)(redundant2.byInterval); trieStats(trie2); foreach(e; redundant2.byCodepoint) assert(trie2[e], text(cast(uint)e, " - ", trie2[e])); foreach(i; 0..1024) { assert(trie2[i] == (i in redundant2)); } auto redundant3 = Set( 2, 4, 6, 8, 16, 2+16, 4+16, 16+6, 16+8, 16+16, 2+32, 4+32, 32+6, 32+8, ); enum max3 = 256; // sliceBits auto trie3 = buildTrie!(bool, uint, max3, sliceBits!(6,8), sliceBits!(4,6), sliceBits!(0,4) )(redundant3.byInterval); trieStats(trie3); foreach(i; 0..max3) assert(trie3[i] == (i in redundant3), text(cast(uint)i)); auto redundant4 = Set( 10, 64, 64+10, 128, 128+10, 256, 256+10, 512, 1000, 2000, 3000, 4000, 5000, 6000 ); enum max4 = 2^^16; auto trie4 = buildTrie!(bool, size_t, max4, sliceBits!(13, 16), sliceBits!(9, 13), sliceBits!(6, 9) , sliceBits!(0, 6) )(redundant4.byInterval); foreach(i; 0..max4){ if(i in redundant4) assert(trie4[i], text(cast(uint)i)); } trieStats(trie4); alias mapToS = mapTrieIndex!(useItemAt!(0, char)); string[] redundantS = ["tea", "start", "orange"]; redundantS.sort!((a,b) => mapToS(a) < mapToS(b))(); auto strie = buildTrie!(bool, string, useItemAt!(0, char))(redundantS); // using first char only assert(redundantS == ["orange", "start", "tea"]); assert(strie["test"], text(strie["test"])); assert(!strie["aea"]); assert(strie["s"]); // a bit size test auto a = array(map!(x => to!ubyte(x))(iota(0, 256))); auto bt = buildTrie!(bool, ubyte, sliceBits!(7, 8), sliceBits!(5, 7), sliceBits!(0, 5))(a); trieStats(bt); foreach(i; 0..256) assert(bt[cast(ubyte)i]); } template useItemAt(size_t idx, T) if(isIntegral!T || is(T: dchar)) { size_t impl(in T[] arr){ return arr[idx]; } alias useItemAt = assumeSize!(impl, 8*T.sizeof); } template useLastItem(T) { size_t impl(in T[] arr){ return arr[$-1]; } alias useLastItem = assumeSize!(impl, 8*T.sizeof); } template fullBitSize(Prefix...) { static if(Prefix.length > 0) enum fullBitSize = bitSizeOf!(Prefix[0])+fullBitSize!(Prefix[1..$]); else enum fullBitSize = 0; } template idxTypes(Key, size_t fullBits, Prefix...) { static if(Prefix.length == 1) {// the last level is value level, so no index once reduced to 1-level alias idxTypes = AliasSeq!(); } else { // Important note on bit packing // Each level has to hold enough of bits to address the next one // The bottom level is known to hold full bit width // thus it's size in pages is full_bit_width - size_of_last_prefix // Recourse on this notion alias idxTypes = AliasSeq!( idxTypes!(Key, fullBits - bitSizeOf!(Prefix[$-1]), Prefix[0..$-1]), BitPacked!(typeof(Prefix[$-2](Key.init)), fullBits - bitSizeOf!(Prefix[$-1])) ); } } //============================================================================ @safe pure int comparePropertyName(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) if (is(Char1 : dchar) && is(Char2 : dchar)) { import std.ascii : toLower; import std.algorithm : cmp, map, filter; static bool pred(dchar c) {return !c.isWhite && c != '-' && c != '_';} return cmp( a.map!toLower.filter!pred, b.map!toLower.filter!pred); } @safe pure unittest { assert(!comparePropertyName("foo-bar", "fooBar")); } bool propertyNameLess(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) @safe pure if (is(Char1 : dchar) && is(Char2 : dchar)) { return comparePropertyName(a, b) < 0; } //============================================================================ // Utilities for compression of Unicode code point sets //============================================================================ @safe void compressTo(uint val, ref ubyte[] arr) pure nothrow { // not optimized as usually done 1 time (and not public interface) if(val < 128) arr ~= cast(ubyte)val; else if(val < (1<<13)) { arr ~= (0b1_00<<5) | cast(ubyte)(val>>8); arr ~= val & 0xFF; } else { assert(val < (1<<21)); arr ~= (0b1_01<<5) | cast(ubyte)(val>>16); arr ~= (val >> 8) & 0xFF; arr ~= val & 0xFF; } } @safe uint decompressFrom(const(ubyte)[] arr, ref size_t idx) pure { import std.exception : enforce; uint first = arr[idx++]; if(!(first & 0x80)) // no top bit -> [0..127] return first; uint extra = ((first>>5) & 1) + 1; // [1, 2] uint val = (first & 0x1F); enforce(idx + extra <= arr.length, "bad code point interval encoding"); foreach(j; 0..extra) val = (val<<8) | arr[idx+j]; idx += extra; return val; } package ubyte[] compressIntervals(Range)(Range intervals) if(isInputRange!Range && isIntegralPair!(ElementType!Range)) { ubyte[] storage; uint base = 0; // RLE encode foreach(val; intervals) { compressTo(val[0]-base, storage); base = val[0]; if(val[1] != lastDchar+1) // till the end of the domain so don't store it { compressTo(val[1]-base, storage); base = val[1]; } } return storage; } @safe pure unittest { import std.typecons; auto run = [tuple(80, 127), tuple(128, (1<<10)+128)]; ubyte[] enc = [cast(ubyte)80, 47, 1, (0b1_00<<5) | (1<<2), 0]; assert(compressIntervals(run) == enc); auto run2 = [tuple(0, (1<<20)+512+1), tuple((1<<20)+512+4, lastDchar+1)]; ubyte[] enc2 = [cast(ubyte)0, (0b1_01<<5) | (1<<4), 2, 1, 3]; // odd length-ed assert(compressIntervals(run2) == enc2); size_t idx = 0; assert(decompressFrom(enc, idx) == 80); assert(decompressFrom(enc, idx) == 47); assert(decompressFrom(enc, idx) == 1); assert(decompressFrom(enc, idx) == (1<<10)); idx = 0; assert(decompressFrom(enc2, idx) == 0); assert(decompressFrom(enc2, idx) == (1<<20)+512+1); assert(equalS(decompressIntervals(compressIntervals(run)), run)); assert(equalS(decompressIntervals(compressIntervals(run2)), run2)); } // Creates a range of $(D CodepointInterval) that lazily decodes compressed data. @safe package auto decompressIntervals(const(ubyte)[] data) pure { return DecompressedIntervals(data); } @safe struct DecompressedIntervals { pure: const(ubyte)[] _stream; size_t _idx; CodepointInterval _front; this(const(ubyte)[] stream) { _stream = stream; popFront(); } @property CodepointInterval front() { assert(!empty); return _front; } void popFront() { if(_idx == _stream.length) { _idx = size_t.max; return; } uint base = _front[1]; _front[0] = base + decompressFrom(_stream, _idx); if(_idx == _stream.length)// odd length ---> till the end _front[1] = lastDchar+1; else { base = _front[0]; _front[1] = base + decompressFrom(_stream, _idx); } } @property bool empty() const { return _idx == size_t.max; } @property DecompressedIntervals save() { return this; } } static assert(isInputRange!DecompressedIntervals); static assert(isForwardRange!DecompressedIntervals); //============================================================================ version(std_uni_bootstrap){} else { // helper for looking up code point sets @trusted ptrdiff_t findUnicodeSet(alias table, C)(in C[] name) pure { import std.range : assumeSorted; import std.algorithm : map; auto range = assumeSorted!((a,b) => propertyNameLess(a,b)) (table.map!"a.name"()); size_t idx = range.lowerBound(name).length; if(idx < range.length && comparePropertyName(range[idx], name) == 0) return idx; return -1; } // another one that loads it @trusted bool loadUnicodeSet(alias table, Set, C)(in C[] name, ref Set dest) pure { auto idx = findUnicodeSet!table(name); if(idx >= 0) { dest = Set(asSet(table[idx].compressed)); return true; } return false; } @trusted bool loadProperty(Set=CodepointSet, C) (in C[] name, ref Set target) pure { alias ucmp = comparePropertyName; // conjure cumulative properties by hand if(ucmp(name, "L") == 0 || ucmp(name, "Letter") == 0) { target = asSet(uniProps.Lu); target |= asSet(uniProps.Ll); target |= asSet(uniProps.Lt); target |= asSet(uniProps.Lo); target |= asSet(uniProps.Lm); } else if(ucmp(name,"LC") == 0 || ucmp(name,"Cased Letter")==0) { target = asSet(uniProps.Ll); target |= asSet(uniProps.Lu); target |= asSet(uniProps.Lt);// Title case } else if(ucmp(name, "M") == 0 || ucmp(name, "Mark") == 0) { target = asSet(uniProps.Mn); target |= asSet(uniProps.Mc); target |= asSet(uniProps.Me); } else if(ucmp(name, "N") == 0 || ucmp(name, "Number") == 0) { target = asSet(uniProps.Nd); target |= asSet(uniProps.Nl); target |= asSet(uniProps.No); } else if(ucmp(name, "P") == 0 || ucmp(name, "Punctuation") == 0) { target = asSet(uniProps.Pc); target |= asSet(uniProps.Pd); target |= asSet(uniProps.Ps); target |= asSet(uniProps.Pe); target |= asSet(uniProps.Pi); target |= asSet(uniProps.Pf); target |= asSet(uniProps.Po); } else if(ucmp(name, "S") == 0 || ucmp(name, "Symbol") == 0) { target = asSet(uniProps.Sm); target |= asSet(uniProps.Sc); target |= asSet(uniProps.Sk); target |= asSet(uniProps.So); } else if(ucmp(name, "Z") == 0 || ucmp(name, "Separator") == 0) { target = asSet(uniProps.Zs); target |= asSet(uniProps.Zl); target |= asSet(uniProps.Zp); } else if(ucmp(name, "C") == 0 || ucmp(name, "Other") == 0) { target = asSet(uniProps.Co); target |= asSet(uniProps.Lo); target |= asSet(uniProps.No); target |= asSet(uniProps.So); target |= asSet(uniProps.Po); } else if(ucmp(name, "graphical") == 0){ target = asSet(uniProps.Alphabetic); target |= asSet(uniProps.Mn); target |= asSet(uniProps.Mc); target |= asSet(uniProps.Me); target |= asSet(uniProps.Nd); target |= asSet(uniProps.Nl); target |= asSet(uniProps.No); target |= asSet(uniProps.Pc); target |= asSet(uniProps.Pd); target |= asSet(uniProps.Ps); target |= asSet(uniProps.Pe); target |= asSet(uniProps.Pi); target |= asSet(uniProps.Pf); target |= asSet(uniProps.Po); target |= asSet(uniProps.Zs); target |= asSet(uniProps.Sm); target |= asSet(uniProps.Sc); target |= asSet(uniProps.Sk); target |= asSet(uniProps.So); } else if(ucmp(name, "any") == 0) target = Set.fromIntervals(0, 0x110000); else if(ucmp(name, "ascii") == 0) target = Set.fromIntervals(0, 0x80); else return loadUnicodeSet!(uniProps.tab)(name, target); return true; } // CTFE-only helper for checking property names at compile-time @safe bool isPrettyPropertyName(C)(in C[] name) { import std.algorithm : find; auto names = [ "L", "Letter", "LC", "Cased Letter", "M", "Mark", "N", "Number", "P", "Punctuation", "S", "Symbol", "Z", "Separator", "Graphical", "any", "ascii" ]; auto x = find!(x => comparePropertyName(x, name) == 0)(names); return !x.empty; } // ditto, CTFE-only, not optimized @safe private static bool findSetName(alias table, C)(in C[] name) { return findUnicodeSet!table(name) >= 0; } template SetSearcher(alias table, string kind) { /// Run-time checked search. static auto opCall(C)(in C[] name) if(is(C : dchar)) { import std.conv : to; CodepointSet set; if(loadUnicodeSet!table(name, set)) return set; throw new Exception("No unicode set for "~kind~" by name " ~name.to!string()~" was found."); } /// Compile-time checked search. static @property auto opDispatch(string name)() { static if(findSetName!table(name)) { CodepointSet set; loadUnicodeSet!table(name, set); return set; } else static assert(false, "No unicode set for "~kind~" by name " ~name~" was found."); } } /** A single entry point to lookup Unicode $(CODEPOINT) sets by name or alias of a block, script or general category. It uses well defined standard rules of property name lookup. This includes fuzzy matching of names, so that 'White_Space', 'white-SpAce' and 'whitespace' are all considered equal and yield the same set of white space $(CHARACTERS). */ @safe public struct unicode { /** Performs the lookup of set of $(CODEPOINTS) with compile-time correctness checking. This short-cut version combines 3 searches: across blocks, scripts, and common binary properties. Note that since scripts and blocks overlap the usual trick to disambiguate is used - to get a block use $(D unicode.InBlockName), to search a script use $(D unicode.ScriptName). See_Also: $(LREF block), $(LREF script) and (not included in this search) $(LREF hangulSyllableType). */ static @property auto opDispatch(string name)() pure { static if(findAny(name)) return loadAny(name); else static assert(false, "No unicode set by name "~name~" was found."); } /// unittest { auto ascii = unicode.ASCII; assert(ascii['A']); assert(ascii['~']); assert(!ascii['\u00e0']); // matching is case-insensitive assert(ascii == unicode.ascII); assert(!ascii['à']); // underscores, '-' and whitespace in names are ignored too auto latin = unicode.in_latin1_Supplement; assert(latin['à']); assert(!latin['$']); // BTW Latin 1 Supplement is a block, hence "In" prefix assert(latin == unicode("In Latin 1 Supplement")); import std.exception; // run-time look up throws if no such set is found assert(collectException(unicode("InCyrilliac"))); } /** The same lookup across blocks, scripts, or binary properties, but performed at run-time. This version is provided for cases where $(D name) is not known beforehand; otherwise compile-time checked $(LREF opDispatch) is typically a better choice. See the $(S_LINK Unicode properties, table of properties) for available sets. */ static auto opCall(C)(in C[] name) if(is(C : dchar)) { return loadAny(name); } /** Narrows down the search for sets of $(CODEPOINTS) to all Unicode blocks. Note: Here block names are unambiguous as no scripts are searched and thus to search use simply $(D unicode.block.BlockName) notation. See $(S_LINK Unicode properties, table of properties) for available sets. See_Also: $(S_LINK Unicode properties, table of properties). */ struct block { mixin SetSearcher!(blocks.tab, "block"); } /// unittest { // use .block for explicitness assert(unicode.block.Greek_and_Coptic == unicode.InGreek_and_Coptic); } /** Narrows down the search for sets of $(CODEPOINTS) to all Unicode scripts. See the $(S_LINK Unicode properties, table of properties) for available sets. */ struct script { mixin SetSearcher!(scripts.tab, "script"); } /// unittest { auto arabicScript = unicode.script.arabic; auto arabicBlock = unicode.block.arabic; // there is an intersection between script and block assert(arabicBlock['؁']); assert(arabicScript['؁']); // but they are different assert(arabicBlock != arabicScript); assert(arabicBlock == unicode.inArabic); assert(arabicScript == unicode.arabic); } /** Fetch a set of $(CODEPOINTS) that have the given hangul syllable type. Other non-binary properties (once supported) follow the same notation - $(D unicode.propertyName.propertyValue) for compile-time checked access and $(D unicode.propertyName(propertyValue)) for run-time checked one. See the $(S_LINK Unicode properties, table of properties) for available sets. */ struct hangulSyllableType { mixin SetSearcher!(hangul.tab, "hangul syllable type"); } /// unittest { // L here is syllable type not Letter as in unicode.L short-cut auto leadingVowel = unicode.hangulSyllableType("L"); // check that some leading vowels are present foreach(vowel; '\u1110'..'\u115F') assert(leadingVowel[vowel]); assert(leadingVowel == unicode.hangulSyllableType.L); } private: alias ucmp = comparePropertyName; static bool findAny(string name) { return isPrettyPropertyName(name) || findSetName!(uniProps.tab)(name) || findSetName!(scripts.tab)(name) || (ucmp(name[0..2],"In") == 0 && findSetName!(blocks.tab)(name[2..$])); } static auto loadAny(Set=CodepointSet, C)(in C[] name) pure { import std.conv : to; Set set; bool loaded = loadProperty(name, set) || loadUnicodeSet!(scripts.tab)(name, set) || (name.length > 2 && ucmp(name[0..2],"In") == 0 && loadUnicodeSet!(blocks.tab)(name[2..$], set)); if(loaded) return set; throw new Exception("No unicode set by name "~name.to!string()~" was found."); } // FIXME: re-disable once the compiler is fixed // Disabled to prevent the mistake of creating instances of this pseudo-struct. //@disable ~this(); } unittest { assert(unicode("InHebrew") == asSet(blocks.Hebrew)); assert(unicode("separator") == (asSet(uniProps.Zs) | asSet(uniProps.Zl) | asSet(uniProps.Zp))); assert(unicode("In-Kharoshthi") == asSet(blocks.Kharoshthi)); } enum EMPTY_CASE_TRIE = ushort.max;// from what gen_uni uses internally // control - '\r' enum controlSwitch = ` case '\u0000':..case '\u0008':case '\u000E':..case '\u001F':case '\u007F':..case '\u0084':case '\u0086':..case '\u009F': case '\u0009':..case '\u000C': case '\u0085': `; // TODO: redo the most of hangul stuff algorithmically in case of Graphemes too // kill unrolled switches private static bool isRegionalIndicator(dchar ch) @safe { return ch >= '\U0001F1E6' && ch <= '\U0001F1FF'; } template genericDecodeGrapheme(bool getValue) { alias graphemeExtend = graphemeExtendTrie; alias spacingMark = mcTrie; static if(getValue) alias Value = Grapheme; else alias Value = void; Value genericDecodeGrapheme(Input)(ref Input range) { enum GraphemeState { Start, CR, RI, L, V, LVT } static if(getValue) Grapheme grapheme; auto state = GraphemeState.Start; enum eat = q{ static if(getValue) grapheme ~= ch; range.popFront(); }; dchar ch; assert(!range.empty, "Attempting to decode grapheme from an empty " ~ Input.stringof); while(!range.empty) { ch = range.front; final switch(state) with(GraphemeState) { case Start: mixin(eat); if(ch == '\r') state = CR; else if(isRegionalIndicator(ch)) state = RI; else if(isHangL(ch)) state = L; else if(hangLV[ch] || isHangV(ch)) state = V; else if(hangLVT[ch]) state = LVT; else if(isHangT(ch)) state = LVT; else { switch(ch) { mixin(controlSwitch); goto L_End; default: goto L_End_Extend; } } break; case CR: if(ch == '\n') mixin(eat); goto L_End_Extend; case RI: if(isRegionalIndicator(ch)) mixin(eat); else goto L_End_Extend; break; case L: if(isHangL(ch)) mixin(eat); else if(isHangV(ch) || hangLV[ch]) { state = V; mixin(eat); } else if(hangLVT[ch]) { state = LVT; mixin(eat); } else goto L_End_Extend; break; case V: if(isHangV(ch)) mixin(eat); else if(isHangT(ch)) { state = LVT; mixin(eat); } else goto L_End_Extend; break; case LVT: if(isHangT(ch)) { mixin(eat); } else goto L_End_Extend; break; } } L_End_Extend: while(!range.empty) { ch = range.front; // extend & spacing marks if(!graphemeExtend[ch] && !spacingMark[ch]) break; mixin(eat); } L_End: static if(getValue) return grapheme; } } public: // Public API continues /++ Computes the length of grapheme cluster starting at $(D index). Both the resulting length and the $(D index) are measured in $(S_LINK Code unit, code units). Params: C = type that is implicitly convertible to $(D dchars) input = array of grapheme clusters index = starting index into $(D input[]) Returns: length of grapheme cluster +/ size_t graphemeStride(C)(in C[] input, size_t index) if(is(C : dchar)) { auto src = input[index..$]; auto n = src.length; genericDecodeGrapheme!(false)(src); return n - src.length; } /// @safe unittest { assert(graphemeStride(" ", 1) == 1); // A + combing ring above string city = "A\u030Arhus"; size_t first = graphemeStride(city, 0); assert(first == 3); //\u030A has 2 UTF-8 code units assert(city[0..first] == "A\u030A"); assert(city[first..$] == "rhus"); } /++ Reads one full grapheme cluster from an input range of dchar $(D inp). For examples see the $(LREF Grapheme) below. Note: This function modifies $(D inp) and thus $(D inp) must be an L-value. +/ Grapheme decodeGrapheme(Input)(ref Input inp) if(isInputRange!Input && is(Unqual!(ElementType!Input) == dchar)) { return genericDecodeGrapheme!true(inp); } unittest { Grapheme gr; string s = " \u0020\u0308 "; gr = decodeGrapheme(s); assert(gr.length == 1 && gr[0] == ' '); gr = decodeGrapheme(s); assert(gr.length == 2 && equalS(gr[0..2], " \u0308")); s = "\u0300\u0308\u1100"; assert(equalS(decodeGrapheme(s)[], "\u0300\u0308")); assert(equalS(decodeGrapheme(s)[], "\u1100")); s = "\u11A8\u0308\uAC01"; assert(equalS(decodeGrapheme(s)[], "\u11A8\u0308")); assert(equalS(decodeGrapheme(s)[], "\uAC01")); } /++ $(P Iterate a string by grapheme.) $(P Useful for doing string manipulation that needs to be aware of graphemes.) See_Also: $(LREF byCodePoint) +/ auto byGrapheme(Range)(Range range) if(isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { // TODO: Bidirectional access static struct Result { private Range _range; private Grapheme _front; bool empty() @property { return _front.length == 0; } Grapheme front() @property { return _front; } void popFront() { _front = _range.empty ? Grapheme.init : _range.decodeGrapheme(); } static if(isForwardRange!Range) { Result save() @property { return Result(_range.save, _front); } } } auto result = Result(range); result.popFront(); return result; } /// unittest { import std.conv; import std.range; import std.algorithm; auto text = "noe\u0308l"; // noël using e + combining diaeresis assert(text.walkLength == 5); // 5 code points auto gText = text.byGrapheme; assert(gText.walkLength == 4); // 4 graphemes assert(gText.take(3).equal("noe\u0308".byGrapheme)); assert(gText.drop(3).equal("l".byGrapheme)); } // For testing non-forward-range input ranges version(unittest) private static struct InputRangeString { private string s; bool empty() @property { return s.empty; } dchar front() @property { return s.front; } void popFront() { s.popFront(); } } unittest { import std.conv; import std.range; import std.algorithm; assert("".byGrapheme.walkLength == 0); auto reverse = "le\u0308on"; assert(reverse.walkLength == 5); auto gReverse = reverse.byGrapheme; assert(gReverse.walkLength == 4); foreach(text; AliasSeq!("noe\u0308l"c, "noe\u0308l"w, "noe\u0308l"d)) { assert(text.walkLength == 5); static assert(isForwardRange!(typeof(text))); auto gText = text.byGrapheme; static assert(isForwardRange!(typeof(gText))); assert(gText.walkLength == 4); assert(gText.array.retro.equal(gReverse)); } auto nonForwardRange = InputRangeString("noe\u0308l").byGrapheme; static assert(!isForwardRange!(typeof(nonForwardRange))); assert(nonForwardRange.walkLength == 4); } /++ $(P Lazily transform a range of $(LREF Grapheme)s to a range of code points.) $(P Useful for converting the result to a string after doing operations on graphemes.) $(P Acts as the identity function when given a range of code points.) +/ auto byCodePoint(Range)(Range range) if(isInputRange!Range && is(Unqual!(ElementType!Range) == Grapheme)) { // TODO: Propagate bidirectional access static struct Result { private Range _range; private size_t i = 0; bool empty() @property { return _range.empty; } dchar front() @property { return _range.front[i]; } void popFront() { ++i; if(i >= _range.front.length) { _range.popFront(); i = 0; } } static if(isForwardRange!Range) { Result save() @property { return Result(_range.save, i); } } } return Result(range); } /// Ditto Range byCodePoint(Range)(Range range) if(isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { return range; } /// unittest { import std.conv : text; import std.range; string s = "noe\u0308l"; // noël // reverse it and convert the result to a string string reverse = s.byGrapheme .array .retro .byCodePoint .text; assert(reverse == "le\u0308on"); // lëon } unittest { import std.conv; import std.algorithm; assert("".byGrapheme.byCodePoint.equal("")); string text = "noe\u0308l"; static assert(is(typeof(text.byCodePoint) == string)); auto gText = InputRangeString(text).byGrapheme; static assert(!isForwardRange!(typeof(gText))); auto cpText = gText.byCodePoint; static assert(!isForwardRange!(typeof(cpText))); assert(cpText.walkLength == text.walkLength); } @trusted: /++ $(P A structure designed to effectively pack $(CHARACTERS) of a $(CLUSTER). ) $(P $(D Grapheme) has value semantics so 2 copies of a $(D Grapheme) always refer to distinct objects. In most actual scenarios a $(D Grapheme) fits on the stack and avoids memory allocation overhead for all but quite long clusters. ) See_Also: $(LREF decodeGrapheme), $(LREF graphemeStride) +/ @trusted struct Grapheme { import std.exception : enforce; public: this(C)(in C[] chars...) if(is(C : dchar)) { this ~= chars; } this(Input)(Input seq) if(!isDynamicArray!Input && isInputRange!Input && is(ElementType!Input : dchar)) { this ~= seq; } /// Gets a $(CODEPOINT) at the given index in this cluster. dchar opIndex(size_t index) const pure nothrow @nogc { assert(index < length); return read24(isBig ? ptr_ : small_.ptr, index); } /++ Writes a $(CODEPOINT) $(D ch) at given index in this cluster. Warning: Use of this facility may invalidate grapheme cluster, see also $(LREF Grapheme.valid). +/ void opIndexAssign(dchar ch, size_t index) pure nothrow @nogc { assert(index < length); write24(isBig ? ptr_ : small_.ptr, ch, index); } /// unittest { auto g = Grapheme("A\u0302"); assert(g[0] == 'A'); assert(g.valid); g[1] = '~'; // ASCII tilda is not a combining mark assert(g[1] == '~'); assert(!g.valid); } /++ Random-access range over Grapheme's $(CHARACTERS). Warning: Invalidates when this Grapheme leaves the scope, attempts to use it then would lead to memory corruption. +/ @system auto opSlice(size_t a, size_t b) pure nothrow @nogc { return sliceOverIndexed(a, b, &this); } /// ditto @system auto opSlice() pure nothrow @nogc { return sliceOverIndexed(0, length, &this); } /// Grapheme cluster length in $(CODEPOINTS). @property size_t length() const pure nothrow @nogc { return isBig ? len_ : slen_ & 0x7F; } /++ Append $(CHARACTER) $(D ch) to this grapheme. Warning: Use of this facility may invalidate grapheme cluster, see also $(D valid). See_Also: $(LREF Grapheme.valid) +/ ref opOpAssign(string op)(dchar ch) { static if(op == "~") { if(!isBig) { if(slen_ + 1 > small_cap) convertToBig();// & fallthrough to "big" branch else { write24(small_.ptr, ch, smallLength); slen_++; return this; } } assert(isBig); if(len_ + 1 > cap_) { cap_ += grow; ptr_ = cast(ubyte*)enforce(realloc(ptr_, 3*(cap_+1)), "realloc failed"); } write24(ptr_, ch, len_++); return this; } else static assert(false, "No operation "~op~" defined for Grapheme"); } /// unittest { import std.algorithm.comparison : equal; auto g = Grapheme("A"); assert(g.valid); g ~= '\u0301'; assert(g[].equal("A\u0301")); assert(g.valid); g ~= "B"; // not a valid grapheme cluster anymore assert(!g.valid); // still could be useful though assert(g[].equal("A\u0301B")); } /// Append all $(CHARACTERS) from the input range $(D inp) to this Grapheme. ref opOpAssign(string op, Input)(Input inp) if(isInputRange!Input && is(ElementType!Input : dchar)) { static if(op == "~") { foreach(dchar ch; inp) this ~= ch; return this; } else static assert(false, "No operation "~op~" defined for Grapheme"); } /++ True if this object contains valid extended grapheme cluster. Decoding primitives of this module always return a valid $(D Grapheme). Appending to and direct manipulation of grapheme's $(CHARACTERS) may render it no longer valid. Certain applications may chose to use Grapheme as a "small string" of any $(CODEPOINTS) and ignore this property entirely. +/ @property bool valid()() /*const*/ { auto r = this[]; genericDecodeGrapheme!false(r); return r.length == 0; } this(this) { if(isBig) {// dup it auto raw_cap = 3*(cap_+1); auto p = cast(ubyte*)enforce(malloc(raw_cap), "malloc failed"); p[0..raw_cap] = ptr_[0..raw_cap]; ptr_ = p; } } ~this() { if(isBig) { free(ptr_); } } private: enum small_bytes = ((ubyte*).sizeof+3*size_t.sizeof-1); // "out of the blue" grow rate, needs testing // (though graphemes are typically small < 9) enum grow = 20; enum small_cap = small_bytes/3; enum small_flag = 0x80, small_mask = 0x7F; // 16 bytes in 32bits, should be enough for the majority of cases union { struct { ubyte* ptr_; size_t cap_; size_t len_; size_t padding_; } struct { ubyte[small_bytes] small_; ubyte slen_; } } void convertToBig() { size_t k = smallLength; ubyte* p = cast(ubyte*)enforce(malloc(3*(grow+1)), "malloc failed"); for(int i=0; i<k; i++) write24(p, read24(small_.ptr, i), i); // now we can overwrite small array data ptr_ = p; len_ = slen_; assert(grow > len_); cap_ = grow; setBig(); } void setBig() pure nothrow @nogc { slen_ |= small_flag; } @property size_t smallLength() const pure nothrow @nogc { return slen_ & small_mask; } @property ubyte isBig() const pure nothrow @nogc { return slen_ & small_flag; } } static assert(Grapheme.sizeof == size_t.sizeof*4); /// unittest { import std.algorithm : filter; string bold = "ku\u0308hn"; // note that decodeGrapheme takes parameter by ref auto first = decodeGrapheme(bold); assert(first.length == 1); assert(first[0] == 'k'); // the next grapheme is 2 characters long auto wideOne = decodeGrapheme(bold); // slicing a grapheme yields a random-access range of dchar assert(wideOne[].equalS("u\u0308")); assert(wideOne.length == 2); static assert(isRandomAccessRange!(typeof(wideOne[]))); // all of the usual range manipulation is possible assert(wideOne[].filter!isMark().equalS("\u0308")); auto g = Grapheme("A"); assert(g.valid); g ~= '\u0301'; assert(g[].equalS("A\u0301")); assert(g.valid); g ~= "B"; // not a valid grapheme cluster anymore assert(!g.valid); // still could be useful though assert(g[].equalS("A\u0301B")); } unittest { auto g = Grapheme("A\u0302"); assert(g[0] == 'A'); assert(g.valid); g[1] = '~'; // ASCII tilda is not a combining mark assert(g[1] == '~'); assert(!g.valid); } unittest { import std.conv; import std.algorithm; import std.range; // not valid clusters (but it just a test) auto g = Grapheme('a', 'b', 'c', 'd', 'e'); assert(g[0] == 'a'); assert(g[1] == 'b'); assert(g[2] == 'c'); assert(g[3] == 'd'); assert(g[4] == 'e'); g[3] = 'Й'; assert(g[2] == 'c'); assert(g[3] == 'Й', text(g[3], " vs ", 'Й')); assert(g[4] == 'e'); assert(!g.valid); g ~= 'ц'; g ~= '~'; assert(g[0] == 'a'); assert(g[1] == 'b'); assert(g[2] == 'c'); assert(g[3] == 'Й'); assert(g[4] == 'e'); assert(g[5] == 'ц'); assert(g[6] == '~'); assert(!g.valid); Grapheme copy = g; copy[0] = 'X'; copy[1] = '-'; assert(g[0] == 'a' && copy[0] == 'X'); assert(g[1] == 'b' && copy[1] == '-'); assert(equalS(g[2..g.length], copy[2..copy.length])); copy = Grapheme("АБВГДЕЁЖЗИКЛМ"); assert(equalS(copy[0..8], "АБВГДЕЁЖ"), text(copy[0..8])); copy ~= "xyz"; assert(equalS(copy[13..15], "xy"), text(copy[13..15])); assert(!copy.valid); Grapheme h; foreach(dchar v; iota(cast(int)'A', cast(int)'Z'+1).map!"cast(dchar)a"()) h ~= v; assert(equalS(h[], iota(cast(int)'A', cast(int)'Z'+1))); } /++ $(P Does basic case-insensitive comparison of strings $(D str1) and $(D str2). This function uses simpler comparison rule thus achieving better performance than $(LREF icmp). However keep in mind the warning below.) Params: str1 = a string or a $(D ForwardRange) of $(D dchar)s str2 = a string or a $(D ForwardRange) of $(D dchar)s Returns: An $(D int) that is 0 if the strings match, &lt;0 if $(D str1) is lexicographically "less" than $(D str2), &gt;0 if $(D str1) is lexicographically "greater" than $(D str2) Warning: This function only handles 1:1 $(CODEPOINT) mapping and thus is not sufficient for certain alphabets like German, Greek and few others. See_Also: $(LREF icmp) $(XREF_PACK algorithm,comparison,cmp) +/ int sicmp(S1, S2)(S1 str1, S2 str2) if(isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar) && isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar)) { import std.utf : decode; alias sTable = simpleCaseTable; size_t ridx=0; foreach(dchar lhs; str1) { if(ridx == str2.length) return 1; dchar rhs = std.utf.decode(str2, ridx); int diff = lhs - rhs; if(!diff) continue; size_t idx = simpleCaseTrie[lhs]; size_t idx2 = simpleCaseTrie[rhs]; // simpleCaseTrie is packed index table if(idx != EMPTY_CASE_TRIE) { if(idx2 != EMPTY_CASE_TRIE) {// both cased chars // adjust idx --> start of bucket idx = idx - sTable[idx].n; idx2 = idx2 - sTable[idx2].n; if(idx == idx2)// one bucket, equivalent chars continue; else// not the same bucket diff = sTable[idx].ch - sTable[idx2].ch; } else diff = sTable[idx - sTable[idx].n].ch - rhs; } else if(idx2 != EMPTY_CASE_TRIE) { diff = lhs - sTable[idx2 - sTable[idx2].n].ch; } // one of chars is not cased at all return diff; } return ridx == str2.length ? 0 : -1; } /// unittest{ assert(sicmp("Август", "авгусТ") == 0); // Greek also works as long as there is no 1:M mapping in sight assert(sicmp("ΌΎ", "όύ") == 0); // things like the following won't get matched as equal // Greek small letter iota with dialytika and tonos assert(sicmp("ΐ", "\u03B9\u0308\u0301") != 0); // while icmp has no problem with that assert(icmp("ΐ", "\u03B9\u0308\u0301") == 0); assert(icmp("ΌΎ", "όύ") == 0); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { int sicmp(const(char)[] str1, const(char)[] str2) { return sicmp!(const(char)[], const(char)[])(str1, str2); } int sicmp(const(wchar)[] str1, const(wchar)[] str2) { return sicmp!(const(wchar)[], const(wchar)[])(str1, str2); } int sicmp(const(dchar)[] str1, const(dchar)[] str2) { return sicmp!(const(dchar)[], const(dchar)[])(str1, str2); } } private int fullCasedCmp(Range)(dchar lhs, dchar rhs, ref Range rtail) @trusted pure /*TODO nothrow*/ { import std.algorithm : skipOver; alias fTable = fullCaseTable; size_t idx = fullCaseTrie[lhs]; // fullCaseTrie is packed index table if(idx == EMPTY_CASE_TRIE) return lhs; size_t start = idx - fTable[idx].n; size_t end = fTable[idx].size + start; assert(fTable[start].entry_len == 1); for(idx=start; idx<end; idx++) { auto entryLen = fTable[idx].entry_len; if(entryLen == 1) { if(fTable[idx].seq[0] == rhs) { return 0; } } else {// OK it's a long chunk, like 'ss' for German dstring seq = fTable[idx].seq[0..entryLen]; if(rhs == seq[0] && rtail.skipOver(seq[1..$])) { // note that this path modifies rtail // iff we managed to get there return 0; } } } return fTable[start].seq[0]; // new remapped character for accurate diffs } /++ $(P Does case insensitive comparison of $(D str1) and $(D str2). Follows the rules of full case-folding mapping. This includes matching as equal german ß with "ss" and other 1:M $(CODEPOINT) mappings unlike $(LREF sicmp). The cost of $(D icmp) being pedantically correct is slightly worse performance. ) +/ int icmp(S1, S2)(S1 str1, S2 str2) if(isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar) && isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar)) { for(;;) { if(str1.empty) return str2.empty ? 0 : -1; dchar lhs = str1.front; if(str2.empty) return 1; dchar rhs = str2.front; str1.popFront(); str2.popFront(); int diff = lhs - rhs; if(!diff) continue; // first try to match lhs to <rhs,right-tail> sequence int cmpLR = fullCasedCmp(lhs, rhs, str2); if(!cmpLR) continue; // then rhs to <lhs,left-tail> sequence int cmpRL = fullCasedCmp(rhs, lhs, str1); if(!cmpRL) continue; // cmpXX contain remapped codepoints // to obtain stable ordering of icmp diff = cmpLR - cmpRL; return diff; } } /// unittest{ assert(icmp("Rußland", "Russland") == 0); assert(icmp("ᾩ -> \u1F70\u03B9", "\u1F61\u03B9 -> ᾲ") == 0); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { int icmp(const(char)[] str1, const(char)[] str2) { return icmp!(const(char)[], const(char)[])(str1, str2); } int icmp(const(wchar)[] str1, const(wchar)[] str2) { return icmp!(const(wchar)[], const(wchar)[])(str1, str2); } int icmp(const(dchar)[] str1, const(dchar)[] str2) { return icmp!(const(dchar)[], const(dchar)[])(str1, str2); } } unittest { import std.conv; import std.exception : assertCTFEable; import std.algorithm; assertCTFEable!( { foreach(cfunc; AliasSeq!(icmp, sicmp)) { foreach(S1; AliasSeq!(string, wstring, dstring)) foreach(S2; AliasSeq!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(cfunc("".to!S1(), "".to!S2()) == 0); assert(cfunc("A".to!S1(), "".to!S2()) > 0); assert(cfunc("".to!S1(), "0".to!S2()) < 0); assert(cfunc("abc".to!S1(), "abc".to!S2()) == 0); assert(cfunc("abcd".to!S1(), "abc".to!S2()) > 0); assert(cfunc("abc".to!S1(), "abcd".to!S2()) < 0); assert(cfunc("Abc".to!S1(), "aBc".to!S2()) == 0); assert(cfunc("авГуст".to!S1(), "АВгУСТ".to!S2()) == 0); // Check example: assert(cfunc("Август".to!S1(), "авгусТ".to!S2()) == 0); assert(cfunc("ΌΎ".to!S1(), "όύ".to!S2()) == 0); }(); // check that the order is properly agnostic to the case auto strs = [ "Apple", "ORANGE", "orAcle", "amp", "banana"]; sort!((a,b) => cfunc(a,b) < 0)(strs); assert(strs == ["amp", "Apple", "banana", "orAcle", "ORANGE"]); } assert(icmp("ßb", "ssa") > 0); // Check example: assert(icmp("Russland", "Rußland") == 0); assert(icmp("ᾩ -> \u1F70\u03B9", "\u1F61\u03B9 -> ᾲ") == 0); assert(icmp("ΐ"w, "\u03B9\u0308\u0301") == 0); assert(sicmp("ΐ", "\u03B9\u0308\u0301") != 0); //bugzilla 11057 assert( icmp("K", "L") < 0 ); }); } // This is package for the moment to be used as a support tool for std.regex // It needs a better API /* Return a range of all $(CODEPOINTS) that casefold to and from this $(D ch). */ package auto simpleCaseFoldings(dchar ch) { alias sTable = simpleCaseTable; static struct Range { pure nothrow: uint idx; //if == uint.max, then read c. union { dchar c; // == 0 - empty range uint len; } @property bool isSmall() const { return idx == uint.max; } this(dchar ch) { idx = uint.max; c = ch; } this(uint start, uint size) { idx = start; len = size; } @property dchar front() const { assert(!empty); if(isSmall) { return c; } auto ch = sTable[idx].ch; return ch; } @property bool empty() const { if(isSmall) { return c == 0; } return len == 0; } @property uint length() const { if(isSmall) { return c == 0 ? 0 : 1; } return len; } void popFront() { if(isSmall) c = 0; else { idx++; len--; } } } immutable idx = simpleCaseTrie[ch]; if (idx == EMPTY_CASE_TRIE) return Range(ch); auto entry = sTable[idx]; immutable start = idx - entry.n; return Range(start, entry.size); } unittest { import std.exception : assertCTFEable; import std.algorithm : canFind; import std.array; assertCTFEable!((){ auto r = simpleCaseFoldings('Э').array; assert(r.length == 2); assert(r.canFind('э') && r.canFind('Э')); auto sr = simpleCaseFoldings('~'); assert(sr.equalS("~")); //A with ring above - casefolds to the same bucket as Angstrom sign sr = simpleCaseFoldings('Å'); assert(sr.length == 3); assert(sr.canFind('å') && sr.canFind('Å') && sr.canFind('\u212B')); }); } /++ $(P Returns the $(S_LINK Combining class, combining class) of $(D ch).) +/ ubyte combiningClass(dchar ch) @safe pure nothrow @nogc { return combiningClassTrie[ch]; } /// unittest{ // shorten the code alias CC = combiningClass; // combining tilda assert(CC('\u0303') == 230); // combining ring below assert(CC('\u0325') == 220); // the simple consequence is that "tilda" should be // placed after a "ring below" in a sequence } @safe pure nothrow @nogc unittest { foreach(ch; 0..0x80) assert(combiningClass(ch) == 0); assert(combiningClass('\u05BD') == 22); assert(combiningClass('\u0300') == 230); assert(combiningClass('\u0317') == 220); assert(combiningClass('\u1939') == 222); } /// Unicode character decomposition type. enum UnicodeDecomposition { /// Canonical decomposition. The result is canonically equivalent sequence. Canonical, /** Compatibility decomposition. The result is compatibility equivalent sequence. Note: Compatibility decomposition is a $(B lossy) conversion, typically suitable only for fuzzy matching and internal processing. */ Compatibility } /** Shorthand aliases for character decomposition type, passed as a template parameter to $(LREF decompose). */ enum { Canonical = UnicodeDecomposition.Canonical, Compatibility = UnicodeDecomposition.Compatibility }; /++ Try to canonically compose 2 $(CHARACTERS). Returns the composed $(CHARACTER) if they do compose and dchar.init otherwise. The assumption is that $(D first) comes before $(D second) in the original text, usually meaning that the first is a starter. Note: Hangul syllables are not covered by this function. See $(D composeJamo) below. +/ public dchar compose(dchar first, dchar second) pure nothrow { import std.internal.unicode_comp; import std.algorithm : map; import std.range : assumeSorted; size_t packed = compositionJumpTrie[first]; if(packed == ushort.max) return dchar.init; // unpack offset and length size_t idx = packed & composeIdxMask, cnt = packed >> composeCntShift; // TODO: optimize this micro binary search (no more then 4-5 steps) auto r = compositionTable[idx..idx+cnt].map!"a.rhs"().assumeSorted(); auto target = r.lowerBound(second).length; if(target == cnt) return dchar.init; auto entry = compositionTable[idx+target]; if(entry.rhs != second) return dchar.init; return entry.composed; } /// unittest{ assert(compose('A','\u0308') == '\u00C4'); assert(compose('A', 'B') == dchar.init); assert(compose('C', '\u0301') == '\u0106'); // note that the starter is the first one // thus the following doesn't compose assert(compose('\u0308', 'A') == dchar.init); } /++ Returns a full $(S_LINK Canonical decomposition, Canonical) (by default) or $(S_LINK Compatibility decomposition, Compatibility) decomposition of $(CHARACTER) $(D ch). If no decomposition is available returns a $(LREF Grapheme) with the $(D ch) itself. Note: This function also decomposes hangul syllables as prescribed by the standard. See_Also: $(LREF decomposeHangul) for a restricted version that takes into account only hangul syllables but no other decompositions. +/ public Grapheme decompose(UnicodeDecomposition decompType=Canonical)(dchar ch) { import std.internal.unicode_decomp; import std.algorithm : until; static if(decompType == Canonical) { alias table = decompCanonTable; alias mapping = canonMappingTrie; } else static if(decompType == Compatibility) { alias table = decompCompatTable; alias mapping = compatMappingTrie; } ushort idx = mapping[ch]; if(!idx) // not found, check hangul arithmetic decomposition return decomposeHangul(ch); auto decomp = table[idx..$].until(0); return Grapheme(decomp); } /// unittest { assert(compose('A','\u0308') == '\u00C4'); assert(compose('A', 'B') == dchar.init); assert(compose('C', '\u0301') == '\u0106'); // note that the starter is the first one // thus the following doesn't compose assert(compose('\u0308', 'A') == dchar.init); assert(decompose('Ĉ')[].equalS("C\u0302")); assert(decompose('D')[].equalS("D")); assert(decompose('\uD4DC')[].equalS("\u1111\u1171\u11B7")); assert(decompose!Compatibility('¹')[].equalS("1")); } //---------------------------------------------------------------------------- // Hangul specific composition/decomposition enum jamoSBase = 0xAC00; enum jamoLBase = 0x1100; enum jamoVBase = 0x1161; enum jamoTBase = 0x11A7; enum jamoLCount = 19, jamoVCount = 21, jamoTCount = 28; enum jamoNCount = jamoVCount * jamoTCount; enum jamoSCount = jamoLCount * jamoNCount; // Tests if $(D ch) is a Hangul leading consonant jamo. bool isJamoL(dchar ch) pure nothrow @nogc { // first cmp rejects ~ 1M code points above leading jamo range return ch < jamoLBase+jamoLCount && ch >= jamoLBase; } // Tests if $(D ch) is a Hangul vowel jamo. bool isJamoT(dchar ch) pure nothrow @nogc { // first cmp rejects ~ 1M code points above trailing jamo range // Note: ch == jamoTBase doesn't indicate trailing jamo (TIndex must be > 0) return ch < jamoTBase+jamoTCount && ch > jamoTBase; } // Tests if $(D ch) is a Hangul trailnig consonant jamo. bool isJamoV(dchar ch) pure nothrow @nogc { // first cmp rejects ~ 1M code points above vowel range return ch < jamoVBase+jamoVCount && ch >= jamoVBase; } int hangulSyllableIndex(dchar ch) pure nothrow @nogc { int idxS = cast(int)ch - jamoSBase; return idxS >= 0 && idxS < jamoSCount ? idxS : -1; } // internal helper: compose hangul syllables leaving dchar.init in holes void hangulRecompose(dchar[] seq) pure nothrow @nogc { for(size_t idx = 0; idx + 1 < seq.length; ) { if(isJamoL(seq[idx]) && isJamoV(seq[idx+1])) { int indexL = seq[idx] - jamoLBase; int indexV = seq[idx+1] - jamoVBase; int indexLV = indexL * jamoNCount + indexV * jamoTCount; if(idx + 2 < seq.length && isJamoT(seq[idx+2])) { seq[idx] = jamoSBase + indexLV + seq[idx+2] - jamoTBase; seq[idx+1] = dchar.init; seq[idx+2] = dchar.init; idx += 3; } else { seq[idx] = jamoSBase + indexLV; seq[idx+1] = dchar.init; idx += 2; } } else idx++; } } //---------------------------------------------------------------------------- public: /** Decomposes a Hangul syllable. If $(D ch) is not a composed syllable then this function returns $(LREF Grapheme) containing only $(D ch) as is. */ Grapheme decomposeHangul(dchar ch) { int idxS = cast(int)ch - jamoSBase; if(idxS < 0 || idxS >= jamoSCount) return Grapheme(ch); int idxL = idxS / jamoNCount; int idxV = (idxS % jamoNCount) / jamoTCount; int idxT = idxS % jamoTCount; int partL = jamoLBase + idxL; int partV = jamoVBase + idxV; if(idxT > 0) // there is a trailling consonant (T); <L,V,T> decomposition return Grapheme(partL, partV, jamoTBase + idxT); else // <L, V> decomposition return Grapheme(partL, partV); } /// unittest { import std.algorithm; assert(decomposeHangul('\uD4DB')[].equal("\u1111\u1171\u11B6")); } /++ Try to compose hangul syllable out of a leading consonant ($(D lead)), a $(D vowel) and optional $(D trailing) consonant jamos. On success returns the composed LV or LVT hangul syllable. If any of $(D lead) and $(D vowel) are not a valid hangul jamo of the respective $(CHARACTER) class returns dchar.init. +/ dchar composeJamo(dchar lead, dchar vowel, dchar trailing=dchar.init) pure nothrow @nogc { if(!isJamoL(lead)) return dchar.init; int indexL = lead - jamoLBase; if(!isJamoV(vowel)) return dchar.init; int indexV = vowel - jamoVBase; int indexLV = indexL * jamoNCount + indexV * jamoTCount; dchar syllable = jamoSBase + indexLV; return isJamoT(trailing) ? syllable + (trailing - jamoTBase) : syllable; } /// unittest { assert(composeJamo('\u1111', '\u1171', '\u11B6') == '\uD4DB'); // leaving out T-vowel, or passing any codepoint // that is not trailing consonant composes an LV-syllable assert(composeJamo('\u1111', '\u1171') == '\uD4CC'); assert(composeJamo('\u1111', '\u1171', ' ') == '\uD4CC'); assert(composeJamo('\u1111', 'A') == dchar.init); assert(composeJamo('A', '\u1171') == dchar.init); } unittest { import std.conv; static void testDecomp(UnicodeDecomposition T)(dchar ch, string r) { Grapheme g = decompose!T(ch); assert(equalS(g[], r), text(g[], " vs ", r)); } testDecomp!Canonical('\u1FF4', "\u03C9\u0301\u0345"); testDecomp!Canonical('\uF907', "\u9F9C"); testDecomp!Compatibility('\u33FF', "\u0067\u0061\u006C"); testDecomp!Compatibility('\uA7F9', "\u0153"); // check examples assert(decomposeHangul('\uD4DB')[].equalS("\u1111\u1171\u11B6")); assert(composeJamo('\u1111', '\u1171', '\u11B6') == '\uD4DB'); assert(composeJamo('\u1111', '\u1171') == '\uD4CC'); // leave out T-vowel assert(composeJamo('\u1111', '\u1171', ' ') == '\uD4CC'); assert(composeJamo('\u1111', 'A') == dchar.init); assert(composeJamo('A', '\u1171') == dchar.init); } /** Enumeration type for normalization forms, passed as template parameter for functions like $(LREF normalize). */ enum NormalizationForm { NFC, NFD, NFKC, NFKD } enum { /** Shorthand aliases from values indicating normalization forms. */ NFC = NormalizationForm.NFC, ///ditto NFD = NormalizationForm.NFD, ///ditto NFKC = NormalizationForm.NFKC, ///ditto NFKD = NormalizationForm.NFKD }; /++ Returns $(D input) string normalized to the chosen form. Form C is used by default. For more information on normalization forms see the $(S_LINK Normalization, normalization section). Note: In cases where the string in question is already normalized, it is returned unmodified and no memory allocation happens. +/ inout(C)[] normalize(NormalizationForm norm=NFC, C)(inout(C)[] input) { import std.algorithm : sort, SwapStrategy; import std.range : zip; import std.array : appender; auto anchors = splitNormalized!norm(input); if(anchors[0] == input.length && anchors[1] == input.length) return input; dchar[] decomposed; decomposed.reserve(31); ubyte[] ccc; ccc.reserve(31); auto app = appender!(C[])(); do { app.put(input[0..anchors[0]]); foreach(dchar ch; input[anchors[0]..anchors[1]]) static if(norm == NFD || norm == NFC) { foreach(dchar c; decompose!Canonical(ch)[]) decomposed ~= c; } else // NFKD & NFKC { foreach(dchar c; decompose!Compatibility(ch)[]) decomposed ~= c; } ccc.length = decomposed.length; size_t firstNonStable = 0; ubyte lastClazz = 0; foreach(idx, dchar ch; decomposed) { auto clazz = combiningClass(ch); ccc[idx] = clazz; if(clazz == 0 && lastClazz != 0) { // found a stable code point after unstable ones sort!("a[0] < b[0]", SwapStrategy.stable) (zip(ccc[firstNonStable..idx], decomposed[firstNonStable..idx])); firstNonStable = decomposed.length; } else if(clazz != 0 && lastClazz == 0) { // found first unstable code point after stable ones firstNonStable = idx; } lastClazz = clazz; } sort!("a[0] < b[0]", SwapStrategy.stable) (zip(ccc[firstNonStable..$], decomposed[firstNonStable..$])); static if(norm == NFC || norm == NFKC) { import std.algorithm : countUntil; size_t idx = 0; auto first = countUntil(ccc, 0); if(first >= 0) // no starters?? no recomposition { for(;;) { auto second = recompose(first, decomposed, ccc); if(second == decomposed.length) break; first = second; } // 2nd pass for hangul syllables hangulRecompose(decomposed); } } static if(norm == NFD || norm == NFKD) app.put(decomposed); else { import std.algorithm : remove; auto clean = remove!("a == dchar.init", SwapStrategy.stable)(decomposed); app.put(decomposed[0 .. clean.length]); } // reset variables decomposed.length = 0; decomposed.assumeSafeAppend(); ccc.length = 0; ccc.assumeSafeAppend(); input = input[anchors[1]..$]; // and move on anchors = splitNormalized!norm(input); }while(anchors[0] != input.length); app.put(input[0..anchors[0]]); return cast(inout(C)[])app.data; } /// unittest { // any encoding works wstring greet = "Hello world"; assert(normalize(greet) is greet); // the same exact slice // An example of a character with all 4 forms being different: // Greek upsilon with acute and hook symbol (code point 0x03D3) assert(normalize!NFC("ϓ") == "\u03D3"); assert(normalize!NFD("ϓ") == "\u03D2\u0301"); assert(normalize!NFKC("ϓ") == "\u038E"); assert(normalize!NFKD("ϓ") == "\u03A5\u0301"); } unittest { import std.conv; assert(normalize!NFD("abc\uF904def") == "abc\u6ED1def", text(normalize!NFD("abc\uF904def"))); assert(normalize!NFKD("2¹⁰") == "210", normalize!NFKD("2¹⁰")); assert(normalize!NFD("Äffin") == "A\u0308ffin"); // check example // any encoding works wstring greet = "Hello world"; assert(normalize(greet) is greet); // the same exact slice // An example of a character with all 4 forms being different: // Greek upsilon with acute and hook symbol (code point 0x03D3) assert(normalize!NFC("ϓ") == "\u03D3"); assert(normalize!NFD("ϓ") == "\u03D2\u0301"); assert(normalize!NFKC("ϓ") == "\u038E"); assert(normalize!NFKD("ϓ") == "\u03A5\u0301"); } // canonically recompose given slice of code points, works in-place and mutates data private size_t recompose(size_t start, dchar[] input, ubyte[] ccc) pure nothrow { assert(input.length == ccc.length); int accumCC = -1;// so that it's out of 0..255 range bool foundSolidStarter = false; // writefln("recomposing %( %04x %)", input); // first one is always a starter thus we start at i == 1 size_t i = start+1; for(; ; ) { if(i == input.length) break; int curCC = ccc[i]; // In any character sequence beginning with a starter S // a character C is blocked from S if and only if there // is some character B between S and C, and either B // is a starter or it has the same or higher combining class as C. //------------------------ // Applying to our case: // S is input[0] // accumCC is the maximum CCC of characters between C and S, // as ccc are sorted // C is input[i] if(curCC > accumCC) { dchar comp = compose(input[start], input[i]); if(comp != dchar.init) { input[start] = comp; input[i] = dchar.init;// put a sentinel // current was merged so its CCC shouldn't affect // composing with the next one } else { // if it was a starter then accumCC is now 0, end of loop accumCC = curCC; if(accumCC == 0) break; } } else{ // ditto here accumCC = curCC; if(accumCC == 0) break; } i++; } return i; } // returns tuple of 2 indexes that delimit: // normalized text, piece that needs normalization and // the rest of input starting with stable code point private auto splitNormalized(NormalizationForm norm, C)(const(C)[] input) { import std.typecons : tuple; auto result = input; ubyte lastCC = 0; foreach(idx, dchar ch; input) { static if(norm == NFC) if(ch < 0x0300) { lastCC = 0; continue; } ubyte CC = combiningClass(ch); if(lastCC > CC && CC != 0) { return seekStable!norm(idx, input); } if(notAllowedIn!norm(ch)) { return seekStable!norm(idx, input); } lastCC = CC; } return tuple(input.length, input.length); } private auto seekStable(NormalizationForm norm, C)(size_t idx, in C[] input) { import std.utf : codeLength; import std.typecons : tuple; auto br = input[0..idx]; size_t region_start = 0;// default for(;;) { if(br.empty)// start is 0 break; dchar ch = br.back; if(combiningClass(ch) == 0 && allowedIn!norm(ch)) { region_start = br.length - std.utf.codeLength!C(ch); break; } br.popFront(); } ///@@@BUG@@@ can't use find: " find is a nested function and can't be used..." size_t region_end=input.length;// end is $ by default foreach(i, dchar ch; input[idx..$]) { if(combiningClass(ch) == 0 && allowedIn!norm(ch)) { region_end = i+idx; break; } } // writeln("Region to normalize: ", input[region_start..region_end]); return tuple(region_start, region_end); } /** Tests if dchar $(D ch) is always allowed (Quick_Check=YES) in normalization form $(D norm). */ public bool allowedIn(NormalizationForm norm)(dchar ch) { return !notAllowedIn!norm(ch); } /// unittest { // e.g. Cyrillic is always allowed, so is ASCII assert(allowedIn!NFC('я')); assert(allowedIn!NFD('я')); assert(allowedIn!NFKC('я')); assert(allowedIn!NFKD('я')); assert(allowedIn!NFC('Z')); } // not user friendly name but more direct private bool notAllowedIn(NormalizationForm norm)(dchar ch) { static if(norm == NFC) alias qcTrie = nfcQCTrie; else static if(norm == NFD) alias qcTrie = nfdQCTrie; else static if(norm == NFKC) alias qcTrie = nfkcQCTrie; else static if(norm == NFKD) alias qcTrie = nfkdQCTrie; else static assert("Unknown normalization form "~norm); return qcTrie[ch]; } unittest { assert(allowedIn!NFC('я')); assert(allowedIn!NFD('я')); assert(allowedIn!NFKC('я')); assert(allowedIn!NFKD('я')); assert(allowedIn!NFC('Z')); } } version(std_uni_bootstrap) { // old version used for bootstrapping of gen_uni.d that generates // up to date optimal versions of all of isXXX functions @safe pure nothrow @nogc public bool isWhite(dchar c) { import std.ascii : isWhite; return isWhite(c) || c == lineSep || c == paraSep || c == '\u0085' || c == '\u00A0' || c == '\u1680' || c == '\u180E' || (c >= '\u2000' && c <= '\u200A') || c == '\u202F' || c == '\u205F' || c == '\u3000'; } } else { // trusted -> avoid bounds check @trusted pure nothrow @nogc { // hide template instances behind functions (Bugzilla 13232) ushort toLowerIndex(dchar c) { return toLowerIndexTrie[c]; } ushort toLowerSimpleIndex(dchar c) { return toLowerSimpleIndexTrie[c]; } dchar toLowerTab(size_t idx) { return toLowerTable[idx]; } ushort toTitleIndex(dchar c) { return toTitleIndexTrie[c]; } ushort toTitleSimpleIndex(dchar c) { return toTitleSimpleIndexTrie[c]; } dchar toTitleTab(size_t idx) { return toTitleTable[idx]; } ushort toUpperIndex(dchar c) { return toUpperIndexTrie[c]; } ushort toUpperSimpleIndex(dchar c) { return toUpperSimpleIndexTrie[c]; } dchar toUpperTab(size_t idx) { return toUpperTable[idx]; } } public: /++ Whether or not $(D c) is a Unicode whitespace $(CHARACTER). (general Unicode category: Part of C0(tab, vertical tab, form feed, carriage return, and linefeed characters), Zs, Zl, Zp, and NEL(U+0085)) +/ @safe pure nothrow @nogc public bool isWhite(dchar c) { return isWhiteGen(c); // call pregenerated binary search } /++ Return whether $(D c) is a Unicode lowercase $(CHARACTER). +/ @safe pure nothrow @nogc bool isLower(dchar c) { import std.ascii : isLower, isASCII; if(isASCII(c)) return isLower(c); return lowerCaseTrie[c]; } @safe unittest { import std.ascii : isLower; foreach(v; 0..0x80) assert(isLower(v) == .isLower(v)); assert(.isLower('я')); assert(.isLower('й')); assert(!.isLower('Ж')); // Greek HETA assert(!.isLower('\u0370')); assert(.isLower('\u0371')); assert(!.isLower('\u039C')); // capital MU assert(.isLower('\u03B2')); // beta // from extended Greek assert(!.isLower('\u1F18')); assert(.isLower('\u1F00')); foreach(v; unicode.lowerCase.byCodepoint) assert(.isLower(v) && !isUpper(v)); } /++ Return whether $(D c) is a Unicode uppercase $(CHARACTER). +/ @safe pure nothrow @nogc bool isUpper(dchar c) { import std.ascii : isUpper, isASCII; if(isASCII(c)) return isUpper(c); return upperCaseTrie[c]; } @safe unittest { import std.ascii : isLower; foreach(v; 0..0x80) assert(isLower(v) == .isLower(v)); assert(!isUpper('й')); assert(isUpper('Ж')); // Greek HETA assert(isUpper('\u0370')); assert(!isUpper('\u0371')); assert(isUpper('\u039C')); // capital MU assert(!isUpper('\u03B2')); // beta // from extended Greek assert(!isUpper('\u1F00')); assert(isUpper('\u1F18')); foreach(v; unicode.upperCase.byCodepoint) assert(isUpper(v) && !.isLower(v)); } /++ If $(D c) is a Unicode uppercase $(CHARACTER), then its lowercase equivalent is returned. Otherwise $(D c) is returned. Warning: certain alphabets like German and Greek have no 1:1 upper-lower mapping. Use overload of toLower which takes full string instead. +/ @safe pure nothrow @nogc dchar toLower(dchar c) { // optimize ASCII case if(c < 0xAA) { if(c < 'A') return c; if(c <= 'Z') return c + 32; return c; } size_t idx = toLowerSimpleIndex(c); if(idx != ushort.max) { return toLowerTab(idx); } return c; } //TODO: Hidden for now, needs better API. //Other transforms could use better API as well, but this one is a new primitive. @safe pure nothrow @nogc private dchar toTitlecase(dchar c) { // optimize ASCII case if(c < 0xAA) { if(c < 'a') return c; if(c <= 'z') return c - 32; return c; } size_t idx = toTitleSimpleIndex(c); if(idx != ushort.max) { return toTitleTab(idx); } return c; } private alias UpperTriple = AliasSeq!(toUpperIndex, MAX_SIMPLE_UPPER, toUpperTab); private alias LowerTriple = AliasSeq!(toLowerIndex, MAX_SIMPLE_LOWER, toLowerTab); // generic toUpper/toLower on whole string, creates new or returns as is private S toCase(alias indexFn, uint maxIdx, alias tableFn, S)(S s) @trusted pure if(isSomeString!S) { import std.array : appender; foreach(i, dchar cOuter; s) { ushort idx = indexFn(cOuter); if(idx == ushort.max) continue; auto result = appender!S(s[0..i]); result.reserve(s.length); foreach(dchar c; s[i .. $]) { idx = indexFn(c); if(idx == ushort.max) result.put(c); else if(idx < maxIdx) { c = tableFn(idx); result.put(c); } else { auto val = tableFn(idx); // unpack length + codepoint uint len = val>>24; result.put(cast(dchar)(val & 0xFF_FFFF)); foreach(j; idx+1..idx+len) result.put(tableFn(j)); } } return result.data; } return s; } unittest //12428 { import std.array; auto s = "abcdefghij".replicate(300); s = s[0..10]; toUpper(s); assert(s == "abcdefghij"); } // generic toUpper/toLower on whole range, returns range private auto toCaser(alias indexFn, uint maxIdx, alias tableFn, Range)(Range str) // Accept range of dchar's if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && ElementEncodingType!Range.sizeof == dchar.sizeof) { static struct ToCaserImpl { @property bool empty() { return !nLeft && r.empty; } @property auto front() { if (!nLeft) { dchar c = r.front; const idx = indexFn(c); if (idx == ushort.max) { buf[0] = c; nLeft = 1; } else if (idx < maxIdx) { buf[0] = tableFn(idx); nLeft = 1; } else { auto val = tableFn(idx); // unpack length + codepoint nLeft = val >> 24; if (nLeft == 0) nLeft = 1; assert(nLeft <= buf.length); buf[nLeft - 1] = cast(dchar)(val & 0xFF_FFFF); foreach (j; 1 .. nLeft) buf[nLeft - j - 1] = tableFn(idx + j); } } return buf[nLeft - 1]; } void popFront() { if (!nLeft) front(); assert(nLeft); --nLeft; if (!nLeft) r.popFront(); } static if (isForwardRange!Range) { @property auto save() { auto ret = this; ret.r = r.save; return ret; } } private: Range r; uint nLeft; dchar[3] buf = void; } return ToCaserImpl(str); } /********************* * Convert input range or string to upper or lower case. * * Does not allocate memory. * Characters in UTF-8 or UTF-16 format that cannot be decoded * are treated as $(XREF utf, replacementDchar). * * Params: * str = string or range of characters * * Returns: * an InputRange of dchars * * See_Also: * $(LREF toUpper), $(LREF toLower) */ auto asLowerCase(Range)(Range str) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { import std.utf : byDchar; // Decode first return toCaser!LowerTriple(str.byDchar); } else { return toCaser!LowerTriple(str); } } /// ditto auto asUpperCase(Range)(Range str) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { import std.utf : byDchar; // Decode first return toCaser!UpperTriple(str.byDchar); } else { return toCaser!UpperTriple(str); } } /// @safe pure unittest { import std.algorithm.comparison : equal; assert("hEllo".asUpperCase.equal("HELLO")); } auto asLowerCase(Range)(auto ref Range str) if (isConvertibleToString!Range) { return asLowerCase!(StringTypeOf!Range)(str); } auto asUpperCase(Range)(auto ref Range str) if (isConvertibleToString!Range) { return asUpperCase!(StringTypeOf!Range)(str); } unittest { assert(testAliasedString!asLowerCase("hEllo")); assert(testAliasedString!asUpperCase("hEllo")); } unittest { import std.array; auto a = "HELLo".asLowerCase; auto savea = a.save; auto s = a.array; assert(s == "hello"); s = savea.array; assert(s == "hello"); string[] lower = ["123", "abcфеж", "\u0131\u023f\u03c9", "i\u0307\u1Fe2"]; string[] upper = ["123", "ABCФЕЖ", "I\u2c7e\u2126", "\u0130\u03A5\u0308\u0300"]; foreach (i, slwr; lower) { import std.utf : byChar; auto sx = slwr.asUpperCase.byChar.array; assert(sx == toUpper(slwr)); auto sy = upper[i].asLowerCase.byChar.array; assert(sy == toLower(upper[i])); } // Not necessary to call r.front for (auto r = lower[3].asUpperCase; !r.empty; r.popFront()) { } import std.algorithm.comparison : equal; "HELLo"w.asLowerCase.equal("hello"d); "HELLo"w.asUpperCase.equal("HELLO"d); "HELLo"d.asLowerCase.equal("hello"d); "HELLo"d.asUpperCase.equal("HELLO"d); import std.utf : byChar; assert(toLower("\u1Fe2") == asLowerCase("\u1Fe2").byChar.array); } // generic capitalizer on whole range, returns range private auto toCapitalizer(alias indexFnUpper, uint maxIdxUpper, alias tableFnUpper, Range)(Range str) // Accept range of dchar's if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && ElementEncodingType!Range.sizeof == dchar.sizeof) { static struct ToCapitalizerImpl { @property bool empty() { return lower ? lwr.empty : !nLeft && r.empty; } @property auto front() { if (lower) return lwr.front; if (!nLeft) { dchar c = r.front; const idx = indexFnUpper(c); if (idx == ushort.max) { buf[0] = c; nLeft = 1; } else if (idx < maxIdxUpper) { buf[0] = tableFnUpper(idx); nLeft = 1; } else { auto val = tableFnUpper(idx); // unpack length + codepoint nLeft = val >> 24; if (nLeft == 0) nLeft = 1; assert(nLeft <= buf.length); buf[nLeft - 1] = cast(dchar)(val & 0xFF_FFFF); foreach (j; 1 .. nLeft) buf[nLeft - j - 1] = tableFnUpper(idx + j); } } return buf[nLeft - 1]; } void popFront() { if (lower) lwr.popFront(); else { if (!nLeft) front(); assert(nLeft); --nLeft; if (!nLeft) { r.popFront(); lwr = r.asLowerCase(); lower = true; } } } static if (isForwardRange!Range) { @property auto save() { auto ret = this; ret.r = r.save; ret.lwr = lwr.save; return ret; } } private: Range r; typeof(r.asLowerCase) lwr; // range representing the lower case rest of string bool lower = false; // false for first character, true for rest of string dchar[3] buf = void; uint nLeft = 0; } return ToCapitalizerImpl(str); } /********************* * Capitalize input range or string, meaning convert the first * character to upper case and subsequent characters to lower case. * * Does not allocate memory. * Characters in UTF-8 or UTF-16 format that cannot be decoded * are treated as $(XREF utf, replacementDchar). * * Params: * str = string or range of characters * * Returns: * an InputRange of dchars * * See_Also: * $(LREF toUpper), $(LREF toLower) * $(LREF asUpperCase), $(LREF asLowerCase) */ auto asCapitalized(Range)(Range str) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { static if (ElementEncodingType!Range.sizeof < dchar.sizeof) { import std.utf : byDchar; // Decode first return toCapitalizer!UpperTriple(str.byDchar); } else { return toCapitalizer!UpperTriple(str); } } /// @safe pure unittest { import std.algorithm.comparison : equal; assert("hEllo".asCapitalized.equal("Hello")); } auto asCapitalized(Range)(auto ref Range str) if (isConvertibleToString!Range) { return asCapitalized!(StringTypeOf!Range)(str); } unittest { assert(testAliasedString!asCapitalized("hEllo")); } @safe pure nothrow @nogc unittest { auto r = "hEllo".asCapitalized(); assert(r.front == 'H'); } unittest { import std.array; auto a = "hELLo".asCapitalized; auto savea = a.save; auto s = a.array; assert(s == "Hello"); s = savea.array; assert(s == "Hello"); string[2][] cases = [ ["", ""], ["h", "H"], ["H", "H"], ["3", "3"], ["123", "123"], ["h123A", "H123a"], ["феж", "Феж"], ["\u1Fe2", "\u03a5\u0308\u0300"], ]; foreach (i; 0 .. cases.length) { import std.utf : byChar; auto r = cases[i][0].asCapitalized.byChar.array; auto result = cases[i][1]; assert(r == result); } // Don't call r.front for (auto r = "\u1Fe2".asCapitalized; !r.empty; r.popFront()) { } import std.algorithm.comparison : equal; "HELLo"w.asCapitalized.equal("Hello"d); "hElLO"w.asCapitalized.equal("Hello"d); "hello"d.asCapitalized.equal("Hello"d); "HELLO"d.asCapitalized.equal("Hello"d); import std.utf : byChar; assert(asCapitalized("\u0130").byChar.array == asUpperCase("\u0130").byChar.array); } // TODO: helper, I wish std.utf was more flexible (and stright) private size_t encodeTo(char[] buf, size_t idx, dchar c) @trusted pure nothrow @nogc { if (c <= 0x7F) { buf[idx] = cast(char)c; idx++; } else if (c <= 0x7FF) { buf[idx] = cast(char)(0xC0 | (c >> 6)); buf[idx+1] = cast(char)(0x80 | (c & 0x3F)); idx += 2; } else if (c <= 0xFFFF) { buf[idx] = cast(char)(0xE0 | (c >> 12)); buf[idx+1] = cast(char)(0x80 | ((c >> 6) & 0x3F)); buf[idx+2] = cast(char)(0x80 | (c & 0x3F)); idx += 3; } else if (c <= 0x10FFFF) { buf[idx] = cast(char)(0xF0 | (c >> 18)); buf[idx+1] = cast(char)(0x80 | ((c >> 12) & 0x3F)); buf[idx+2] = cast(char)(0x80 | ((c >> 6) & 0x3F)); buf[idx+3] = cast(char)(0x80 | (c & 0x3F)); idx += 4; } else assert(0); return idx; } unittest { char[] s = "abcd".dup; size_t i = 0; i = encodeTo(s, i, 'X'); assert(s == "Xbcd"); i = encodeTo(s, i, cast(dchar)'\u00A9'); assert(s == "X\xC2\xA9d"); } // TODO: helper, I wish std.utf was more flexible (and stright) private size_t encodeTo(wchar[] buf, size_t idx, dchar c) @trusted pure { import std.utf; if (c <= 0xFFFF) { if (0xD800 <= c && c <= 0xDFFF) throw (new UTFException("Encoding an isolated surrogate code point in UTF-16")).setSequence(c); buf[idx] = cast(wchar)c; idx++; } else if (c <= 0x10FFFF) { buf[idx] = cast(wchar)((((c - 0x10000) >> 10) & 0x3FF) + 0xD800); buf[idx+1] = cast(wchar)(((c - 0x10000) & 0x3FF) + 0xDC00); idx += 2; } else assert(0); return idx; } private size_t encodeTo(dchar[] buf, size_t idx, dchar c) @trusted pure nothrow @nogc { buf[idx] = c; idx++; return idx; } private void toCaseInPlace(alias indexFn, uint maxIdx, alias tableFn, C)(ref C[] s) @trusted pure if (is(C == char) || is(C == wchar) || is(C == dchar)) { import std.utf; size_t curIdx = 0; size_t destIdx = 0; alias slowToCase = toCaseInPlaceAlloc!(indexFn, maxIdx, tableFn); size_t lastUnchanged = 0; // in-buffer move of bytes to a new start index // the trick is that it may not need to copy at all static size_t moveTo(C[] str, size_t dest, size_t from, size_t to) { // Interestingly we may just bump pointer for a while // then have to copy if a re-cased char was smaller the original // later we may regain pace with char that got bigger // In the end it sometimes flip-flops between the 2 cases below if(dest == from) return to; // got to copy foreach(C c; str[from..to]) str[dest++] = c; return dest; } while(curIdx != s.length) { size_t startIdx = curIdx; dchar ch = decode(s, curIdx); // TODO: special case for ASCII auto caseIndex = indexFn(ch); if(caseIndex == ushort.max) // unchanged, skip over { continue; } else if(caseIndex < maxIdx) // 1:1 codepoint mapping { // previous cased chars had the same length as uncased ones // thus can just adjust pointer destIdx = moveTo(s, destIdx, lastUnchanged, startIdx); lastUnchanged = curIdx; dchar cased = tableFn(caseIndex); auto casedLen = codeLength!C(cased); if(casedLen + destIdx > curIdx) // no place to fit cased char { // switch to slow codepath, where we allocate return slowToCase(s, startIdx, destIdx); } else { destIdx = encodeTo(s, destIdx, cased); } } else // 1:m codepoint mapping, slow codepath { destIdx = moveTo(s, destIdx, lastUnchanged, startIdx); lastUnchanged = curIdx; return slowToCase(s, startIdx, destIdx); } assert(destIdx <= curIdx); } if(lastUnchanged != s.length) { destIdx = moveTo(s, destIdx, lastUnchanged, s.length); } s = s[0..destIdx]; } // helper to precalculate size of case-converted string private template toCaseLength(alias indexFn, uint maxIdx, alias tableFn) { size_t toCaseLength(C)(in C[] str) { import std.utf; size_t codeLen = 0; size_t lastNonTrivial = 0; size_t curIdx = 0; while(curIdx != str.length) { size_t startIdx = curIdx; dchar ch = decode(str, curIdx); ushort caseIndex = indexFn(ch); if(caseIndex == ushort.max) continue; else if(caseIndex < maxIdx) { codeLen += startIdx - lastNonTrivial; lastNonTrivial = curIdx; dchar cased = tableFn(caseIndex); codeLen += codeLength!C(cased); } else { codeLen += startIdx - lastNonTrivial; lastNonTrivial = curIdx; auto val = tableFn(caseIndex); auto len = val>>24; dchar cased = val & 0xFF_FFFF; codeLen += codeLength!C(cased); foreach(j; caseIndex+1..caseIndex+len) codeLen += codeLength!C(tableFn(j)); } } if(lastNonTrivial != str.length) codeLen += str.length - lastNonTrivial; return codeLen; } } unittest { import std.conv; alias toLowerLength = toCaseLength!(LowerTriple); assert(toLowerLength("abcd") == 4); assert(toLowerLength("аБВгд456") == 10+3); } // slower code path that preallocates and then copies // case-converted stuf to the new string private template toCaseInPlaceAlloc(alias indexFn, uint maxIdx, alias tableFn) { void toCaseInPlaceAlloc(C)(ref C[] s, size_t curIdx, size_t destIdx) @trusted pure if (is(C == char) || is(C == wchar) || is(C == dchar)) { import std.utf : decode; alias caseLength = toCaseLength!(indexFn, maxIdx, tableFn); auto trueLength = destIdx + caseLength(s[curIdx..$]); C[] ns = new C[trueLength]; ns[0..destIdx] = s[0..destIdx]; size_t lastUnchanged = curIdx; while(curIdx != s.length) { size_t startIdx = curIdx; // start of current codepoint dchar ch = decode(s, curIdx); auto caseIndex = indexFn(ch); if(caseIndex == ushort.max) // skip over { continue; } else if(caseIndex < maxIdx) // 1:1 codepoint mapping { dchar cased = tableFn(caseIndex); auto toCopy = startIdx - lastUnchanged; ns[destIdx .. destIdx+toCopy] = s[lastUnchanged .. startIdx]; lastUnchanged = curIdx; destIdx += toCopy; destIdx = encodeTo(ns, destIdx, cased); } else // 1:m codepoint mapping, slow codepath { auto toCopy = startIdx - lastUnchanged; ns[destIdx .. destIdx+toCopy] = s[lastUnchanged .. startIdx]; lastUnchanged = curIdx; destIdx += toCopy; auto val = tableFn(caseIndex); // unpack length + codepoint uint len = val>>24; destIdx = encodeTo(ns, destIdx, cast(dchar)(val & 0xFF_FFFF)); foreach(j; caseIndex+1..caseIndex+len) destIdx = encodeTo(ns, destIdx, tableFn(j)); } } if(lastUnchanged != s.length) { auto toCopy = s.length - lastUnchanged; ns[destIdx..destIdx+toCopy] = s[lastUnchanged..$]; destIdx += toCopy; } assert(ns.length == destIdx); s = ns; } } /++ Converts $(D s) to lowercase (by performing Unicode lowercase mapping) in place. For a few characters string length may increase after the transformation, in such a case the function reallocates exactly once. If $(D s) does not have any uppercase characters, then $(D s) is unaltered. +/ void toLowerInPlace(C)(ref C[] s) @trusted pure if (is(C == char) || is(C == wchar) || is(C == dchar)) { toCaseInPlace!(LowerTriple)(s); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { void toLowerInPlace(ref char[] s) { toLowerInPlace!char(s); } void toLowerInPlace(ref wchar[] s) { toLowerInPlace!wchar(s); } void toLowerInPlace(ref dchar[] s) { toLowerInPlace!dchar(s); } } /++ Converts $(D s) to uppercase (by performing Unicode uppercase mapping) in place. For a few characters string length may increase after the transformation, in such a case the function reallocates exactly once. If $(D s) does not have any lowercase characters, then $(D s) is unaltered. +/ void toUpperInPlace(C)(ref C[] s) @trusted pure if (is(C == char) || is(C == wchar) || is(C == dchar)) { toCaseInPlace!(UpperTriple)(s); } // overloads for the most common cases to reduce compile time/code size @safe pure /*TODO nothrow*/ { void toUpperInPlace(ref char[] s) { toUpperInPlace!char(s); } void toUpperInPlace(ref wchar[] s) { toUpperInPlace!wchar(s); } void toUpperInPlace(ref dchar[] s) { toUpperInPlace!dchar(s); } } /++ Returns a string which is identical to $(D s) except that all of its characters are converted to lowercase (by preforming Unicode lowercase mapping). If none of $(D s) characters were affected, then $(D s) itself is returned. +/ S toLower(S)(S s) @trusted pure if(isSomeString!S) { return toCase!(LowerTriple)(s); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { string toLower(string s) { return toLower!string(s); } wstring toLower(wstring s) { return toLower!wstring(s); } dstring toLower(dstring s) { return toLower!dstring(s); } } @trusted unittest //@@@BUG std.format is not @safe { import std.format : format; foreach(ch; 0..0x80) assert(std.ascii.toLower(ch) == toLower(ch)); assert(toLower('Я') == 'я'); assert(toLower('Δ') == 'δ'); foreach(ch; unicode.upperCase.byCodepoint) { dchar low = ch.toLower(); assert(low == ch || isLower(low), format("%s -> %s", ch, low)); } assert(toLower("АЯ") == "ая"); assert("\u1E9E".toLower == "\u00df"); assert("\u00df".toUpper == "SS"); } //bugzilla 9629 unittest { wchar[] test = "hello þ world"w.dup; auto piece = test[6..7]; toUpperInPlace(piece); assert(test == "hello Þ world"); } unittest { import std.algorithm : cmp; string s1 = "FoL"; string s2 = toLower(s1); assert(cmp(s2, "fol") == 0, s2); assert(s2 != s1); char[] s3 = s1.dup; toLowerInPlace(s3); assert(s3 == s2); s1 = "A\u0100B\u0101d"; s2 = toLower(s1); s3 = s1.dup; assert(cmp(s2, "a\u0101b\u0101d") == 0); assert(s2 !is s1); toLowerInPlace(s3); assert(s3 == s2); s1 = "A\u0460B\u0461d"; s2 = toLower(s1); s3 = s1.dup; assert(cmp(s2, "a\u0461b\u0461d") == 0); assert(s2 !is s1); toLowerInPlace(s3); assert(s3 == s2); s1 = "\u0130"; s2 = toLower(s1); s3 = s1.dup; assert(s2 == "i\u0307"); assert(s2 !is s1); toLowerInPlace(s3); assert(s3 == s2); // Test on wchar and dchar strings. assert(toLower("Some String"w) == "some string"w); assert(toLower("Some String"d) == "some string"d); // bugzilla 12455 dchar c = 'İ'; // '\U0130' LATIN CAPITAL LETTER I WITH DOT ABOVE assert(isUpper(c)); assert(toLower(c) == 'i'); // extend on 12455 reprot - check simple-case toUpper too c = '\u1f87'; assert(isLower(c)); assert(toUpper(c) == '\u1F8F'); } /++ If $(D c) is a Unicode lowercase $(CHARACTER), then its uppercase equivalent is returned. Otherwise $(D c) is returned. Warning: Certain alphabets like German and Greek have no 1:1 upper-lower mapping. Use overload of toUpper which takes full string instead. toUpper can be used as an argument to $(XREF_PACK algorithm,iteration,map) to produce an algorithm that can convert a range of characters to upper case without allocating memory. A string can then be produced by using $(XREF_PACK algorithm,mutation,copy) to send it to an $(XREF array, appender). +/ @safe pure nothrow @nogc dchar toUpper(dchar c) { // optimize ASCII case if(c < 0xAA) { if(c < 'a') return c; if(c <= 'z') return c - 32; return c; } size_t idx = toUpperSimpleIndex(c); if(idx != ushort.max) { return toUpperTab(idx); } return c; } /// unittest { import std.algorithm; import std.uni; import std.array; auto abuf = appender!(char[])(); "hello".map!toUpper.copy(&abuf); assert(abuf.data == "HELLO"); } @trusted unittest { import std.format : format; foreach(ch; 0..0x80) assert(std.ascii.toUpper(ch) == toUpper(ch)); assert(toUpper('я') == 'Я'); assert(toUpper('δ') == 'Δ'); auto title = unicode.Titlecase_Letter; foreach(ch; unicode.lowerCase.byCodepoint) { dchar up = ch.toUpper(); assert(up == ch || isUpper(up) || title[up], format("%x -> %x", ch, up)); } } /++ Returns a string which is identical to $(D s) except that all of its characters are converted to uppercase (by preforming Unicode uppercase mapping). If none of $(D s) characters were affected, then $(D s) itself is returned. +/ S toUpper(S)(S s) @trusted pure if(isSomeString!S) { return toCase!(UpperTriple)(s); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { string toUpper(string s) { return toUpper!string(s); } wstring toUpper(wstring s) { return toUpper!wstring(s); } dstring toUpper(dstring s) { return toUpper!dstring(s); } } unittest { import std.algorithm : cmp; string s1 = "FoL"; string s2; char[] s3; s2 = toUpper(s1); s3 = s1.dup; toUpperInPlace(s3); assert(s3 == s2, s3); assert(cmp(s2, "FOL") == 0); assert(s2 !is s1); s1 = "a\u0100B\u0101d"; s2 = toUpper(s1); s3 = s1.dup; toUpperInPlace(s3); assert(s3 == s2); assert(cmp(s2, "A\u0100B\u0100D") == 0); assert(s2 !is s1); s1 = "a\u0460B\u0461d"; s2 = toUpper(s1); s3 = s1.dup; toUpperInPlace(s3); assert(s3 == s2); assert(cmp(s2, "A\u0460B\u0460D") == 0); assert(s2 !is s1); } unittest { static void doTest(C)(const(C)[] s, const(C)[] trueUp, const(C)[] trueLow) { import std.format : format; string diff = "src: %( %x %)\nres: %( %x %)\ntru: %( %x %)"; auto low = s.toLower() , up = s.toUpper(); auto lowInp = s.dup, upInp = s.dup; lowInp.toLowerInPlace(); upInp.toUpperInPlace(); assert(low == trueLow, format(diff, low, trueLow)); assert(up == trueUp, format(diff, up, trueUp)); assert(lowInp == trueLow, format(diff, cast(ubyte[])s, cast(ubyte[])lowInp, cast(ubyte[])trueLow)); assert(upInp == trueUp, format(diff, cast(ubyte[])s, cast(ubyte[])upInp, cast(ubyte[])trueUp)); } foreach(S; AliasSeq!(dstring, wstring, string)) { S easy = "123"; S good = "abCФеж"; S awful = "\u0131\u023f\u2126"; S wicked = "\u0130\u1FE2"; auto options = [easy, good, awful, wicked]; S[] lower = ["123", "abcфеж", "\u0131\u023f\u03c9", "i\u0307\u1Fe2"]; S[] upper = ["123", "ABCФЕЖ", "I\u2c7e\u2126", "\u0130\u03A5\u0308\u0300"]; foreach(val; AliasSeq!(easy, good)) { auto e = val.dup; auto g = e; e.toUpperInPlace(); assert(e is g); e.toLowerInPlace(); assert(e is g); } foreach(i, v; options) { doTest(v, upper[i], lower[i]); } // a few combinatorial runs foreach(i; 0..options.length) foreach(j; i..options.length) foreach(k; j..options.length) { auto sample = options[i] ~ options[j] ~ options[k]; auto sample2 = options[k] ~ options[j] ~ options[i]; doTest(sample, upper[i] ~ upper[j] ~ upper[k], lower[i] ~ lower[j] ~ lower[k]); doTest(sample2, upper[k] ~ upper[j] ~ upper[i], lower[k] ~ lower[j] ~ lower[i]); } } } /++ Returns whether $(D c) is a Unicode alphabetic $(CHARACTER) (general Unicode category: Alphabetic). +/ @safe pure nothrow @nogc bool isAlpha(dchar c) { // optimization if(c < 0xAA) { size_t x = c - 'A'; if(x <= 'Z' - 'A') return true; else { x = c - 'a'; if(x <= 'z'-'a') return true; } return false; } return alphaTrie[c]; } @safe unittest { auto alpha = unicode("Alphabetic"); foreach(ch; alpha.byCodepoint) assert(isAlpha(ch)); foreach(ch; 0..0x4000) assert((ch in alpha) == isAlpha(ch)); } /++ Returns whether $(D c) is a Unicode mark (general Unicode category: Mn, Me, Mc). +/ @safe pure nothrow @nogc bool isMark(dchar c) { return markTrie[c]; } @safe unittest { auto mark = unicode("Mark"); foreach(ch; mark.byCodepoint) assert(isMark(ch)); foreach(ch; 0..0x4000) assert((ch in mark) == isMark(ch)); } /++ Returns whether $(D c) is a Unicode numerical $(CHARACTER) (general Unicode category: Nd, Nl, No). +/ @safe pure nothrow @nogc bool isNumber(dchar c) { return numberTrie[c]; } @safe unittest { auto n = unicode("N"); foreach(ch; n.byCodepoint) assert(isNumber(ch)); foreach(ch; 0..0x4000) assert((ch in n) == isNumber(ch)); } /++ Returns whether $(D c) is a Unicode punctuation $(CHARACTER) (general Unicode category: Pd, Ps, Pe, Pc, Po, Pi, Pf). +/ @safe pure nothrow @nogc bool isPunctuation(dchar c) { return punctuationTrie[c]; } unittest { assert(isPunctuation('\u0021')); assert(isPunctuation('\u0028')); assert(isPunctuation('\u0029')); assert(isPunctuation('\u002D')); assert(isPunctuation('\u005F')); assert(isPunctuation('\u00AB')); assert(isPunctuation('\u00BB')); foreach(ch; unicode("P").byCodepoint) assert(isPunctuation(ch)); } /++ Returns whether $(D c) is a Unicode symbol $(CHARACTER) (general Unicode category: Sm, Sc, Sk, So). +/ @safe pure nothrow @nogc bool isSymbol(dchar c) { return symbolTrie[c]; } unittest { import std.format : format; assert(isSymbol('\u0024')); assert(isSymbol('\u002B')); assert(isSymbol('\u005E')); assert(isSymbol('\u00A6')); foreach(ch; unicode("S").byCodepoint) assert(isSymbol(ch), format("%04x", ch)); } /++ Returns whether $(D c) is a Unicode space $(CHARACTER) (general Unicode category: Zs) Note: This doesn't include '\n', '\r', \t' and other non-space $(CHARACTER). For commonly used less strict semantics see $(LREF isWhite). +/ @safe pure nothrow @nogc bool isSpace(dchar c) { return isSpaceGen(c); } unittest { assert(isSpace('\u0020')); auto space = unicode.Zs; foreach(ch; space.byCodepoint) assert(isSpace(ch)); foreach(ch; 0..0x1000) assert(isSpace(ch) == space[ch]); } /++ Returns whether $(D c) is a Unicode graphical $(CHARACTER) (general Unicode category: L, M, N, P, S, Zs). +/ @safe pure nothrow @nogc bool isGraphical(dchar c) { return graphicalTrie[c]; } unittest { auto set = unicode("Graphical"); import std.format : format; foreach(ch; set.byCodepoint) assert(isGraphical(ch), format("%4x", ch)); foreach(ch; 0..0x4000) assert((ch in set) == isGraphical(ch)); } /++ Returns whether $(D c) is a Unicode control $(CHARACTER) (general Unicode category: Cc). +/ @safe pure nothrow @nogc bool isControl(dchar c) { return isControlGen(c); } unittest { assert(isControl('\u0000')); assert(isControl('\u0081')); assert(!isControl('\u0100')); auto cc = unicode.Cc; foreach(ch; cc.byCodepoint) assert(isControl(ch)); foreach(ch; 0..0x1000) assert(isControl(ch) == cc[ch]); } /++ Returns whether $(D c) is a Unicode formatting $(CHARACTER) (general Unicode category: Cf). +/ @safe pure nothrow @nogc bool isFormat(dchar c) { return isFormatGen(c); } unittest { assert(isFormat('\u00AD')); foreach(ch; unicode("Format").byCodepoint) assert(isFormat(ch)); } // code points for private use, surrogates are not likely to change in near feature // if need be they can be generated from unicode data as well /++ Returns whether $(D c) is a Unicode Private Use $(CODEPOINT) (general Unicode category: Co). +/ @safe pure nothrow @nogc bool isPrivateUse(dchar c) { return (0x00_E000 <= c && c <= 0x00_F8FF) || (0x0F_0000 <= c && c <= 0x0F_FFFD) || (0x10_0000 <= c && c <= 0x10_FFFD); } /++ Returns whether $(D c) is a Unicode surrogate $(CODEPOINT) (general Unicode category: Cs). +/ @safe pure nothrow @nogc bool isSurrogate(dchar c) { return (0xD800 <= c && c <= 0xDFFF); } /++ Returns whether $(D c) is a Unicode high surrogate (lead surrogate). +/ @safe pure nothrow @nogc bool isSurrogateHi(dchar c) { return (0xD800 <= c && c <= 0xDBFF); } /++ Returns whether $(D c) is a Unicode low surrogate (trail surrogate). +/ @safe pure nothrow @nogc bool isSurrogateLo(dchar c) { return (0xDC00 <= c && c <= 0xDFFF); } /++ Returns whether $(D c) is a Unicode non-character i.e. a $(CODEPOINT) with no assigned abstract character. (general Unicode category: Cn) +/ @safe pure nothrow @nogc bool isNonCharacter(dchar c) { return nonCharacterTrie[c]; } unittest { auto set = unicode("Cn"); foreach(ch; set.byCodepoint) assert(isNonCharacter(ch)); } private: // load static data from pre-generated tables into usable datastructures @safe auto asSet(const (ubyte)[] compressed) pure { return CodepointSet.fromIntervals(decompressIntervals(compressed)); } @safe pure nothrow auto asTrie(T...)(in TrieEntry!T e) { return const(CodepointTrie!T)(e.offsets, e.sizes, e.data); } @safe pure nothrow @nogc @property { // It's important to use auto return here, so that the compiler // only runs semantic on the return type if the function gets // used. Also these are functions rather than templates to not // increase the object size of the caller. auto lowerCaseTrie() { static immutable res = asTrie(lowerCaseTrieEntries); return res; } auto upperCaseTrie() { static immutable res = asTrie(upperCaseTrieEntries); return res; } auto simpleCaseTrie() { static immutable res = asTrie(simpleCaseTrieEntries); return res; } auto fullCaseTrie() { static immutable res = asTrie(fullCaseTrieEntries); return res; } auto alphaTrie() { static immutable res = asTrie(alphaTrieEntries); return res; } auto markTrie() { static immutable res = asTrie(markTrieEntries); return res; } auto numberTrie() { static immutable res = asTrie(numberTrieEntries); return res; } auto punctuationTrie() { static immutable res = asTrie(punctuationTrieEntries); return res; } auto symbolTrie() { static immutable res = asTrie(symbolTrieEntries); return res; } auto graphicalTrie() { static immutable res = asTrie(graphicalTrieEntries); return res; } auto nonCharacterTrie() { static immutable res = asTrie(nonCharacterTrieEntries); return res; } //normalization quick-check tables auto nfcQCTrie() { import std.internal.unicode_norm; static immutable res = asTrie(nfcQCTrieEntries); return res; } auto nfdQCTrie() { import std.internal.unicode_norm; static immutable res = asTrie(nfdQCTrieEntries); return res; } auto nfkcQCTrie() { import std.internal.unicode_norm; static immutable res = asTrie(nfkcQCTrieEntries); return res; } auto nfkdQCTrie() { import std.internal.unicode_norm; static immutable res = asTrie(nfkdQCTrieEntries); return res; } //grapheme breaking algorithm tables auto mcTrie() { import std.internal.unicode_grapheme; static immutable res = asTrie(mcTrieEntries); return res; } auto graphemeExtendTrie() { import std.internal.unicode_grapheme; static immutable res = asTrie(graphemeExtendTrieEntries); return res; } auto hangLV() { import std.internal.unicode_grapheme; static immutable res = asTrie(hangulLVTrieEntries); return res; } auto hangLVT() { import std.internal.unicode_grapheme; static immutable res = asTrie(hangulLVTTrieEntries); return res; } // tables below are used for composition/decomposition auto combiningClassTrie() { import std.internal.unicode_comp; static immutable res = asTrie(combiningClassTrieEntries); return res; } auto compatMappingTrie() { import std.internal.unicode_decomp; static immutable res = asTrie(compatMappingTrieEntries); return res; } auto canonMappingTrie() { import std.internal.unicode_decomp; static immutable res = asTrie(canonMappingTrieEntries); return res; } auto compositionJumpTrie() { import std.internal.unicode_comp; static immutable res = asTrie(compositionJumpTrieEntries); return res; } //case conversion tables auto toUpperIndexTrie() { static immutable res = asTrie(toUpperIndexTrieEntries); return res; } auto toLowerIndexTrie() { static immutable res = asTrie(toLowerIndexTrieEntries); return res; } auto toTitleIndexTrie() { static immutable res = asTrie(toTitleIndexTrieEntries); return res; } //simple case conversion tables auto toUpperSimpleIndexTrie() { static immutable res = asTrie(toUpperSimpleIndexTrieEntries); return res; } auto toLowerSimpleIndexTrie() { static immutable res = asTrie(toLowerSimpleIndexTrieEntries); return res; } auto toTitleSimpleIndexTrie() { static immutable res = asTrie(toTitleSimpleIndexTrieEntries); return res; } } }// version(!std_uni_bootstrap)
D
module mscorlib.System.Runtime.Versioning; import mscorlib.System : __DotNet__Attribute, __DotNet__AttributeStruct, __DotNet__Object, String, FlagsAttribute, SerializableAttribute, AttributeUsageAttribute, Attribute; import mscorlib.System.Runtime.CompilerServices : FriendAccessAllowedAttribute; import mscorlib.System.Diagnostics : ConditionalAttribute; // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\BinaryCompatibility.cs' // // Provides a simple way to test whether an application was built against specific .NET Framework // flavors and versions, with the intent of allowing Framework developers to mimic behavior of older // Framework releases. This allows us to make behavioral breaking changes in a binary compatible way, // for an application. This works at the per-AppDomain level, not process nor per-Assembly. // // To opt into newer behavior, applications must specify a TargetFrameworkAttribute on their assembly // saying what version they targeted, or a host must set this when creating an AppDomain. Note // that command line apps don't have this attribute! // // To use this class: // Developers need to figure out whether they're working on the phone, desktop, or Silverlight, and // what version they are introducing a breaking change in. Pick one predicate below, and use that // to decide whether to run the new or old behavior. Example: // // if (BinaryCompatibility.TargetsAtLeast_Phone_V7_1) { // // new behavior for phone 7.1 and other releases where we will integrate this change, like .NET Framework 4.5 // } // else { // // Legacy behavior // } // // If you are making a breaking change in one specific branch that won't be integrated normally to // all other branches (ie, say you're making breaking changes to Windows Phone 8 after .NET Framework v4.5 // has locked down for release), then add in specific predicates for each relevant platform. // // Maintainers of this class: // Revisit the table once per release, perhaps at the end of the last coding milestone, to verify a // default policy saying whether all quirks from a particular flavor & release should be enabled in // other releases (ie, should all Windows Phone 8.0 quirks be enabled in .NET Framework v5)? // // History: // Here is the order in which releases were made along with some basic integration information. The idea // is to track what set of compatibility features are present in each other. // While we cannot guarantee this list is perfectly linear (ie, a feature could be implemented in the last // few weeks before shipping and make it into only one of three concommittent releases due to triaging), // this is a good high level summary of code flow. // // Desktop Silverlight Windows Phone // .NET Framework 3.0 -> Silverlight 2 // .NET Framework 3.5 // Silverlight 3 // Silverlight 4 // .NET Framework 4 Phone 8.0 // .NET Framework 4.5 Phone 8.1 // .NET Framework 4.5.1 Phone 8.1 // // (Note: Windows Phone 7.0 was built using the .NET Compact Framework, which forked around v1 or v1.1) // // Compatibility Policy decisions: // If we cannot determine that an app was built for a newer .NET Framework (ie, the app has no // TargetFrameworkAttribute), then quirks will be enabled to emulate older behavior. // As such, your test code should define the TargetFrameworkAttribute (which VS does for you) // if you want to see the new behavior! @__DotNet__Attribute!(FriendAccessAllowedAttribute.stringof) package(mscorlib) class BinaryCompatibility : __DotNet__Object { private this() {} // prevent instantiation //TODO: generate property 'TargetsAtLeast_Phone_V7_1' //TODO: generate property 'TargetsAtLeast_Phone_V8_0' //TODO: generate property 'TargetsAtLeast_Desktop_V4_5' //TODO: generate property 'TargetsAtLeast_Desktop_V4_5_1' //TODO: generate property 'TargetsAtLeast_Desktop_V4_5_2' //TODO: generate property 'TargetsAtLeast_Desktop_V4_5_3' //TODO: generate property 'TargetsAtLeast_Desktop_V4_5_4' //TODO: generate property 'TargetsAtLeast_Desktop_V5_0' //TODO: generate property 'TargetsAtLeast_Silverlight_V4' //TODO: generate property 'TargetsAtLeast_Silverlight_V5' //TODO: generate property 'TargetsAtLeast_Silverlight_V6' //TODO: generate property 'AppWasBuiltForFramework' //TODO: generate property 'AppWasBuiltForVersion' private static TargetFrameworkId s_AppWasBuiltForFramework; private static int s_AppWasBuiltForVersion; private static immutable BinaryCompatibilityMap s_map/*todo: implement initializer*/ = null; private enum wchar c_componentSeparator/*todo: implement initializer*/ = wchar(); private enum wchar c_keyValueSeparator/*todo: implement initializer*/ = wchar(); private enum wchar c_versionValuePrefix/*todo: implement initializer*/ = wchar(); private enum String c_versionKey/*todo: implement initializer*/ = null; private enum String c_profileKey/*todo: implement initializer*/ = null; private static final class BinaryCompatibilityMap : __DotNet__Object { package(mscorlib) bool TargetsAtLeast_Phone_V7_1; package(mscorlib) bool TargetsAtLeast_Phone_V8_0; package(mscorlib) bool TargetsAtLeast_Phone_V8_1; package(mscorlib) bool TargetsAtLeast_Desktop_V4_5; package(mscorlib) bool TargetsAtLeast_Desktop_V4_5_1; package(mscorlib) bool TargetsAtLeast_Desktop_V4_5_2; package(mscorlib) bool TargetsAtLeast_Desktop_V4_5_3; package(mscorlib) bool TargetsAtLeast_Desktop_V4_5_4; package(mscorlib) bool TargetsAtLeast_Desktop_V5_0; package(mscorlib) bool TargetsAtLeast_Silverlight_V4; package(mscorlib) bool TargetsAtLeast_Silverlight_V5; package(mscorlib) bool TargetsAtLeast_Silverlight_V6; //TODO: generate constructor //TODO: generate method AddQuirksForFramework } //TODO: generate method ParseTargetFrameworkMonikerIntoEnum //TODO: generate method ParseFrameworkName //TODO: generate method ReadTargetFrameworkId } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\CompatibilitySwitch.cs' // public class CompatibilitySwitch : __DotNet__Object { private this() {} // prevent instantiation //TODO: generate method IsEnabled //TODO: generate method GetValue //TODO: generate method IsEnabledInternal //TODO: generate method GetValueInternal //TODO: generate method GetAppContextOverridesInternalCall //TODO: generate method IsEnabledInternalCall //TODO: generate method GetValueInternalCall } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\ComponentGuaranteesAttribute.cs' // @__DotNet__Attribute!(FlagsAttribute.stringof) @__DotNet__Attribute!(SerializableAttribute.stringof) public enum ComponentGuaranteesOptions { None = 0, Exchange = 0x1, Stable = 0x2, SideBySide = 0x4, } @__DotNet__Attribute!(AttributeUsageAttribute.stringof/*, AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor | AttributeTargets.Event, AllowMultiple = false, Inherited = false*/) public final class ComponentGuaranteesAttribute : Attribute { private ComponentGuaranteesOptions _guarantees; //TODO: generate constructor //TODO: generate property 'Guarantees' } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\NonVersionableAttribute.cs' // // This Conditional is here to strip the annotations for targets where ReadyToRun is not supported. // If this attribute is ever made public, this Conditional should be removed. @__DotNet__Attribute!(ConditionalAttribute.stringof/*, "FEATURE_READYTORUN"*/) @__DotNet__Attribute!(AttributeUsageAttribute.stringof/*, AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = false, Inherited = false*/) private final class NonVersionableAttribute : Attribute { //TODO: generate constructor } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\ResourceAttributes.cs' // @__DotNet__Attribute!(AttributeUsageAttribute.stringof/*, AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false*/) @__DotNet__Attribute!(ConditionalAttribute.stringof/*, "RESOURCE_ANNOTATION_WORK"*/) public final class ResourceConsumptionAttribute : Attribute { private ResourceScope _consumptionScope; private ResourceScope _resourceScope; //TODO: generate constructor //TODO: generate constructor //TODO: generate property 'ResourceScope' //TODO: generate property 'ConsumptionScope' } @__DotNet__Attribute!(AttributeUsageAttribute.stringof/*, AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Constructor, Inherited = false*/) @__DotNet__Attribute!(ConditionalAttribute.stringof/*, "RESOURCE_ANNOTATION_WORK"*/) public final class ResourceExposureAttribute : Attribute { private ResourceScope _resourceExposureLevel; //TODO: generate constructor //TODO: generate property 'ResourceExposureLevel' } // Default visibility is Public, which isn't specified in this enum. // Public == the lack of Private or Assembly // Does this actually work? Need to investigate that. @__DotNet__Attribute!(FlagsAttribute.stringof) public enum ResourceScope { None = 0, // Resource type Machine = 0x1, Process = 0x2, AppDomain = 0x4, Library = 0x8, // Visibility Private = 0x10, Assembly = 0x20, } @__DotNet__Attribute!(FlagsAttribute.stringof) package(mscorlib) enum SxSRequirements { None = 0, AppDomainID = 0x1, ProcessID = 0x2, CLRInstanceID = 0x4, AssemblyName = 0x8, TypeName = 0x10, } public class VersioningHelper : __DotNet__Object { private this() {} // prevent instantiation private enum ResourceScope ResTypeMask/*todo: implement initializer*/ = (cast(ResourceScope)0); private enum ResourceScope VisibilityMask/*todo: implement initializer*/ = (cast(ResourceScope)0); //TODO: generate method GetRuntimeId //TODO: generate method MakeVersionSafeName //TODO: generate method MakeVersionSafeName //TODO: generate method GetCLRInstanceString //TODO: generate method GetRequirements } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\TargetFrameworkAttribute.cs' // @__DotNet__Attribute!(AttributeUsageAttribute.stringof/*, AttributeTargets.Assembly, AllowMultiple = false, Inherited = false*/) public final class TargetFrameworkAttribute : Attribute { private String _frameworkName; private String _frameworkDisplayName; //TODO: generate constructor //TODO: generate property 'FrameworkName' //TODO: generate property 'FrameworkDisplayName' } // // Source Generated From 'D:\git\coreclr\src\mscorlib\src\System\Runtime\Versioning\TargetFrameworkId.cs' // // What type of .NET Framework was this application compiled against? @__DotNet__Attribute!(FriendAccessAllowedAttribute.stringof) package(mscorlib) enum TargetFrameworkId { NotYetChecked = 0, Unrecognized = 1, Unspecified = 2, NetFramework = 3, Portable = 4, NetCore = 5, Silverlight = 6, Phone = 7, }
D
instance BDT_1044_Bandit_L(Npc_Default) { name[0] = NAME_Bandit; guild = GIL_BDT; id = 1044; voice = 1; flags = 0; npcType = NPCTYPE_AMBIENT; aivar[AIV_EnemyOverride] = TRUE; B_SetAttributesToChapter(self,1); fight_tactic = FAI_HUMAN_COWARD; EquipItem(self,ItMw_2H_Sword_M_01); B_CreateAmbientInv(self); B_SetNpcVisual(self,MALE,"Hum_Head_Thief",Face_P_Tough_Rodriguez,BodyTex_P,ItAr_BDT_M); Mdl_SetModelFatness(self,0); Mdl_ApplyOverlayMds(self,"Humans_Relaxed.mds"); B_GiveNpcTalents(self); B_SetFightSkills(self,30); daily_routine = Rtn_Start_1044; }; func void Rtn_Start_1044() { TA_Smalltalk(0,0,12,0,"NW_CASTLEMINE_TOWER_STAND_02"); TA_Smalltalk(12,0,0,0,"NW_CASTLEMINE_TOWER_STAND_02"); };
D
/* REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test17450.d(17): Error: returning `&s.bar` escapes a reference to parameter `s` fail_compilation/test17450.d(17): perhaps annotate the parameter with `return` fail_compilation/test17450.d(20): Error: returning `&this.bar` escapes a reference to parameter `this` fail_compilation/test17450.d(20): perhaps annotate the parameter with `return` --- */ // https://issues.dlang.org/show_bug.cgi?id=17450 alias dg_t = void delegate(); struct S { @safe dg_t foo1(ref S s) { return &s.bar; } @safe dg_t foo2() { return &bar; } @safe dg_t foo3(return ref S s) { return &s.bar; } @safe dg_t foo4() return { return &bar; } @safe void bar(); } /* TEST_OUTPUT: --- fail_compilation/test17450.d(103): Error: scope variable `c` may not be returned fail_compilation/test17450.d(106): Error: scope variable `this` may not be returned --- */ // https://issues.dlang.org/show_bug.cgi?id=17450 #line 100 class C { @safe dg_t foo1(scope C c) { return &c.bar; } @safe dg_t foo2() scope { return &bar; } @safe dg_t foo3(return scope C c) { return &c.bar; } @safe dg_t foo4() return scope { return &bar; } @safe void bar(); }
D
obj/ee_avr8_asm.S.o: /cygdrive/c/TMP_WO~1/lab2_v2/erika/src/ee_avr8_asm.S
D
module vcf_parser.header; import std.exception : basicExceptionCtors; import std.conv; import std.string; import std.process; import std.stdio; import std.path; import std.array : uninitializedArray; import std.math : sqrt, floor; // Custom exceptions static class QualNotNumeric : Exception { mixin basicExceptionCtors; } static class BPPOSNotNumeric : Exception { mixin basicExceptionCtors; } static class MisformatVCFLine : Exception { mixin basicExceptionCtors; } // User defined structures struct FloatMatrix2D { int rows; int cols; string[] row_ids; string[] allele; string[] col_ids; float[][] values; this(int r, int c) { this.rows = r; this.cols = c; } void setrow(float[] vals) { this.values ~= vals; } void setci(string[] ci) { this.col_ids = ci; } void setri(string[] ri) { this.row_ids = ri; } void setrallele(string[] ral) { this.allele = ral; } } struct IntMatrix2D { int rows; int cols; int current_col; string[] row_ids; string[] allele; string[] col_ids; int[][] values; this(int r, int c) { this.rows = r; this.cols = c; this.current_col = 0; this.values = uninitializedArray!(int[][])(r, c); } void setcolval(int row, int col, int val) { this.values[row][col] = val; } void setri(char[][] ri) { string[] rids; foreach(ridcharr; ri[0..$]) { string current_rid = ""; foreach (rich; ridcharr[0..$]) { current_rid ~= rich; } rids ~= [current_rid]; } this.row_ids = rids; } void setci(string ci) { this.col_ids ~= [ci]; } void setallele(string allelestring) { this.allele ~= [allelestring]; } int[][] getvalues() { return this.values; } int[] getrowvaluebyindex(int r) { return this.values[r]; } string getallelebyrowindex(int r) { return this.allele[r]; } int getrowcount() { return this.rows; } int getcolcount() { return this.cols; } string[] getrowids() { return this.row_ids; } string[] getcolids() { return this.col_ids; } float getpj(int row) { float rowmean = 0.0; int notmissing = 0; int[] get_row = this.values[row]; foreach(var; get_row) { if (var != -1) { rowmean += to!float(var); ++notmissing; } } return (rowmean/to!float(notmissing))*0.5; } IntMatrix2D impute_genotypes() { foreach(col; 0..this.cols) { float rowmean = 0.0; int rowdem = 0; foreach(row; 0..this.rows) { if (row != -1) { rowmean += to!float(this.values[row][col]); ++rowdem; } } rowmean = rowmean/to!float(rowdem); rowmean = floor(rowmean); foreach(row; 0..this.rows) { if(this.values[row][col] == -1) { this.values[row][col] = to!int(rowmean); } } } return this; } bool to_csv(string vcffile, string csvfilename) { File csvfile = File(csvfilename, "w"); // csv header line csvfile.write("# This file was created from " ~ baseName(vcffile) ~ "\n"); csvfile.write("# nrow " ~ to!string(this.cols) ~ "\n"); csvfile.write("# ncol " ~ to!string(this.rows) ~ "\n"); csvfile.write("ids"); foreach(snp; this.row_ids) { csvfile.write("," ~ snp); } csvfile.write("\n"); foreach(col; 0..this.cols) { csvfile.write(this.col_ids[col]); foreach(row; 0..this.rows) { if (this.values[row][col] == -1) { csvfile.write(",NA"); } else { csvfile.write("," ~ to!string(this.values[row][col])); } } csvfile.write("\n"); } csvfile.close(); return true; } } // Auxillary functions ulong[string] getvcfcounts(string vcffile) { /* // This is a rudementary non-gnu coreutils dependent // variant counter for vcf files auto f = File(vcffile); size_t c = 0; // count of lines size_t h = 0; // count of # auto buffer = uninitializedArray!(ubyte[])(1024); foreach (chunk; f.byChunk(buffer)) { foreach(ch; chunk) { if(ch == '\n') { ++c; } if(ch == '#') { ++h; } } } size_t vars = c-(h/2)-1; return vars; */ // This sample and variant counter for vcf files depends on // gnu core utils: grep, awk, wc, and cut auto grep = executeShell("grep ^[^##] " ~ vcffile ~ " | wc -l"); auto goutput = strip(grep.output); auto vars = to!ulong(goutput); auto countsamps = executeShell("grep \"#CHROM\" " ~ vcffile ~ " | cut -f 10- | awk -F '\t' '{ print NF }'"); auto coutput = strip(countsamps.output); auto samps = to!ulong(coutput); ulong[string] vcfinfo; vcfinfo["samples"] = samps; vcfinfo["variants"] = vars; return vcfinfo; } int gt_to_score(string gt) { if(gt.length > 1) { auto gts = gt.split("|"); if (count(gts) < 2) gts = gt.split("/"); if(gts[0] == "." || gts[1] == ".") { return -1; } int par_one = to!int(gts[0]); int par_two = to!int(gts[1]); return par_one*(par_one+1)/2+par_two; } else if (gt.length == 1) { // haploids return 0; } return 0; } FloatMatrix2D compute_grm_from_rgm(IntMatrix2D rgm) { // calculations based on hail formula: // https://hail.is/docs/0.2/methods/genetics.html#hail.methods.genetic_relatedness_matrix auto grm = FloatMatrix2D(rgm.getrowcount(), rgm.getcolcount()); auto rowcount = rgm.getrowcount(); auto cids = rgm.getcolids(); auto rids = rgm.getrowids(); grm.setri(rids); grm.setci(cids); foreach(i; 0..rowcount) { auto allelestring = rgm.getallelebyrowindex(i); auto rowdata = rgm.getrowvaluebyindex(i); float[] newrowdata; foreach(j; 0..rowdata.length) { auto alleles = allelestring.split(':'); auto ref_al = alleles[0]; if (rowdata[j] < 0) { newrowdata ~= [0.00]; } else { float pj = rgm.getpj(to!int(j)); float m = to!float(rowcount); // Cij - 2pj // grm i,j = ------------------ // sqrt(2pj(1-pj)m) float val_ij = (to!float(rowdata[j])-(2*pj))/(sqrt(((2*pj)*(1-pj)*m))); newrowdata ~= [val_ij]; } } grm.setrow(newrowdata); } return grm; }
D
// Written in the D programming language // Author: Timon Gehr // License: http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0 import std.array, std.conv, std.algorithm, std.range, std.string; import lexer, parser, expression, statement, declaration, scope_, util; import analyze; import variant; public import operators; public import interpret; public import scheduler; // TODO: this is just a stub string uniqueIdent(string base){ shared static id=0; return base~to!string(id++); } // helper macros string[2] splitScope(string s){ if(!s.startsWith("sc=")) return ["sc",s]; string[2] r; alias std.string.indexOf indexOf; auto i = indexOf(s,";"); return [s[3..i], s[i+1..$]]; } enum SemRet = q{ static if(is(typeof(this):typeof(return))) return this; else static if(is(typeof(return)==class)) return null; else static if(is(typeof(return)==bool)) return true; else return; }; template MultiArgument(alias a,string s) if(s.canFind(",")){ enum sp = splitScope(s); enum ss=sp[1].split(","); enum MultiArgument={ string r; foreach(t;ToTuple!ss) r~=a!(mixin(X!q{sc=@(sp[0]);@(t)})); return r; }(); } template Rewrite(string s) if(!s.canFind(",")){ enum Rewrite=mixin(X!q{ while(@(s).rewrite){ debug{ auto rw=@(s).rewrite; assert(!!cast(typeof(@(s)))@(s).rewrite, text("rewrite from ",typeid(typeof(@(s)))," to ",typeid(rw))); } assert(@(s)!is @(s).rewrite, "non-terminating rewrite! "~.to!string(@(s))); //assert(!!cast(typeof(@(s)))@(s).rewrite,"cannot store "~.to!string(typeid(@(s).rewrite))~" into reference of type "~.to!string(typeid(typeof(@(s))))); @(s)=cast(typeof(@(s)))cast(void*)@(s).rewrite; } }); } template ConstFold(string s) if(!s.canFind(",")){ enum sp = splitScope(s); enum ConstFold=mixin(X!q{ @(sp[1]).constFold(@(sp[0])); mixin(Rewrite!q{@(sp[1])}); }); } template FinishDeductionProp(string s) if(!s.canFind(",")){ enum FinishDeductionProp=mixin(X!q{ if(!@(s).finishDeduction(sc)) mixin(ErrEplg); }); } template FinishDeduction(string s) if(!s.canFind(",")){ enum FinishDeduction=mixin(X!q{ if(!@(s).finishDeduction(sc)) mixin(SetErr!q{@(s)}); }); } template PropErr(string s) if(!s.canFind(",")){ enum sp = splitScope(s); enum PropErr=s.length?mixin(X!q{ static if(is(typeof(@(sp[1])): Node)){ if(@(sp[1]).sstate==SemState.error){ // auto xxx = @(sp[1]);dw("propagated error from ", typeid(xxx)," ",@(sp[1])," to ",this); @(ErrEplg) } }else foreach(x;@(sp[1])) mixin(PropErr!q{x}); }):mixin(X!q{if(sstate==SemState.error){@(NoRetry)mixin(SemRet);}}); } template PropErr(string s) if(s.canFind(",")){ alias MultiArgument!(.PropErr,s) PropErr; } template PropRetryNoRew(string s) if(!s.canFind(",")){ enum sp = splitScope(s); enum PropRetryNoRew=mixin(X!q{ static assert(!is(typeof(_nR))); if(auto _nR=@(sp[1]).needRetry){ assert(_nR!=2 || sstate != SemState.error,text("error in cdep from ",@(sp[1])," to ",toString())); if(sstate != SemState.error){ needRetry = _nR; if(_nR==2){mixin(SetErr!q{@(sp[1])});} // dw("propagated retry ",_nR," from ",@(sp[1])," to ",toString()," ",__LINE__); Scheduler().await(this, @(sp[1]), @(sp[0])); } mixin(SemRet); } }); } template PropRetry(string s) if(!s.canFind(",")){ enum sp = splitScope(s); enum PropRetry=Rewrite!(sp[1])~PropRetryNoRew!s; } template PropRetry(string s) if(s.canFind(",")){ alias MultiArgument!(.PropRetry,s) PropRetry; } template SemProp(string s){ enum sp = splitScope(s); enum SemProp = PropRetry!s~PropErr!(sp[1]); } enum CheckRewrite=mixin(X!q{ if(rewrite) mixin(SemRet); }); enum SemCheck=mixin(X!q{ if(needRetry||rewrite||sstate==SemState.error){mixin(SemRet);} }); private template _SemChldImpl(string s, string op, string sc){ // TODO: get rid of duplication template Doit(string v){ enum Doit=mixin(X!((op[0..3]!="exp"?q{ if(@(v).sstate != SemState.completed) }:"")~q{@(v).@(op)(@(sc));@(Rewrite!v);})); } enum ss=s.split(","); enum _SemChldImpl={ string r; foreach(t;ToTuple!ss){ r~=mixin(X!q{ static if(is(typeof(@(t)): Node)){ @(Doit!t) if(@(t).sstate != SemState.completed) mixin(PropRetryNoRew!q{sc=@(sc);@(t)}); else{ static if(is(typeof(@(t)): Expression) && !is(typeof(@(t)):Type) &&(!is(typeof(this):Expression)||is(typeof(this):Type))){ if(@(t).sstate==SemState.completed) mixin(ConstFold!q{sc=@(sc);@(t)}); } } }else{ foreach(ref x;@(t)) mixin(_SemChldImpl!("x","@(op)","@(sc)")); static if(is(typeof(@(t)): Expression[]) && (!is(typeof(this)==TemplateInstanceExp)||"@(t)"!="args")){ pragma(msg, typeof(this)," @(t)"); @(t)=mixin(`Tuple.expand(@(sc),AccessCheck.all,@(t),@(t~"Leftover"))`); if(mixin(`@(t~"Leftover")`)){ mixin(_SemChldImpl!("@(t)Leftover","@(op)","@(sc)")); } mixin(PropErr!q{@(t)}); } } }); } return r; }(); } template SemChld(string s){ // perform semantic analysis on child node, propagate all errors enum sp = splitScope(s); enum SemChld=_SemChldImpl!(sp[1],q{semantic},sp[0])~PropErr!s; } template SemChldPar(string s){ enum sp = splitScope(s); enum SemChldPar=_SemChldImpl!(sp[1],q{semantic},sp[0]); } template SemChldExp(string s){ // perform semantic analysis on child node, require that it is an expression enum sp = splitScope(s); enum SemChldExp=_SemChldImpl!(sp[1],q{expSemantic},sp[0])~PropErr!s; } template SemChldExpPar(string s){ enum sp = splitScope(s); enum SemChldExpPar=_SemChldImpl!(sp[1],q{expSemantic},sp[0]); } template ConvertTo(string s) if(s.split(",").length==2){ enum ss = s.split(","); enum ConvertTo=mixin(X!q{ assert(!@(ss[0]).rewrite && @(ss[0]).sstate == SemState.completed,"ConvertTo!q{@(s)}"); @(ss[0])=@(ss[0]).convertTo(@(ss[1])); mixin(SemChldExp!q{@(ss[0])}); assert(!@(ss[0]).rewrite,"ConvertTo!q{@(s)}"); }); } template ImplConvertTo(string s) if(s.split(",").length==2){ enum ss = s.split(","); enum ImplConvertTo=mixin(X!q{ assert(!@(ss[0]).rewrite && @(ss[0]).sstate == SemState.completed,@(ss[0]).toString()~" "~to!string(@(ss[0]).rewrite)~" "~to!string(@(ss[0]).sstate)); @(ss[0])=@(ss[0]).implicitlyConvertTo(@(ss[1])); mixin(SemChldExp!q{@(ss[0])}); assert(!@(ss[0]).rewrite,"ImplConvertTo!q{@(s)}"); }); } template ImplConvertToPar(string s) if(s.split(",").length==2){ enum ss = s.split(","); enum ImplConvertToPar=mixin(X!q{ assert(!@(ss[0]).rewrite && @(ss[0]).sstate == SemState.completed); @(ss[0])=@(ss[0]).implicitlyConvertTo(@(ss[1])); mixin(SemChldExpPar!q{@(ss[0])}); assert(!@(ss[0]).rewrite,"ImplConvertToPar!q{@(s)}"); }); } template CreateBinderForDependent(string name, string fun=lowerf(name)){ mixin(mixin(X!q{ template @(name)(string s, bool propErr = true) if(s.split(",")[0].split(";").length==2){ enum ss = s.split(";"); enum var = ss[0]; enum spl = var.split(" "); enum varn = strip(spl.length==1?var:spl[$-1]); enum sss = ss[1].split(","); enum e1 = sss[0]; enum er = sss[1..$].join(" , "); enum @(name)=` auto _@(name)_`~varn~`=`~e1~`.@(fun)(`~er~`); if(auto d=_@(name)_`~varn~`.dependee){ static if(is(typeof(return) A: Dependent!T,T)) return d.dependent!T; else mixin(`~(propErr?q{SemProp}:q{PropRetry})~`!q{sc=d.scope_;d.node}); } `~(propErr?`assert(!_@(name)_`~varn~`.dependee,text("illegal dependee ",_@(name)_`~varn~`.dependee.node," ",_@(name)_`~varn~`.dependee.node.sstate));`:``)~` static if(!is(typeof(_@(name)_`~varn~`)==Dependent!void))`~var~`=_@(name)_`~varn~`.value; `; } })); } mixin CreateBinderForDependent!("ImplConvertsTo","implicitlyConvertsTo"); mixin CreateBinderForDependent!("RefConvertsTo"); mixin CreateBinderForDependent!("ConstConvertsTo"); mixin CreateBinderForDependent!("ConvertsTo"); mixin CreateBinderForDependent!("TypeMostGeneral"); mixin CreateBinderForDependent!("TypeCombine"); mixin CreateBinderForDependent!("Combine"); mixin CreateBinderForDependent!("Unify"); mixin CreateBinderForDependent!("TypeMatch"); mixin CreateBinderForDependent!("RefCombine"); mixin CreateBinderForDependent!("MatchCall"); mixin CreateBinderForDependent!("MatchCallHelper"); mixin CreateBinderForDependent!("AtLeastAsSpecialized"); mixin CreateBinderForDependent!("DetermineMostSpecialized"); mixin CreateBinderForDependent!("Lookup"); mixin CreateBinderForDependent!("LookupHere"); mixin CreateBinderForDependent!("GetUnresolved"); mixin CreateBinderForDependent!("GetUnresolvedHere"); mixin CreateBinderForDependent!("IsDeclAccessible"); mixin CreateBinderForDependent!("DetermineOverride"); mixin CreateBinderForDependent!("FindOverrider"); mixin CreateBinderForDependent!("LookupSealedOverloadSet"); mixin CreateBinderForDependent!("LookupSealedOverloadSetWithRetry"); mixin CreateBinderForDependent!("EliminateLessSpecializedTemplateMatches"); template IntChld(string s) if(!s.canFind(",")){ enum IntChld=mixin(X!q{ @(s).interpret(sc); mixin(SemProp!q{@(s)}); }); } template Configure(string s){ enum Configure={ string r; auto ss=s.split("."); auto ss2=ss[1].split("="); if(ss2[1][$-1]==';') ss2[1]=ss2[1][0..$-1]; r~="auto _old_"~ss[0]~"_"~ss2[0]~"="~ss[0]~"."~ss2[0]~";\n"; r~="scope(exit) "~ss[0]~"."~ss2[0]~"="~"_old_"~ss[0]~"_"~ss2[0]~";\n"; r~=s~";"; return r; }(); } template RevEpoLkup(string e){ enum RevEpoLkup=mixin(X!q{ if(auto ident=@(e).isIdentifier()){ if(ident.recursiveLookup && !ident.isLookupIdentifier()){ if(!ident.meaning && ident.sstate != SemState.error){ //ident.lookup(sc); mixin(Lookup!q{_; ident, sc, sc}); if(auto nr=ident.needRetry) { needRetry = nr; return; } } if(ident.sstate == SemState.failed){ // show lookup error ident.sstate = SemState.begin; mixin(SemChldPar!q{@(e)}); } if(ident.sstate != SemState.error && ident.meaning){ // constructor calls are not subject to reverse eponymous lookup // reverse eponymous lookup is also not performed for reference // aggregate declarations. This behaviour is copied from DMD. static if(is(typeof(this)==CallExp)) if(ident.meaning.isAggregateDecl()) goto Lnorevepolkup; @(e) = ident.reverseEponymousLookup(sc); Lnorevepolkup:; } } } }); } template RevEpoNoHope(string e){ enum RevEpoNoHope=mixin(X!q{ if(auto ident = e.isIdentifier()){ if(ident.recursiveLookup && !ident.isLookupIdentifier()){ if(!ident.meaning && ident.sstate != SemState.error){ ident.noHope(sc); } } } }); } /+ // alternative implementation using an additional flag (firstlookup): template RevEpoLkup(string e){ enum RevEpoLkup=mixin(X!q{ if(firstlookup){ auto ident = e.isIdentifier(); if(!ident) firstlookup=false; else{ if(!ident.meaning){ ident.lookup(sc); mixin(PropRetry!q{e}); } if(e.sstate == SemState.failed){ mixin(SemChld!q{e}); assert(0); }else{ assert(!!cast(Identifier)ident); writeln(typeid(ident)); sc.note(ident.toString()~" here",ident.loc); e = ident.reverseEponymousLookup(sc); writeln(typeid(this.e));sc.note(e.toString()~" here",e.loc); firstlookup = false; } } } }); } +/ enum SemState:ubyte{ error, failed, // identifier lookup failed pre, begin, started, completed, } enum SemPrlgDontSchedule=q{ if(sstate == SemState.error||sstate == SemState.completed||rewrite){mixin(SemRet);} //dw(cccc++); if(!champ||cccc>champ.cccc) champ=this; //dw(champ); /+debug scope(failure){ if(loc.line) write("here! ",loc," ",typeid(this)); else write("here! ",toString()," ",typeid(this)); static if(is(typeof(meaning))) write(" meaning: ",meaning," ",typeid(this.meaning)," ",meaning.sstate); writeln(); }+/ }; enum SemPrlg=SemPrlgDontSchedule~q{ Scheduler().add(this,sc); }; //static if(is(typeof(dw(this)))) dw(this); // removed because they crash the program when compiled with DMD sometimes /+ debug scope(failure){ static if(is(typeof(sc))) if(sc) sc.note("here!",loc); static if(is(typeof(this):Declaration)) writeln(scope_); }+/ /+ debug scope(exit){ if(sstate != SemState.completed && returns_this){ assert(needRetry||sstate == SemState.error,toString()~" is not done but returns"); } }+/ //static if(is(typeof(sc))) if(sc){ // sc.note("prolog "~this.to!string~"@"~__LINE__.to!string,loc); // writeln(sc); //} //if(sstate>SemState.begin){sc.error("cyclic dependency",loc);sstate=SemState.error;return this;} enum NoRetry=q{ needRetry = false; Scheduler().remove(this); }; enum SemEplg=q{ mixin(NoRetry); sstate = SemState.completed; mixin(SemRet); }; template RewEplg(string s) if(!s.canFind(",")){ enum RewEplg=mixin(X!q{ assert(!rewrite," rewrite mustn't be set already "~toString()~" "~rewrite.toString()); rewrite = @(s); // dw("rewriting ",this," to ",rewrite," ",__LINE__); static assert(is(typeof(return)==void)||is(typeof(return)==bool)); Scheduler().remove(this); mixin(SemRet); }); } enum ErrEplg=q{ // dw(this," ",__LINE__); mixin(NoRetry); sstate=SemState.error; mixin(SemRet); }; template SetErr(string s) if(!s.canFind(",")){ enum t=s.length?s~".":""; enum SetErr=mixin(X!q{ @(t)needRetry=false; // TODO: macrolize? Scheduler().remove(@(s.length?s:"this")); @(t)sstate=SemState.error; }); } enum RetryEplg=q{ /+if(!needRetry)+/ assert(sstate != SemState.error,"1"); Identifier.tryAgain = true; needRetry = true; mixin(SemRet); }; enum RetryBreakEplg=q{ assert(sstate != SemState.error,"2"); needRetry = true; mixin(SemRet); }; template Semantic(T) if(is(T==Node)){ // TODO: needRetry and sstate could be final properties to save one byte of space // profile to see if it is worth it. Node rewrite; /+Node _rewrite; @property Node rewrite(){ return _rewrite; } @property Node rewrite(Node n){ if(!_rewrite) assert(!!n); dw("old: ",_rewrite); dw("new: ",n); return _rewrite=n; }+/ SemState sstate = SemState.begin; ubyte needRetry = false; // needRetry == 2: unwind stack for circular dep handling /+ubyte _needRetry = false; @property ubyte needRetry(){ return _needRetry; } @property void needRetry(ubyte val){ assert(val!=1||sstate!=SemState.error); assert(!val || sstate != SemState.completed || isExpression()&&isExpression().isConstant(),val.to!string); _needRetry=val; }+/ invariant(){ //assert(sstate!=SemState.error||needRetry!=1, "needRetry and error "~to!string(loc)~" "~to!string(typeid(this))~(cast(Identifier)this?" "~(cast(Identifier)this).name:"")~" Identifier.tryAgain: "~to!string(Identifier.tryAgain)~" needRetry: "~to!string(needRetry)); // !!!!? } void semantic(Scope sc)in{assert(sstate>=SemState.begin);}body{ mixin(SemPrlg); sc.error("feature not implemented",loc); mixin(ErrEplg); } // analysis is trapped because of circular await-relationship involving this node void noHope(Scope sc){} } // error nodes (TODO: file bug against covariance error) mixin template Semantic(T) if(is(T==ErrorDecl)||is(T==ErrorExp)||is(T==ErrorStm)||is(T==ErrorTy)){ override void semantic(Scope sc){ } static if(is(T:Declaration)) override void presemantic(Scope sc){assert(0);} } enum InContext:ubyte{ none, addressTaken, called, instantiated, passedToTemplateAndOrAliased, fieldExp, } // expressions mixin template Semantic(T) if(is(T==Expression)){ Type type; invariant(){ assert(sstate != SemState.completed || type && type.sstate == SemState.completed,text(typeid(this)," ",loc)); } // run before semantic if the expression occurs in a specified context void isInContext(InContext inContext){ } // TODO: those are not strictly necessary: final void willTakeAddress(){ isInContext(InContext.addressTaken); } final void willCall(){ isInContext(InContext.called); } final void willInstantiate(){ isInContext(InContext.instantiated); } final void willPassToTemplateAndOrAlias(){ isInContext(InContext.passedToTemplateAndOrAliased); } final void willAlias(){ willPassToTemplateAndOrAlias(); } final void willPassToTemplate(){ willPassToTemplateAndOrAlias(); } protected mixin template ContextSensitive(){ enum isContextSensitive = true; static assert(!is(typeof(super.inContext)), "already context-sensitive"); auto inContext = InContext.none; override void isInContext(InContext inContext){ assert(this.inContext.among(InContext.none, inContext), text(this," ",this.inContext," ",inContext)); this.inContext=inContext; } final void transferContext(Expression r){ final switch(inContext) with(InContext){ case none: break; case addressTaken: r.willTakeAddress(); break; case called: r.willCall(); break; case instantiated: r.willInstantiate(); break; case passedToTemplateAndOrAliased: r.willPassToTemplateAndOrAlias(); break; case fieldExp: if(auto sym=isSymbol()) sym.inContext=InContext.fieldExp; break; } } } void initOfVar(VarDecl decl){} override void semantic(Scope sc){ mixin(SemPrlg); sc.error("feature "~to!string(typeid(this))~" not implemented",loc); mixin(ErrEplg); } Type typeSemantic(Scope sc){ // dw(this," ",sstate," ",typeid(this)); Expression me=this; if(sstate != SemState.completed){ // TODO: is this ok? me.semantic(sc); mixin(Rewrite!q{me}); if(auto ty=me.isType()) return ty; if(me is this) mixin(SemCheck); else mixin(SemProp!q{me}); } // the empty tuple is an expression except if a type is requested if(auto et=me.isExpTuple()) if(!et.length) return et.type; if(auto sym=me.isSymbol()) if(auto ov=sym.meaning.isCrossScopeOverloadSet()){ ov.reportConflict(sc,loc); goto Lerr; } sc.error(format("%s '%s' is used as a type",me.kind,me.toString()),loc); me.sstate = SemState.error; Lerr:mixin(ErrEplg); } final void expSemantic(Scope sc){ semantic(sc); auto f = this; mixin(Rewrite!q{f}); void errorOut(){ sc.error(format("%s '%s' is not an expression", f.kind, f.toString()), loc); rewrite = null; mixin(ErrEplg); } if(f.sstate == SemState.completed){ if(f.isType()) return errorOut(); else if(auto et=f.isTuple()){ foreach(x; et) if(x.isType()) return errorOut(); } } } final void weakenAccessCheck(AccessCheck check){ static struct WeakenCheck{ immutable AccessCheck check; void perform(Symbol self){ self.accessCheck = min(self.accessCheck, check); } void perform(CurrentExp self){ self.accessCheck = min(self.accessCheck, check); } void perform(MixinExp self){ self.accessCheck = min(self.accessCheck, check); } } runAnalysis!WeakenCheck(this,check); } final void restoreAccessCheck(Scope sc, AccessCheck check){ // TODO: _perform_ access check static struct RestoreCheck{ immutable AccessCheck check; bool r=false; enum b=q{ if(self.accessCheck<check) r=true; self.accessCheck = check; }; void perform(Symbol self){ mixin(b); } void perform(CurrentExp self){ mixin(b); } void perform(MixinExp self){ mixin(b); } } if(runAnalysis!RestoreCheck(this,check).r){ static struct Reset{ void perform(Expression e){ if(!e.isType()) e.sstate = SemState.begin; } } runAnalysis!Reset(this); semantic(sc); } } final void checkAccess(Scope sc,AccessCheck accessCheck){ if(accessCheck==AccessCheck.none) return; if(auto s=AliasDecl.getAliasBase(this)){ if(s.accessCheck<accessCheck){ s.accessCheck = accessCheck; static struct ResetSstate{ void perform(Expression e){ if(e.sstate==SemState.error) return; e.sstate = SemState.begin; assert(!e.rewrite); } } runAnalysis!ResetSstate(this); semantic(sc); } } } bool isConstant(){ return false; } bool isConstFoldable(){ return false; } bool isUnique(){ return false; } Expression clone(Scope sc, InContext inContext, AccessCheck accessCheck, const ref Location loc)in{ assert(sstate == SemState.completed); }body{ Expression r; if(isConstFoldable()) r=cloneConstant(); else r=ddup(); r.loc = loc; r.isInContext(inContext); return r; } private bool fdontConstFold = false; // mere optimization final void dontConstFold(){fdontConstFold = true;} final bool isAConstant(){return fdontConstFold;} final void constFold(Scope sc)in{ assert(sstate == SemState.completed); assert(!rewrite); }body{ if(!isConstFoldable() || fdontConstFold) return; // import std.stdio; writeln("folding constant ", this); interpret(sc); } bool isLvalue(){return false;} final bool checkLvalue(Scope sc, ref Location l){ if(isLvalue()) return true; sc.error(format("%s '%s' is not an lvalue",kind,toString()),l); return false; } final bool canMutate(){ return isLvalue() && type.isMutable(); } bool checkMutate(Scope sc, ref Location l){ if(checkLvalue(sc,l)){ if(type.isMutable()) return true; else sc.error(format("%s '%s' of type '%s' is read-only",kind,loc.rep,type),l); } return false; } Dependent!bool implicitlyConvertsTo(Type rhs)in{ assert(sstate == SemState.completed,toString()~" in state "~to!string(sstate)); }body{ if(auto t=type.implicitlyConvertsTo(rhs).prop) return t; auto l = type.getHeadUnqual().isIntegral(), r = rhs.getHeadUnqual().isIntegral(); if(l && r && l.bitSize()<128 && r.bitSize()<128){ // TODO: VRP for cent and ucent // note: r.getLongRange is always valid for other basic types if(l.op == Tok!"long" || l.op == Tok!"ulong"){ return r.getLongRange().contains(getLongRange()).independent; }else{ return r.getIntRange().contains(getIntRange()).independent; } } return false.independent; } Expression implicitlyConvertTo(Type to)in{ assert(to && to.sstate == SemState.completed); }body{ if(type.equals(to)) return this; auto r = New!ImplicitCastExp(to,this); r.loc = loc; return r; } bool typeEquals(Type rhs)in{ assert(sstate == SemState.completed, text(typeid(this)," ",this," ",sstate," ",loc)); }body{ return type.equals(rhs); } final bool finishDeduction(Scope sc)in{assert(!!sc,text(this));}body{ static struct PropagateErrors{ void perform(CallExp exp){ // improve overload error messages // (don't show redundant deduction failure messages) // not required for correctness foreach(a;exp.args) if(auto ae = a.isAddressExp()) if(ae.isUndeducedFunctionLiteral()){ auto r=ae.e.isSymbol().meaning; mixin(SetErr!q{r}); } /// } } runAnalysis!PropagateErrors(this); static struct FinishDeduction{ Scope sc; bool result = true; void perform(Symbol sym){ if(sym.isFunctionLiteral) result &= runAnalysis!FinishDeduction(sym.meaning,sc).result; if(sym.meaning) if(auto cso=sym.meaning.isCrossScopeOverloadSet()){ cso.reportConflict(sc,sym.loc); mixin(SetErr!q{sym}); } } void perform(FunctionDef fd){ if(fd.sstate == SemState.error) return; size_t unres=0; foreach(x; fd.type.params) if(x.sstate!=SemState.error && x.mustBeTypeDeduced()) unres++; if(!unres) return; result = false; if(unres==1){ foreach(x; fd.type.params){ if(!x.mustBeTypeDeduced()) continue; sc.error(format("cannot deduce type for function literal parameter%s", x.name?" '"~x.name.name~"'":""),x.loc); break; } }else sc.error("cannot deduce parameter types for function literal", fd.type.params[0].loc.to(fd.type.params[$-1].loc)); mixin(SetErr!q{fd.type}); mixin(SetErr!q{fd}); return; } } return runAnalysis!FinishDeduction(this,sc).result; } // careful: this has to be kept in sync with Type.mostGeneral final Dependent!Type typeMostGeneral(Expression rhs)in{ assert(sstate == SemState.completed && sstate == rhs.sstate); }body{ Type r = null; mixin(ImplConvertsTo!q{bool l2r; this, rhs.type}); mixin(ImplConvertsTo!q{bool r2l; rhs, this.type}); if(l2r ^ r2l){ r = r2l ? type : rhs.type; STC stc = this.type.getHeadSTC() & rhs.type.getHeadSTC(); r.getHeadUnqual().applySTC(stc); } return r.independent; } final Dependent!Type typeCombine(Expression rhs)in{ assert(sstate == SemState.completed && sstate == rhs.sstate); }body{ if(auto r = typeMostGeneral(rhs).prop) return r; return type.combine(rhs.type); } Dependent!bool convertsTo(Type rhs)in{assert(sstate == SemState.completed);}body{ if(auto t=implicitlyConvertsTo(rhs).prop) return t; if(auto t=type.convertsTo(rhs.getUnqual().getConst()).prop) return t; return false.independent; } final Expression convertTo(Type to)in{assert(type&&to);}body{ if(type is to) return this; /+/ TODO: do we need this? Why? If needed, also consider the dependee !is null case auto iconvd = implicitlyConvertsTo(to); if(!iconvd.dependee&&iconvd.value) return implicitlyConvertTo(to); /// +/ auto r = New!CastExp(STC.init,to,this); r.loc = loc; return r; } Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context)in{ assert(sstate == SemState.completed); }body{ auto rd=type.getHeadUnqual().matchCallHelper(sc, loc, this_, args, context); if(rd.value) rd.value = this; // valid for dependee is null and dependee !is null return rd; } final Dependent!Expression matchCall(Scope sc, const ref Location loc, Expression[] args)in{ assert(sstate == SemState.completed); }body{ MatchContext context; mixin(MatchCallHelper!q{auto r; this, sc, loc, null, args, context}); if(!r){ if(sc && finishDeduction(sc)) matchError(sc, loc, null, args); return null.independent!Expression; } if(r.sstate == SemState.completed) r=r.resolveInout(context.inoutRes); else assert(r.needRetry||r.sstate==SemState.error||cast(TemplateInstanceExp)r, text(r," ",r.sstate," ",r.needRetry));//||r.isSymbol()&&(r.isSymbol().isSymbolMatcher||r.isSymbol().isFunctionLiteral)||cast(TemplateInstanceExp)r,text(r," ",typeid(r),r.isSymbol()?" "~r.isSymbol().meaning.toString():""," ",args," ",r.sstate," ",r.needRetry)); return r.independent; } Expression resolveInout(InoutRes res)in{ assert(sstate == SemState.completed); }body{ type = type.resolveInout(res); return this; } void matchError(Scope sc, Location loc, Type this_, Expression[] args){ sc.error(format("%s '%s' of type '%s' is not callable",kind,toString(),type.toString()),loc); } /* members */ Scope getMemberScope()in{ assert(sstate == SemState.completed); }body{ return type.getMemberScope(); } /* get an expression that can be used as 'this' reference. this is useful for eg. e.bar!().foo, where e.bar!() is the lhs expression for the member access, but only 'e' will be used as 'this' reference. */ Expression extractThis(){ return this; } AccessCheck deferredAccessCheck(){ return AccessCheck.none; } IntRange getIntRange(){return type.getIntRange();} LongRange getLongRange(){return type.getLongRange();} // needed for template instantiation bool tmplArgEquals(Expression rhs)in{ assert(sstate == SemState.completed,"not completed sstate "~toString()); assert(rhs.sstate == SemState.completed,"rhs not completed sstate "~rhs.toString()); }body{ assert(0, "unsupported operation"); } size_t tmplArgToHash(){ // default implementation provided // in order to support arbitrary expressions // as tuple variable initializers // TODO: this is hacky return 0; } } //pragma(msg, __traits(classInstanceSize,Expression)); // 0u. TODO: reduce and report mixin template Semantic(T) if(is(T==LiteralExp)){ static Expression factory(Variant value)in{ assert(!!value.getType()); }body{ auto vtype=value.getType(); if(auto tt=vtype.isTypeTuple()){ auto vals=value.getTuple(); auto exprs=new Expression[](vals.length); foreach(i,v;vals){ exprs[i]=factory(v); assert(exprs[i].sstate==SemState.completed && exprs[i].type==tt.allIndices()[i]); } return New!ExpTuple(exprs.captureTemplArgs, vtype); } auto r = New!LiteralExp(value); r.semantic(null); mixin(Rewrite!q{r}); assert(r.type is vtype); r.dontConstFold(); return r; } static Expression polyStringFactory(string value){ Expression r = factory(Variant(value, Type.get!string())); assert(cast(LiteralExp)r); (cast(LiteralExp)cast(void*)r).lit.type = Tok!"``"; return r; } override void semantic(Scope sc){ mixin(SemPrlg); type = value.getType(); mixin(SemEplg); } override bool isConstant(){ return true; } override bool isConstFoldable(){ return true; } final bool isPolyString(){return lit.type == Tok!"``";} override bool typeEquals(Type rhs){ if(super.typeEquals(rhs)) return true; if(!isPolyString()) return false; return rhs is Type.get!wstring()||rhs is Type.get!dstring(); } override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; if(type.getHeadUnqual().isSomeString()) if(auto ptr = rhs.getHeadUnqual().isPointerTy()){ return implicitlyConvertsTo(ptr.ty.getDynArr()); } if(isPolyString()){ assert(Type.get!wstring().implicitlyConvertsTo(rhs).isIndependent && Type.get!dstring().implicitlyConvertsTo(rhs).isIndependent ); return Type.get!wstring().implicitlyConvertsTo(rhs).or( Type.get!dstring().implicitlyConvertsTo(rhs)); } return false.independent; } override IntRange getIntRange(){ if(auto bt = type.getHeadUnqual().isIntegral()){ auto v = value.get!ulong(); bool s = bt.isSigned() || bt.bitSize()<32; return IntRange(cast(int)v,cast(int)v,s); } return super.getIntRange(); } override LongRange getLongRange(){ if(auto bt = type.getHeadUnqual().isIntegral()){ auto v = value.get!ulong(); bool s = bt.isSigned() || bt.bitSize()<64; return LongRange(v,v,s); } return super.getLongRange(); } override bool tmplArgEquals(Expression rhs){ if(!type.equals(rhs.type)) return false; if(!rhs.isConstant()) return false; return interpretV()==rhs.interpretV(); } override size_t tmplArgToHash(){ assert(!!type,text("no type! ",this)); import hashtable; return FNV(type.toHash(), value.toHash()); } } mixin template Semantic(T) if(is(T==ArrayLiteralExp)){ Expression litLeftover=null; override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{lit}); if(!lit.length){type=Type.get!EmptyArray(); mixin(SemEplg);} auto ty=lit[0].type; if(!type) foreach(i,x;lit[1..$]){ mixin(ImplConvertsTo!q{bool xtoty; x, ty}); // TODO: ditto? mixin(ImplConvertsTo!q{bool tytox; ty, x.type}); // TODO: ditto? if(!tytox){ tytox = true; foreach(y;lit[0..i+1]){ mixin(ImplConvertsTo!q{bool ytox; y, x.type}); if(!(tytox &= ytox)) break; } } if(xtoty^tytox){ ty = tytox ? x.type : ty; continue; } mixin(Combine!q{Type newty; ty, x.type}); // TODO: keep state? if(newty){ ty=newty; continue; } if((x.isAddressExp()||x.isArrayLiteralExp()) && x.type is Type.get!void()) continue; sc.error(format("incompatible type '%s' in array of '%s'",x.type,ty),x.loc); mixin(ErrEplg); } // TODO: is there a better solution than using 'void' as the type // for undeduced function literals? if(ty is Type.get!void()) foreach(x; lit){ if(x.isAddressExp()||x.isArrayLiteralExp()) if(x.type is ty){ type = ty; mixin(SemEplg); } } if(type){ ty=type.getElementType(); assert(!!ty); } if(ty.getHeadUnqual() !is Type.get!void()) foreach(ref x; lit) x=x.implicitlyConvertTo(ty); mixin(SemChldPar!q{lit}); alias util.all all; // TODO: file bug assert(all!(_=>_.sstate == SemState.completed)(lit)); type=ty.getDynArr(); mixin(SemEplg); } override bool isUnique(){ return true; } // TODO: analyze what's contained within override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; if(rhs.getHeadUnqual() is Type.get!(void[])()) return true.independent; Type et = rhs.getElementType(); if(auto arr = rhs.getHeadUnqual().isArrayTy()) if(arr.length != lit.length) return false.independent; if(!et) return false.independent; foreach(x; lit){ // TODO: keep state somewhere? this can lead to quadratic performance mixin(ImplConvertsTo!q{bool xtoet; x, et}); if(!xtoet) return false.independent; } return true.independent; } override bool tmplArgEquals(Expression rhs){ if(!type.equals(rhs.type)) return false; return interpretV()==rhs.interpretV(); } override size_t tmplArgToHash(){ import hashtable; return FNVred(lit); } } mixin template Semantic(T) if(is(T _==PostfixExp!S,TokenType S)){ static if(is(T _==PostfixExp!S,TokenType S)): static assert(S==Tok!"++" || S==Tok!"--"); /// mixin OpOverloadMembers; TmpVarExp tmp1,tmp2; /// override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChldExp!q{e}); if(e.checkMutate(sc,loc)){ auto v = Type.get!void(); auto ty = e.type.getHeadUnqual(); if((ty.isBasicType() && e !is v)||ty.isPointerTy()){ type = e.type; mixin(SemEplg); } }else mixin(ErrEplg); if(!tmp1){ assert(!tmp2); tmp1=New!TmpVarExp(e); tmp1.loc=loc; tmp1.semantic(sc); assert(!!tmp1.sym); tmp2=New!TmpVarExp(tmp1.sym); tmp2.loc=loc; tmp2.initTmpVarDecl(sc,true); tmp2.semantic(sc); assert(!!tmp2.sym); } mixin(OpOverload!("opUnary",q{[LiteralExp.polyStringFactory(TokChars!S)]}, q{(Expression[]).init},"tmp1.sym","sc",q{ auto tmpe=New!(BinaryExp!(Tok!","))(tmp1,tmp2); tmpe.loc=loc; r=New!(BinaryExp!(Tok!","))(tmpe,r); r.loc=loc; r=New!(BinaryExp!(Tok!","))(r,tmp2.sym); r.loc=loc; })); sc.error(format("type '%s' does not support postfix "~TokChars!op,e.type),loc); mixin(ErrEplg); } } mixin template OpOverloadMembers(){ // TODO: this bloats the AST, find a better way? Expression opoverload=null; Expression oofun=null; GaggingScope oosc=null; } template BuildOpOver(string opover,string e, string name, string tmargs){ enum BuildOpOver = mixin(X!q{ if(!@(opover)){ auto id=New!Identifier("@(name)"); id.loc=loc; @(opover)=New!(BinaryExp!(Tok!"."))(@(e),id); @(opover).loc=loc; @({ if(tmargs.length) return mixin(X!q{ @(opover)=New!TemplateInstanceExp(@(opover),@(tmargs)); @(opover).loc=loc; }); return ""; }()); } }); } template OpOverload(string name, string tmargs="", string args="", string e="e", string sc="sc", string post=""){ enum OpOverload = mixin(X!q{ @(BuildOpOver!("opoverload",e,name,tmargs)); if(!oosc) oosc=New!GaggingScope(@(sc)); opoverload.willCall(); mixin(SemChldPar!q{sc=oosc;opoverload}); auto args = @(args); if(!oofun&&opoverload.sstate==SemState.completed){ mixin(MatchCall!q{oofun; opoverload, @(sc), loc, args}); if(!oofun) mixin(SetErr!q{opoverload}); } if(oofun){ mixin(SemChldPar!q{sc=oosc;oofun}); oosc=null; Expression r=New!CallExp(oofun,args); r.loc=loc; @(post) r.semantic(sc); mixin(RewEplg!q{r}); } }); } mixin template Semantic(T) if(is(T==IndexExp)){ Expression aLeftover=null; DollarScope ascope; mixin DollarExp.DollarProviderImpl!e; mixin ContextSensitive; mixin OpOverloadMembers; override void semantic(Scope sc_){ {alias sc_ sc;mixin(SemPrlg);} {alias sc_ sc;mixin(SemChldPar!q{e});} if(!ascope) ascope = New!DollarScope(sc_, this); alias ascope sc; if(e.isType()){ auto r=typeSemantic(sc); // TODO: ok? mixin(SemCheck); assert(!!r); mixin(RewEplg!q{r}); }else if(e.isExpTuple()||e.sstate == SemState.completed && e.type.isTypeTuple()){ mixin(SemChldExp!q{a}); mixin(PropErr!q{e}); if(a.length==0){ e.loc=loc; mixin(RewEplg!q{e}); } if(a.length>1){ sc.error(format("can only use one index to index '%s'",e.type),a[1].loc.to(a[$-1].loc)); mixin(ErrEplg); } a[0].prepareInterpret(); mixin(SemChld!q{a}); auto s_t = Type.get!Size_t(); mixin(ImplConvertTo!q{a[0],s_t}); mixin(IntChld!q{a[0]}); auto n = a[0].interpretV().get!ulong(); bool checkn(size_t len){ if(n<len) return true; sc.error(format("tuple index %s is out of bounds [0%s..%d%s)",a[0].toString(),Size_t.suffix,len,Size_t.suffix),a[0].loc); return false; } Expression r; if(auto et=e.isExpTuple()){ if(!checkn(et.length)) mixin(ErrEplg); r=et.index(sc,inContext,loc,n); }else if(auto c=e.isCommaExp()){ bool err=false; Expression go(CommaExp c){ Expression rhs; if(auto cc=c.e2.isCommaExp()) rhs=go(cc); else{ auto et=c.e2.isExpTuple(); assert(!!et); if(!checkn(et.length)){ err=true; return c; } rhs=et.index(sc,inContext,loc,n); } auto r=New!(BinaryExp!(Tok!","))(c.e1, rhs); r.brackets++; r.loc=c.loc; return r; } r=go(c); if(err) mixin(ErrEplg); }else assert(0,text(e," ",e.loc)); r.semantic(sc); mixin(RewEplg!q{r}); }else{ mixin(SemChld!q{a}); mixin(PropErr!q{e}); auto ty = e.type.getHeadUnqual(); bool isEmpty = false; if(auto dyn=ty.isDynArrTy()){ type = dyn.ty; }else if(auto arr=ty.isArrayTy()){ // TODO: sanity check against length type = arr.ty; }else if(auto ptr=ty.isPointerTy()){ if(!a.length){ sc.error("need bounds to slice pointer", loc); mixin(ErrEplg); } type = ptr.ty; }else if(ty is Type.get!EmptyArray()){ type = Type.get!void(); isEmpty = true; }else{ mixin(OpOverload!("opIndex","","a","e","sc_")); sc.error(format("'%s' is not indexable", e.type),loc); mixin(ErrEplg); } // it is a dynamic array, an array or pointer type if(!a.length) type = type.getDynArr(); else{ if(a.length>1){ sc.error(format("can only use one index to index '%s'",e.type),a[0].loc.to(a[$-1].loc)); mixin(ErrEplg); } auto s_t = Type.get!Size_t(); mixin(ImplConvertTo!q{a[0],s_t}); mixin(ConstFold!q{e}); // TODO: length could be a maximum ulong length; if(auto le = e.isArrayLiteralExp()) length = le.lit.length; else if(e.isConstant()){ auto v = e.interpretV(); // TODO: this is inefficient length = v.length; }else if(!isEmpty) goto Lafter; //import std.stdio; wrietln("duh ",e,length); LongRange rng; if(s_t is Type.get!uint()){ auto r = a[0].getIntRange(); rng = LongRange(r.min, r.max,false); }else{ assert(s_t is Type.get!ulong()); rng = a[0].getLongRange(); } if(!length||!rng.overlaps(LongRange(0,length-1,false))){ mixin(ConstFold!q{a[0]}); sc.error(format("array index %s is out of bounds [0%s..%d%s)", a[0].toString(),Size_t.suffix,length,Size_t.suffix),a[0].loc); mixin(ErrEplg); } Lafter:; } if(!isConstFoldable()){ mixin(ConstFold!q{e}); foreach(ref x; a) mixin(ConstFold!q{x}); } mixin(SemEplg); } } override bool isConstant(){ if(!a.length) return e.isConstant(); assert(a.length==1,to!string(this)); return e.isConstant() && a[0].isConstant(); } override bool isConstFoldable(){ if(!a.length) return e.isConstFoldable(); assert(a.length==1,to!string(this)); return e.isConstFoldable() && a[0].isConstFoldable(); } override Type typeSemantic(Scope sc_){ //mixin(SemChld!q{e}); {alias sc_ sc; mixin(SemChld!q{e});} auto tp = e.isTuple(); Type ty; if(!tp || !a.length){ alias sc_ sc; ty=e.typeSemantic(sc_); mixin(SemProp!q{e}); } if(!a.length){ mixin(NoRetry); if(tp) { e.loc=loc; return ty; } else { return ty.getDynArr(); } } Scope sc; if(tp){ if(!ascope) ascope = New!DollarScope(sc_,this); sc = ascope; }else sc = sc_; foreach(x;a) x.prepareInterpret(); mixin(SemChldExp!q{a}); if(a.length>1){ if(tp) sc.error(format("can only use one index to index '%s'",e.type),a[0].loc.to(a[$-1].loc)); else sc.error("can only specify one dimension for fixed-length array",a[0].loc.to(a[$-1].loc)); mixin(ErrEplg); } assert(a.length==1); auto s_t=Type.get!Size_t(); mixin(ImplConvertTo!q{a[0],s_t}); mixin(IntChld!q{a[0]}); mixin(NoRetry); ulong n = a[0].interpretV().get!ulong(); if(tp){ if(n>=tp.length){ sc.error(format("tuple index %s is out of bounds [0%s..%d%s)",a[0].toString(),Size_t.suffix,tp.length,Size_t.suffix),a[0].loc); mixin(ErrEplg); } return tp.index(sc,inContext,loc,n).typeSemantic(sc); } // TODO: DMD considers 16777215 as the upper bound for static array size assert(!!ty); return ty.getArray(n); } override bool isLvalue(){ return !!a.length; // slice expression is no lvalue } override @property string kind(){ return a.length?"index expression":"slice"; } /+ // TODO (?) static string __dgliteralRng(){ string r; foreach(x;["IntRange", "LongRange"]){ r~=mixin(X!q{ override @(x) get@(x)(){ if(ty.isArrayTy()||ty.isDynArrTy()){ }else return super.get@(x)(); // TODO: associative arrays } }); } return r; } mixin(__dgliteralRng()); +/ } mixin template Semantic(T) if(is(T==SliceExp)){ DollarScope ascope; mixin DollarExp.DollarProviderImpl!e; mixin OpOverloadMembers; override void semantic(Scope sc_){ {alias sc_ sc; mixin(SemPrlg);} //mixin(SemChldPar!q{e}); if(e.sstate != SemState.completed){ alias sc_ sc; mixin(SemChldPar!q{e}); } mixin(Rewrite!q{e}); if(!ascope) ascope = New!DollarScope(sc_, this); // mixin(MaybeFold!q{e,l,r}); // TODO: this is better if(e.isTuple()||e.type&&e.type.isTuple()){ Expression r=null; if(auto tp = e.isTuple()){ r=sliceTuple(sc_,tp); }else if(auto c=e.isCommaExp()){ Expression go(CommaExp c){ Expression rhs; if(auto cc=c.e2.isCommaExp()){ rhs=go(cc); }else{ auto tp=c.e2.isTuple(); assert(!!tp); rhs=sliceTuple(sc_,tp); } if(!rhs) return null; auto r=New!(BinaryExp!(Tok!","))(c.e1, rhs); r.brackets++; r.loc=c.loc; return r; } r=go(c); }else assert(0); if(!r) return; r.semantic(sc_); mixin(RewEplg!q{r}); }else{ alias ascope sc; mixin(SemChldExpPar!q{e}); // does not use the scope anyway. mixin(SemChld!q{l,r}); mixin(PropErr!q{e}); auto ty = e.type.getHeadUnqual(); bool isEmpty = false; if(auto dyn=ty.isDynArrTy()){ type = dyn.ty; }else if(auto arr=ty.isArrayTy()){ // TODO: sanity check against length type = arr.ty; }else if(auto ptr=ty.isPointerTy()){ type = ptr.ty; }else if(ty is Type.get!EmptyArray()){ type = Type.get!void(); isEmpty = true; }else{ // TODO: this gc allocates mixin(OpOverload!("opSlice","",q{[l,r]},"e","sc_")); sc.error(format("'%s' is not sliceable",e.type),loc); mixin(ErrEplg); } // it is a dynamic array, an array or pointer type type = type.getDynArr(); auto s_t = Type.get!Size_t(); mixin(ImplConvertToPar!q{l,s_t}); mixin(ImplConvertTo!q{r,s_t}); mixin(PropErr!q{l}); // TODO: remove code duplication between here and IndexExp.semantic // TODO: length could be a maximum ulong length; if(auto le = e.isArrayLiteralExp()) length = le.lit.length; else if(e.isConstant()){ auto v = e.interpretV(); // TODO: this is inefficient length = v.length; }else if(!isEmpty) goto Lafter; LongRange[2] rng; if(s_t is Type.get!uint()){ auto r1 = l.getIntRange(), r2 = r.getIntRange(); rng[0] = LongRange(r1.min, r1.max,false); rng[1] = LongRange(r2.min, r2.max,false); }else{ assert(s_t is Type.get!ulong()); rng[0] = l.getLongRange(); rng[1] = r.getLongRange(); } if(!rng[0].overlaps(LongRange(0,length,false)) || !rng[1].overlaps(LongRange(0,length,false))){ mixin(ConstFold!q{l}); mixin(ConstFold!q{r}); sc.error(format("slice indices [%s..%s] are out of bounds [0%s..%d%s]",l.toString(),r.toString(),Size_t.suffix,length,Size_t.suffix),l.loc.to(r.loc)); mixin(ErrEplg); } if(s_t is Type.get!uint() && l.getIntRange().gr(r.getIntRange()) || s_t is Type.get!ulong() && l.getLongRange().gr(r.getLongRange())){ sc.error("lower slice index exceeds upper slice index",l.loc.to(r.loc)); mixin(ErrEplg); } Lafter: if(!isConstFoldable()){ mixin(ConstFold!q{e}); mixin(ConstFold!q{l}); mixin(ConstFold!q{r}); } mixin(SemEplg); } } override Type typeSemantic(Scope sc){ e.typeSemantic(sc); mixin(SemProp!q{e}); if(auto tp=e.isTuple()) return cast(TypeTuple)cast(void*)sliceTuple(sc, tp); return super.typeSemantic(sc); } override bool isConstant(){ return e.isConstant() && l.isConstant() && r.isConstant(); } override bool isConstFoldable(){ return e.isConstFoldable() && l.isConstFoldable() && r.isConstFoldable(); } override void isInContext(InContext ctx){ with(InContext) if(ctx.among(passedToTemplateAndOrAliased, fieldExp)) e.isInContext(ctx); } override @property string kind(){ return e.kind; } private: Expression sliceTuple(Scope sc_, Tuple tp){ enum SemRet = q{ return null; }; alias ascope sc; auto s_t = Type.get!Size_t(); l.prepareInterpret(); r.prepareInterpret(); mixin(SemChldExp!q{l,r}); mixin(ImplConvertToPar!q{l,s_t}); mixin(ImplConvertTo!q{r,s_t}); mixin(PropErr!q{l}); // TODO: macrolize? l.interpret(sc); r.interpret(sc); mixin(SemProp!q{l,r}); auto a = l.interpretV().get!ulong(); auto b = r.interpretV().get!ulong(); auto len = tp.length; if(a>len || b>len){ sc.error(format("tuple slice indices [%s..%s] are out of bounds [0%s..%d%s]",l.toString(),r.toString(),Size_t.suffix,len,Size_t.suffix),l.loc.to(r.loc)); mixin(ErrEplg); } if(a>b){ sc.error("lower tuple slice index exceeds upper tuple slice index",l.loc.to(r.loc)); mixin(ErrEplg); } auto r=tp.slice(loc,a,b); r.semantic(sc); mixin(NoRetry); return r; } } mixin template Semantic(T) if(is(T==ImportExp)){ Expression aLeftover=null; override void semantic(Scope sc){ mixin(SemPrlg); foreach(x;a) x.prepareInterpret(); mixin(SemChld!q{a}); if(a.length<1){ sc.error("missing file name for import expression", loc); mixin(ErrEplg); }else if(a.length>1){ sc.error("too many arguments for import expression", loc); mixin(ErrEplg); } mixin(FinishDeductionProp!q{a[0]}); // TODO: this code is identical for MixinExp int which; Type[3] types = [Type.get!(const(char)[])(), Type.get!(const(wchar)[])(), Type.get!(const(dchar)[])()]; foreach(i,t;types) if(!which){ mixin(ImplConvertsTo!q{bool icd; a[0], t}); if(icd) which=cast(int)i+1; } if(!which){ sc.error("expected string argument for import expression", a[0].loc); mixin(ErrEplg); } foreach(i,t; types) if(i+1==which) mixin(ImplConvertTo!q{a[0],t}); assert(a[0].sstate == SemState.completed); a[0].interpret(sc); if(aLeftover) aLeftover.interpret(sc); mixin(SemProp!q{a[0]}); if(aLeftover) mixin(SemProp!q{aLeftover}); auto file = a[0].interpretV().convertTo(Type.get!string()).get!string(); auto cm = sc.getModule(); auto repo = cm.repository; string error=null; auto str=repo.readFile(file,error); if(error){ sc.error(error,a[0].loc); mixin(ErrEplg); } auto r=LiteralExp.polyStringFactory(str); r.loc=loc; mixin(RewEplg!q{r}); } } mixin template Semantic(T) if(is(T==AssertExp)){ Expression aLeftover=null; override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{a}); if(a.length<1){ sc.error("missing arguments to assert", loc); mixin(ErrEplg); }else if(a.length>2){ sc.error("too many arguments to assert", loc); mixin(ErrEplg); } a[0]=a[0].convertTo(Type.get!bool()); // TODO: this is maybe not perfectly appropriate if(a.length>1 && a[1].type !is Type.get!string()) a[1]=a[1].implicitlyConvertTo(Type.get!(const(char)[])()); mixin(SemChld!q{a}); type = Type.get!void(); foreach(ref x;a) mixin(ConstFold!q{x}); mixin(SemEplg); } } mixin template Semantic(T) if(is(T _==UnaryExp!S,TokenType S)){ static if(overloadableUnary.canFind(TokChars!S)) mixin OpOverloadMembers; static if(is(T _==UnaryExp!S,TokenType S)): override void semantic(Scope sc){ mixin(SemPrlg); static if(S==Tok!"&"){ auto sym = e.isSymbol(); if(!sym||sym.inContext==InContext.none) e.willTakeAddress(); } mixin(SemChldExp!q{e}); static if(S!=Tok!"&"&&S!=Tok!"!"){ auto ty=e.type.getHeadUnqual(); // integral promote enum types to unqualified base if(auto et=ty.isEnumTy()){ mixin(GetEnumBase!q{ty;et.decl}); ty=ty.getHeadUnqual(); } } static if(S==Tok!"!"){ auto bl = Type.get!bool(); mixin(ConvertTo!q{e,bl}); type = bl; mixin(SemEplg); }else static if(S==Tok!"-" || S==Tok!"+" || S==Tok!"~"){ auto v = Type.get!void(); if(ty.isBasicType() && e !is v && ty !is Type.get!bool()){ type = e.type; mixin(SemEplg); } }else static if(S==Tok!"++" || S==Tok!"--"){ if(e.canMutate()){ auto v = Type.get!void(); if(ty.isBasicType()&&e !is v&&ty !is Type.get!bool()||ty.isPointerTy()){ type = e.type; mixin(SemEplg); } } }else static if(S==Tok!"*"){ if(auto p=ty.isPointerTy()){ type = p.ty; mixin(SemEplg); } }else static if(S==Tok!"&"){ if(e.type.isTuple()){ // TODO: propose element-wise semantics sc.error("cannot take address of sequence", loc); mixin(ErrEplg); }if(auto lv = e.isLvalue()){ // TODO: this is a hack, find solution for taking address of // overloaded declaration FunctionDecl fd=null; auto fe = e.isFieldExp(); if(auto s=fe?fe.e2:e.isSymbol()){ fd=tryGetFunctionDecl(s); if(fd){ if(s.type is Type.get!void()) // need deduction first type = Type.get!void; else{ if(auto fdef=fd.isFunctionDef()){ if(!fdef.finishedInference()){ needRetry=true; Scheduler().await(this,fdef,fdef.scope_); return; }} // resolve inout and check this pointer compatibility InoutRes inoutRes; if(fe)if(auto this_ = fe.e1.extractThis()){ if(fd.stc&STCinout) inoutRes = irFromSTC(this_.type.getHeadSTC()); if(inoutRes==InoutRes.immutable_) inoutRes=InoutRes.inoutConst; if(fd.needsAccessCheck(fe.accessCheck)){ mixin(RefConvertsTo!q{ auto compat; this_.type, this_.type.getHeadUnqual() .applySTC(fd.stc&STCtypeconstructor) .resolveInout(inoutRes), 0 }); if(!compat){ FunctionDecl.incompatibleThisError(sc,e.loc,this_.type.getHeadSTC(),fd.stc&STCtypeconstructor, fd); mixin(ErrEplg); } } } s.type=fd.type; s.meaning=fd; auto res=fd.type.resolveInout(inoutRes); if(fd.stc&STCstatic) type=res.getPointer(); else type=res.getDelegate(); } } } if(!fd) type=e.type.getPointer(); mixin(SemEplg); }else{ sc.error(format("cannot take address of %s '%s'",e.kind,e.loc.rep),loc); mixin(ErrEplg); } }else static assert(0); static if(overloadableUnary.canFind(TokChars!S)){ // TODO: this gc allocates mixin(OpOverload!("opUnary",q{ [LiteralExp.polyStringFactory(TokChars!S)] },q{(Expression[]).init})); } // TODO: array ops static if(S==Tok!"*"){ sc.error(format("cannot dereference expression '%s' of non-pointer type '%s'",e.loc.rep,e.type),loc); }else static if(S==Tok!"++" || S==Tok!"--"){ if(e.checkMutate(sc,loc)) // TODO: it would be better to first check if the type is fully off sc.error(format("type '%s' does not support prefix "~TokChars!S,e.type),loc); }else{ sc.error(format("invalid argument type '%s' to unary "~TokChars!S,e.type),loc); } mixin(ErrEplg); } // TODO: constant addresses should be possible to be taken too static if(S==Tok!"+"||S==Tok!"-"||S==Tok!"~"||S==Tok!"!"){ override bool isConstant(){ return e.isConstant(); } override bool isConstFoldable(){ return e.isConstFoldable(); } } static if(S==Tok!"&"){ override void noHope(Scope sc){ auto fe = e.isFieldExp(); if(auto s=fe?fe.e2:e.isSymbol()){ auto fd=tryGetFunctionDecl(s); if(auto fdef=fd.isFunctionDef()){ if(!fdef.finishedInference()) fdef.cancelInference(); } } } private static FunctionDecl tryGetFunctionDecl(Symbol s){ FunctionDecl fd=null; if(auto ov=s.meaning.isOverloadSet()){ if(ov.decls.length==1) if(auto fdo=ov.decls[0].isFunctionDecl()) fd = fdo; }else if(auto fdd=s.meaning.isFunctionDecl()) fd = fdd; return fd; } override void isInContext(InContext inContext){ if(inContext == InContext.passedToTemplateAndOrAliased){ if(auto sym=e.isSymbol()) sym.accessCheck=AccessCheck.none; }else if(inContext == InContext.fieldExp){ if(auto sym=e.isSymbol()) sym.inContext=InContext.fieldExp; } } override bool isConstant(){ return !!e.isSymbol(); // TODO: correct? } override Dependent!bool implicitlyConvertsTo(Type rhs){ // function literals implicitly convert to both function and delegate if(auto sym = e.isSymbol() ){ if(auto fd = sym.meaning.isFunctionDef() ){ auto rhsu = rhs.getHeadUnqual(); if(auto dg = rhsu.isDelegateTy()){ if(fd.inferStatic){ assert(sym.isStrong); return fd.type.addQualifiers(STCimmutable).getDelegate() .implicitlyConvertsTo(dg); } }else if(fd.canBeStatic) if(auto ptr = rhsu.isPointerTy() ){ if(auto ft = ptr.ty.isFunctionTy()){ return fd.type.getPointer() .implicitlyConvertsTo(rhsu); } } }} return super.implicitlyConvertsTo(rhs); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ return e.matchCallHelper(sc, loc, this_, args, context); } override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ e.matchError(sc,loc,this_,args); } // this is necessary to make template delegate literals work correctly // the scope of the symbol must be adjusted override Expression clone(Scope sc, InContext inContext, AccessCheck accessCheck, const ref Location loc){ auto ctx=InContext.addressTaken; if(inContext==inContext.fieldExp) ctx=inContext; auto r=New!(UnaryExp!(Tok!"&"))(e.clone(sc,ctx,accessCheck,loc)); r.loc = loc; r.semantic(sc); return r; } final bool isUndeducedFunctionLiteral(){ auto r=type is Type.get!void(); assert(!r || e.isSymbol() && e.isSymbol().isFunctionLiteral); return r; } override bool tmplArgEquals(Expression rhs){ if(this is rhs) return true; if(auto ae=rhs.isAddressExp()) return e.tmplArgEquals(ae.e); return false; } override size_t tmplArgToHash(){ import hashtable; return FNV(e.tmplArgToHash()); } } static if(S==Tok!"++"||S==Tok!"--"||S==Tok!"*") override bool isLvalue(){return true;} private static string __dgliteralRng(){ string r; foreach(x;["IntRange","LongRange"]){ r~=mixin(X!q{ override @(x) get@(x)(){ alias @(x) R; auto r = e.get@(x)(); static if(S==Tok!"!"){ bool t = r.min==0&&r.max==0; bool f = !r.contains(R(0,0,r.signed)); return t ? R(1,1,true) : f ? R(0,0,true) : R(0,1,true); }else static if(S==Tok!"+") return r; else static if(S==Tok!"-") return -r; else static if(S==Tok!"++"||S==Tok!"--"){ r = mixin(`r`~TokChars!S[0]~`R(1,1,r.signed)`); if(auto ty = e.type.getHeadUnqual().isIntegral()){ auto siz = ty.bitSize(); static if(is(R==IntRange)){ if(siz>=32) return r; r = r.narrow(ty.isSigned(),siz); }else{ if(siz>=64) return r; auto nr = r.narrow(ty.isSigned(),siz); return R(nr.min,nr.max,nr.signed); } } return r; }else static if(S==Tok!"~") return ~r; return super.get@(x)(); } }); } return r; } mixin(__dgliteralRng()); } mixin template Semantic(T) if(is(T==BinaryExp!(Tok!"."))){ } class MatcherTy: Type{ Type adapted; bool ambiguous; WhichTemplateParameter which; this(WhichTemplateParameter which)in{ with(WhichTemplateParameter) assert(which == type || which == tuple); }body{ this.which = which; sstate = SemState.completed; } override Dependent!void typeMatch(Type from){ if(which==WhichTemplateParameter.tuple && !from.isTuple()) return indepvoid; if(!adapted) adapted=from; else{ mixin(Unify!q{Type c; adapted, from}); // TODO: full unification if(c) adapted=c; else{ // if unification fails, ignore 'void' // this eg. helps when one argument is an empty array // void foo(T)(T[] a, T[] b); foo([],[1,2,3]) auto v = Type.get!void(); if(adapted==v) adapted=from; else if(from!=v) ambiguous=true; } } return indepvoid; } override string toString(){return "<<MT("~adapted.to!string()~")>>";} override bool hasPseudoTypes(){ return true; } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==MatcherTy)){} struct TemplArgsWithTypes{ TemplArgs args; TypeTemplArgs argTypes; } class TemplateInstanceDecl: Declaration{ TemplateDecl parent; // template this instance was instantiated from Expression instantiation; // an expression that is responsible for analysis // of this instance. (either a symbol or a instantiation) TemplArgs args; // arguments as given by the instantiation site TypeTemplArgs argTypes; // types of the template arguments TemplArgs resolved; // arguments as given to the template body Match match = Match.exact; // match level. Expression constraint; BlockDecl bdy; TemplateScope paramScope; Scope parentScope; bool isMixin = false; final @property bool completedMatching(){ return matchState>=MatchState.completed; } final @property bool hasFailedToMatch(){ return matchState==MatchState.failed; } final @property bool completedParameterResolution(){ return matchState > MatchState.resolvedSemantic; } private{ enum MatchState{ start, // start matching iftiStart, // start matching in ifti mode iftiPrepare, iftiMatching, // continue ifti matching resolvedSemantic, // apply default args iftiResolvedSemantic,// apply default args and return to iftiMatch if necessary checkMatch, // check if there is a match checkConstraint, // check the constraint checkingConstraint, // checking in progress completed, // matching succeeded failed, // matching failed analysis, // analyzing template body } MatchState matchState = MatchState.start; } this(TemplateDecl parent, const ref Location loc, Expression expr, TemplArgsWithTypes args)in{ assert(expr.isSymbol() || expr.isTemplateInstanceExp()); assert(parent && parent.scope_); }body{ super(parent.stc, parent.name); this.parent=parent; this.args=args.args; this.argTypes=args.argTypes; this.constraint = parent.constraint?parent.constraint.ddup():null; this.bdy=parent.bdy; // NOTE: bdy is the original template body at this point! this.loc = loc; if(!this.instantiation) this.instantiation = expr; // TODO: need to handle FieldExp? scope_ = parentScope = parent.scope_; sstate = SemState.begin; } this(TemplateDecl parent, const ref Location loc, Expression func, TemplArgsWithTypes args, Expression[] iftiArgs)in{ assert(func.isSymbol() || func.isTemplateInstanceExp()); }body{ this(parent, loc, func, args); this.origIftiArgs = iftiArgs; this.matchState = MatchState.iftiStart; } final void gag()in{ assert(!paramScope && !iftiScope); }body{ scope_ = New!GaggingRecordingScope(parentScope); } final void ungag()in{ assert(isGagged,text("attempted to ungag ",this," which was not gagged")); }body{ assert(!!cast(GaggingRecordingScope)scope_); (cast(GaggingRecordingScope)cast(void*)scope_).replay(parentScope); scope_ = parentScope; paramScope.parent = parentScope; Scheduler().add(this, scope_); } void initializeMixin(Scope sc)in{assert(!isGagged);}body{ isMixin=true; scope_ = parentScope = sc; } final @property bool isGagged(){ return scope_ !is parentScope; } final FunctionDecl iftiDecl()in{ assert(finishedInstantiation()); }body{ return parent.iftiDecl()?bdy.decls[0].isFunctionDecl():null; } private bool determineInstanceScope()in{ assert(paramScope && paramScope.parent is paramScope.iparent); }body{ Scope instanceScope = parentScope; bool removeStatic = false; int maxn = parentScope.getFrameNesting(); foreach(i,x;args){ Declaration decl = null; if(auto addr=x.isAddressExp()) x=addr.e; // delegate literals if(auto sym = AliasDecl.getAliasBase(x)) decl=sym.meaning; else if(auto ty = x.isType()) // DMD 2.060 does not do this: if(auto at = ty.isAggregateTy()) decl=at.decl; if(!decl) continue; assert(!!decl && decl.scope_,x.to!string); // TODO: find out if it is reasonable to make this assertion pass: // assert(decl.scope_.getDeclaration() || decl.stc & STCstatic, decl.toString()); if(decl.stc & STCstatic || !decl.scope_.getDeclaration()) continue; auto n = decl.scope_.getFrameNesting(); if(n>=maxn){ maxn=n; if(instanceScope !is parentScope && !decl.scope_.isNestedIn(instanceScope)){ instanceScope = parentScope; removeStatic=false; break; // TODO: fix! } instanceScope = decl.scope_; removeStatic=true; } } paramScope.iparent = instanceScope; return removeStatic; } private void fillScopes()in{ assert(scope_&&paramScope); }body{ foreach(i,x;resolved){ // TODO: don't leak references /+if(parent.params[i].which!=WhichTemplateParameter.alias_) x.checkAccess(paramScope,AccessCheck.all);+/ auto al = New!AliasDecl(STC.init, New!VarDecl(STC.init, x, parent.params[i].name, null)); al.semantic(paramScope); mixin(PropErr!q{al}); debug{ mixin(Rewrite!q{al}); assert(al.sstate == SemState.completed); } } } private bool checkResolvedValidity(){ foreach(i,x; parent.params[0..min(parent.tuplepos,resolved.length)]) if(resolved[i] && (resolved[i].sstate == SemState.error || !x.matches(resolved[i]).force)) return false; return true; } private bool checkIftiArgsValidity(){ foreach(x;iftiArgs) if(x.sstate==SemState.error) return false; return true; } private bool startMatching(Scope sc_){ auto tuplepos = parent.tuplepos; auto params = parent.params; resolved = (new Expression[params.length]).captureTemplArgs; // resolve non-tuple parameters if(args.length>tuplepos&&tuplepos==params.length) return false; resolved[0..min(tuplepos, args.length)] = args[0..min(tuplepos,args.length)]; // TODO: dollar // TODO: does this work? if(!paramScope){ paramScope = New!TemplateScope(scope_,scope_,this); } // this always fills the first tuple parameter // other possible semantics would be to only fill the // first tuple parameter if it is the last template parameter // this would lead to uniform treatment of multiple tuple // parameters in a template parameter list, which is more pure, // but potentially less useful. if(tuplepos<params.length && args.length>tuplepos){ auto expr = args[tuplepos..args.length]; // TODO: dollar Expression et = New!ExpTuple(expr,New!TypeTuple(argTypes[tuplepos..args.length])); et.semantic(scope_); mixin(Rewrite!q{et}); assert(et.sstate == SemState.completed); resolved[tuplepos]=et; } assert({ foreach(x;resolved) if(x&&x.sstate!=SemState.completed) return false; return true; }()); if(!checkResolvedValidity()) return false; if(matchState == MatchState.iftiStart) initializeIFTI(); return true; } private{ Expression[] origIftiArgs; Expression[] iftiArgs; Parameter[] iftiEponymousParameters; MatcherTy[] matcherTypes; NestedScope iftiScope; } private void initializeIFTI(){ // TODO: gc allocation auto fd = parent.iftiDecl(); if(!fd){ // TODO: this is probably not required (and the test suite does not cover it) assert(matchState == MatchState.iftiStart); matchState = MatchState.start; return; } auto funparams = fd.type.params; iftiEponymousParameters = new Parameter[funparams.length]; matcherTypes = new MatcherTy[parent.params.length]; // function literal type deduction // TODO: can the efficiency be improved? iftiArgs = origIftiArgs.dup; foreach(i,ref a;iftiArgs) if(auto ae = origIftiArgs[i].isAddressExp()) if(ae.isUndeducedFunctionLiteral()) a=ae.ddup(); } private void prepareIFTI(){ // TODO: this is quite inefficient // TODO: use region allocator and release lots of memory at once // TODO: keep around iftiScope, and update it correctly auto fdecl = parent.iftiDecl(); assert(!!fdecl); auto funparams = fdecl.type.params; // because of tuples, the array may change its size in one iteration iftiEponymousParameters.length=funparams.length; iftiEponymousParameters.assumeSafeAppend(); // ok foreach(i,ref t;iftiEponymousParameters) t=funparams[i].ddup(); iftiScope = New!NestedScope(New!GaggingScope(scope_)); foreach(i,p;parent.params){ if(!resolved[i]){ if(p.which == WhichTemplateParameter.type || p.which == WhichTemplateParameter.tuple) matcherTypes[i]=New!MatcherTy(p.which); else continue; } auto al = New!AliasDecl(STC.init, New!VarDecl(STC.init, resolved[i]?resolved[i]:matcherTypes[i], parent.params[i].name,null)); al.semantic(iftiScope); if(al.sstate == SemState.error) continue; debug{ mixin(Rewrite!q{al}); assert(al.sstate == SemState.completed); } } matchState = MatchState.iftiMatching; } private void matchIFTI(){ if(matchState == MatchState.iftiPrepare) prepareIFTI(); auto sc = iftiScope; foreach(ref x;iftiEponymousParameters){ x.type = x.rtype.typeSemantic(iftiScope); mixin(PropRetry!q{x.rtype}); if(!x.type) continue; x.type = x.type.applySTC(x.stc); } mixin(SemChldPar!q{iftiEponymousParameters}); iftiEponymousParameters = Tuple.expandVars(iftiScope, iftiEponymousParameters); foreach(i,a;iftiArgs[0..min($,iftiEponymousParameters.length)]) if(auto ae = a.isAddressExp()) if(ae.isUndeducedFunctionLiteral()){ if(!iftiEponymousParameters[i].type) continue; auto ft = iftiEponymousParameters[i].type.getHeadUnqual().getFunctionTy(); if(!ft) continue; ft=ft.ddup(); // TODO: can we do without these allocations? ft.stripPseudoTypes(); assert(!!cast(Symbol)ae.e); auto sym = cast(Symbol)cast(void*)ae.e; assert(!!cast(FunctionDef)sym.meaning); auto fd = cast(FunctionDef)cast(void*)sym.meaning; if(fd.type.resolve(ft)){ fd.rescope(New!GaggingScope(fd.scope_)); // TODO: allocation ae.sstate=sym.sstate=SemState.begin; } } bool resolvedSome = false; scope(exit)if(resolvedSome){ foreach(i,ref a;iftiArgs) if(auto ae = origIftiArgs[i].isAddressExp()) if(ae.isUndeducedFunctionLiteral()) a=ae.ddup(); } foreach(ref x;iftiArgs) mixin(SemChldPar!q{x}); // dw(iftiArgs," ",map!(_=>_.type)(iftiArgs)); // if this behaviour should be changed, remember to edit // FunctionTy.typeMatch as well //foreach(i,ref a;iftiEponymousParameters[0..min($,iftiArgs.length)]){ auto numt = iftiEponymousParameters.count!((a){ if(!a.type||!a.type.sstate==SemState.completed) return false; auto mt=a.type.getHeadUnqual().isMatcherTy(); return mt && mt.which==WhichTemplateParameter.tuple; }); for(size_t i=0,j=0;i<iftiEponymousParameters.length&&j<=iftiArgs.length;){ auto a=iftiEponymousParameters[i]; if(!a.type||a.type.sstate!=SemState.completed) break; auto mt = a.type.getHeadUnqual().isMatcherTy(); if(mt && mt.which==WhichTemplateParameter.tuple){ auto num=min(iftiArgs.length-j, numt+iftiArgs.length-iftiEponymousParameters.length); if(numt+iftiArgs.length<iftiEponymousParameters.length) num=0; // TODO: the following is somewhat ad-hoc. // the reason it is here is because we cannot create a parameter of type // Seq!void alias util.any any; if(any!(a=>!a.type||a.type.sstate!=SemState.completed|| a.type is Type.get!void())(iftiArgs[j..j+num])) break; //TODO: gc allocation auto types = map!(_=>_.type.getHeadUnqual())(iftiArgs[j..j+num]).toTemplArgs; // mt.typeMatch(New!TypeTuple(types)); // TODO: this might be expensive: mixin(TypeMatch!q{_; mt, New!TypeTuple(types)}); i++; j+=num; continue; }else if(a.type.isTuple()) break; if(j==iftiArgs.length) break; auto iftiType = iftiArgs[j].type.getHeadUnqual(); if(iftiType is Type.get!void()){ if(auto ae = iftiArgs[j].isAddressExp()){ if(ae.isUndeducedFunctionLiteral()){ if(!a.type.isMatcherTy()){ auto sym = cast(Symbol)cast(void*)ae.e; assert(!!cast(FunctionDef)sym.meaning); auto fd = cast(FunctionDef)cast(void*)sym.meaning; iftiType = fd.type; }else{ i++; j++; continue; } } } } //a.type.typeMatch(iftiType); mixin(TypeMatch!q{_; a.type, iftiType}); i++,j++; } //dw(iftiEponymousParameters); //dw(matcherTypes); foreach(i,x; matcherTypes){ if(!resolved[i] && x && x.adapted && !x.ambiguous){ resolvedSome = true; resolved[i]=x.adapted; } } if(resolvedSome){ matchState = MatchState.iftiPrepare; mixin(RetryEplg); } } private bool finishMatching(){ auto tuplepos = parent.tuplepos; auto params = parent.params; foreach(i, p; params){ if(!resolved[i]) continue; if(p.which!=WhichTemplateParameter.constant) continue; if(resolved[i].type.equals(p.type)) continue; // TODO: this 'force' is maybe dangerous match = min(match, resolved[i].type.constConvertsTo(p.type).force ? Match.convConst : Match.convert ); } if(tuplepos < params.length && !resolved[tuplepos]) resolved[tuplepos]=New!ExpTuple((Expression[]).init); // strip default arguments from function types foreach(i;0..params.length){ if(auto cur=resolved[i].maybe!(a=>a.isType())){ auto ncur=cur.stripDefaultArguments(); if(cur !is ncur) resolved[i]=ncur; } } alias util.any any; if(any!(_=>_ is null)(resolved)) return false; fillScopes(); needRetry=false; return true; } final bool finishedInstantiation(){ return bdy !is parent.bdy; } void finishInstantiation(bool startAnalysis)in{ assert(sstate != SemState.error); assert(!hasFailedToMatch()); assert(!finishedInstantiation()); assert(parent.sstate == SemState.completed); assert(!!paramScope); }body{ auto r = parent.getUniqueInstantiation(this); if(r !is this){ if(!r.finishedInstantiation) r.finishInstantiation(startAnalysis); else if(startAnalysis) r.startAnalysis(); mixin(RewEplg!q{r}); } match=Match.exact; // everything within resolved has been converted accordingly auto bdyscope=New!NestedScope(paramScope); bdy = bdy.ddup(); bdy.stc|=parent.stc; if(!isMixin){ if(determineInstanceScope()){ bdy.stc&=~STCstatic; foreach(decl;&bdy.traverseInOrder){ decl.stc&=~STCstatic; if(auto fd=decl.isFunctionDef()) fd.inferStatic=true; // TODO: also infer this for other declarations } } }else bdy.stc&=~STCstatic; auto instanceScope = paramScope.iparent; bdy.presemantic(bdyscope); assert(bdy.scope_ is bdyscope); auto decl=instanceScope.getDeclaration(); if(decl) decl.nestedTemplateInstantiation(this); // TODO: correct? sstate = SemState.begin; if(startAnalysis) this.startAnalysis(); else Scheduler().remove(this); } void startAnalysis()in{ assert(finishedInstantiation); }body{ if(matchState==MatchState.analysis) return; matchState = MatchState.analysis; if(!isGagged) Scheduler().add(this, scope_); } private bool resolveDefault(Scope sc){ bool resolvedSome = false; auto params = parent.params; // TODO: check whether the default argument matches enum SemRet = q{ return true; }; // TODO: get rid of this again foreach(i,ref r; resolved.unsafeByRef) if(!r&&params[i].init){ r=params[i].init.ddup(); resolvedSome = true; } foreach(r;resolved) if(r) r.prepareInterpret(); foreach(ref r;resolved.unsafeByRef()) if(r) mixin(SemChldPar!q{r}); foreach(i,ref x;resolved.unsafeByRef()){ if(!x||x.sstate == SemState.error) continue; TemplateDecl.finishArgumentPreparation(sc, x); mixin(PropRetry!q{x}); //if(!r||r.isSymbol()||r.isType()) continue; //mixin(IntChld!q{r}); } return resolvedSome; } bool iftiAgain; // TODO: we don't want this in the instance! override void semantic(Scope sc_){ if(sstate == SemState.error) return; // TODO: why needed? enum fail = q{ sstate=SemState.completed; matchState = failed; goto case failed; }; // assert(sstate != SemState.error); // would like to have this alias scope_ sc; needRetry=false; Ldecide:final switch(matchState) with(MatchState){ case start, iftiStart: if(!startMatching(sc_)) mixin(fail); if(matchState == start){ matchState = resolvedSemantic; goto case resolvedSemantic; }else { matchState = iftiPrepare; goto case iftiPrepare; } case iftiPrepare, iftiMatching: matchIFTI(); mixin(SemCheck); matchState = iftiResolvedSemantic; iftiAgain = false; goto case iftiResolvedSemantic; case resolvedSemantic, iftiResolvedSemantic: iftiAgain |= resolveDefault(matchState==iftiResolvedSemantic?iftiScope:scope_); mixin(SemCheck); assert(!needRetry); if(matchState == iftiResolvedSemantic && !iftiAgain) if(!checkIftiArgsValidity()) mixin(fail); if(matchState == resolvedSemantic || !iftiAgain){ matchState = checkMatch; goto case checkMatch; }else{ matchState = iftiPrepare; goto case iftiPrepare; } case checkMatch: foreach(ref x;resolved.unsafeByRef()){if(x) mixin(SemChld!q{x});} if(!checkResolvedValidity()||!finishMatching()) mixin(fail); // do implicit conversions foreach(i; 0..resolved.length){ auto x = resolved[i]; scope(exit) resolved[i]=x; auto p = parent.params[i]; mixin(Rewrite!q{x}); if(x.isType()) continue; if(p.which==WhichTemplateParameter.constant){ mixin(ImplConvertTo!q{x,p.type}); x.semantic(sc); x.interpret(sc); mixin(Rewrite!q{x}); mixin(PropErr!q{x}); assert(x.sstate == SemState.completed); }else if(p.which==WhichTemplateParameter.tuple) break; } matchState = checkConstraint; goto case checkConstraint; case checkConstraint: auto uniq=parent.getUniqueInstantiation(this); if(uniq is this){ if(constraint){ analyzeConstraint(); mixin(SemCheck); if(!constraint.interpretV()){ mixin(fail); } } }else{ if(!uniq.completedMatching) mixin(SemChld!q{uniq}); assert(uniq.completedMatching); if(uniq.matchState == failed){ matchState=failed; goto case failed; } } matchState = completed; goto case completed; case checkingConstraint: if(sc) sc.error("recursive template expansion in template constraint", constraint.loc); mixin(ErrEplg); // give the instance exp a chance to finish the instantiation process case completed,failed: Scheduler().remove(this); break; case analysis: assert(finishedInstantiation); instanceSemantic(sc_); break; } } void emitError(Scope sc)in{assert(hasFailedToMatch());}body{ if(!sc||!sc.handler.showsEffect) return; if(constraint&&constraint.sstate==SemState.completed&& constraint.isConstant()&&!constraint.interpretV()){ //TODO: show exact failing clause sc.error("template constraint failed", loc); }else{ // TODO: more explicit error message sc.error("instantiation does not match template declaration",loc); } } private void instanceSemantic(Scope sc_)in{ assert(finishedInstantiation); }body{ {alias sc_ sc;mixin(SemPrlg);} assert(sstate == SemState.begin); sstate = SemState.started; scope(exit) if(sstate == SemState.started) sstate = SemState.begin; assert(!constraint||constraint.type is Type.get!bool()); assert(!constraint||constraint.isConstant() && constraint.interpretV()); assert(bdy !is parent.bdy); scope(exit) if(sstate == SemState.error) sc_.note("instantiated here",instantiation.loc);// TODO: improve {alias sc_ sc;mixin(SemChld!q{sc=bdy.scope_;bdy});} mixin(SemEplg); } private{ Parameter[] eponymousFunctionParameters; Scope constraintScope; } private void initializeConstraintScope(){ if(!constraintScope){ constraintScope = paramScope.cloneNested(paramScope.iparent); if(parent.eponymousDecl) if(auto fd = parent.eponymousDecl.isFunctionDecl()){ // TODO: gc allocation eponymousFunctionParameters = fd.type.params.dup; foreach(ref x; eponymousFunctionParameters) x=x.ddup; } } } private void analyzeConstraint(){ alias constraintScope sc; mixin(PropErr!q{constraint}); if(constraint.sstate == SemState.completed && constraint.isConstant()) return; initializeConstraintScope(); foreach(ref x; eponymousFunctionParameters){ mixin(SemChldPar!q{x}); if(x.sstate == SemState.error) mixin(SetErr!q{constraint}); } mixin(PropErr!q{constraint}); matchState = MatchState.checkingConstraint; scope(exit) matchState = MatchState.checkConstraint; constraint.prepareInterpret(); constraint.prepareLazyConditionalSemantic(); mixin(SemChldExp!q{constraint}); mixin(ConvertTo!q{constraint,Type.get!bool()}); mixin(IntChld!q{constraint}); } /* template instances serve as containers for other declarations they do not need to be checked for accessibility */ override bool needsAccessCheck(AccessCheck check){ return false; } override string kind(){return "template instance";} override string toString(){ auto r = resolved; return name.toString()~"!("~join(map!(to!string)(r),",")~")"; } mixin DownCastMethod; mixin Visitors; } import rope_; interface Tuple{ Expression index(Scope sc, InContext inContext, const ref Location loc, ulong index) in{assert(index<length);} Expression slice(const ref Location loc, ulong a, ulong b) in{assert(a<=b && b<length);} @property size_t length(); int opApply(scope int delegate(Expression) dg); static T expand(T,S...)(Scope sc,AccessCheck accessCheck,T a, ref Expression leftover, ref S replicate)if(is(T _:X[],X)||is(T _:Rope!(X,TemplArgInfo),X)){ T r; S rep; Expression oldLeftover=leftover; leftover=null; static if(is(T _:X[],X))enum isarray=true;else enum isarray=false; // TODO: fix this ASAP typeof(r.length) index = 0; foreach(i,x;a){ if(!x) continue; if(x.isTuple()||x.type&&x.type.isTuple()){ size_t len; void spliceExpTuple(ExpTuple et){ static if(isarray){ auto exprs=et.exprs.array; foreach(ref exp;exprs){ exp=exp.clone(sc,InContext.none,accessCheck,et.loc); exp.checkAccess(sc, accessCheck); } static if(!rep.length){ if(exprs.length&&leftover){ auto ne=New!(BinaryExp!(Tok!","))(leftover, exprs[0]); ne.loc=ne.e1.loc.to(ne.e2.loc); ne.semantic(sc); exprs[0]=ne; leftover=null; } } }else{ auto exprs=et.exprs; assert(accessCheck==AccessCheck.none); } r~=a[index..i]~exprs; } if(auto et=x.isExpTuple()){ len=et.length; spliceExpTuple(et); }else if(auto tt=x.isTypeTuple()){ len=tt.length; static if(isarray) T tts=tt.types.generalize!Expression.array; else T tts=tt.types.generalize!Expression; r~=a[index..i]~tts; // TODO: ok? }else static if(isarray&&!rep.length){ if(auto ce=x.isCommaExp()){ ExpTuple et; auto commaLeft=splitCommaExp(ce,et); if(!leftover) leftover=commaLeft; else{ auto nl=New!(BinaryExp!(Tok!","))(leftover, commaLeft); nl.loc=nl.e1.loc.to(nl.e2.loc); leftover=nl; } spliceExpTuple(et); }else assert(0); }else assert(0); foreach(j,ref rr;rep){ rr~=replicate[j][index..i]; foreach(k;0..len) rr~=replicate[j][i]; } index=i+1; } } if(index){ foreach(j,ref rr;rep) rr~=replicate[j][index..$]; foreach(j,rr;rep) replicate[j]=rr;// bug: simple assignment does not work } if(oldLeftover){ if(leftover){ auto nl=New!(BinaryExp!(Tok!","))(leftover, oldLeftover); nl.loc=nl.e1.loc.to(nl.e2.loc); leftover=nl; }else leftover=oldLeftover; } return index?r~=a[index..a.length]:a; // TODO: dollar } static Expression splitCommaExp(CommaExp ce, ref ExpTuple et){ Expression go(CommaExp e){ if(auto ce=e.e2.isCommaExp()){ auto r=New!(BinaryExp!(Tok!","))(e.e1, go(ce)); r.loc=r.e1.loc.to(r.e2.loc); return r; } et=e.e2.isExpTuple(); assert(!!et); return e.e1; } return go(ce); } static VarDecl[] expandVars(Scope sc, VarDecl[] a) in{ /+ alias util.all all; assert(all!(_=>!_.rtype&&!_.init||_.sstate.among(SemState.completed,SemState.error))(a));+/ }body{ // TODO: this is very naive and inefficient VarDecl[] r; typeof(r.length) index = 0; foreach(i,x;a){ if(!x.type||x.sstate==SemState.error) continue; if(auto tp=x.type.isTypeTuple()){ assert(x.tupleContext && x.tupleContext.tupleAlias); r~=a[index..i]~x.tupleContext.vds; index=i+1; } } return index?r~a[index..$]:a; } static Parameter[] expandVars(Scope sc,Parameter[] a){ // ditto return cast(Parameter[])expandVars(sc,cast(VarDecl[])a); } enum toStringInitial="("; enum toStringFinal=")"; enum toStringEmpty=toStringInitial~toStringFinal; } class ExpTuple: Expression, Tuple{ /* indexing an expression tuple might create a symbol reference therefore we need to remember the access check level. */ AccessCheck accessCheck = AccessCheck.all; this(Expression[] exprs){ this(exprs.captureTemplArgs); } this(TemplArgs exprs)in{ alias util.all all; }body{ // TODO: gc allocation this.exprs = exprs; } this(size_t len, Expression exp)in{ assert(exp.sstate == SemState.completed); assert(len<=size_t.max); }body{ auto exprsa = new Expression[cast(size_t)len]; foreach(ref x;exprsa) x=exp; exprs = exprsa.captureTemplArgs; } /+private+/ this(TemplArgs exprs, Type type){// TODO: report DMD bug this.exprs=exprs; this.type=type; semantic(null); } override Tuple isTuple(){return this;} Expression index(Scope sc, InContext inContext, const ref Location loc, ulong index){ assert(index<length); // TODO: get rid of this when DMD is fixed assert(sstate == SemState.completed); return indexImpl(sc,inContext,loc,exprs[cast(size_t)index]); } final allIndices(Scope sc, InContext inContext, const ref Location loc){ static struct AllIndices{ private{ Scope sc; InContext inContext; Location loc; ExpTuple tp; } int opApply(scope int delegate(Expression) dg){ foreach(exp;this.tp.exprs) if(auto r=dg(tp.indexImpl(sc,inContext,loc,exp))) return r; return 0; } } return AllIndices(sc,inContext,loc,this); } private Expression indexImpl(Scope sc, InContext inContext, const ref Location loc, Expression exp){ auto r=exp.clone(sc,inContext,accessCheck,loc); r.checkAccess(sc, accessCheck); return r; } Expression slice(const ref Location loc, ulong a,ulong b)in{ assert(a<=b && b<=length); }body{ assert(sstate == SemState.completed); assert(cast(TypeTuple)type); auto types = (cast(TypeTuple)cast(void*)type).types; return New!ExpTuple(exprs[cast(size_t)a..cast(size_t)b],New!TypeTuple(types[cast(size_t)a..cast(size_t)b])); } @property size_t length(){ return exprs.length;} int opApply(scope int delegate(Expression) dg){ foreach(x; exprs) if(auto r = dg(x)) return r; return 0; } override void semantic(Scope sc){ mixin(SemPrlg); alias util.all all; mixin(SemChld!q{exprs.unsafeByRef}); Expression dummyLeftover=null; exprs=Tuple.expand(sc, AccessCheck.none, exprs, dummyLeftover); assert(!dummyLeftover); // the empty tuple is an expression except if a type is requested if(exprs.length && exprs.value.typeOnly){ auto r=New!TypeTuple(cast(TypeTemplArgs)exprs); // TODO: ok? assert(r.sstate == SemState.completed); mixin(RewEplg!q{r}); } // auto tt = exprs.map!(x=>x.isType() ? assert(cast(Type)x), cast(Type)cast(void*)x : x.type).rope; // TODO: report DMD bug if(!type){ auto tta = new Type[exprs.length]; foreach(i,ref x;tta){ if(auto ty=exprs[i].isType()) x = ty; else x = exprs[i].type; } auto tt = tta.captureTemplArgs; type = New!TypeTuple(tt); } dontConstFold(); mixin(SemEplg); } override ExpTuple clone(Scope sc, InContext inContext, AccessCheck accessCheck, const ref Location loc){ // auto r = New!ExpTuple(sc, exprs.map!(x => x.clone(sc,InContext.passedToTemplateAndOrAliased,loc)).rope, type); // TODO: report DMD bug /+auto exprsa = new Expression[exprs.length]; foreach(i,ref x;exprsa) x = exprs[i].clone(sc,InContext.passedToTemplateAndOrAliased,loc); auto r = New!ExpTuple(sc, exprsa.ropeCapture, type);+/ auto r = New!ExpTuple(exprs, type); r.accessCheck = accessCheck; r.loc = loc; return r; } override string toString(){return toStringInitial~join(map!(to!string)(exprs),",")~toStringFinal;} override @property string kind(){return "sequence";} override bool isConstant(){ return exprs.value.isConstant; } override bool isConstFoldable(){ return exprs.value.isConstFoldable; } override bool isLvalue(){ return exprs.value.isLvalue; } mixin TupleImplConvTo!exprs; mixin DownCastMethod; mixin Visitors; override bool tmplArgEquals(Expression rhs){ alias util.all all; import std.range; if(auto et = rhs.isExpTuple()){ if(et.length != length) return false; return all!(_=>_[0].tmplArgEquals(_[1]))(zip(exprs,et.exprs)); } // this is not going to happen, since template parameters are only compared // if both match the instantiation => both are tuples or not tuples return false; } override size_t tmplArgToHash(){ import hashtable; return toHash(exprs.value.hash); } private: TemplArgs exprs; } mixin template TupleImplConvTo(alias exprs){ override Dependent!bool implicitlyConvertsTo(Type rhs){ auto tt = rhs.isTypeTuple(); if(!tt||tt.length!=length) return false.independent; Node[] dep; Scope idk = null; import std.range; foreach(x; zip(exprs, tt.types)){ auto iconvd = x[0].implicitlyConvertsTo(x[1]); if(iconvd.dependee){ assert(!idk || iconvd.dependee.scope_ is idk); idk = iconvd.dependee.scope_; dep ~= iconvd.dependee.node; // TODO: this is inefficient continue; } if(!iconvd.value) return false.independent; } if(idk) return multidep(dep, idk).dependent!bool; assert(!dep.length); return true.independent; } } class TypeTuple: Type, Tuple{ this(TypeTemplArgs types)in{ alias util.all all; // assert(all!(_=>_.sstate==SemState.completed)(types)); // assert(all!(_=>!_.isTuple())(types)); }body{ this.types = types; sstate = SemState.completed; } override void semantic(Scope sc){ mixin(SemPrlg); assert(0); } override Tuple isTuple(){return this;} Expression index(Scope sc, InContext inContext, const ref Location loc, ulong index){ assert(index<length); // TODO: get rid of this when DMD is fixed assert(sstate == SemState.completed); return types[cast(size_t)index]; } final allIndices(){ return types; } Expression slice(const ref Location loc, ulong a,ulong b)in{ assert(a<=b && b<=length); }body{ assert(sstate == SemState.completed); return New!TypeTuple(types[cast(size_t)a..cast(size_t)b]); } @property size_t length(){ return types.length;} // workaround for lacking delegate contravariance final override int opApply(scope int delegate(Expression) dg){ return opApply(cast(int delegate(Type))dg); } final int opApply(scope int delegate(Type) dg){ foreach(x; types) if(auto r = dg(x)) return r; return 0; } override string toString(){return toStringInitial~join(map!(to!string)(types),",")~toStringFinal;} override @property string kind(){return "type sequence";} override bool equals(Type rhs){ alias util.all all; import std.range; if(auto tt = rhs.isTypeTuple()){ if(tt.length!=types.length) return false; return all!(a=>a[0].equals(a[1]))(zip(types, tt.types)); } return false; } mixin TupleImplConvTo!types; // TODO: optimize this: override Dependent!Type combine(Type rhs){ if(auto tpl=rhs.isTypeTuple()){ if(equals(rhs)) return this.independent!Type; if(tpl.length!=length) return null.independent!Type; auto ts = new Type[types.length]; // TODO: allocation (eg. prune allocation when combination yields) foreach(i;0..types.length){ mixin(Combine!q{auto r; types[i], tpl.types[i]}); ts[i]=r; } return New!TypeTuple(ts.captureTemplArgs).independent!Type; } return null.independent!Type; } mixin DownCastMethod; mixin Visitors; override bool tmplArgEquals(Expression rhs){ alias util.all all; import std.range; if(auto tt = rhs.isTypeTuple()){ if(tt.length!=types.length) return false; return all!(_=>_[0].tmplArgEquals(_[1]))(zip(types,tt.types)); } return false; } override size_t tmplArgToHash(){ import hashtable; return toHash(types.value.hash); } static TypeTemplArgs expand(R)(R tts)if(isInputRange!R&&is(ElementType!R==Type)){ TypeTemplArgs r; foreach(x;tts){ if(auto ty=x.isTypeTuple()) r~=ty.types; else r~=x; } return r; } override protected Type getArray(ulong size){ assert(0,text("cannot create array of ",this)); } private static funcliteralTQ(){string r; // TODO: make those more efficient for very long tuples. // TODO: replace funcliteralTQ by delegate literal once possible. foreach(x; typeQualifiers){ // getConst, getImmutable, getShared, getInout. auto impl(string s){ return `New!TypeTuple(types.map!(t=>t.`~s~`()).array.captureTemplArgs)`; } r ~= mixin(X!q{ protected override Type get@(upperf(x))Impl(){ return @(impl(`get`~upperf(x))); } override Type getTail@(upperf(x))(){ return @(impl(`getTail`~upperf(x))); } Type in@(upperf(x))Context(){return @(impl(`in`~upperf(x)~`Context`));} }); } return r; } mixin(funcliteralTQ); private: TypeTemplArgs types; } mixin template Semantic(T) if(is(T==TemplateParameter)){ override void semantic(Scope sc){ mixin(SemPrlg); if(rtype){ type = rtype.typeSemantic(sc); mixin(SemProp!q{rtype}); if(rspec){ // TODO: ok? rspec.prepareInterpret(); mixin(SemChldExp!q{rspec}); mixin(FinishDeductionProp!q{rspec}); mixin(ImplConvertTo!q{rspec, type}); mixin(IntChld!q{rspec}); } assert(!spec); }else if(rspec){ // TODO: alias!! spec = rspec.typeSemantic(sc); mixin(SemProp!q{rspec}); } mixin(SemEplg); } final Dependent!bool matches(Expression arg)in{ assert(sstate == SemState.completed); assert(arg.sstate == SemState.completed); assert(which != WhichTemplateParameter.tuple); }body{ final switch(which) with(WhichTemplateParameter){ case alias_: // TODO: rspec!! return (AliasDecl.getAliasBase(arg)||arg.isType()||arg.isConstant()).independent; case constant: if(!arg.isConstant()) return false.independent; assert(!!this.type && this.type.sstate == SemState.completed); assert(!rspec || rspec.sstate == SemState.completed); mixin(ImplConvertsTo!q{bool iconv; arg, this.type}); if(!iconv) return false.independent; // TODO: implicit conversion is wasteful on GC if(rspec){ auto conv=arg.implicitlyConvertTo(this.type); conv.semantic(null); mixin(Rewrite!q{conv}); // TODO: this loses the expression... if(conv.sstate!=SemState.completed) return Dependee(conv, null).dependent!bool; if(arg.interpretV()!=rspec.interpretV()) return false.independent; } return true.independent; case type, this_: if(!arg.isType) return false.independent; if(!spec) return true.independent; return arg.implicitlyConvertsTo(spec); case tuple: assert(0); } } invariant(){assert(sstate != SemState.completed || !rtype || !!type);} } mixin template Semantic(T) if(is(T==TemplateDecl)){ /* position of the first tuple parameter, or params.length if there is none */ size_t tuplepos = -1; Declaration eponymousDecl; // TODO: how to deal with overloading? FunctionDecl iftiDecl(){ //if(!eponymousDecl||bdy.decls.length!=1) return null; if(!eponymousDecl) return null; return eponymousDecl.isFunctionDecl(); } Dependent!bool atLeastAsSpecialized(TemplateDecl rhs)in{ assert(sstate == SemState.completed && sstate == rhs.sstate); }body{ Dependee dependee; if(tuplepos != params.length){ if(rhs.tuplepos == rhs.params.length) return false.independent; // no tuple param is more specialized } // TODO: there should be more rules foreach(i,p; params[0..min($, rhs.params.length)]){ auto rp = rhs.params[i]; with(WhichTemplateParameter) if(p.which == tuple && rp.which != tuple || p.which == alias_ && rp.which != alias_) return false.independent; if(p.spec && rp.spec){ // the answer 'false' might be determined from incomplete information auto rptopd=rp.spec.implicitlyConvertsTo(p.spec); auto ptorpd=p.spec.implicitlyConvertsTo(rp.spec); if(auto d=rptopd.dependee){dependee = d; continue;} if(auto d=ptorpd.dependee){dependee = d; continue;} if(rptopd.value&&!ptorpd.value) return false.independent; } } return Dependent!bool(dependee, true); } static void finishArgumentPreparation(Scope sc, ref Expression x){ // TODO: fix code duplication! if(x.sstate != SemState.completed) return; if(x.isType()) return; if(auto ae=x.isAddressExp()) if(auto lit=ae.e.isSymbol()){ // turn the function literal into a function declaration lit.isFunctionLiteral=false; if(auto fd = lit.meaning.isFunctionDecl()){ if(fd.type.hasUnresolvedParameters()){ lit.sstate = SemState.begin; fd.sstate = SemState.pre; fd.scope_ = null; lit.meaning = fd.templatizeLiteral(sc,lit.loc); lit.inContext = InContext.none; lit.meaning.semantic(sc); mixin(Rewrite!q{lit.meaning}); assert(lit.meaning.sstate == SemState.completed && !lit.meaning.needRetry); x = lit; } return; } } if(x.isType()||AliasDecl.getAliasBase(x)) return; x.interpret(sc); } override void semantic(Scope sc){ if(sstate == SemState.pre) presemantic(sc); mixin(SemPrlg); foreach(x; params) x.sstate = max(x.sstate,SemState.begin); mixin(SemChld!q{params}); tuplepos=params.length; foreach_reverse(i,x; params) if(x.which == WhichTemplateParameter.tuple) tuplepos = i; // See if the eponymous declaration can be determined without analyzing // the template body. This is required for IFTI and template constraints. // TODO: deal with overloaded eponymous symbols foreach(x; bdy.decls){ if(x.name && x.name.name is name.name) eponymousDecl = x; break; } sc.getModule().addTemplateDecl(this); mixin(SemEplg); } /* templates are always accessible, it is the contents of their instantiations that might not be. */ override bool needsAccessCheck(AccessCheck check){ return false; } /+ // TODO: where to put this? final static void verifyArgs(Expression[] args){ alias util.all all; assert(all!(_=>_.sstate == SemState.completed &&(_.isType()||_.isConstant()||_.isSymbol())||_.isAddressExp()&&_.isAddressExp().e.isSymbol())(args),{ string r; foreach(x;args){ r~=text(x," ",x.sstate == SemState.completed," ",!!x.isType(),!!x.isConstant(),!!x.isSymbol(),'\n'); } return r; }()); } +/ private Declaration matchHelper(bool isIFTI, T...)(Scope sc, const ref Location loc, bool gagged, bool isMixin, T ts){ static if(isIFTI) assert(!isMixin); alias ts[isIFTI+1] args; // respect this_ assert(!!scope_); assert(sstate == SemState.completed); // shortcut, could also be left out static if(!isIFTI) if(!isMixin) if(auto r=store.lookup(args.args)){ if(r.finishedInstantiation()){ if(!gagged&&r.isGagged()) r.ungag(); return r; } } auto inst = New!TemplateInstanceDecl(this,loc,ts[isIFTI..$]); if(isMixin) inst.initializeMixin(sc); if(gagged) inst.gag(); if(!inst.completedMatching){ inst.semantic(sc); mixin(Rewrite!q{inst}); } return inst; } TemplateInstanceDecl getUniqueInstantiation(TemplateInstanceDecl inst){ if(!inst.isMixin){ if(auto exst = store.lookup(inst.resolved)) inst = exst; else store.add(inst); } // dw("built ", inst); return inst; } override Declaration matchInstantiation(Scope sc, const ref Location loc, bool gagged, bool isMixin, Expression expr, TemplArgsWithTypes args){ auto r=matchHelper!false(sc, loc, !sc||!sc.handler.showsEffect||gagged, isMixin, expr, args); return r; } override Declaration matchIFTI(Scope sc, const ref Location loc, Type this_, Expression func, TemplArgsWithTypes args, Expression[] funargs){ if(!iftiDecl) return matchInstantiation(sc, loc, !sc||!sc.handler.showsEffect, false, func, args); auto gagged=!sc||!sc.handler.showsEffect; // TODO: get rid of !sc auto r=matchHelper!true(sc, loc, gagged, false, this_, func, args, funargs); // TODO: more explicit error message if(!r && !gagged) sc.error("could not match call to function template",loc); return r; } final override Dependent!Declaration matchCall(Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args, ref MatchContext context){ assert(0); } void forallInstances(scope void delegate(TemplateInstanceDecl) dg){ foreach(k,v;store.instances) dg(v); } private: struct TemplateInstanceStore{ import hashtable; static bool eq(TemplArgs a,TemplArgs b){ if(a.length!=b.length) return false; foreach(i;0..a.length) if(!a[i].tmplArgEquals(b[i])) return false; return true; } // equality check static size_t h0(TemplArgs a){ return a.tmplArgToHash(); } // hash private HashMap!(TemplArgs,TemplateInstanceDecl, eq, h0) instances; void add(TemplateInstanceDecl decl)in{ assert(decl.completedParameterResolution); }body{ foreach(x; decl.resolved) if(auto ty = x.isType()) if(ty.hasPseudoTypes()) return; instances[decl.resolved] = decl; } TemplateInstanceDecl lookup(TemplArgs args){ return instances.get(args,null); } } TemplateInstanceStore store; } mixin template Semantic(T) if(is(T==TemplateMixinDecl)){ // TODO: peek into ongoing instantiation for more precision? override void potentialInsert(Scope sc, Declaration dependee){ sc.potentialInsertArbitrary(dependee,this); } override void potentialRemove(Scope sc, Declaration dependee){ sc.potentialRemoveArbitrary(dependee,this); } override void presemantic(Scope sc){ if(sstate != SemState.pre) return; TemplateInstanceExp tie; if(auto ti=inst.isTemplateInstanceExp()) tie = ti; else{ tie = New!TemplateInstanceExp(inst,(Expression[]).init); tie.loc = inst.loc; inst = tie; } tie.isMixin = true; tie.willAlias(); tie.matchingOnly(); scope_ = sc; sstate = SemState.begin; potentialInsert(sc, this); } NamespaceDecl nspace = null; override void semantic(Scope sc){ mixin(SemPrlg); if(sstate == SemState.pre) presemantic(sc); scope(exit) if(!needRetry) potentialRemove(sc, this); mixin(SemChld!q{inst}); assert(cast(Symbol)inst,text(inst," ",inst.sstate," ",typeid(this.inst))); auto sym=cast(Symbol)cast(void*)inst; assert(cast(TemplateInstanceDecl)sym.meaning); auto meaning=cast(TemplateInstanceDecl)cast(void*)sym.meaning; meaning.bdy.pickupSTC(stc); meaning.startAnalysis(); auto instsc=meaning.bdy.scope_; if(!sc.addImport(instsc,ImportKind.mixin_)) mixin(ErrEplg); potentialRemove(sc, this); sym.makeStrong(); mixin(SemChld!q{inst}); if(name&&!nspace) nspace = New!NamespaceDecl(instsc,name); if(nspace) mixin(SemChld!q{nspace}); mixin(SemEplg); } override int traverseInOrder(scope int delegate(Declaration) dg){ if(auto r=dg(this)) return r; if(auto sym=inst.isSymbol()) if(sym.meaning) if(auto meaning=sym.meaning.isTemplateInstanceDecl()) return meaning.bdy.traverseInOrder(dg); return 0; } } class NamespaceDecl: Declaration{ Scope sc; this(Scope sc,Identifier name){ super(STC.init,name); this.sc=sc; } override string toString(){ return name.toString(); } override @property string kind(){ return "name space"; } mixin Visitors; mixin DownCastMethod; } mixin template Semantic(T) if(is(T==NamespaceDecl)){} mixin template Semantic(T) if(is(T==TemplateInstanceExp)){ TemplArgs analyzedArgs; TypeTemplArgs argTypes; @property bool analyzedArgsInitialized(){ return analyzedArgs.length||!args.length; } bool isMixin = false; override void semantic(Scope sc){ mixin(SemPrlg); // eponymous template trick if(!!res){ if(inContext==InContext.called) iftiResSemantic(sc); else instantiateResSemantic(sc); return; } mixin(RevEpoLkup!q{e}); foreach(x; args){ x.willPassToTemplate(); if(x.sstate != SemState.completed && !x.isFunctionLiteralExp()) x.prepareInterpret(); x.weakenAccessCheck(AccessCheck.none); } e.willInstantiate(); mixin(SemChld!q{e}); if(auto r=e.isUFCSCallExp()){ if(auto sym=r.e.isSymbol()) sym.inContext=InContext.none; // clear context auto tmpl = New!TemplateInstanceExp(r.e,args); tmpl.loc = loc; tmpl.willCall(); r.instantiate(tmpl, inContext==InContext.called); r.semantic(sc); mixin(RewEplg!q{r}); } mixin(SemChld!q{args}); alias util.any any; Expression container = null; auto sym = e.isSymbol(); AccessCheck accessCheck; if(!sym){ if(auto fld = e.isFieldExp()){ container = fld.e1; sym = fld.e2; accessCheck = fld.accessCheck; }else{ // TODO: this error message has a duplicate in Declaration.matchInstantiation sc.error(format("can only instantiate templates, not %s%ss",e.kind,e.kind[$-1]=='s'?"e":""),loc); mixin(ErrEplg); } }else accessCheck=sym.accessCheck; foreach(i,ref x; args){ TemplateDecl.finishArgumentPreparation(sc, x); mixin(PropRetry!q{x}); } mixin(SemChld!q{args}); if(!analyzedArgsInitialized){ analyzedArgs = args.captureTemplArgs(); Expression dummyLeftover=null; analyzedArgs = Tuple.expand(sc,AccessCheck.none,analyzedArgs,dummyLeftover); assert(!dummyLeftover); argTypes = TypeTuple.expand(args.map!((a){ // TODO: this is hacky (the type passed is irrelevant), better approaches? if(auto tt=a.isTypeTuple()) return tt; return a.type; })); } mixin(SemProp!q{sym.meaning}); if(inContext==InContext.called) return IFTIsemantic(sc,container,sym,accessCheck); instantiateSemantic(sc,container,sym,accessCheck); } Expression[] iftiArgs; mixin ContextSensitive; private void IFTIsemantic(Scope sc, Expression container, Symbol sym, AccessCheck accessCheck){ mixin(SemChld!q{e,args}); type = type.get!void(); // the state will be reset in matchCallHelper if(!inst) mixin(SemEplg); finishSemantic(sc, container, sym, accessCheck); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type th_, Expression[] funargs, ref MatchContext context){ assert(!th_); enum SemRet = q{ return this.independent!Expression; }; assert(inContext==InContext.called); assert(sstate == SemState.completed || sstate == SemState.begin); sstate = SemState.begin; iftiArgs = funargs; Expression container = null; Type this_ = null; auto sym = e.isSymbol(); if(sym) this_ = sym.maybeThisContext(); else{ assert(!!cast(FieldExp)e); if(auto fld=cast(FieldExp)cast(void*)e){ container = fld.e1; sym = fld.e2; if(auto tt=container.extractThis()) this_ = tt.type; } } inst = sym.meaning.matchIFTI(sc, loc, this_, this, TemplArgsWithTypes(analyzedArgs,argTypes), funargs); if(!inst||inst.sstate==SemState.error) mixin(ErrEplg); if(!inst.isTemplateInstanceDecl || !(cast(TemplateInstanceDecl)cast(void*)inst).completedMatching){ mixin(SemChld!q{inst}); } if(sc) semantic(sc); else needRetry = true; mixin(SemRet); } private void instantiateSemantic(Scope sc, Expression container, Symbol sym, AccessCheck accessCheck){ if(!inst){ inst = sym.meaning.matchInstantiation(sc, loc, false, isMixin, this, TemplArgsWithTypes(analyzedArgs,argTypes)); if(!inst||inst.sstate==SemState.error) mixin(ErrEplg); } assert(!!inst); finishSemantic(sc, container, sym, accessCheck); } private void finishSemantic(Scope sc, Expression container, Symbol sym, AccessCheck accessCheck){ if(!inst.isTemplateInstanceDecl || !(cast(TemplateInstanceDecl)cast(void*)inst).completedMatching){ mixin(PropErr!q{inst}); mixin(SemChld!q{inst}); } if(auto symm=inst.isSymbolMatcher()){ assert(symm.hasFailedToMatch()); symm.emitError(sc); mixin(ErrEplg); } assert(!!cast(TemplateInstanceDecl)inst, text(typeid(this.inst))); auto inst = cast(TemplateInstanceDecl)cast(void*)inst; // update static type of inst if(inst.hasFailedToMatch()){ inst.emitError(sc); mixin(ErrEplg); } auto decl = inst.parent; if(!isMixin && decl.isMixin){ sc.error("cannot instantiate a mixin template regularly", loc); sc.note("declared here", decl.loc); mixin(ErrEplg); } needRetry=false; // ! changing meaning of 'sym' if(!inst.finishedInstantiation()){ inst.finishInstantiation(!matchOnly); // start analysis? mixin(Rewrite!q{inst}); } if(sc.handler.showsEffect&&inst.isGagged) inst.ungag(); sym = New!Symbol(inst); sym.loc = loc; sym.accessCheck = accessCheck; if(matchOnly) sym.makeWeak(); // do not propagate errors transferContext(sym); if(inst.instantiation is this) inst.instantiation = sym; // transfer ownership if(container && !isMixin){ auto res = New!(BinaryExp!(Tok!"."))(container, sym); res.loc = loc; this.res = res; }else res = sym; if(!isMixin){ // for eponymous template trick: attempt lookup and don't perform trick if it fails eponymous=New!Identifier(decl.name.name); eponymous.loc=loc; eponymous.accessCheck=accessCheck; } semantic(sc); // no indefinite recursion because 'res' is now set } private void instantiateResSemantic(Scope sc){ if(eponymous){ if(!eponymous.meaning && eponymous.sstate != SemState.failed && eponymous.sstate != SemState.error){ eponymous.recursiveLookup = false; mixin(Lookup!q{_; eponymous, sc, res.getMemberScope()}); } if(auto nr=eponymous.needRetry) { needRetry = nr; return; } mixin(PropErr!q{eponymous}); } if(!eponymous||eponymous.sstate == SemState.failed){ needRetry=false; auto r = res; if(r.sstate!=SemState.completed&&r.sstate!=SemState.error) r.needRetry=true; // let the caller do the semantic analysis mixin(RewEplg!q{r}); } Expression r=New!(BinaryExp!(Tok!"."))(res, eponymous); r.loc=loc; r.needRetry=true; // let the caller do the semantic analysis transferContext(r); mixin(RewEplg!q{r}); } private void iftiResSemantic(Scope sc){ // TODO: fix this kludge instantiateResSemantic(sc); if(!rewrite) return; assert(!!cast(Expression)rewrite); if((cast(Expression)cast(void*)rewrite).isType()) return; auto tmp = rewrite.sstate!=SemState.completed?null.independent!Expression: (cast(Expression)cast(void*)rewrite).matchCall(sc, loc, iftiArgs); if(tmp.dependee||!tmp.value){ static class MatchCallWhenReady: Expression{ Expression exp; Expression[] iftiArgs; this(Expression e, const ref Location l, Expression[] ia){ exp = e; loc = l; iftiArgs = ia; } override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{exp}); Expression r; auto f=exp; if(exp.isType()) r=exp; else{ mixin(MatchCall!q{r; exp, sc, loc, iftiArgs}); if(!r) mixin(ErrEplg); } if(rewrite) return; // TODO: ok? mixin(RewEplg!q{r}); } override string toString(){ return exp.toString(); } } auto r = New!MatchCallWhenReady(cast(Expression)cast(void*)rewrite, loc, iftiArgs); rewrite = null; r.semantic(sc); if(rewrite) return; // TODO: ok? mixin(RewEplg!q{r}); } rewrite = tmp.value; if(!rewrite) mixin(ErrEplg); } override void noHope(Scope sc){ if(res){ auto unresolved = res.getMemberScope(); if(unresolved&&!unresolved.inexistent(sc,eponymous)) mixin(ErrEplg); }else{ mixin(RevEpoNoHope!q{e}); } } public final void matchingOnly(){ matchOnly = true; } private: Expression res; Identifier eponymous; Declaration inst; bool matchOnly = false; } mixin template Semantic(T) if(is(T==ABinaryExp)){ } mixin template Semantic(T) if(is(T _==BinaryExp!S,TokenType S) && !is(T==BinaryExp!(Tok!"."))){ static if(is(T _==BinaryExp!S,TokenType S)): static if(overloadableBinary.canFind(TokChars!S) || TokChars!S[$-1]=='=' && overloadableBinary.canFind(TokChars!S[0..$-1])||S==Tok!"=="||S==Tok!"!="){ mixin OpOverloadMembers; static if(overloadableBinary.canFind(TokChars!S)){ Expression opoverloadR; Expression oofunR; } } static if(S==Tok!"!in"){ Expression opin; } static if(S==Tok!"||"||S==Tok!"&&") bool lazyConditionalSemantic = false; override void semantic(Scope sc){ mixin(SemPrlg); // TODO: can this be solved more elegantly? static if(S==Tok!"||"||S==Tok!"&&"){ if(lazyConditionalSemantic){ e1.prepareInterpret(); mixin(SemChldExp!q{e1}); auto bl = Type.get!bool(); mixin(ConvertTo!q{e1,bl}); mixin(IntChld!q{e1}); if(cast(bool)e1.interpretV()^(S==Tok!"&&")) mixin(RewEplg!q{e1}); else{ mixin(SemChldExp!q{e2}); auto vd = Type.get!void(); if(e2.type.getHeadUnqual() is vd){ type = vd; }else{ mixin(ConvertTo!q{e2,bl}); type = bl; } mixin(ConstFold!q{e2}); mixin(SemEplg); } } } mixin(SemChldExp!q{e1,e2}); // constant folding done by hijacking the SemEplg macro TODO: better options? auto c1 = e1.isConstFoldable(), c2 = e2.isConstFoldable(); enum SemEplg = q{ if(c1^c2){ // if both are constant, then the entire expression will be folded if(c1) mixin(ConstFold!q{e1}); else mixin(ConstFold!q{e2}); } }~SemEplg; static if(isAssignOp(S)){ // TODO: properties, array ops \ ~= if((e1.canMutate()||e1.isLengthExp())&&(S==Tok!"="||!e1.type.isTypeTuple())){ type = e1.type; static if(S==Tok!"~="){ if(auto tt=type.isDynArrTy()){ auto elt=tt.getElementType(); mixin(ImplConvertsTo!q{auto e2toelt; e2, elt}); if(e2toelt) e2=e2.implicitlyConvertTo(elt); else e2=e2.implicitlyConvertTo(type); }else goto Lnomatch; }else static if(S==Tok!"+=" || S==Tok!"-="){ if(auto tt=type.isPointerTy()){ auto s_t = Type.get!Size_t(); assert(tt.getSizeof() == s_t.getSizeof()); e2=e2.implicitlyConvertTo(s_t); }else e2=e2.implicitlyConvertTo(type); }else e2=e2.implicitlyConvertTo(type); mixin(SemChld!q{e2}); mixin(ConstFold!q{e2}); /+if(e2.implicitlyConvertsTo(type)){ ... }else{ sc.error(format("assigning to a '%s' from incompatible type '%s'", e1.type.toString(), e2.type.toString()), loc); mixin(ErrEplg); }+/ static if(S==Tok!"="){ if(e1.type.isTypeTuple()){ auto r=New!TupleAssignExp(e1,e2); r.brackets=brackets; // (for formatting) r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } } mixin(.SemEplg); // don't const fold lhs }else{ Lnomatch: // TODO: opAssign static if(overloadableBinary.canFind(TokChars!S[0..$-1])&&TokChars!S[$-1]=='='){ mixin(OpOverload!("opOpAssign",q{ [LiteralExp.polyStringFactory(TokChars!S[0..$-1])] },"[e2]","e1")); } if(!e1.checkMutate(sc,loc)) mixin(ErrEplg); if(e1.finishDeduction(sc) && e2.finishDeduction(sc)){ static if(S==Tok!"~="){ // TODO: allocation sc.error(format("cannot append to expression of type '%s'", type),loc); }else{ sc.error(format("cannot use expression of type '%s' in the left hand side of '"~TokChars!S~"'",e1.type),loc); } } mixin(ErrEplg); } //sc.error(format("expression '%s' is not assignable",e1.loc.rep),loc); }else static if(S==Tok!"in"){ // TODO }else static if(S==Tok!"!in"){ if(!opin){ opin = New!(BinaryExp!(Tok!"in"))(e1,e2); opin.loc=loc; } mixin(SemChld!q{opin}); auto bl = Type.get!bool(); mixin(ConvertsTo!q{bool conv; opin, bl}); if(conv){ auto r = New!(UnaryExp!(Tok!"!"))(opin); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } }else static if(isRelationalOp(S)){ Type ty = null; //bool conv1 = e2.implicitlyConvertsTo(e1.type); //bool conv2 = e1.implicitlyConvertsTo(e2.type); mixin(ImplConvertsTo!q{auto conv1; e2, e1.type}); mixin(ImplConvertsTo!q{auto conv2; e1, e2.type}); if(conv1 ^ conv2){ if(conv1) ty = e1.type; else ty = e2.type; }else{ mixin(TypeCombine!q{auto tt; e1,e2}); if(tt) ty=tt; } if(ty){ auto tyu=ty.getHeadUnqual(); // promote comparison method of the enum base type if(auto et=tyu.isEnumTy()){ mixin(GetEnumBase!q{tyu;et.decl}); tyu=tyu.getHeadUnqual(); } mixin(ImplConvertToPar!q{e1,ty}); mixin(ImplConvertTo!q{e2,ty}); // TODO: figure out exact spec for is and !is mixin(PropErr!q{e1}); assert(e1.sstate == SemState.completed && e2.sstate == SemState.completed); type = Type.get!bool(); static if(S!=Tok!"=="&&S!=Tok!"!="&&S!=Tok!"is"&&S!=Tok!"!is"){ if(ty.isComplex()){ sc.error("cannot compare complex operands",loc); mixin(ErrEplg); } } if(auto el = tyu.getElementType()){ // TODO: stub exp strategies are inefficient // TODO: DMD does not do this. report bug. Expression x=New!(BinaryExp!S)(New!StubExp(el),New!StubExp(el)); x.loc = loc; mixin(SemChld!q{x}); } mixin(SemEplg); } // TODO: Associative arrays // TODO: operator overloading }else static if(isLogicalOp(S)){ static assert(S==Tok!"&&"||S==Tok!"||"); auto bl = Type.get!bool(); e1=e1.convertTo(bl); // TODO: implicit explicit conversion // allow (bool) && (void), (bool) || (void) auto ty2 = e2.type.getHeadUnqual(); if(ty2 !is Type.get!void()){ e2=e2.convertTo(bl); // TODO: implicit explicit conversion ty2 = bl; } mixin(SemChld!q{e1,e2}); type = ty2; mixin(SemEplg); }else static if(isShiftOp(S)||isArithmeticOp(S)||isBitwiseOp(S)){ auto t1=e1.type.getHeadUnqual(), t2=e2.type.getHeadUnqual(); // integral promote enum types to unqualified base if(auto et1=t1.isEnumTy()){ mixin(GetEnumBase!q{t1;et1.decl}); t1=t1.getHeadUnqual(); } if(auto et2=t2.isEnumTy()){ mixin(GetEnumBase!q{t2;et2.decl}); t2=t2.getHeadUnqual(); } auto bt1=t1.isBasicType(), bt2=t2.isBasicType(); auto v = Type.get!void(); static if(isShiftOp(S)){ if(bt1 && bt2 && bt1 !is v && bt2 !is v){ if(bt1.isIntegral()&&bt2.isIntegral()){ bt1=bt1.intPromote(); // correctly promote qualified types if(bt1 is t1) t1 = e1.type; else t1 = bt1; mixin(ImplConvertTo!q{e1,t1}); assert(e1.sstate == SemState.completed); type = t1; int valid = true; bool narrow; if(bt1.bitSize()==32) narrow = true; else{narrow = false;assert(bt1.bitSize()==64);} if(bt2.bitSize()==32){ auto r = e2.getIntRange(); if(!r.overlaps(IntRange(0,narrow?31:63,r.signed))) valid = false; }else{ assert(bt2.bitSize()==64); auto r = e2.getLongRange(); if(!r.overlaps(LongRange(0,narrow?31:63,r.signed))) valid = false; } if(!valid){ // TODO: display exact amount if it is known sc.error(format("shift amount is outside the range 0..%d",narrow?31:63),loc); mixin(ErrEplg); } mixin(SemEplg); } } }else static if(isArithmeticOp(S) || isBitwiseOp(S)){ enum isBitwise = isBitwiseOp(S); if(bt1 && bt2 && bt1 !is v && bt2 !is v && (!isBitwise||bt1.isIntegral()&&bt2.isIntegral())){ static if(isBitwise){auto bl=Type.get!bool();if(bt1 is bl && bt2 is bl) goto Ldontpromote;} bt1=bt1.intPromote(); bt2=bt2.intPromote(); // correctly promote qualified types if(bt1 is t1) t1 = e1.type; else t1 = bt1; if(bt2 is t2) t2 = e2.type; else t2 = bt2; Ldontpromote: static if(S == Tok!"*" || S==Tok!"/" || S==Tok!"%"){ bool f1 = bt1.isImaginary() && (bt2.isFloating() || bt2.isIntegral()); bool f2 = bt2.isImaginary() && (bt1.isFloating() || bt1.isIntegral()); if(f1) { if(bt2.isIntegral()){ Type tt; if(bt1 == Type.get!ifloat()) tt = Type.get!float(); else if(bt1 == Type.get!idouble) tt = Type.get!double(); else tt = Type.get!real(); mixin(ImplConvertTo!q{e2,tt}); } type = S==Tok!"%"?e2.type.getHeadUnqual():bt1; }else if(f2) { if(bt1.isIntegral()){ Type tt; if(bt2 == Type.get!ifloat()) tt = Type.get!float(); else if(bt2 == Type.get!idouble) tt = Type.get!double(); else tt = Type.get!real(); mixin(ImplConvertTo!q{e1,tt}); type = S==Tok!"%"?e2.type.getHeadUnqual():bt2; } } if(f1 || f2){ sc.error("mixed real and imaginary operations not supported yet",loc); mixin(ErrEplg); // mixin(SemChld!q{e1,e2}~SemEplg); } } {mixin(Combine!q{auto ty; t1, t2}); if(ty){ auto conve2to = ty; static if(S == Tok!"%") if(auto bty = ty.isComplex()){ if(bt2.isIntegral()){ if(bty.op == Tok!"cfloat") conve2to=Type.get!float(); else if(bty.op == Tok!"cdouble") conve2to=Type.get!double(); else if(bty.op == Tok!"creal") conve2to=Type.get!real(); else assert(0); }else if(bt2.isImaginary()) conve2to=e2.type; else{ sc.error("cannot compute the remainder of complex number division",loc); mixin(ErrEplg); } } mixin(ImplConvertToPar!q{e1,ty}); mixin(ImplConvertTo!q{e2,conve2to}); mixin(PropErr!q{e1}); assert(e1.sstate == SemState.completed && e2.sstate == SemState.completed); static if(S == Tok!"/" || S==Tok!"%"){ if(bt1.isIntegral() && bt2.isIntegral()) if(e2.isConstant() && e2.interpretV() == Variant(0,e2.type)){ sc.error("divide by zero", loc); mixin(ErrEplg); } } type = ty; mixin(SemEplg); }} }else static if(S==Tok!"+"||S==Tok!"-"){ // pointer arithmetics if(bt2&&bt2.isIntegral() && t1.isPointerTy()){ type = e1.type; mixin(SemEplg); }else static if(S==Tok!"+"){ if(bt1&&bt1.isIntegral() && t2.isPointerTy()){ type = e2.type; mixin(SemEplg); } } } }else static assert(0); }else static if(S==Tok!"~"){ Type el1 = e1.type.getElementType(), el2 = e2.type.getElementType(); bool f1 = !!el1, f2 = !!el2; bool e1toel2, e2toel1; if(f2) mixin(ImplConvertsTo!q{e1toel2; e1, el2}); if(f1) mixin(ImplConvertsTo!q{e2toel1; e2, el1}); if(f1 && f2){ if(e1toel2){ f1 = false; el1 = e1.type; } if(e2toel1){ f2 = false; el2 = e2.type; } } // TODO: if arr1 is of type int[][], what is the meaning of arr1~[]? switch(f1<<1|f2){ case 0b11: // both are arrays mixin(TypeMostGeneral!q{auto mg; e1,e2}); if(mg){ type = mg.getElementType(); }else{ mixin(RefCombine!q{auto ty; el1, el2, 0}); if(ty) type = ty; else{ // TODO: there might be a better place/approach for this logic auto l1 = e1.isLiteralExp(), l2 = e2.isLiteralExp(); Type elo; if(l1 && l1.isPolyString()) elo = el2; else if(l2 && l2.isPolyString()) elo = el1; if(elo){ auto elou = elo.getHeadUnqual(); import std.typetuple; foreach(T; TypeTuple!(char,wchar,dchar)){ if(elou is Type.get!T()){ mixin(RefCombine!q{ type; type.get!(immutable(T))(), elo, 0 }); break; } } } } break; } case 0b10: // array ~ element if(e2toel1) type = el1; else{ mixin(ImplConvertsTo!q{auto e2toe1; e2, e1.type}); if(e2toe1){f2=true; type = el1;} } break; case 0b01: // element ~ array if(e1toel2) type = el2; else{ mixin(ImplConvertsTo!q{auto e1toe2; e1, e2.type}); if(e1toe2){f1=true; type = el2;} } break; default: // both are elements break; } if(type){ // TODO: unique data mustn't be const-qualified // TODO: except if the unqualified type has mutable indirections //auto stc = type.getHeadSTC(); //if(stc&STCconst){ // stc&=~STCconst; // // TODO: immutable~const should be immutable // // TODO: except if the unqualified type has const indirections // // if((el1.isImmutable() || el2.isImmutable()) // // && el1 is el1.getConst() && el2 is el2.getConst()) // // stc|=STCimmutable; // type = type.getHeadUnqual().applySTC(stc); //} if(!f1) e1=e1.implicitlyConvertTo(type); if(!f2) e2=e2.implicitlyConvertTo(type); type = type.getDynArr(); if(f1&&!e1.type.getUnqual().equals(type.getUnqual())) e1=e1.implicitlyConvertTo(type); if(f2&&!e2.type.getUnqual().equals(type.getUnqual())) e2=e2.implicitlyConvertTo(type); mixin(SemChld!q{e1,e2}); assert(e1.sstate == SemState.completed && e2.sstate == SemState.completed); // structural const folding auto al1 = e1.isArrayLiteralExp(), al2 = e2.isArrayLiteralExp(); if(f1 && f2){ if(al1 && al2){ al1.type = null; al1.sstate = SemState.begin; al1.lit ~= al2.lit; al1.loc = al1.loc.to(al2.loc); mixin(SemChld!q{e1}); mixin(RewEplg!q{e1}); } }else if(f1){ assert(!f2); if(al1){ al1.type = null; al1.sstate = SemState.begin; al1.lit ~= e2; al1.loc = al1.loc.to(e2.loc); mixin(SemChld!q{e1}); mixin(RewEplg!q{e1}); } }else if(f2){ if(al2){ al2.type = null; al2.sstate = SemState.begin; al2.lit = e1~al2.lit; al2.loc = e1.loc.to(al2.loc); mixin(SemChld!q{e2}); mixin(RewEplg!q{e2}); } } mixin(SemEplg); } }else static assert(S==Tok!","); static if(S==Tok!","){ type=e2.type; mixin(SemEplg); }else{ if(!e1.finishDeduction(sc) || !e2.finishDeduction(sc)) goto Lerr; // operator overloading with opBinary and opBinaryRight static if(overloadableBinary.canFind(TokChars!S)){ mixin(BuildOpOver!("opoverloadR","e2","opBinaryRight", q{[LiteralExp.polyStringFactory(TokChars!S)]})); mixin(BuildOpOver!("opoverload","e1","opBinary", q{[LiteralExp.polyStringFactory(TokChars!S)]})); if(!oosc) oosc=New!GaggingScope(sc); opoverloadR.willCall(); opoverload.willCall(); if(auto ti=opoverloadR.isTemplateInstanceExp()) ti.matchingOnly(); if(auto ti=opoverload.isTemplateInstanceExp()) ti.matchingOnly(); mixin(SemChldPar!q{sc=oosc;opoverloadR}); mixin(SemChldPar!q{sc=oosc;opoverload}); if(!oofun&&opoverload.sstate==SemState.completed){ bool other = opoverloadR.sstate==SemState.completed; if(opoverload.isUFCSCallExp()) other = true; auto oofund=opoverload.matchCall(other?oosc:sc, loc, [e2]); if(oofund.dependee.node){ mixin(PropRetry!q{oofund.dependee.node}); if(!other) mixin(PropErr!q{oofund.dependee.node}); } oofun=oofund.value; if(!oofun) mixin(SetErr!q{opoverload}); } if(oofun) mixin(SemChldPar!q{sc=oosc;oofun}); if(!oofunR&&opoverloadR.sstate==SemState.completed){ auto oofunRd=opoverloadR.matchCall(oosc, loc, [e1]); if(oofunRd.dependee.node){ mixin(PropRetry!q{oofunRd.dependee.node}); } oofunR=oofunRd.value; if(!oofunR) mixin(SetErr!q{opoverloadR}); } if(oofunR) mixin(SemChldPar!q{sc=oosc;oofunR}); MatchContext context, contextR; Expression r; if(oofunR && oofunR.sstate == SemState.completed) oofunR.matchCallHelper(oosc, loc, null, [e1], contextR).force; else contextR.match=Match.none; if(oofun && oofun.sstate == SemState.completed) oofun.matchCallHelper(oosc, loc, null, [e1], context).force; else context.match=Match.none; if(contextR.match!=context.match){ if(contextR.match>context.match){ opoverloadR=null; mixin(BuildOpOver!("opoverloadR","e2","opBinaryRight", q{[LiteralExp.polyStringFactory(TokChars!S)]})); auto tmpe=New!TmpVarExp(e1); tmpe.loc=loc; tmpe.semantic(sc); assert(!!tmpe.sym); auto c=New!CallExp(opoverloadR,[tmpe.sym]); r=New!(BinaryExp!(Tok!","))(tmpe,c); r.loc=c.loc=loc; }else{ r=New!CallExp(oofun,[e2]); r.loc=loc; } }else if(context.match!=Match.none){ // TODO: consider specialization sc.error(format(mixin(X!"Both '%s.opBinary!\"@(TokChars!S)\"(%s)' and '%s.opBinaryRight!\"@(TokChars!S)\"(%s)' are equally well matching operator overloads"),e1.loc.rep,e2.loc.rep,e2.loc.rep,e1.loc.rep),loc); mixin(ErrEplg); } oosc=null; if(r){r.semantic(sc);mixin(RewEplg!q{r});} } static if(S==Tok!"in"){ type = Type.get!bool(); super.semantic(sc);// TODO: implement } sc.error(format("incompatible types '%s' and '%s' for binary "~TokChars!S,e1.type,e2.type),loc); Lerr:mixin(ErrEplg); } } override bool isConstant(){ static if(S==Tok!"is" || S==Tok!"!is") return false; else return e1.isConstant() && e2.isConstant(); } override bool isConstFoldable(){ static if(S==Tok!"is" || S==Tok!"!is") return false; else return e1.isConstFoldable() && e2.isConstFoldable(); } static if(S==Tok!","){ override void isInContext(InContext inContext){ e2.isInContext(inContext); } override bool isLvalue(){ return e2.isLvalue(); } } static if(isAssignOp(S)) override bool isLvalue(){ return true; } static if(S==Tok!"~"){ // '~' always reallocates, therefore conversion semantics are less strict override bool isUnique(){ return true; } override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; // the type qualifiers of the head of the element type are unimportant. // example: if arr1, arr2 are of type int[], then arr1~arr2 implicitly converts to immutable(int)[] // example: if arr is of type int*[] then arr~arr implicitly converts to const(int)*[] Type ell = type.getElementType(), elr = rhs.getElementType(); if(ell&&elr) return ell.getHeadUnqual().refConvertsTo(elr.getHeadUnqual(), 0); // if both operands implicitly convert to the result type, their concatenation does too. // example: [1,2,3]~[4,5,6] implicitly converts to short[] // example: 2 ~ [3,4,5] implicitly converts to short[] if(auto rel = rhs.getElementType()){ auto el1 = e1.type.getElementType(), el2 = e2.type.getElementType(); if(el1 && el1.equals(e2.type)){ // array ~ element auto b1=e1.implicitlyConvertsTo(rhs), b2=e2.implicitlyConvertsTo(rel); return b1.and(b2); }else if(el2 && el2.equals(e1.type)){ // element ~ array auto b1=e1.implicitlyConvertsTo(rel), b2=e2.implicitlyConvertsTo(rhs); return b1.and(b2); } } auto b1=e1.implicitlyConvertsTo(rhs), b2=e2.implicitlyConvertsTo(rhs); return b1.and(b2); } } private static string __dgliteralRng(){ string r; foreach(x;["IntRange","LongRange"]){ r~=mixin(X!q{ override @(x) get@(x)(){ static if(isArithmeticOp(S) || isShiftOp(S) || isBitwiseOp(S)){ return mixin(`e1.get@(x)()`~TokChars!S~`e2.get@(x)()`); }else static if(S==Tok!"," || isAssignOp(S)){ return e2.get@(x)(); }else static if(S==Tok!"in"||S==Tok!"!in"){ return super.get@(x)(); }else static if(isRelationalOp(S)){ static if(S==Tok!"is") enum S = Tok!"=="; else static if(S==Tok!"!is") enum S = Tok!"!="; auto it = e1.type.getHeadUnqual().isIntegral(); if(!it) return @(x)(0,1,true); // TODO: make more efficient LongRange r1, r2; if(it.bitSize()<=32){ auto ir1 = e1.getIntRange(); auto ir2 = e2.getIntRange(); if(ir1.signed){ assert(ir2.signed); r1 = LongRange(cast(int)ir1.min,cast(int)ir1.max,true); r2 = LongRange(cast(int)ir2.min,cast(int)ir2.max,true); }else{ assert(!ir1.signed); r1 = LongRange(ir1.min,ir1.max,true); r2 = LongRange(ir2.min,ir2.max,true); } }else r1 = e1.getLongRange(), r2 = e2.getLongRange(); if(r1.min==r1.max && r2.min==r2.max) return mixin(`r1.min `~TokChars!S~` r2.min`)?@(x)(1,1,true):@(x)(0,0,true); static if(S==Tok!"=="||S==Tok!"is"||S==Tok!"!<>"){ return r1.overlaps(r2)?@(x)(0,1,true):@(x)(0,0,true); }else static if(S==Tok!"!="||S==Tok!"!is"||S==Tok!"<>"){ return r1.overlaps(r2)?@(x)(0,1,true):@(x)(1,1,true); }else static if(S==Tok!"<"||S==Tok!"!>="){ return r1.le(r2) ? @(x)(1,1,true) : r1.geq(r2) ? @(x)(0,0,true) : @(x)(0,1,true); }else static if(S==Tok!"<="||S==Tok!"!>"){ return r1.leq(r2) ? @(x)(1,1,true) : r1.gr(r2) ? @(x)(0,0,true) : @(x)(0,1,true); }else static if(S==Tok!">"||S==Tok!"!<="){ return r1.gr(r2) ? @(x)(1,1,true) : r1.leq(r2) ? @(x)(0,0,true) : @(x)(0,1,true); }else static if(S==Tok!">="||S==Tok!"!<"){ return r1.geq(r2) ? @(x)(1,1,true) : r1.le(r2) ? @(x)(0,0,true) : @(x)(0,1,true); }else static if(S==Tok!"<>="||S==Tok!"!<>="){ enum value = S==Tok!"<>="; return @(x)(value, value, true); }else static assert(0,TokChars!S); }else static if(isLogicalOp(S)){ auto r1 = e1.get@(x)(), r2 = e2.get@(x)(); bool f1=!r1.min&&!r1.max, f2=!r2.min&&!r2.max; bool t1=!r1.contains(@(x)(0,0,r1.signed)); bool t2=!r2.contains(@(x)(0,0,r2.signed)); static if(S==Tok!"||"){ if(t1||t2) return @(x)(1,1,true); if(f1&&f2) return @(x)(0,0,true); }else static if(S==Tok!"&&"){ if(t1&&t2) return @(x)(1,1,true); if(f1||f2) return @(x)(0,0,true); }else static assert(0); return @(x)(0,1,true); }else static if(S==Tok!"~"){ return super.get@(x)(); }else static assert(0); } }); } return r; } mixin(__dgliteralRng()); } class TupleAssignExp: TemporaryExp{ ExpTuple e1, e2; Expression commaLeft1,commaLeft2; Expression[] assignments; Expression lowered; this(Expression e1, Expression e2)in{ assert(e1&&e1.sstate==SemState.completed); assert(e2&&e2.sstate==SemState.completed); assert(e1.type.equals(e2.type)); assert(e1.isLvalue()); assert(e1.type.isTypeTuple()); }body{ if(auto ce1=e1.isCommaExp()) commaLeft1=ExpTuple.splitCommaExp(ce1,this.e1); else this.e1=e1.isExpTuple(); if(auto ce2=e2.isCommaExp()) commaLeft2=ExpTuple.splitCommaExp(ce2,this.e2); else this.e2=e2.isExpTuple(); assert(this.e1&&this.e2); } void semantic(Scope sc){ mixin(SemPrlg); type=e1.type; assert(e1.length == e2.length); if(commaLeft1){ commaLeft1.semantic(sc); assert(commaLeft1.sstate==SemState.completed); } if(commaLeft2){ commaLeft2.semantic(sc); assert(commaLeft2.sstate==SemState.completed); } if(assignments.length!=e1.length){ // TODO: InContext.assigned assignments=new Expression[](e1.length); foreach(i,ref assgn;assignments){ assgn=New!(BinaryExp!(Tok!"="))(e1.index(sc,InContext.none,e1.loc,i),e2.index(sc,InContext.none,e2.loc,i)); assgn.loc=loc; } } foreach(ref assgn;assignments) mixin(SemChld!q{assgn}); if(!lowered){ Expression vars=null; auto symbols=new Expression[](e1.length); // TODO: allocation foreach(i;0..e1.length){ auto tmpe=New!TmpVarExp(assignments[i]); tmpe.loc=loc; tmpe.semantic(sc); if(vars){ auto r=New!(BinaryExp!(Tok!","))(vars,tmpe); r.loc=vars.loc; vars=r; }else vars=tmpe; symbols[i]=tmpe.sym; } lowered=New!(BinaryExp!(Tok!","))(vars,New!ExpTuple(symbols)); lowered.loc=loc; if(commaLeft2){ lowered=New!(BinaryExp!(Tok!","))(commaLeft2,lowered); lowered.loc=loc; } if(commaLeft1){ lowered=New!(BinaryExp!(Tok!","))(commaLeft1,lowered); lowered.loc=loc; } } mixin(SemChld!q{lowered}); mixin(NoRetry); sstate=SemState.completed; createTemporary(sc); } override string toString(){ return _brk(e1.toString()~"="~e2.toString()); } mixin Visitors; } mixin template Semantic(T) if(is(T==TupleAssignExp)){} template Semantic(T) if(is(T==TernaryExp)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{e1}); e1=e1.convertTo(Type.get!bool()); mixin(SemChld!q{e1,e2,e3}); auto vd = Type.get!void(); mixin(TypeCombine!q{type; e2, e3}); if(!type){ if(e2.type.getHeadUnqual() is vd){ mixin(ConvertTo!q{e3,vd}); // TODO: implicit explicit conversion type = vd; }else if(e3.type.getHeadUnqual() is vd){ mixin(ConvertTo!q{e2,vd}); // TODO: implicit explicit conversion type = vd; }else{ sc.error(format("incompatible types for ternary operator: '%s' and '%s'",e2.type,e3.type),loc); mixin(ErrEplg); } } mixin(ImplConvertTo!q{e2,type}); mixin(ImplConvertTo!q{e3,type}); if(!isConstFoldable()){ mixin(ConstFold!q{e1}); mixin(ConstFold!q{e2}); mixin(ConstFold!q{e3}); } mixin(NoRetry); sstate=SemState.completed; if(!tmpVarDecl) if(type.isTypeTuple()) createTemporary(sc); } override bool isConstant(){ return e1.isConstant() && e2.isConstant() && e3.isConstant(); } override bool isConstFoldable(){ return e1.isConstFoldable() && e2.isConstFoldable() && e3.isConstFoldable(); } override bool isLvalue(){ return e2.isLvalue() && e3.isLvalue(); } override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; auto b1=e2.implicitlyConvertsTo(rhs), b2 = e3.implicitlyConvertsTo(rhs); return b1.and(b2); } override void isInContext(InContext inContext){ e2.isInContext(inContext); e3.isInContext(inContext); } private static string __dgliteralRng(){ string r; foreach(x;["IntRange","LongRange"]){ r~=mixin(X!q{ override @(x) get@(x)(){ auto r1 = e1.get@(x)(); bool t = !r1.contains(@(x)(0,0,true)); bool f = !r1.min&&!r1.max; if(t) return e2.get@(x)(); if(f) return e3.get@(x)(); return e2.get@(x)().merge(e3.get@(x)()); } }); } return r; } mixin(__dgliteralRng()); } mixin template Semantic(T) if(is(T==IsExp)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!gscope) gscope = New!GaggingScope(sc); auto f = ty.typeSemantic(gscope); mixin(PropRetry!q{sc=gscope;ty}); if(ty.sstate == SemState.error) goto no; assert(!!f); if(f.hasPseudoTypes()) mixin(ErrEplg); Token tok; switch(which){ case WhichIsExp.type: goto yes; case WhichIsExp.isEqual, WhichIsExp.implicitlyConverts: if(tparams.length) goto default; if(tySpec){ auto g = tySpec.typeSemantic(sc); mixin(SemProp!q{tySpec}); assert(!!g); if(g.hasPseudoTypes()) mixin(ErrEplg); if(which == WhichIsExp.isEqual && f.equals(g)) goto yes; if(which == WhichIsExp.implicitlyConverts){ mixin(ImplConvertsTo!q{bool iconv; f,g}); if(iconv) goto yes; } goto no; } default: super.semantic(sc); return; } yes: tok = token!"true"; goto ret; no: tok = token!"false"; goto ret; ret: if(rewrite) return; auto r = New!LiteralExp(tok); r.loc = loc; r.semantic(sc); mixin(RewEplg!q{r}); } private: GaggingScope gscope; } mixin template Semantic(T) if(is(T==TypeidExp)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{e}); sc.error("feature TypeidExp not implemented",loc); mixin(ErrEplg); //mixin(SemEplg); } } mixin template Semantic(T) if(is(T==VoidInitializerExp)){ override void semantic(Scope sc){ mixin(SemPrlg); type = Type.get!void(); mixin(SemEplg); } } mixin template Semantic(T) if(is(T==ArrayInitAssocExp)){ override void semantic(Scope sc){ mixin(SemPrlg); sc.error("unimplemented feature ArrayInitAssocExp",loc); mixin(ErrEplg); } } // abstracts a symbol. almost all circular dependency diagnostics are located here. // CallExp is aware of the possibility of circular dependencies too, because it plays an // important role in overloaded symbol resolution // TemplateInstanceDecl catches circular dependencies in the template constraint. // This is necessary because Symbol does not participate in the template instantiation // process. This is a tradeoff. // note: instances of this class have an identity independent from the referenced declaration enum AccessCheck{ uninitialized, none, ctfe, all, } AccessCheck accessCheckCombine(AccessCheck a, AccessCheck b){ return max(a,b); } class Symbol: Expression{ Declaration meaning; protected this(){} // subclass can construct parent lazily // TODO: compress all these bools into a bitfield bool isStrong;// is symbol dependent on semantic analysis of its meaning bool isWeak; bool isFunctionLiteral; // does symbol own 'meaning' bool isSymbolMatcher; bool errorOnMatchingFailure = true; mixin ContextSensitive; private bool _ignoreProperty = false; @property bool ignoreProperty(){ return _ignoreProperty||inContext==InContext.instantiated||inContext==InContext.passedToTemplateAndOrAliased; } @property void ignoreProperty(bool b)in{ assert(inContext!=InContext.instantiated||b); }body{ _ignoreProperty = b; } auto inoutRes = InoutRes.none; // TODO: is there a better way to do this? auto accessCheck = AccessCheck.all; this(Declaration m, bool strong=false, bool isfunlit=false)in{ assert(!!m); }body{ meaning = m; isStrong = strong; isFunctionLiteral = isfunlit; } void makeStrong(){ if(!isStrong) sstate = SemState.begin; isStrong = true; } void makeWeak(){ isWeak = true; } private enum CircErrMsg=q{if(circ){circErrMsg(); mixin(SemCheck);}}; private void circErrMsg()in{assert(!!circ);}body{ if(circ is this){ Scope errsc = scope_; if(!errsc.handler.showsEffect()){ foreach(x; clist) if(x.scope_.handler.showsEffect()){ // NOTE: the test suite does not cover this case errsc = x.scope_; break; }else if(x.meaning.scope_&&x.meaning.scope_.handler.showsEffect()){ errsc = x.meaning.scope_; break; } } // make emmitted circular dependency errors deterministic // (this is not strictly necessary, but it simplifies regression testing.) if(errsc.handler){ auto first = iota(0,clist.length).reduce!((a,b)=>clist[a].sourcePriority<clist[b].sourcePriority?a:b); clist = chain(clist[first..$],clist[0..first]).array; } //// errsc.error("circular dependencies are illegal",clist[0].loc); circ = null; mixin(SetErr!q{}); foreach_reverse(x; clist[1..$]){ // IFTI might spawn location-free identifiers if(x.loc.line) errsc.note("part of dependency cycle",x.loc); mixin(SetErr!q{x}); } meaning.needRetry = meaning.sstate != SemState.error && meaning.sstate != SemState.completed; clist=[]; }else{ needRetry = 2; clist~=this; } } static Symbol circ = null; private static Symbol[] clist = []; override Expression clone(Scope sc, InContext inContext, AccessCheck accessCheck, const ref Location loc){ auto r=ddup(); r.scope_ = null; r.sstate = SemState.begin; r.loc = loc; r.inContext = inContext; r.accessCheck = accessCheck; r.semantic(sc); return r; } override void semantic(Scope sc){ // dw("semantic: ",this," ",meaning.sstate," ", loc," ",cast(void*)meaning," ",meaning.loc," ",typeid(this.meaning)); debug scope(exit) assert(sstate != SemState.started||needRetry||rewrite,toString()~" "~typeid(this.meaning).toString()); debug scope(exit) assert(needRetry==2||!circ,toString()~" nR: "~to!string(needRetry)~" circ: "~to!string(circ)); mixin(SemPrlgDontSchedule); // if(inContext != InContext.fieldExp) Scheduler().add(this,sc); if(!scope_) scope_=sc; assert(meaning && scope_); if(needRetry) sstate = SemState.begin; needRetry = false; // be reentrant if(sstate >= SemState.started){ // template instances may depend circularly upon each other if(meaning.isTemplateInstanceDecl()){ if(meaning.sstate == SemState.started){ sstate = SemState.begin; needRetry = true; return; } } assert(!circ,toString()); circ = this; sstate = SemState.error; needRetry = 2; clist~=this; return; }else sstate = SemState.started; enum MeaningSemantic = q{ if(meaning.sstate != SemState.completed) meaning.semantic(meaning.scope_); mixin(Rewrite!q{meaning}); }; // resolve alias if(auto al=meaning.isAliasDecl()){ mixin(MeaningSemantic); mixin(CircErrMsg); mixin(SemCheck); mixin(SemProp!q{sc=meaning.scope_;meaning}); if(auto decl = al.simpleAliasedDecl()) meaning = decl; else{ // assert(!!al.aliasee.isType()); sstate = SemState.begin; auto r=al.getAliasee(scope_, accessCheck, inContext, loc); mixin(RewEplg!q{r}); } } alias util.any any; bool needParamDeduction = false; if(auto fd=meaning.isFunctionDecl()){ needParamDeduction=any!(_=>_.mustBeTypeDeduced())(fd.type.params); } if(isSymbolMatcher){ //assert(!!cast(SymbolMatcher)meaning,to!string(meaning)); if(meaning.isSymbolMatcher()){ meaning.semantic(scope_); mixin(CircErrMsg); if(meaning.rewrite) inoutRes = (cast(SymbolMatcher)cast(void*)meaning) .context.inoutRes; mixin(SemProp!q{sc=scope_;meaning}); if(auto sym=meaning.isSymbolMatcher()){ assert(sym.hasFailedToMatch()); if(errorOnMatchingFailure) sym.emitError(scope_); mixin(ErrEplg); } } isSymbolMatcher=false; }else if(isStrong){ if(!needParamDeduction){ // TODO: comprehensive treatment of error gagging if(isFunctionLiteral) meaning.semantic(scope_); else mixin(MeaningSemantic); mixin(CircErrMsg); mixin(SemProp!q{sc=scope_;meaning}); } } // those are not virtual functions because of centralized symbol dependency handling // TODO: make specific parts virtual functions of the relevant classes instead if(auto vd=meaning.isVarDecl()){ if(vd.stc & STCenum || (vd.init&&vd.stc&(STCimmutable|STCconst)&&vd.willInterpretInit())){ mixin(MeaningSemantic); mixin(CircErrMsg); mixin(SemProp!q{sc=meaning.scope_;meaning}); }else if(!vd.type){ mixin(MeaningSemantic); mixin(CircErrMsg); if(!vd.type) mixin(PropRetry!q{sc=meaning.scope_;meaning}); if(!vd.type) mixin(PropErr!q{sc=meaning.scope_;meaning}); } assert(!!vd.type); mixin(VarDecl.SymbolResolve); // this symbol is free-standing // if it is directly inside of an aggregate, then the // current function's this pointer type must apply if(inContext!=InContext.fieldExp) if(vd.scope_ && // (eg. delegate types do not have this) !(vd.stc&(STCstatic|STCenum))) if(auto decl=vd.scope_.getDeclaration()) if(decl.isAggregateDecl()) type = type.applyScopeSTC(sc); if(vd.stc&STCenum){ if(vd.init){ auto r=vd.init.cloneConstant(); r.loc = loc; mixin(RewEplg!q{r}); }else assert(meaning.sstate == SemState.error); } }else if(auto fd=meaning.isFunctionDecl()){ if(!needParamDeduction){ //if(fd.type.hasAutoReturn()){ // DMD 2.059 does this... if(fd.type.hasUnresolvedReturn()){ needRetry = false; mixin(MeaningSemantic); mixin(CircErrMsg); mixin(SemProp!q{sc=meaning.scope_;meaning}); }else fd.propagateSTC(); } fd.type.semantic(meaning.scope_); assert(!fd.rewrite); if(needParamDeduction) type = Type.get!void(); else type = fd.type; }else if(auto tm=meaning.isTemplateDecl()){ if(inContext==InContext.called){ auto s = New!Symbol(meaning); auto r = New!TemplateInstanceExp(s, (Expression[]).init); s.loc = r.loc = loc; s.accessCheck = accessCheck; r.willCall(); r.semantic(sc); mixin(RewEplg!q{r}); } type = Type.get!void(); }else if(auto tm=meaning.isTemplateInstanceDecl()){ // circular template instantiations are allowed // those just don't carry forward the information // whether the template compiled or not. if(tm.sstate != SemState.started){ mixin(MeaningSemantic); mixin(CircErrMsg); if(!isWeak) mixin(SemProp!q{sc=meaning.scope_;meaning}); } type=Type.get!void(); }else if(auto ov=meaning.isOverloadSet()){ foreach(ref x; ov.decls) if(auto fd = x.isFunctionDecl()){ fd.analyzeType(); mixin(Rewrite!q{fd.type}); mixin(CircErrMsg); if(auto nr=fd.type.needRetry) { Scheduler().await(this, fd.type, fd.scope_); needRetry = nr; return; } mixin(PropErr!q{fd.type}); assert(!fd.rewrite); } if(ov.count==1 && ov.decls.length){ // TODO: why does this not bypass sealing? if(auto fd=ov.decls[0].isFunctionDecl()){ meaning = fd; needRetry = 1; return semantic(sc); } }else foreach(ref x;ov.tdecls){ x.semantic(x.scope_); mixin(CircErrMsg); mixin(SemProp!q{sc=x.scope_;x}); } if(!type) type=Type.get!void(); // TODO: fix } else if(typeid(this.meaning) is typeid(ErrorDecl)){mixin(ErrEplg);} else type=Type.get!void(); // same as DMD mixin(CircErrMsg); mixin(SemProp!q{type}); assert(needParamDeduction||!meaning.isFunctionDecl()||(cast(FunctionTy)type).ret); if(auto at=meaning.isAggregateDecl()){ auto r = at.getType(); sstate = SemState.begin; mixin(RewEplg!q{r}); } if(auto et=meaning.isEnumDecl()){ auto r = et.getType(); sstate = SemState.begin; mixin(RewEplg!q{r}); } needRetry = false; if(inContext!=InContext.fieldExp && (!isFunctionLiteral || type !is Type.get!void() && !meaning.isFunctionDef().canBeStatic)) // TODO: coerce? { performAccessCheck(); mixin(SemCheck); } if(inoutRes!=InoutRes.none){sstate=SemState.completed;resolveInout(inoutRes);} if(isImplicitlyCalled()&&inContext!=InContext.fieldExp){ auto s = New!Symbol(meaning); s.loc = loc; s.accessCheck = accessCheck; s.ignoreProperty = true; auto args = Seq!(s,(Expression[]).init); auto r = meaning.stc&STCproperty?New!PropertyCallExp(args):New!CallExp(args); r.loc = loc; r.semantic(sc); mixin(RewEplg!q{r}); } // TODO: simple pointer-chain expression alias? if(!inContext.among(InContext.fieldExp,InContext.passedToTemplateAndOrAliased) && thisType() && maybeThisContext() && !meaning.isFunctionDecl().maybe!(a=>a.isConstructor()) && !meaning.isOverloadSet().maybe!(a=>a.isConstructor()) ){ auto t = New!ThisExp(); t.loc = loc; auto s = New!Symbol(meaning); s.loc = loc; s.accessCheck = accessCheck; s.ignoreProperty = ignoreProperty; auto r = New!(BinaryExp!(Tok!"."))(t,s); r.loc = loc; transferContext(r); r.semantic(sc); mixin(RewEplg!q{r}); } mixin(SemEplg); } final bool isImplicitlyCalled(){ return isImplicitlyCalled(inContext); } final bool isImplicitlyCalled(InContext inContext){ Declaration implcalldecl = meaning.isFunctionDecl(); if(!implcalldecl) if(auto ov=meaning.isOverloadSet()) if(ov.hasFunctions()) implcalldecl=meaning; bool implicitCall; switch(inContext) with(InContext){ case called, addressTaken, instantiated, passedToTemplateAndOrAliased, fieldExp: implicitCall=false; break; default: implicitCall=true; } return implcalldecl && (implicitCall || !ignoreProperty && meaning.stc&STCproperty); } string accessError(){ // TODO: better error message? if(meaning.scope_.getDeclaration().isFunctionDef()) return format("cannot access the frame in which '%s' is stored", loc.rep); else{ // error message duplicated in FieldExp.semantic return format("need 'this' to access %s '%s'",kind,loc.rep); } } void performAccessCheck() in{assert(meaning && scope_);}body{ auto decl = scope_.getDeclaration(); // it is necessary to perform the check in order to get // the correct type deduction, even if we are not interested // in the actual accessibility if(meaning.needsAccessCheck(accessCheck)){ mixin(IsDeclAccessible!q{auto b; Declaration, decl, meaning}); if(!b){ scope_.error(accessError(), loc); scope_.note(format("%s was declared here",kind),meaning.loc); mixin(ErrEplg); } } } invariant(){ assert(!meaning||meaning.name !is this, text(typeid(this.meaning)," ",meaning.loc)); } override string toString(){ auto tmpl=meaning.isTemplateInstanceDecl(); if(!tmpl){ if(auto nsts=cast(NestedScope)meaning.scope_) if(auto tmps=cast(TemplateScope)nsts.parent) tmpl=tmps.tmpl; } if(!meaning.name) return "(symbol)"; // TODO: properly display alias delegate literal symbols if(tmpl && meaning.name.name==tmpl.name.name) return meaning.name.name~"!("~join(map!(to!string)(tmpl.args),",")~")"; return meaning.name.toString(); } override @property string kind(){return meaning.kind;} // TODO: maybe refactor override Scope getMemberScope(){ if(auto tmpl=meaning.isTemplateInstanceDecl()) return tmpl.bdy.scope_; if(auto nspace=meaning.isNamespaceDecl()) return nspace.sc; return super.getMemberScope(); } Type thisType(){ if(!(meaning.stc&STCstatic)||meaning.isOverloadSet()) if(meaning.scope_) // eg. parameters inside function types if(auto decl=meaning.scope_.getDeclaration()) if(auto aggr=decl.isAggregateDecl()) return aggr.getType(); return null; } //// override Expression extractThis(){ if(meaning.isTemplateInstanceDecl()||meaning.isNamespaceDecl()) return null; return this; } final Type maybeThisContext(){ // (similar code in semantic, TODO: can some of it be factored out?) if(inContext==InContext.fieldExp) return null; Declaration mfun=null; for(auto decl=scope_.getDeclaration(); decl&&!decl.isAggregateDecl(); decl=decl.scope_.getDeclaration()) { if(decl.stc&STCstatic) return null; mfun=decl; } if(!mfun||!mfun.isFunctionDecl()) return null; if(auto aggr=scope_.getAggregate()) return aggr.getType().applyScopeSTC(scope_); return null; } override AccessCheck deferredAccessCheck(){ if(meaning.isTemplateInstanceDecl()||meaning.isNamespaceDecl()) return accessCheck; return super.deferredAccessCheck(); } override bool isConstant(){ assert(!!meaning,toString()); //if(meaning.stc|STCstatic) return true; if(auto vd = meaning.isVarDecl()) return vd.stc&STCenum || vd.stc&(STCimmutable|STCconst) && vd.init && vd.init.isConstant(); if(auto vd = meaning.isFunctionDecl()) return true; return false; } override bool isConstFoldable(){ if(auto vd = meaning.isVarDecl()) return !!(vd.stc&STCenum); return false; } // DMD 2.058/2.059 behave approximately like this: /+override bool typeEquals(Type rhs){ if(meaning.stc&STCenum) if(auto vd = meaning.isVarDecl()) return vd.init.typeEquals(rhs); return super.typeEquals(rhs); }+/ // override Type isType(){...} // TODO. override bool isLvalue(){ if(meaning.isTmpVarDecl()) return !!(meaning.stc&STCref); if(!(meaning.stc&STCrvalue) && meaning.isVarDecl()) return true; if(auto ov=meaning.isOverloadSet()) return !!ov.decls.length; return !!meaning.isFunctionDecl(); } override bool checkMutate(Scope sc, ref Location l){ if(meaning.stc&STCproperty) return true; return super.checkMutate(sc, l); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ if(!scope_) scope_=sc; assert(meaning && scope_); if(meaning.isVarDecl()) return super.matchCallHelper(sc, loc, this_, args, context); if(!this_) this_ = maybeThisContext(); mixin(MatchCall!q{auto m; meaning, sc, loc, this_, this, args, context}); if(m){ mixin(Rewrite!q{m}); // resolve the overload in place and then rely on // semantic to catch eventual circular dependencies: meaning = m; isSymbolMatcher=!!meaning.isSymbolMatcher(); sstate = SemState.begin; type = null; Symbol.semantic(scope_); assert(!rewrite||cast(Expression)rewrite); return (cast(Expression)cast(void*)(rewrite?rewrite:this)).independent; } return super.matchCallHelper(sc, loc, this_, args, context); } override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ if(!this_) this_ = maybeThisContext(); if(meaning.isVarDecl()) return super.matchError(sc, loc, this_, args); meaning.matchError(sc,loc,this_,args); } import vrange; override IntRange getIntRange(){ if(auto vd=meaning.isVarDecl()){ if(vd.stc&STCenum || vd.stc&STCstatic&&vd.stc&STCimmutable) return vd.init.getIntRange(); } return super.getIntRange(); } override LongRange getLongRange(){ if(auto vd=meaning.isVarDecl()){ if(vd.stc&STCenum || vd.stc&STCstatic&&vd.stc&STCimmutable) return vd.init.getLongRange(); } return super.getLongRange(); } mixin DownCastMethod; //mixin Interpret!Symbol; mixin Visitors; Scope scope_; // TemplateDecl needs this. override bool tmplArgEquals(Expression rhs){ if(auto sym = rhs.isSymbol()){ auto decl = scope_.getDeclaration(); auto sdecl = sym.scope_.getDeclaration(); return meaning is sym.meaning && Declaration.isDeclAccessible(decl, meaning).force == Declaration.isDeclAccessible(sdecl, meaning).force; } return false; } override size_t tmplArgToHash(){ import hashtable; return FNV(meaning.toHash()); } } import visitors; enum Match{ none, convert, convConst, exact, } enum InoutRes{ none, mutable, immutable_, const_, inout_, inoutConst, // inout(const(T)) } // enum member functions would be nice InoutRes mergeIR(InoutRes ir1, InoutRes ir2){ with(InoutRes){ if(ir1 == ir2 || ir2 == none) return ir1; if(ir1 == none) return ir2; if(ir1.among(inout_,const_,inoutConst) && ir2.among(inout_,const_,inoutConst)) return InoutRes.inoutConst; return InoutRes.const_; } } InoutRes irFromSTC(STC stc){ if(stc&STCimmutable) return InoutRes.immutable_; else if(stc&STCconst){ if(stc&STCinout) return InoutRes.inoutConst; else return InoutRes.const_; }else if(stc&STCinout) return InoutRes.inout_; else return InoutRes.mutable; } struct MatchContext{ auto inoutRes = InoutRes.none; auto match = Match.exact; } class UFCSCallExp: CallExp{ mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==UFCSCallExp)){ this(Expression exp, Expression this_, bool incomplete)in{ assert(exp.isSymbol() || exp.isType()); assert(exp.sstate == SemState.completed); }body{ super(exp, [this_]); this.incomplete = incomplete; } bool incomplete; final void moreArgs(Expression[] margs)in{ assert(incomplete); }body{ args~=margs; incomplete = false; sstate = SemState.begin; } final void instantiate(TemplateInstanceExp e, bool stillIncomplete)in{ assert(incomplete); //assert(e.sstate == SemState.completed && e.inContext == InContext.called); }body{ e.loc=this.e.loc.to(e.loc); this.e=e; incomplete=stillIncomplete; if(!incomplete) sstate = SemState.begin; } override void semantic(Scope sc){ if(incomplete){ type = Type.get!void(); mixin(SemEplg); } super.semantic(sc); } override @property string kind(){ return "UFCS function call"; } override string toString(){ // assert(e.toString().startsWith(".")); // TODO: fix ('this' rewrite might kill this) return args[0].toString()~e.toString()~"("~join(map!(to!string)(args[1..$]),",")~")"; } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ if(!incomplete) return super.matchCallHelper(sc,loc,this_,args,context); // TODO: this allocates //if(e.sstate != SemState.completed) return this.independent!Expression; // TODO: this is a hack auto nargs=this.args~args; e.semantic(sc); if(e.needRetry||e.sstate==SemState.error) return Dependee(e,null).dependent!Expression; mixin(MatchCallHelper!q{auto m; e,sc,loc,this_,nargs,context}); if(!m) return null.independent!Expression; if(m.sstate == SemState.completed) return this.independent!Expression; static class MatchCallWhenReady: Expression{ Expression exp; Expression[] nargs; this(Expression e, const ref Location l, Expression[] nargs){ exp = e; loc = l; this.nargs=nargs; } override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{exp}); Expression r; auto f=exp; if(exp.isType()) r=exp; else{ mixin(MatchCall!q{r; exp, sc, loc, nargs}); if(!r) mixin(ErrEplg); } if(rewrite) return; // TODO: ok? r = New!UFCSCallExp(r,nargs[0],true); r.loc = loc; r.semantic(sc); mixin(RewEplg!q{r}); } override string toString(){ return exp.toString(); } } auto r = New!MatchCallWhenReady(m, loc, nargs); r.semantic(sc); return r.independent!Expression; } } // aware of circular dependencies mixin template Semantic(T) if(is(T==CallExp)){ Expression argsLeftover=null; override void noHope(Scope sc){ mixin(RevEpoNoHope!q{e}); } // This is somewhat hacky private void constructorRewrite(Scope sc){ if(auto ty=e.isType()) if(auto aggrty=ty.getUnqual().isAggregateTy()) if(auto strd=aggrty.decl.isStructDecl()){ // TODO: could re-use the callexp as the consCall field auto r = New!StructConsExp(ty, args); r.argsLeftover=argsLeftover; r.loc = loc; if(tmpVarDecl) r.initOfVar(tmpVarDecl); r.semantic(sc); mixin(RewEplg!q{r}); } } private enum ConstructorRewrite = q{ constructorRewrite(sc); if(rewrite) return; }; override void semantic(Scope sc){ // TODO: type checking // parameter passing mixin(SemPrlg); mixin(RevEpoLkup!q{e}); e.willCall(); mixin(SemChldPar!q{e}); mixin(SemChldExp!q{args}); mixin(PropErr!q{e}); // eg. 1.foo(2), will be rewritten to .foo(1)(2) // this completes the rewrite to .foo(1,2) if(auto r=e.isUFCSCallExp()){ if(r.incomplete){ r.moreArgs(args); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } } mixin(ConstructorRewrite); if(fun is null){ mixin(MatchCall!q{fun; e, sc, loc, args}); // TODO: opCall if(fun is null) mixin(ErrEplg); } mixin(SemChld!q{fun}); mixin(SemProp!q{e}); // catch errors generated in matchCall TODO: still relevant? mixin(ConstructorRewrite); //dw(sstate," ",map!(a=>a.needRetry)(args),args); assert(fun && fun.type); auto tt = fun.type.getHeadUnqual().getFunctionTy(); if(!tt){ // fun was rewritten (eg. @property call, class template) // TODO: opCall mixin(MatchCall!q{fun; fun, sc, loc, args}); assert(fun is null); mixin(ErrEplg); } // TODO: this might be somewhat fragile; make 'reset' // a member function and implement manually where needed static struct Reset{ void perform(Symbol self){ self.scope_=null; self.sstate=SemState.begin; } void perform(Node self){ if(auto e=self.isExpression()) if(e.isType()) return; self.sstate=SemState.begin; } } if(adapted is null) foreach(i,x; tt.params[0..args.length]){ if(x.stc & STClazy){ if(adapted is null) adapted = new Expression[args.length]; else if(adapted[i]) continue; auto vt=Type.get!void(); if(x.type.getHeadUnqual() is vt){ auto narg=New!CastExp(STC.init,vt,args[i]); narg.loc=args[i].loc; args[i]=narg; } auto ft = New!FunctionTy(STC.init,args[i].type,cast(Parameter[])[],VarArgs.none); auto bs = New!BlockStm(cast(Statement[])[New!ReturnStm(args[i])]); // TODO: gc allocates [] auto dg = New!FunctionLiteralExp(ft,bs,FunctionLiteralExp.Kind.delegate_); bs.loc = dg.loc = args[i].loc; adapted[i] = dg; runAnalysis!Reset(args[i]); } } foreach(ref x;adapted) if(x) mixin(SemChld!q{x}); type = tt.ret; if(tt.params.length > args.length){ // default arguments import util: all; assert(all!(a=>a.init !is null)(tt.params[args.length..$])); // TODO: this allocates rather heavily args~=map!(a=>a.init.ddup)(tt.params[args.length..$]).array; foreach(ref arg;args) runAnalysis!Reset(arg); // TODO: replace 'this'-expressions suitably } foreach(i,x; tt.params[0..args.length]){ auto pty = x.type; args[i]=args[i].implicitlyConvertTo(pty); } mixin(SemChld!q{args}); mixin(ConstFold!q{e}); foreach(ref x; args) mixin(ConstFold!q{x}); // call expressions may create temporary variables mixin(NoRetry); sstate=SemState.completed; if(!tmpVarDecl){ if(!(tt.stc&STCbyref)) if(auto aggrty=type.getHeadUnqual().isAggregateTy()) if(aggrty.decl.isValueAggregateDecl()) return createTemporary(sc); if(type.getHeadUnqual().isTypeTuple()) return createTemporary(sc); } // mixin(SemEplg); // not necessary, since NoRetry called above } override bool isLvalue(){ assert(!!fun.type.getHeadUnqual().getFunctionTy()); return !!(fun.type.getHeadUnqual().getFunctionTy().stc & STCref); } override @property string kind(){ return "function call result"; } Expression fun; Expression[] adapted; } class PropertyCallExp: CallExp{ this(Expression exp, Expression[] args){ super(exp,args); } override string toString(){ return _brk(!args.length?e.toString():e.toString()~(args.length==1?args[0].toString():"Seq!("~join(map!(to!string)(args),",")~")")); } override @property string kind(){ return "@property call"; } } // everything concerning error gagging is centralized here import error; class GaggingErrorHandler: ErrorHandler{ static opCall(){static GaggingErrorHandler instance; return instance?instance:(instance=New!GaggingErrorHandler());} override void error(lazy string, Location){ nerrors++; } override void note(lazy string, Location){ /* do nothing */ } override void message(string msg){ /* do nothing */ } /* for errors that span gagging boundaries, this is important information */ override bool showsEffect(){ return false; } } class GaggingScope: NestedScope{ this(Scope parent){super(parent);} override @property ErrorHandler handler(){return GaggingErrorHandler();} override bool insert(Declaration decl){ // cannot insert into gagging scope // probably this will never happen return false; } override void error(lazy string, Location){ /* do nothing */ } override void note(lazy string, Location){ /* do nothing */ } // forward other members: protected override Dependent!Declaration lookupImpl(Scope view, Identifier ident){ return parent.lookupImpl(view, ident); } protected override Dependent!Declaration lookupHereImpl(Scope view, Identifier ident, bool ignoreImports){ return parent.lookupHereImpl(view, ident, ignoreImports); } protected override Dependent!IncompleteScope getUnresolvedImpl(Scope view, Identifier ident, bool onlyMixins, bool noHope=false){ return parent.getUnresolvedImpl(view, ident, onlyMixins, noHope); } protected override bool inexistentImpl(Scope view, Identifier ident){ return parent.inexistentImpl(view, ident); } override FunctionDef getFunction(){return parent.getFunction();} } class GaggingRecordingErrorHandler: GaggingErrorHandler{ override void error(lazy string err, Location loc){ nerrors++; records~=ErrorRecord(err,loc,RecordKind.error); } override void note(lazy string err, Location loc){ records~=ErrorRecord(err,loc,RecordKind.note); } override void message(string err){ records~=ErrorRecord(err,Location.init,RecordKind.message); } void replay(ErrorHandler h){ foreach(r;records) (r.kind==RecordKind.message?h.message(r.err): (r.kind==RecordKind.note?&h.note:&h.error)(r.err,r.loc)); } private: enum RecordKind{ error, note, message } static struct ErrorRecord{ string err; Location loc; RecordKind kind; } ErrorRecord[] records; } class GaggingRecordingScope: GaggingScope{ private GaggingRecordingErrorHandler _handler; this(Scope parent){ _handler = New!GaggingRecordingErrorHandler(); super(parent); } override @property ErrorHandler handler(){ return _handler; } void replay(Scope sc){ _handler.replay(sc.handler); } } mixin template Semantic(T) if(is(T==CastExp)){ protected Dependent!bool checkConv(Scope sc){ // TODO: this requires some code duplication in ImplicitCastExp. Better solutions? mixin(ConvertsTo!q{bool conv; e, type}); if(!conv){ auto oe=e; relaxCastedExpression(); if(oe !is e){ mixin(ConvertsTo!q{auto cc; e, type}); conv=cc; } } if(conv) return true.independent; sc.error(format("cannot cast expression '%s' of type '%s' to '%s'",e.loc.rep,e.type,type),e.loc); //error(format("no viable conversion from type '%s' to '%s'",e.type,type),e.loc); return false.independent; } final protected void relaxCastedExpression(){ if(e.type.isSomeString()) return; if(auto el=e.type.getElementType()) if(auto lit=e.isLiteralExp()) e=lit.toArrayLiteral(); } protected void displayFunctionLiteralConversionError(Scope sc){ sc.error(format("cannot cast function literal to '%s'",type.toString()),loc); } //mixin(DownCastMethods!ImplicitCastExp); ImplicitCastExp isImplicitCastExp(){return null;} override void semantic(Scope sc){ // TODO: sanity checks etc. mixin(SemPrlg); mixin(SemChldExp!q{e}); // TODO: check if rewrite to implicit conversion required if(!ty) { // TODO: works differently for classes..? type = e.type.getHeadUnqual().applySTC(stc); }else{ type=ty.typeSemantic(sc); mixin(SemProp!q{ty}); type=type.applySTC(stc); } // implicitly typed delegate literals convert to both function and // delegate. furthermore, (implicit) casts can be used to determine // the argument types // this is done before the conversion sanity check in order to get // better error messages // TODO: this is heavy fp style. is there a better design? if(auto uexp = e.isAddressExp() ){ // TODO: reduce the DMD bug if(auto sym = uexp.e.isSymbol() ){ if(auto fd = sym.meaning.isFunctionDef() ){ if(sym.type is Type.get!void()){ if(auto fty=type.getHeadUnqual().getFunctionTy()){ // the scope in which the type is resolved might // be different from the initial scope: fd.rescope(sc); // eg. matching overloads fd.type.resolve(fty); uexp.sstate = sym.sstate = SemState.begin; mixin(SemChld!q{e}); }else{ displayFunctionLiteralConversionError(sc); mixin(SetErr!q{fd}); mixin(ErrEplg); } } if(auto dg = type.getHeadUnqual().isDelegateTy()){ if(fd.stc&STCstatic && fd.inferStatic){ assert(sym.isStrong && uexp.type.getFunctionTy()); mixin(ImplConvertsTo!q{ bool delegaterequested; uexp.type.getFunctionTy().getDelegate() , dg }); if(delegaterequested){ fd.addContextPointer(); uexp.sstate = sym.sstate = SemState.begin; } } } }}} mixin(SemChld!q{e}); mixin CreateBinderForDependent!("CheckConv"); mixin(CheckConv!q{bool conversionLegal; this, sc}); if(!conversionLegal) mixin(ErrEplg); auto el = type.getElementType(); if(el && el.getHeadUnqual() !is Type.get!void()){ if(auto al = e.isArrayLiteralExp()){ al.sstate = SemState.begin; al.type = null; foreach(ref x; al.lit) x=x.convertTo(el); mixin(SemChld!q{e}); if(e.type !is type && e.type.getElementType() is type.getElementType()){ e.type = type; } if(e.type is type) mixin(RewEplg!q{e}); } } if(auto te = e.isTernaryExp()){ e.sstate = SemState.begin; te.e2=te.e2.convertTo(type); te.e3=te.e3.convertTo(type); mixin(SemChld!q{e}); if(e.type is type) mixin(RewEplg!q{e}); } mixin(SemEplg); } override bool isConstant(){ if(sstate == SemState.error) return false; assert(sstate == SemState.completed); if(type.getHeadUnqual().isPointerTy() || e.type.getHeadUnqual().isPointerTy()) return false; // TODO! auto iconvd=e.type.implicitlyConvertsTo(type); assert(!iconvd.dependee); // this fact has already been determined at this point. if(iconvd.value) return e.isConstant(); if(type.getHeadUnqual().isPointerTy()) return false; if(type.getHeadUnqual() is Type.get!void()) return false; return e.isConstant(); } override bool isConstFoldable(){ if(sstate == SemState.error) return false; assert(sstate == SemState.completed); if(type.getHeadUnqual().isPointerTy() || e.type.getHeadUnqual().isPointerTy()) return false; // TODO! auto iconvd=e.type.implicitlyConvertsTo(type); assert(!iconvd.dependee); // this fact has already been determined at this point. if(iconvd.value) return e.isConstFoldable(); if(type.getHeadUnqual() is Type.get!void()) return false; return e.isConstFoldable(); } override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t;//TODO: does this work out correctly? return e.implicitlyConvertsTo(rhs); } override Expression implicitlyConvertTo(Type rhs){ if(!super.implicitlyConvertsTo(rhs).force){ // TODO: FIX!!! e=e.implicitlyConvertTo(rhs); return e; }else return super.implicitlyConvertTo(rhs); } private IntRange getBoolRange(BasicType ty){ int osiz = ty.bitSize(); bool t,f; if(osiz==32){ auto r = e.getIntRange(); f = r.min==0 && r.max==0; t = !r.contains(IntRange(0,0,r.signed)); }else{ auto r = e.getLongRange(); f = r.min==0 && r.max==0; t = !r.contains(LongRange(0,0,r.signed)); } return t ? IntRange(1,1,true) : f ? IntRange(0,0,true) : IntRange(0,1,true); } override IntRange getIntRange(){ auto ty = e.type.getHeadUnqual().isIntegral(); auto nt = type.getHeadUnqual().isIntegral(); if(!ty||!nt) return type.getIntRange(); if(nt is Type.get!bool()) return getBoolRange(ty); int size=nt.bitSize(); int osiz=ty.bitSize(); bool signed=nt.isSigned(); if(size<osiz){ // narrowing conversion if(osiz==64){ auto r = e.getLongRange(); return r.narrow(signed, size); }else{ auto r = e.getIntRange(); return r.narrow(signed, size); } }else{ // non-narrowing conversion assert(osiz<64); auto r=e.getIntRange(); if(signed) r=r.toSigned(); else r=r.toUnsigned(); return r; } } override LongRange getLongRange(){ auto ty = e.type.getHeadUnqual().isIntegral(); auto nt = type.getHeadUnqual().isIntegral(); if(!ty||!nt) return type.getLongRange(); int size=nt.bitSize(); int osiz=ty.bitSize(); bool signed=nt.isSigned(); LongRange r; if(osiz==64) r=e.getLongRange(); else{ assert(osiz<=32); auto or=e.getIntRange(); ulong min, max; if(or.signed) min=cast(int)or.min, max=cast(int)or.max; else min = or.min, max = or.max; r=LongRange(min, max, true); } if(signed) r=r.toSigned(); else r=r.toUnsigned(); return r; } } class ImplicitCastExp: CastExp{ this(Expression tt, Expression exp){super(STC.init, tt, exp);} protected override Dependent!bool checkConv(Scope sc){ mixin(ImplConvertsTo!q{bool iconv; e, type}); if(!iconv){ auto oe=e; relaxCastedExpression(); if(oe !is e){ mixin(ImplConvertsTo!q{auto cc; e, type}); iconv=cc; } } if(iconv) return true.independent; sc.error(format("cannot implicitly convert %s '%s' of type '%s' to '%s'",e.kind,e.loc.rep,e.type,type),e.loc); // TODO: replace toString with actual representation return false.independent; } protected override void displayFunctionLiteralConversionError(Scope sc){ sc.error(format("cannot implicitly convert function literal to '%s'",type.toString()),loc); } mixin DownCastMethod; /+ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{e}); auto tt=ty.semantic(sc); mixin(PropRetry!q{tt}); type = tt.isType(); assert(!!type); // if not a type the program is in error mixin(PropErr!q{type}); if(e.implicitlyConvertsTo(type)){mixin(SemEplg);} sc.error(format("cannot implicitly convert expression '%s' of type '%s' to '%s'",e.loc.rep,e.type,type),e.loc); // TODO: replace toString with actual representation //error(format("no viable conversion from type '%s' to '%s'",e.type,type),e.loc); mixin(ErrEplg); } +/ override string toString(){return e.toString();} override string kind(){return e.toString();} } class TmpVarDecl: VarDecl{ override void presemantic(Scope sc){ if(sstate != SemState.pre) return; scope_ = sc; sstate = SemState.begin; } this(STC stc, Expression rtype, Identifier name, Expression initializer){ super(stc, rtype, name, initializer); } override void handleRef(Scope sc){ return actuallyHandleRef(sc); } override TmpVarDecl newVarDecl(STC stc, Expression rtype, Identifier name, Expression init){ return New!TmpVarDecl(stc,rtype,name,init); } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==TmpVarDecl)){ } class TmpVarExp: Expression{ Expression e; TmpVarDecl tmpVarDecl; Expression sym; this(Expression e)in{assert(e&&e.sstate==SemState.completed);}body{ this.e=e; } void initTmpVarDecl(Scope sc,bool forceRvalue)in{assert(!tmpVarDecl);}body{ assert(e&&!sym); tmpVarDecl = New!TmpVarDecl(!forceRvalue&&e.isLvalue()?STCref:STC.init,null,null,e); tmpVarDecl.presemantic(sc); sym = New!Symbol(tmpVarDecl); sym.loc = loc; e = null; } void semantic(Scope sc){ mixin(SemPrlg); if(!tmpVarDecl) initTmpVarDecl(sc,false); mixin(SemChld!q{tmpVarDecl, sym}); type = Type.get!void(); mixin(SemEplg); } override @property string kind(){ return tmpVarDecl.init.kind; } override string toString(){ return tmpVarDecl.init.toString(); } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==TmpVarExp)){ } abstract class TemporaryExp: Expression{ VarDecl tmpVarDecl; //protected bool builtTmpVarDecl = false; override void initOfVar(VarDecl decl){ assert(!tmpVarDecl||tmpVarDecl is decl); if(!(decl.stc&STCenum)) tmpVarDecl = decl; } void createTemporary(Scope sc)in{assert(sstate==SemState.completed);}body{ auto tmpe=New!TmpVarExp(sdup()); tmpe.loc=loc; tmpe.semantic(sc); auto r=New!(BinaryExp!(Tok!","))(tmpe,tmpe.sym); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==TemporaryExp)){} class StructConsExp: TemporaryExp{ Expression[] args; Expression argsLeftover; Identifier constructor; CallExp consCall; bool contextIsNull = false; invariant(){ assert(cast(AggregateTy)(cast()type).getUnqual()&&cast(StructDecl)(cast(AggregateTy)(cast()type).getUnqual()).decl);} private @property StructDecl strd(){ return cast(StructDecl)cast(void*)(cast(AggregateTy)cast(void*)type.getUnqual()).decl; } this(Type type, Expression[] args)in{ auto strty = cast(AggregateTy)type.getUnqual(); assert(strty&&cast(StructDecl)strty.decl); }body{ this.type=type; this.args=args; } override void semantic(Scope sc){ assert(!!type); mixin(SemPrlg); mixin(SemChld!q{args}); // TODO: static opCall mixin(ResolveConstructor); sstate = SemState.completed; needRetry = false; //analyzeTemporary(sc, STC.init); if(!tmpVarDecl){ auto ne=New!StructConsExp(type, args); ne.argsLeftover=argsLeftover; ne.loc=loc; createTemporary(sc); } mixin(SemCheck); mixin(SemEplg); } override @property string kind(){ return "struct literal"; } override string toString(){ return strd.name.toString()~"("~join(map!(to!string)(args),",")~leftoverToString(args,argsLeftover)~")"; } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==StructConsExp)){} enum ResolveConstructor = q{ static if(is(typeof(this)==NewExp)){ alias a2 args; auto caggr = aggr.decl; alias a2Leftover argsLeftover; }else auto caggr = strd; // TODO: struct default constructors mixin(IsDeclAccessible!q{bool b; Declaration, sc.getDeclaration, caggr}); if(!b){ // TODO: these errors must be delayed for struct fields auto parent=caggr.scope_.getDeclaration(); assert(parent.isFunctionDecl()|| parent.isReferenceAggregateDecl()&&caggr.isClassDecl()); static if(is(typeof(this)==NewExp)){ if(parent.isFunctionDecl()){ sc.error(format("cannot construct local %s '%s' outside of its frame", caggr.kind, caggr.name), loc); }else{ sc.error(format("need 'this' pointer of type '%s' to construct nested class '%s'",parent.name, caggr.name), loc); } mixin(ErrEplg); }else{ static assert(is(typeof(this)==StructConsExp)); // TODO: new expression should do this as well contextIsNull = true; } } if(!caggr.isStructDecl()||args.length){ // implicit default constructor if(!constructor){ constructor = New!Identifier("this"); constructor.recursiveLookup = false; constructor.willCall(); } if(!constructor.meaning){ mixin(Lookup!q{_; constructor, sc, caggr.asc}); if(auto nr=constructor.needRetry) { needRetry = nr; return; } } } if(!constructor||constructor.sstate == SemState.failed){ // no constructor for type // TODO: disabled default constructor // TODO: default constructor. (remember to make sure that invisible constructors are respected for the decision whether to create default constructors for structs) if(args.length){ sc.error("too many arguments to "~kind~" (expected zero)",loc); mixin(ErrEplg); } }else{ // nested classes cannot be built like this //if(caggr.isReferenceAggregateDecl()) MatchContext context; mixin(SemChld!q{constructor}); mixin(MatchCallHelper!q{auto r; constructor, sc, loc, type, args, context}); // TODO: assert that we have actually found a constructor if(!r){ //sc.error("no matching constructor found", loc); constructor.matchError(sc,loc,type,args); mixin(ErrEplg); } if(!consCall){ consCall = New!CallExp(constructor, args); consCall.argsLeftover = argsLeftover; consCall.fun = r; consCall.loc = loc; } mixin(SemChld!q{consCall}); assert(constructor.meaning.isFunctionDecl()&& constructor.meaning.isFunctionDecl().isConstructor()); mixin(SemChld!q{constructor}); } }; mixin template Semantic(T) if(is(T==NewExp)){ Identifier constructor; CallExp consCall; Scope scope_; Expression a2Leftover; override void semantic(Scope sc){ mixin(SemPrlg); scope_ = sc; if(a1.length){ sc.error("custom allocators are unsupported", a1[0].loc.to(a1[$-1].loc)); mixin(ErrEplg); } // perform new T[i] => new T[](i) transformation if(auto ie=rty.isIndexExp()){ if(ie.a.length>1){ sc.error("dynamic arrays can only have one dimension", ie.a[0].loc.to(ie.a[$-1].loc)); mixin(ErrEplg); } if(ie.a.length==1){ if(a2.length>0){ sc.error("no further arguments expected", a2[0].loc.to(a2[$-1].loc)); mixin(ErrEplg); } swap(ie.a, a2); } } type = rty.typeSemantic(sc); mixin(SemChld!q{a2}); mixin(SemProp!q{rty}); auto tyu = type.getUnqual(); if(auto da=tyu.isDynArrTy()){ if(!a2.length){ sc.error("expected array length argument", loc); mixin(ErrEplg); } auto d2=da; int actual = 0; foreach(x;1..a2.length){ d2=d2.ty.isDynArrTy(); assert(actual<int.max); actual++; if(!d2) break; } if(!d2){ sc.error(format("too many arguments to new expression (expected at most %s)",toEngNum(actual)),loc); mixin(ErrEplg); } }else if(auto aggr=tyu.isAggregateTy()){ if(!aggr.decl.isReferenceAggregateDecl()) type = type.getPointer(); if(auto iface=aggr.decl.isInterfaceDecl()){ sc.error(format("cannot create instance of interface '%s'",iface.name),loc); mixin(ErrEplg); }else if(!aggr.decl.bdy){ sc.error(format("cannot create instance of incomplete %s '%s'",aggr.decl.kind,aggr.decl.name),loc); mixin(ErrEplg); } mixin(ResolveConstructor); }else{ if(a2.length>1){ sc.error("too many arguments to new expression (expected at most one)",loc); mixin(ErrEplg); } if(a2.length) mixin(ImplConvertTo!q{a2[0], type}); type = type.getPointer(); } mixin(SemEplg); } override void noHope(Scope sc){ if(constructor&&!type.isAggregateTy().decl.asc.inexistent(sc,constructor)) mixin(ErrEplg); } override bool isUnique(){ return true; } // TODO: need to ensure strong purity of constructor! } mixin template Semantic(T) if(is(T==Identifier)){ /* specifies whether or not to resume lookup recursively in parent scopes if it fails in the initially given scope. */ bool recursiveLookup = true; /* specifies whether this identifier should ignore imported scopes other than template mixins. */ bool onlyMixins = false; // TODO: merge those two bools into one bit field override void semantic(Scope sc){ if(!meaning) lookupSemantic(sc, sc); else super.semantic(sc); } final protected void lookupSemantic(Scope sc, Scope lkup)in{ assert(!meaning); }body{ mixin(SemPrlg); assert(sstate != SemState.failed); ///lookup(lkup); mixin(Lookup!q{_;this,sc,lkup}); if(needRetry) return; if(sstate == SemState.failed){ sc.error(format("undefined identifier '%s'",name), loc); mixin(ErrEplg); } super.semantic(sc); } /* looks up the given identifier in the scope given by the argument. + if needRetry is set after the call, then the lookup should be retried later + if sstate is SemState.failed after the call, then the lookup failed + if the lookup succeeds, then 'meaning' will become initialized */ final Dependent!void lookup(Scope sc, Scope lkup)in{ assert(!!lkup); assert(!meaning && sstate != SemState.error && sstate != SemState.failed, text(meaning," ",sstate)); }out{ if(!needRetry && sstate != SemState.error && sstate != SemState.failed) assert(meaning && meaning.scope_,text(this)); }body{ enum SemRet = q{ return indepvoid; }; //needRetry = false; // TODO: why was this here? needRetry = true; if(allowDelay){ sstate=SemState.begin; // reset if(recursiveLookup) mixin(Lookup!q{meaning; lkup, sc, this}); else mixin(LookupHere!q{meaning; lkup, sc, this, onlyMixins}); if(!meaning){ // TODO: get rid of this. (It is required because of memory re-use.) // This can be removed when unresolved scopes will no longer be their own // abstraction. if(unresolved) unresolved = lkup.getUnresolved(sc, this, onlyMixins, false).force; if(unresolved){ auto l = unresolved.potentialLookup(sc,this); if(l.length){ needRetry = true; unresolved = null; return multidep(cast(Node[])l).dependent!void; } if(!unresolved.inexistent(sc,this)) mixin(ErrEplg); unresolved = null; tryAgain = true; } sstate = SemState.started; mixin(RetryBreakEplg); }else if(typeid(this.meaning) is typeid(DoesNotExistDecl)){ meaning = null; needRetry=false; sstate = SemState.failed; }else{ needRetry=false; tryAgain = true; } }else{ if(sstate == SemState.started){ needRetry = true; tryAgain = true; mixin(GetUnresolved!q{unresolved;lkup,sc,this,onlyMixins,false}); } sstate = SemState.begin; mixin(RetryEplg); } unresolved = null; return indepvoid; // lkup.note(text("looked up ", this, " as ", meaning), loc); } /* performs reverse eponymous lookup for eponymous templates eg. T foo(T)(T arg){return foo!T(arg);} and eg. double foo(T)(T arg){return foo(2.0);} should compile */ final Expression reverseEponymousLookup(Scope sc)in{ assert(!!meaning); assert(sstate != SemState.error); assert(recursiveLookup); }body{ if(auto nest=cast(NestedScope)meaning.scope_){ if(auto tmpl=cast(TemplateScope)nest.parent){ if(tmpl.tmpl.name.name is name){ auto parent = New!LookupIdentifier(name,tmpl.tmpl.scope_); parent.loc = loc; parent.recursiveLookup = false; return parent; } } } return this; } override void noHope(Scope sc){ if(meaning) return; auto unresolved=sc.getUnresolved(sc, this, onlyMixins, true).force; if(unresolved&&!unresolved.inexistent(sc, this)) mixin(ErrEplg); } static bool tryAgain = false; static bool allowDelay = false; /+ static bool tryAgain(){return _tryAgain;} static void tryAgain(bool b){ static int count=0; assert(!b||count++<100); import std.stdio; writeln(b); _tryAgain=b; }+/ private: IncompleteScope unresolved = null; } class LookupIdentifier: Identifier{ Scope lkup; this(string name, Scope lkup){ super(name); this.lkup = lkup; } override void semantic(Scope sc){ if(!meaning) lookupSemantic(sc, lkup); else super.semantic(sc); } mixin DownCastMethod; } mixin template Semantic(T) if(is(T==ModuleIdentifier)){ alias lkup mscope; override void semantic(Scope sc){ assert(!!sc.getModule()); if(!mscope) mscope = sc.getModule().sc; super.semantic(sc); } } // useful for UFCS: a .identifier that fails lookup silently class SilentModuleIdentifier: ModuleIdentifier{ this(string name){super(name);} override void semantic(Scope sc){ assert(!!sc.getModule); if(!mscope) mscope = sc.getModule().sc; if(!meaning){ mixin(SemPrlg); assert(sstate != SemState.failed); mixin(Lookup!q{_;this,sc,mscope}); if(sstate == SemState.failed) mixin(ErrEplg); if(needRetry) return; } Symbol.semantic(sc); } } abstract class CurrentExp: Expression{ auto accessCheck = AccessCheck.all; Scope scope_; final FunctionDecl enclosingMemberFunction(){ return enclosingMemberFunction(scope_); } static FunctionDecl enclosingMemberFunction(Scope scope_){ Declaration mfun=null; for(Declaration dl=scope_.getDeclaration(); dl && !dl.isAggregateDecl(); dl=dl.scope_.getDeclaration()){ if(dl.stc&STCstatic) return null; mfun=dl; } return mfun.maybe!(mfun=>mfun.isFunctionDecl()); } override void semantic(Scope sc){ mixin(SemPrlg); scope_ = sc; auto aggr=sc.getAggregate(); if(!aggr){ sc.error(format("invalid use of '%s' outside of an aggregate declaration", toString()), loc); mixin(ErrEplg); } if(accessCheck!=AccessCheck.none){ if(!enclosingMemberFunction()){ sc.error(format("invalid use of '%s' outside of a nonstatic member function", toString()), loc); mixin(ErrEplg); } } mixin CreateBinderForDependent!("DetermineType"); mixin(DetermineType!q{type; this, sc, aggr}); type = type.applyScopeSTC(sc); mixin(SemEplg); } override bool isLvalue(){ assert(cast(AggregateTy)type.getHeadUnqual()); return !!(cast(AggregateTy)type.getHeadUnqual()).decl.isValueAggregateDecl(); } abstract Dependent!Type determineType(Scope sc, AggregateDecl d); override @property string kind(){ return "current object"; } mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==CurrentExp)){} mixin template Semantic(T) if(is(T==ThisExp)){ protected override Dependent!Type determineType(Scope sc, AggregateDecl d){ return d.getType().independent!Type; } override bool tmplArgEquals(Expression rhs){ return rhs.isThisExp()&&rhs.type.equals(type); } } mixin template Semantic(T) if(is(T==SuperExp)){ protected override Dependent!Type determineType(Scope sc, AggregateDecl d){ auto raggr = d.isReferenceAggregateDecl(); if(raggr){ if(raggr.parents.length) raggr.findFirstNParents(1); if(raggr.parents.length){ if(raggr.parents[0].needRetry) return Dependee(raggr.parents[0], raggr.scope_).dependent!Type; if(raggr.parents[0].sstate==SemState.error){ mixin(SetErr!q{}); return Dependee(this,null).dependent!Type; } }else goto Lerror; assert(raggr.parents[0].sstate == SemState.completed); assert(!!cast(AggregateTy)raggr.parents[0]); if(!(cast(AggregateTy)cast(void*)raggr.parents[0]).decl.isClassDecl()) goto Lerror; return (cast(AggregateTy)cast(void*)raggr.parents[0]).decl.getType().independent!Type; }else goto Lerror; Lerror: // cast is workaround for bug in DMD sc.error(format("no super class for type '%s'",(cast(Type)d.getType()).toString()),loc); mixin(SetErr!q{}); return Dependee(this,null).dependent!Type; } override bool tmplArgEquals(Expression rhs){ return rhs.isSuperExp()&&rhs.type.equals(type); } } mixin template Semantic(T) if(is(T==FieldExp)){ mixin ContextSensitive; override Expression clone(Scope sc, InContext inContext, AccessCheck accessCheck, const ref Location loc){ if(e1.isCurrentExp()) return e2.clone(sc, inContext, accessCheck, loc); auto fe1 = e1.clone(sc, inContext==InContext.fieldExp?inContext:InContext.none, accessCheck, loc); auto fe2 = e2.clone(sc, e2.inContext, accessCheck, loc); assert(cast(Symbol)fe2); auto r = New!(BinaryExp!(Tok!"."))(fe1,cast(Symbol)cast(void*)fe2); r.loc = loc; r.inContext = inContext; r.semantic(sc); return r; } Expression res; Expression ufcs; // TODO: we do not want this to take up space in every instance @property Expression member(){ return res ? res : e2; } AccessCheck accessCheck; override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{e1}); mixin(PropErr!q{e2}); Type scopeThisType; auto msc = e1.getMemberScope(); if(accessCheck == AccessCheck.init){ accessCheck = e2.accessCheck; if(!e1.isType()) e2.accessCheck = e1.deferredAccessCheck(); } if(e2.accessCheck!=AccessCheck.none) e2.loc=loc; Expression this_; if(!msc){ if(auto ptr=e1.type.getHeadUnqual().isPointerTy()) msc = ptr.ty.getMemberScope(); if(!msc){ this_ = e1.extractThis(); goto Linexistent; } e1 = New!(UnaryExp!(Tok!"*"))(e1); mixin(SemChld!q{e1}); } this_ = e1.extractThis(); if(!e2.meaning){ if(auto ident = e2.isIdentifier()){ //e2.implicitCall = false; ident.recursiveLookup = false; //ident.lookup(msc); if(ident.sstate != SemState.failed){ ident.inContext = InContext.fieldExp; mixin(Lookup!q{_;ident,sc,msc}); if(auto nr=ident.needRetry) { needRetry=nr; return; } mixin(PropErr!q{ident}); } if(ident.sstate == SemState.failed) goto Linexistent; } } assert(!!e2.meaning); // TODO: find a better design here if(rewrite) return; e2.inContext = InContext.fieldExp; e2.semantic(sc); res = e2; mixin(Rewrite!q{res}); auto rew=e2.rewrite; e2.rewrite = null; mixin(SemProp!q{e2}); e2.rewrite=rew; //// if(auto ae = res.isAddressExp()){ if(auto sym=ae.e.isSymbol()){ auto b=New!(BinaryExp!(Tok!"."))(e1, sym); b.loc=loc; auto r=New!(UnaryExp!(Tok!"&"))(b); r.loc=loc; transferContext(r); r.semantic(sc); mixin(RewEplg!q{r}); } }else if(auto sym = res.isSymbol()){ e2=sym; type = e2.type; Type thisType=sym.thisType(); bool needThis = !!thisType; if(needThis){ if(this_) if(sym.meaning.needsAccessCheck(AccessCheck.all)) if(auto vd=sym.meaning.isVarDecl()) if(vd.isField){ assert(!!this_.type.getUnqual().isAggregateTy()); auto stc = this_.type.getHeadSTC(); type=type.applySTC(stc); assert(this_.sstate == SemState.completed); // delegates do not implicitly convert to const if(stc&STCconst && !e2.type.implicitlyConvertsTo(type).force){ sc.error(format("cannot load field '%s' of type '%s' from const-qualified receiver",e2, e2.type), loc); sc.note(format("%s was declared here",kind),e2.meaning.loc); mixin(ErrEplg); } e2.type = type; } if(sym.meaning.needsAccessCheck(accessCheck)){ needRetry=false; auto newThis_=this_; thisCheckAndRebind(sc, newThis_, thisType); mixin(SemCheck); if(!newThis_){ sym.accessCheck=accessCheck; sym.performAccessCheck(); mixin(SemProp!q{sym}); } if(this_ && newThis_ !is this_){ auto b = New!(BinaryExp!(Tok!"."))(newThis_,e2); b.loc = loc; auto r = New!(BinaryExp!(Tok!","))(this_,b); r.loc = loc; transferContext(r); r.semantic(sc); mixin(RewEplg!q{r}); } goto Lok; } }else if(sym.meaning.needsAccessCheck(accessCheck)){ sym.accessCheck=accessCheck; sym.performAccessCheck(); mixin(SemProp!q{sym}); } }else if(this_){ static FieldExp concatenate(Expression base, FieldExp f){ if(auto f2=f.e1.isFieldExp()){ auto e1=concatenate(base, f2); auto r = New!(BinaryExp!(Tok!"."))(e1,f.e2); r.loc = f.loc; return r; }else if(auto sym=f.e1.isSymbol()){ auto r = New!(BinaryExp!(Tok!"."))(base, sym); auto l=r.loc=base.loc.to(f.e1.loc); r = New!(BinaryExp!(Tok!"."))(r, f.e2); r.loc=l.to(f.e2.loc); return r; }else assert(0, text((a=>typeid(a))(f.e1))); } if(auto et=res.isExpTuple()){ // TODO: can some cloning be avoided here?: auto exprs=new Expression[](et.length); // TODO: allocation TmpVarExp tmpe; Expression base; if(!AliasDecl.isAliasable(e1)){ tmpe=New!TmpVarExp(e1); tmpe.loc=e1.loc; tmpe.semantic(sc); base=tmpe.sym; }else base=e1; size_t i=0; foreach(e;et.allIndices(sc,InContext.fieldExp,loc)){ if(auto sym=e.isSymbol()){ exprs[i]=New!(BinaryExp!(Tok!"."))(base, sym); exprs[i].loc=loc; }else if(auto fld=e.isFieldExp()){ exprs[i]=concatenate(base, fld); }else exprs[i]=e; i++; } auto net = New!ExpTuple(exprs); net.loc=loc; Expression r; if(tmpe){ r = New!(BinaryExp!(Tok!","))(tmpe, net); r.brackets++; r.loc = loc; }else r = net; transferContext(r); r.semantic(sc); mixin(RewEplg!q{r}); } Expression r; if(auto fres=res.isFieldExp()){ r=concatenate(e1, fres); transferContext(r); r.semantic(sc); }else r=res; // type or enum on instance. ignore side effects of e1 mixin(RewEplg!q{r}); /*// TODO: do we rather want this: // enum reference. we need to evaluate 'this', but it // does not matter for the field expression //assert(e2.meaning.stc & STCenum); auto r=New!(BinaryExp!(Tok!","))(this_,res); r.brackets++; r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r});*/ } if(!this_){ // we do not have a 'this' pointer // and we do not need a 'this' pointer Expression r=res; if(auto sym=r.isSymbol()){ // allow implicit call rewrite sym.sstate = SemState.begin; sym.inContext = InContext.none; transferContext(sym); sym.accessCheck = accessCheck; sym.semantic(sc); } mixin(RewEplg!q{r}); }/+else{ // we have a 'this' pointer that we don't need }+/ Lok: // in order to be able to reuse isImplicitlyCalled (TODO: improve) if(e2.isImplicitlyCalled(inContext)){ auto b = New!(BinaryExp!(Tok!"."))(e1,e2); b.loc = loc; e2.ignoreProperty=true; auto args = Seq!(b,(Expression[]).init); auto r = e2.meaning.stc&STCproperty?New!PropertyCallExp(args):New!CallExp(args); r.loc = loc; r.semantic(sc); mixin(RewEplg!q{r}); } assert(!!type); mixin(SemEplg); Linexistent: if(isBuiltInField(sc,this_)) return; // TODO: opDispatch // TODO: alias this if(e1 is this_&&!ufcs) if(auto id=e2.isIdentifier()){ auto ufcs=New!SilentModuleIdentifier(id.name); ufcs.loc=e2.loc; ufcs.ignoreProperty=true; e2.transferContext(ufcs); if(!ufcs.inContext.among(InContext.called, InContext.instantiated)) ufcs.inContext=InContext.called; this.ufcs=ufcs; } if(ufcs){ assert(e1 is this_); mixin(SemChldPar!q{ufcs}); if(ufcs.isSymbol()||ufcs.isType()) if(ufcs.sstate == SemState.completed){ bool incomplete=inContext.among(InContext.called,InContext.instantiated); incomplete&=!(ufcs.isSymbol()&&ufcs.isSymbol().meaning.stc&STCproperty); auto r = New!UFCSCallExp(ufcs, this_, incomplete); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } } TemplateInstanceDecl tmpl; if(auto fe=e1.isFieldExp()) if(auto t=fe.e2.meaning.isTemplateInstanceDecl()) tmpl=t; if(!tmpl) if(auto symb=e1.isSymbol()) if(symb.meaning)if(auto t=symb.meaning.isTemplateInstanceDecl()) tmpl=t; if(tmpl) sc.error(format("no member '%s' for %s '%s'",member.toString(),e1.kind,e1),loc); else sc.error(format("no member '%s' for type '%s'",member.toString(),e1.isType()?e1:e1.type),loc); mixin(ErrEplg); } override void noHope(Scope sc){ if(e1.sstate!=SemState.completed) return; if(auto i=e2.isIdentifier()){ if(i.meaning) return; auto msc = e1.getMemberScope(); if(!msc) return; auto unresolved = msc.getUnresolved(sc,i, false, true).force; if(unresolved&&!unresolved.inexistent(sc,i)) mixin(ErrEplg); } } /* given that 'this' of type thisType is required, check if this_ can be used as the 'this' pointer */ private void thisCheckAndRebind(Scope sc,ref Expression this_, Type thisType){ bool tryRebind(){ auto thisExp=New!ThisExp(); // TODO: ensure this only happens once per symbol thisExp.loc=loc; thisExp.semantic(New!GaggingScope(sc)); assert(util.among(thisExp.sstate,SemState.error,SemState.completed)); if(thisExp.sstate==SemState.error) return false; this_=thisExp; return true; } auto ttu = thisType.getUnqual(); if(!this_){ // statically bound calls to virtual member functions if(auto fd=sc.getFunction()) if(auto decl=sc.getAggregate()) if(fd.scope_.getDeclaration() is decl) if(auto raggr=decl.isReferenceAggregateDecl()){ auto etu = cast(Type)raggr.getType(); // cast is workaround for DMD bug mixin(RefConvertsTo!q{bool conv; etu, ttu, 0}); if(conv) goto Lok; } // member function templates if(auto sym=e1.isSymbol()) if(sym.meaning.isTemplateInstanceDecl()){ auto decl = sc.getDeclaration(); mixin(IsDeclAccessible!q{bool acc; Declaration, decl, sym.meaning}); if(acc) goto Lok; } tryRebind(); if(!this_){ // error message duplicated in Symbol.semantic sc.error(format("need 'this' to access %s '%s'", e2.meaning?e2.kind:"member",e2.loc.rep),loc); if(e2.meaning) sc.note(format("%s was declared here",e2.kind),e2.meaning.loc); mixin(ErrEplg); } } // successfully resolved non-tuple field expression that // requires 'this' auto etu = this_.type.getUnqual(); mixin(RefConvertsTo!q{bool conv; etu, ttu, 0}); if(!conv){ tryRebind(); etu=this_.type.getUnqual(); mixin(RefConvertsTo!q{bool conv2; etu, ttu, 0}); if(!conv2){ sc.error(format("need 'this' of type '%s' to access %s '%s'", thisType.toString(),e2.kind,e2.loc.rep),loc); mixin(ErrEplg); } } Lok:; } override Dependent!bool implicitlyConvertsTo(Type rhs){ return member.implicitlyConvertsTo(rhs); } override bool isLvalue(){ return member.isLvalue(); } override Scope getMemberScope(){ return member.getMemberScope(); } override Expression extractThis(){ if(isTuple()) return null; if(e2.meaning.isTemplateInstanceDecl()||e2.meaning.isNamespaceDecl()) return e1.extractThis(); return this; } override AccessCheck deferredAccessCheck(){ if(isTuple()) return AccessCheck.all; if(!e2.meaning.needsAccessCheck(accessCheck)) return e1.deferredAccessCheck(); return super.deferredAccessCheck(); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type th_, Expression[] args, ref MatchContext context){ assert(!th_); enum SemRet = q{ return this.independent!Expression; }; if(member.isTuple()) return null.independent!Expression; Type this_ = null; // delegate and function pointer fields do not receive the implicit 'this' if(!e2.meaning.isVarDecl()) if(auto tt=e1.extractThis()) this_=tt.type; assert(e2.inContext==InContext.fieldExp); mixin(MatchCallHelper!q{auto exp; e2, sc, loc, this_, args, context}); if(!exp) return null.independent!Expression; assert(!!cast(Symbol)exp); auto sym = cast(Symbol)cast(void*)exp; e2 = sym; sstate = SemState.begin; type = null; semantic(e2.scope_); Expression r = this; mixin(Rewrite!q{r}); mixin(SemRet); } override void matchError(Scope sc, Location loc, Type th_, Expression[] args){ assert(!th_); Type this_ = null; if(auto tt=e1.extractThis()) this_=tt.type; if(member.isTuple()) super.matchError(sc,loc,this_,args); return e2.matchError(sc,loc,this_,args); } import vrange; override IntRange getIntRange(){ return member.getIntRange(); } override LongRange getLongRange(){ return member.getLongRange(); } /* rewrites built-in fields and returns whether it was a built-in */ bool isBuiltInField(Scope sc,Expression this_)in{ assert(!isTuple()); assert(e1.sstate == SemState.completed); assert(!!cast(Identifier)e2); }body{ auto name = (cast(Identifier)cast(void*)e2).name; auto ty = e1.isType(); bool isType = true; if(ty is null){ ty = e1.type; isType = false; } Expression r = null; if(auto elt = ty.getElementType()){ if(!isType) switch(name){ case "ptr": r=New!PtrExp(e1); goto Lrewrite; case "length": r=New!LengthExp(e1); goto Lrewrite; default: break; }else switch(name){ case "ptr": type = elt.getPointer(); if(accessCheck != AccessCheck.none){ thisCheckAndRebind(sc, this_, ty); return true; } goto Lnorewrite; case "length": type = Type.get!Size_t(); if(accessCheck != AccessCheck.none){ thisCheckAndRebind(sc, this_, ty); return true; } goto Lnorewrite; default: break; } } if(auto tp=e1.isTuple()){ if(name=="length"){ r=LiteralExp.factory(Variant(tp.length, Type.get!Size_t())); goto Lrewrite; } } return false; Lrewrite: r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); Lnorewrite: mixin(SemEplg); } override bool isConstant(){ return e1.isConstant(); } override bool isConstFoldable(){ return e1.isConstFoldable(); } // TemplateDecl needs this. override bool tmplArgEquals(Expression rhs){ if(e1.isCurrentExp()){ if(auto sym = rhs.isSymbol()) return e2.tmplArgEquals(sym); } if(auto fld = rhs.isFieldExp()) return e2.tmplArgEquals(fld.e2) && e1.tmplArgEquals(fld.e1); return false; } override size_t tmplArgToHash(){ import hashtable; if(e1.isCurrentExp()) return e2.tmplArgToHash(); return FNV(e2.meaning.toHash(), e1.tmplArgToHash()); } } class PtrExp: Expression{ Expression e; this(Expression e)in{ assert(e.sstate == SemState.completed); assert(e.type.getElementType()); }body{ this.e=e; type=e.type.getElementType().getPointer(); sstate = SemState.completed; } override string toString(){return e.toString()~".ptr";} override @property string kind(){return "array base pointer";} override void semantic(Scope sc){mixin(SemPrlg); assert(0);} mixin Visitors; } class LengthExp: Expression{ Expression e; this(Expression e)in{ assert(e.sstate == SemState.completed); assert(e.type.getElementType()); }body{ this.e=e; type=Type.get!Size_t(); sstate = SemState.completed; } override bool checkMutate(Scope sc, ref Location l){ return e.checkMutate(sc,l); } override string toString(){return e.toString()~".length";} override @property string kind(){return "array length";} override void semantic(Scope sc){mixin(SemPrlg); assert(0);} mixin DownCastMethod; mixin Visitors; } mixin template Semantic(T) if(is(T==DollarExp)){ Scope scope_; override void semantic(Scope sc){ if(!meaning) meaning=sc.getDollar(); if(!meaning){ sc.error("'$' is undefined outside index or slice operators",loc); mixin(ErrEplg); } // Symbol.semantic(sc); // DMD BUG: DMD thinks this call is dynamically bound super.semantic(sc); } static VarDecl createDecl(Scope ascope, STC stc, Expression init)in{ assert(!!ascope); }body{ // TODO: the allocation of a new identifier is unnecessary auto dollar = new VarDecl(stc, Type.get!Size_t(), New!Identifier("__dollar"), init); dollar.sstate = SemState.begin; // do not add to scope dollar.scope_ = ascope; dollar.semantic(ascope); mixin(Rewrite!q{dollar}); assert(dollar.sstate == SemState.completed); return dollar; } override bool isLvalue(){ return false; } override @property string kind(){ return "array length"; } override string toString(){ return "$"; } mixin template DollarProviderImpl(alias e){ VarDecl dollar; // interface DollarProvider VarDecl getDollar(){ if(!dollar){ auto stc = STC.init; Expression init = null; void createInit(Tuple tp){ stc |= STCenum; init = LiteralExp.factory(Variant(tp.length, Type.get!Size_t())); } if(auto tp=e.isTuple()) createInit(tp); else if(e.type){ if(auto tp=e.type.isTuple()) createInit(tp); } // dollar variables outside function scope are 'static' auto decl=ascope.getDeclaration(); if(!decl||!decl.isFunctionDef()) stc |= STCstatic; dollar = DollarExp.createDecl(ascope, stc, init); } return dollar; } } } mixin template Semantic(T) if(is(T==FunctionLiteralExp)){ protected FunctionDef createFunctionDef(FunctionTy fty,Identifier name, CompoundStm bdy){ return New!FunctionDef(STC.init,fty,name,cast(BlockStm)null,cast(BlockStm)null,cast(Identifier)null,bdy); } override void semantic(Scope sc){ mixin(SemPrlg); auto dg=createFunctionDef(fty,New!Identifier(uniqueIdent("__dgliteral")),bdy); if(which==Kind.none) dg.inferStatic=true; dg.inferAttributes=true; // TODO: re-enable auto decl=sc.getDeclaration(); dg.sstate = SemState.begin; dg.scope_ = sc; // Symbol will use this scope to reason for analyzing DG auto sym=New!Symbol(dg, true, true); if(which==Kind.function_ || which!=Kind.delegate_ && !decl) dg.stc |= STCstatic; else if(decl&&decl.isReferenceAggregateDecl()) dg.stc |= STCfinal; sym.loc=dg.loc=loc; Expression e = New!(UnaryExp!(Tok!"&"))(sym); e.brackets++; e.loc=loc; transferContext(e); e.semantic(sc); if(auto enc=sc.getDeclaration()) enc.nestedFunctionLiteral(dg); auto r = e; mixin(PropErr!q{r}); mixin(RewEplg!q{r}); } mixin ContextSensitive; } mixin template Semantic(T) if(is(T==ConditionDeclExp)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!decl) decl=New!VarDecl(stc,ty,name,init); if(!sym) sym=New!Symbol(decl); mixin(SemChld!q{decl,sym}); type = decl.type; mixin(SemEplg); } private: VarDecl decl; Symbol sym; } // types mixin template Semantic(T) if(is(T==Type)){ override void semantic(Scope sc) { } override Type typeSemantic(Scope sc) { semantic(sc); auto r=this; mixin(Rewrite!q{r}); return r; } override Type clone(Scope,InContext,AccessCheck accessCheck,const ref Location) { return this; } final protected Type checkVarDeclError(Scope sc, VarDecl me)in{assert(sc);}body{ if(me.name) sc.error(format("%s '%s' has invalid type '%s'", me.kind, me.name, this), me.loc); else sc.error(format("%s has invalid type '%s'", me.kind, this), me.loc); return New!ErrorTy(); } Type checkVarDecl(Scope, VarDecl){return this;} Type getArray(ulong size){ if(auto r=arrType.get(size,null)) return r; return arrType[size]=ArrayTy.create(this,size); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ return null.independent!Expression; } override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ sc.error(format("%s '%s' is not callable",kind,toString()),loc); } private static funcliteralTQ(){string r; foreach(x; typeQualifiers){ // getConst, getImmutable, getShared, getInout, getPointer, getDynArr. remember to keep getArray in sync. r ~= mixin(X!q{ private Type @(x)Type; final Type get@(upperf(x))(){ if(@(x)Type) return @(x)Type; return @(x)Type=get@(upperf(x))Impl(); } protected Type get@(upperf(x))Impl(){return @(upperf(x))Ty.create(this);} Type getTail@(upperf(x))(){return this;} Type in@(upperf(x))Context(){return this;} }); } foreach(x; ["pointer","dynArr"]){ r ~= mixin(X!q{ private Type @(x)Type; final Type get@(upperf(x))()in{ assert(!isTypeTuple(),text("cannot create array of ",this)); }body{ if(@(x)Type) return @(x)Type; return @(x)Type=@(upperf(x))Ty.create(this); } }); } return r; }mixin(funcliteralTQ()); Type applySTC(STC stc){ auto r = this; if(stc&STCimmutable) r = r.getImmutable(); if(stc&STCconst||stc&STCin) r = r.getConst(); if(stc&STCinout) r = r.getInout(); if(stc&STCshared) r = r.getShared(); return r; } STC getHeadSTC(){ return STC.init;} final Type applyScopeSTC(Scope sc){ auto aggr=sc.getAggregate(); if(!aggr) return this; auto fl=sc.getDeclaration(), type = this; if(fl !is aggr) for(Declaration dl;;fl=dl){ dl=fl.scope_.getDeclaration(); if(dl is aggr) break; } if(auto fd=fl.isFunctionDecl()){ type = type.applySTC(fl.stc&STCtypeconstructor); } return type; } Type getHeadUnqual(){return this;} // is implemented as lazy field in the relevant classes Type getUnqual(){return this;} // ditto Type getElementType(){return null;} bool isMutable(){return true;} /* this alias exists in order to be robust against language changes involving an additional qualifier that can co-exist with immutable */ alias isImmutableTy isImmutable; // TODO: isConst, on by-need basis BasicType isIntegral(){return null;} BasicType isComplex(){return null;} final Type isSomeString(){ return this is get!string() || this is get!wstring() || this is get!dstring() ? this : null; } final FunctionTy getFunctionTy(){ // TODO: could be a virtual function instead if(auto fty = isFunctionTy()) return fty; if(auto dgt = isDelegateTy()) return dgt.ft; if(auto fpt = isPointerTy()) return fpt.ty.isFunctionTy(); return null; } /* used for matching inout. the formal parameter type is adapted to match the actual argument as good as possible. */ final Type adaptTo(Type from, ref InoutRes inoutRes){ auto t1=this, t2=from; auto tu1=t1.getHeadUnqual(), tu2=t2.getHeadUnqual(); if(tu1.isPointerTy() && tu2.isPointerTy() || tu1.isDynArrTy() && tu2.isDynArrTy()) t1=tu1, t2=tu2; return t1.adaptToImpl(t2, inoutRes); } Type adaptToImpl(Type from, ref InoutRes inoutRes){ return this; } /* used for IFTI and template type parameter matching */ Dependent!void typeMatch(Type from){ return indepvoid; } bool hasPseudoTypes(){ return false; } override Type resolveInout(InoutRes inoutRes){ return this; } /* important for is-expressions and parameter matching: function, delegate and function pointer types cannot always be kept unique, since they may include default arguments */ bool equals(Type rhs){ return this is rhs; } override Dependent!bool convertsTo(Type rhs){ if(auto et=rhs.getHeadUnqual().isEnumTy()){ mixin(GetEnumBase!q{auto base;et.decl}); return convertsTo(base.applySTC(rhs.getHeadSTC())); } return rhs.getHeadUnqual() is Type.get!void() ?true.independent: implicitlyConvertsTo(rhs.getUnqual().getConst()); } override Dependent!bool implicitlyConvertsTo(Type rhs){ return this.refConvertsTo(rhs.getHeadUnqual(),0); } final Dependent!bool constConvertsTo(Type rhs){ return !this.getUnqual().equals(rhs.getUnqual()) ?false.independent: implicitlyConvertsTo(rhs); } // bool isSubtypeOf(Type rhs){...} /* stronger condition than subtype relationship. a 'num'-times reference to a this must be a subtype of a 'num'-times reference to an rhs. */ Dependent!bool refConvertsTo(Type rhs, int num){ assert(rhs); if(this is rhs) return true.independent; if(num < 2){ if(auto d=rhs.isConstTy()) return refConvertsTo(d.ty.getTailConst(), 0); } return false.independent; } final protected Dependent!Type mostGeneral(Type rhs){ if(rhs is this) return this.independent; Type r = null; mixin(ImplConvertsTo!q{bool l2r; this, rhs}); mixin(ImplConvertsTo!q{bool r2l; rhs, this}); if(l2r ^ r2l){ r = r2l ? this : rhs; STC stc = this.getHeadSTC() & rhs.getHeadSTC(); r = r.getHeadUnqual().applySTC(stc); } return r.independent; } // TODO: similar code occurs in 3 places final protected Dependent!Type refMostGeneral(Type rhs, int num){ if(rhs is this) return this.independent; Type r = null; mixin(RefConvertsTo!q{bool l2r; this, rhs, num}); mixin(RefConvertsTo!q{bool r2l; rhs, this, num}); if(l2r ^ r2l) r = r2l ? this : rhs; return r.independent; } /* common type computation. roughly TDPL p60 note: most parts of the implementation are in subclasses */ Dependent!Type combine(Type rhs){ if(auto r = mostGeneral(rhs).prop) return r; auto unqual = rhs.getHeadUnqual(); if(unqual !is rhs) return unqual.combine(this); return null.independent!Type; } Dependent!Type refCombine(Type rhs, int num)in{assert(!!rhs);}body{ if(auto d=rhs.isQualifiedTy()) return d.refCombine(this, num); if(auto r = refMostGeneral(rhs, num).prop) return r; if(num < 2){ if(num) return getConst().refCombine(rhs.getConst(), 0); auto tconst = getTailConst(); if(this !is tconst) return tconst.refCombine(rhs.getTailConst(), 0); } return null.independent!Type; } Dependent!Type unify(Type rhs){ if(rhs.isQualifiedTy()) return rhs.unify(this); return combine(rhs); } Type stripDefaultArguments(){ return this; } /* members */ override Scope getMemberScope(){ return null; } override Expression extractThis(){ // would prefer using typeof(null) return null; } /* built-in properties */ ulong getSizeof(){ assert(0, "no size yet for type "~to!string(this)); } /* get the ranges associated with a type. expressions often allow more specific statements about their range. */ override IntRange getIntRange(){return IntRange.full(true);} override LongRange getLongRange(){return LongRange.full(true);} // TemplateDecl needs this. override bool tmplArgEquals(Expression rhs){ if(auto type = cast(Type)rhs) return equals(type); return false; } override size_t tmplArgToHash(){ return toHash(); // TODO!: fix! } } mixin template Semantic(T) if(is(T==DelegateTy)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{ft}); mixin(SemEplg); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ auto rd=ft.matchCallHelper(sc, loc, this_, args, context); if(rd.value) rd.value = this; // valid for dependent is null and dependent !is null return rd; } override bool equals(Type rhs){ if(auto dgt = rhs.isDelegateTy()) return ft.equals(dgt.ft); return false; } override Dependent!bool refConvertsTo(Type rhs, int num){ if(auto dgt = rhs.isDelegateTy()) return ft.refConvertsTo(dgt.ft, num+1); return super.refConvertsTo(rhs,num); } override Dependent!Type combine(Type rhs){ if(auto r = mostGeneral(rhs).prop) return r; auto unqual = rhs.getHeadUnqual(); return unqual.refCombine(this,0); } // TODO: would like to have Dependent!DelegateTy here... override Dependent!Type refCombine(Type rhs, int num){ if(auto dgt = rhs.isDelegateTy()){ mixin(RefCombine!q{auto rcomb; ft, dgt.ft, num+1}); assert(!rcomb||cast(FunctionTy)rcomb); if(auto r = cast(FunctionTy)cast(void*)rcomb) return r.getDelegate().independent!Type; } return null.independent!Type; } override Dependent!Type unify(Type rhs){ if(auto rft=rhs.getFunctionTy()){ mixin(Unify!q{auto unf; ft, rft}); if(unf){ assert(cast(FunctionTy)unf); return (cast(FunctionTy)cast(void*)unf).getDelegate().independent!Type; } } return null.independent!Type; } override DelegateTy resolveInout(InoutRes res){ return ft.resolveInout(res).getDelegate(); } override Dependent!void typeMatch(Type from){ // function pointers might convert to a delegate // so matching should succeed // for robustness and convenience, this also accepts a normal // function type if(auto rft=from.getHeadUnqual().getFunctionTy()) ft.typeMatch(rft); /+ if(auto ptr=from.isPointerTy()) if(auto pft=ptr.ty.isFunctionTy()) ft.typeMatch(pft);+/ return indepvoid; } override bool hasPseudoTypes(){ return ft.hasPseudoTypes(); } private static string __dgliteralQual(){ string r; foreach(x;["const","immutable","inout","shared"]){ r~= mixin(X!q{ override Type getTail@(upperf(x))(){ return ft.addQualifiers(STC@(x)).getDelegate(); } override Type in@(upperf(x))Context(){ return ft.in@(upperf(x))Context().getDelegate(); } }); } return r; } mixin(__dgliteralQual()); override Type stripDefaultArguments(){ return ft.stripDefaultArguments().getDelegate(); } } mixin template Semantic(T) if(is(T==FunctionTy)){ Scope scope_; void reset()in{ assert(hasUnresolvedParameters()); }body{ sstate = SemState.begin; foreach(x;params) x.sstate = SemState.begin; } override void semantic(Scope sc){ mixin(SemPrlg); assert(!!sc); scope_=sc; if(rret){ ret = rret.typeSemantic(sc); mixin(PropRetry!q{rret}); } if(ret) mixin(SemChldPar!q{ret}); foreach(p; params){ if(p.sstate==SemState.pre) p.sstate = SemState.begin; // never insert into scope if(!p.rtype && !p.init) continue; // parameter type needs to be deduced p.semantic(sc); // TODO: rewriting parameters ever needed? assert(!p.rewrite); } foreach(p;params){mixin(PropRetry!q{p});} if(rret) mixin(PropErr!q{rret}); if(ret) mixin(PropErr!q{ret}); mixin(PropErr!q{params}); params = Tuple.expandVars(sc,params); mixin(SemEplg); } override Type checkVarDecl(Scope sc, VarDecl me){ return checkVarDeclError(sc,me); } bool hasUnresolvedParameters(){ foreach(x;params) if(x.mustBeTypeDeduced()) return true; return false; } bool errorsInParams(){ if(sstate != SemState.error) return false; foreach(x;params) if(x.sstate == SemState.error) return true; return false; } bool resolve(FunctionTy rhs)in{ assert(!!rhs); }body{ bool r; if(!ret){ret = rhs.ret; r=!!ret;} foreach(i,p; params[0..min($,rhs.params.length)]){ if(!p.type){ auto ty=rhs.params[i].type; if(ty&&ty.sstate==SemState.completed&&ty.getHeadUnqual()!is Type.get!void()){ p.type=ty; r=true; p.semantic(scope_); } } } return r; } bool resolve(Expression[] args){ bool r=false; foreach(i,p; params[0..min($,args.length)]) if(!p.type){ auto ty = args[i].type; if(ty&&ty.getHeadUnqual()!is Type.get!void()){ p.type=ty; r=true; p.semantic(scope_); } } return r; } override FunctionTy resolveInout(InoutRes res){ alias util.TypeTuple!(__traits(allMembers,InoutRes)) M; static assert(M[0]=="none"); final switch(res){ foreach(x;M[1..$]){ enum e = mixin("InoutRes."~x); enum i = "cache_inoutres_"~x; case e: if(mixin(i)) return mixin(i); auto r=dup(); r.params = r.params.dup; foreach(ref p;r.params){ p=p.ddup(); p.type = p.type.resolveInout(res); p.rtype=null; p.stc=(p.stc&~STCinout)|p.type.getHeadSTC(); } foreach(xx;M[1..$]) mixin("r.cache_inoutres_"~xx)=r; r.ret = r.ret.resolveInout(res); static if(e!=InoutRes.inout_)if(r.stc&STCinout){ static if(e!=InoutRes.inoutConst) r=r.removeQualifiers(STCinout); static if(e==InoutRes.immutable_) r=r.addQualifiers(STCimmutable); else static if(e==InoutRes.const_) r=r.addQualifiers(STCconst); else static if(e==InoutRes.inoutConst) r=r.addQualifiers(STCconst); } return mixin(i)=r; } case InoutRes.none: return this; } } override Dependent!void typeMatch(Type rhs){ if(auto ft = rhs.isFunctionTy()){ if(ret&&ft.ret){mixin(TypeMatch!q{_; ret, ft.ret});}//ret.typeMatch(ft.ret); foreach(i,p;params[0..min($,ft.params.length)]){ auto mt = p.type ? p.type.isMatcherTy() : null; if(mt && mt.which==WhichTemplateParameter.tuple){ //TODO: gc allocation alias util.all all; if(i+1==params.length&&all!(_=>_.type !is null)(ft.params[i..$])){ import rope_; auto types = toTemplArgs(map!(_=>_.type)(ft.params[i..$])); //mt.typeMatch(New!TypeTuple(types)); // TODO: this might be expensive: mixin(TypeMatch!q{_; mt, New!TypeTuple(types)}); } break; } if(p.type && ft.params[i].type) //p.type.typeMatch(ft.params[i].type); mixin(TypeMatch!q{_; p.type, ft.params[i].type}); } } return indepvoid; } override bool hasPseudoTypes(){ if(ret && ret.hasPseudoTypes()) return true; foreach(p;params) if(p.type && p.type.hasPseudoTypes()) return true; return false; } final void stripPseudoTypes(){ if(ret && ret.hasPseudoTypes()) ret=null; foreach(p;params) if(p.type && p.type.hasPseudoTypes()) p.type = null; } override Dependent!Type unify(Type rhs){ if(auto ft = rhs.isFunctionTy()){ // TODO: unify STC if(vararg != ft.vararg || stc!=ft.stc||ft.params.length!=params.length) return Type.init.independent; Type r; auto p = new Parameter[params.length]; // TODO: avoid allocation if(!ret) r=ft.ret; else if(!ft.ret) r=ret; else mixin(Unify!q{r; ret, ft.ret}); foreach(i,ref x;p){ // TODO: unify STC x = New!Parameter(params[i].stc, null, null, null); if(!ft.params[i]||!params[i]||ft.params[i].stc!=params[i].stc) continue; Type tt; if(!params[i].type) tt = ft.params[i].type; else if(!ft.params[i].type) tt = params[i].type; else mixin(Unify!q{tt;params[i].type,ft.params[i].type}); x.type = tt; } //if(ret == r && params == p) return this.independent!Type; auto res = New!FunctionTy(stc,r,p,vararg); do res.semantic(scope_); // TODO: not great while(!res.sstate == SemState.completed); return res.independent!Type; }else return rhs.unify(this); } override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ alias util.any any; // TODO: file bug if(args.length > params.length || any!(_=>_.init is null)(params[args.length..params.length])){ context.match=Match.none; return null.independent!Expression; } resolve(args); foreach(x;params) if(x.sstate == SemState.error||!x.type) return null.independent!Expression; immutable len = args.length; auto at = new Type[len]; // GC allocation, could be done on stack! // TODO: make behave like actual overloading // check compatibility of the 'this' pointer if(this_&&stc&STCinout) context.inoutRes = irFromSTC(this_.getHeadSTC()); foreach(i,p; params[0..len]){ if(!p.type) continue; at[i] = p.type.adaptTo(args[i].type, context.inoutRes); } if(this_){ mixin(RefConvertsTo!q{ auto compat; this_, this_.getHeadUnqual() .applySTC(stc&STCtypeconstructor) .resolveInout(context.inoutRes), 0 }); if(!compat) return null.independent!Expression; } foreach(i,ref x;at) x = x.resolveInout(context.inoutRes); // the code that follows assumes the four matching level semantics static assert(Match.min == 0 && Match.max == Match.exact && Match.exact == 3); Match match = Match.exact; foreach(i,p; params[0..len]){ if(!(p.stc & STCbyref)){ if(args[i].typeEquals(at[i])) continue; if(p.stc&STClazy && at[i].getHeadUnqual() is Type.get!void()) continue; mixin(ImplConvertsTo!q{bool iconv; args[i], at[i];}); if(!iconv){ match = Match.none; break; }else{ mixin(ConstConvertsTo!q{bool cconv; args[i].type, at[i]}); if(cconv){ if(match == Match.exact) match = Match.convConst; }else match = Match.convert; // Note: Match.none breaks the loop } }else if(p.stc & STCref){ mixin(RefConvertsTo!q{bool rconv;args[i].type,at[i],1}); if(!rconv || !args[i].isLvalue()){ match = Match.none; break; } }else{// if(params[i].stc & STCout){ assert(p.stc & STCout); mixin(RefConvertsTo!q{bool rconv;at[i], args[i].type,1}); if(!rconv || !args[i].isLvalue() || !args[i].type.isMutable()){ match = Match.none; break; } } } context.match = match; return (match == Match.none ? null : this).independent!Expression; } final bool hasAutoReturn(){return rret is null;} final bool hasUnresolvedReturn(){return hasAutoReturn() && ret is null;} final void resolveReturn(Type to)in{ assert(hasUnresolvedReturn()); assert(!!to && to.sstate == SemState.completed); }body{ ret = to; } override bool equals(Type rhs){ return compareImpl(rhs); } private template CIT(bool implconv){ static if(implconv) alias Dependent!bool CIT; else alias bool CIT; } private CIT!implconv compareImpl(bool implconv=false)(Type rhs){ static if(implconv){ auto tt=true.independent, ff=false.independent; } else{ auto tt=true, ff=false; } // cannot access frame pointer to 'all'. TODO: file bug if(auto ft = rhs.isFunctionTy()){ auto stc1 = stc, stc2 = ft.stc; // STC's could be inferred (TODO: is this exactly right?) if(hasUnresolvedParameters()) stc1&=~STCinferrable, stc2&=~STCinferrable; static if(implconv){ stc1 &= ~STCproperty, stc2 &= ~STCproperty; // STCproperty does not matter stc1 &= ~STCauto, stc2 &= ~STCauto; // STCauto does not matter if(stc1 & STCsafe || stc1 & STCtrusted) stc1 &= ~STCsafe & ~STCtrusted, stc2 &= ~STCsafe & ~STCtrusted & ~STCsystem; // immutable -> const is ok if(stc1 & STCimmutable && stc2 & STCconst) stc1 &= ~STCimmutable, stc2 &= ~STCconst; // attributes that can be freely dropped: static STC[] droppable=[STCconst,STCimmutable,STCpure,STCnothrow,STCsafe]; foreach(drop;droppable) if(stc1 & drop) stc1 &= ~drop, stc2 &= ~drop; // TODO: more implicit conversion rules if(ret){ mixin(RefConvertsTo!q{bool rc;ret, ft.ret, 0}); if(!rc) return ff; } }else if(ret && !ret.equals(ft.ret)) return ff; if(!((stc1==stc2 && params.length == ft.params.length) && vararg == ft.vararg)) return ff; //all!(_=>_[0].type.equals(_[1].type))(zip(params,ft.params)) && foreach(i,x; params) if(x.type && !x.type.equals(ft.params[i].type)|| (x.stc&(STCbyref|STClazy))!=(ft.params[i].stc&(STCbyref|STClazy))) return ff; return tt; }else return ff; } // TODO: rename and don't implement them override Dependent!bool refConvertsTo(Type rhs, int num){ if(num<2) return compareImpl!true(rhs); else return compareImpl!false(rhs).independent; } // TODO: would like to have Dependent!FunctionTy here... override Dependent!Type refCombine(Type rhs, int num){ if(auto ft = rhs.isFunctionTy()){ if(this.equals(rhs)) return this.independent!Type; } return null.independent!Type; } DelegateTy getDelegate()in{ assert(sstate==SemState.completed); }body{ if(dgtype) return dgtype; dgtype = New!DelegateTy(this); dgtype.semantic(scope_); mixin(Rewrite!q{dgtype}); assert(dgtype.sstate == SemState.completed); return dgtype; } // function types are not mutable // and can be shared freely among threads override bool isMutable(){return false;} protected{ override FunctionTy getConstImpl(){ return this; } override FunctionTy getImmutableImpl(){ return this; } override FunctionTy getSharedImpl()() { return this; } override FunctionTy getInoutImpl(){ return this; } } override FunctionTy inConstContext(){ return removeQualifiers(STCconst); } override FunctionTy inImmutableContext(){ return removeQualifiers(STCimmutable|STCconst|STCinout|STCshared); } override FunctionTy inSharedContext(){ return removeQualifiers(STCshared); } override FunctionTy inInoutContext(){ return removeQualifiers(STCinout); } // delegate types can be tail-qualified // DelegateTy is a client of this functionality final FunctionTy addQualifiers(STC qual){ return modifyQualifiers!true(qual); } final FunctionTy removeQualifiers(STC qual){ return modifyQualifiers!false(qual); } override FunctionTy stripDefaultArguments(){ assert(sstate==SemState.completed); if(strippedDefaultArguments) return strippedDefaultArguments; // TODO: get rid of the allocation in the common case Parameter stripParam(Parameter param){ if(!param.rtype && !param.init) return param; // parameter type yet to be deduced assert(param.sstate==SemState.completed); auto ntype=param.type.stripDefaultArguments(); assert(ntype.sstate==SemState.completed); if(ntype!=param.type||param.init){ auto nparam=New!Parameter(param.stc,ntype,param.name,null); nparam.type=ntype; nparam.sstate=SemState.completed; return nparam; } return param; } auto nret=ret.stripDefaultArguments(); auto nparams=params.map!stripParam.array; // TODO: allocation import util: any; if(nret !is ret || any!(a=>a[0]!is a[1])(zip(nparams,params))){ // (this should be a precondition, but with broken overriding semantics, why bother:) assert(sstate==SemState.completed); strippedDefaultArguments=New!FunctionTy(stc,nret,nparams,vararg); strippedDefaultArguments.ret=nret; strippedDefaultArguments.sstate=SemState.completed; strippedDefaultArguments.scope_=scope_; strippedDefaultArguments.strippedDefaultArguments=strippedDefaultArguments; }else strippedDefaultArguments=this; return strippedDefaultArguments; } // TODO: does this duplicate all that is relevant? FunctionTy dup(){ auto res=New!FunctionTy(stc,rret,params,vararg); res.ret = ret; res.sstate = sstate; return res; } private: FunctionTy modifyQualifiers(bool add)(STC qual){ static if(add){ if((stc&qual) == qual) return this; auto diffq = stc&qual^qual; }else{ if(!(stc&qual)) return this; auto diffq = stc&qual; } static if(add){ if(stc&STCimmutable){ diffq&=~(STCconst|STCinout|STCshared); if(!diffq) return this; } } diffq&=-diffq; //switch(diffq){ // wtf. DMD codegen bug? foreach(x; ToTuple!qualifiers){ enum s=mixin("STC"~x); enum i="cache_"~x~(add?"":"_no"); enum irev = i~".cache_"~x~(add?"_no":""); // alias ID!(mixin(i)) cache; // wut? if(diffq==s){ // case s: if(!mixin(i)){ mixin(i) = dup(); static if(add) mixin(i).stc|=s; else mixin(i).stc&=~s; mixin(irev)=this; } return mixin(i).modifyQualifiers!add(qual); } } /+default: +/assert(0, STCtoString(diffq));//} } DelegateTy dgtype; FunctionTy strippedDefaultArguments; enum qualifiers = ["const","immutable","inout","nothrow","pure","shared", "safe","trusted","system"]; static string __dgliteralgenCaches(){ string r; foreach(x; qualifiers) r~="FunctionTy cache_"~x~", cache_"~x~"_no;\n"; foreach(x; __traits(allMembers,InoutRes)[1..$]) r~="FunctionTy cache_inoutres_"~x~";"; r~="public void clearCaches(){"; // TODO: these are not all caches! r~="dgtype=null;"; r~="strippedDefaultArguments=null;"; foreach(x; qualifiers) r~="cache_"~x~"=null;cache_"~x~"_no=null;"; foreach(x; __traits(allMembers,InoutRes)[1..$]) r~="cache_inoutres_"~x~"=null;"; r~="}"; return r; } mixin(__dgliteralgenCaches); } mixin template Semantic(T) if(is(T==BasicType)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin({ string r=`Type r;switch(op){`; foreach(x; basicTypes) r~=mixin(X!q{case Tok!"@(x)": r=Type.get!(BasicTypeRep!"@(x)")();break;}); return r~`default: assert(0);}`; }()); assert(r !is this,text(r)); mixin(RewEplg!q{r}); } override Type checkVarDecl(Scope sc, VarDecl me){ if(op!=Tok!"void"||me.stc&STClazy) return this; return checkVarDeclError(sc,me); } BasicType intPromote(){ switch(op){ case Tok!"bool": case Tok!"byte", Tok!"ubyte", Tok!"char": case Tok!"short", Tok!"ushort", Tok!"wchar": return Type.get!int(); case Tok!"dchar": return Type.get!uint(); default: return this; } } private static immutable int[] strength= [Tok!"bool":1,Tok!"char":2,Tok!"byte":2,Tok!"ubyte":2,Tok!"wchar":3,Tok!"short":3,Tok!"ushort":3, Tok!"dchar":4,Tok!"int":4,Tok!"uint":4,Tok!"long":5,Tok!"ulong":5,Tok!"cent":6,Tok!"ucent":6,Tok!"float":7,Tok!"double":7,Tok!"real":7, Tok!"ifloat":-1,Tok!"idouble":-1,Tok!"ireal":-1,Tok!"cfloat":-2,Tok!"cdouble":-2,Tok!"creal":-2, Tok!"void":0]; override BasicType isIntegral(){return strength[op]>0 && strength[op]<=6 ? this : null;} final BasicType isFloating(){return strength[op]==7 ? this : null;} override BasicType isComplex(){return strength[op]==-2 ? this : null;} final BasicType isImaginary(){return strength[op]==-1 ? this : null;} final BasicType flipSigned(){ switch(op){ case Tok!"byte": return Type.get!ubyte(); case Tok!"ubyte": return Type.get!byte(); case Tok!"short": return Type.get!ushort(); case Tok!"ushort": return Type.get!short(); case Tok!"int": return Type.get!uint(); case Tok!"uint": return Type.get!int(); case Tok!"long": return Type.get!ulong(); case Tok!"ulong": return Type.get!long(); case Tok!"cent": return Type.get!UCent(); case Tok!"ucent": return Type.get!Cent(); case Tok!"char": return Type.get!byte(); case Tok!"wchar": return Type.get!short(); case Tok!"dchar": return Type.get!int(); default: return this; } } final int bitSize(){ return basicTypeBitSize(op); } final bool isSigned(){ return basicTypeIsSigned(op); } override ulong getSizeof(){return basicTypeBitSize(op)>>3;} override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto bt=rhs.getHeadUnqual().isBasicType()){ // transitive closure of TDPL p44 if(op == Tok!"void") return (bt.op == Tok!"void").independent; if(strength[op]>=0 && strength[bt.op]>0) return (strength[op]<=strength[bt.op]).independent; if(strength[bt.op]==-2) return true.independent; // both must be imaginary: return (strength[op] == -1 && strength[bt.op] == -1).independent; } return false.independent; } override Dependent!bool convertsTo(Type rhs){ if(auto t=super.convertsTo(rhs).prop) return t; // all basic types except void can be cast to each other if(auto bt=rhs.getUnqual().isBasicType()) return (op != Tok!"void" || bt.op == Tok!"void").independent; return false.independent; } override Dependent!Type combine(Type rhs){ if(this is rhs.getHeadUnqual()) return this.independent!Type; else if(rhs is Type.get!void()) return null.independent!Type;; if(auto bt=rhs.getHeadUnqual().isBasicType()){ if(strength[op]>0&&strength[bt.op]>=0){ if(strength[op]<4&&strength[bt.op]<4) return Type.get!int().independent!Type; if(strength[op]<strength[bt.op]) return bt.independent!Type; if(strength[op]>strength[bt.op]) return this.independent!Type; }else{ if(strength[bt.op]==-2) return bt.complCombine(this).independent!Type; else if(strength[bt.op]==-1) return bt.imagCombine(this).independent!Type; } switch(strength[op]){ case -2: return complCombine(bt).independent!Type; case -1: // imaginary types return imagCombine(bt).independent!Type; case 0: return null.independent!Type; case 4: return Type.get!uint().independent!Type; case 5: return Type.get!ulong().independent!Type; case 6: return Type.get!UCent().independent!Type; case 7: if(op==Tok!"float" && bt.op==Tok!"float") return this.independent!Type; else if(op!=Tok!"real" && bt.op!=Tok!"real") return Type.get!double().independent!Type; else return Type.get!real().independent!Type; default: assert(0); } } return super.combine(rhs); } // TODO: compress into a single template and two alias private BasicType imagCombine(BasicType bt)in{assert(strength[op]==-1);}body{ if(strength[bt.op]==-1){ if(op==Tok!"ifloat" && bt.op==Tok!"ifloat") return this; else if(op!=Tok!"ireal" && bt.op!=Tok!"ireal") return Type.get!idouble(); else return Type.get!ireal(); } // imaginary + complex if(strength[bt.op]==-2){ if(op==Tok!"ifloat" && bt.op==Tok!"cfloat") return Type.get!cfloat(); if(op!=Tok!"ireal" && bt.op!=Tok!"creal") return Type.get!cdouble(); if(op==Tok!"ireal" || bt.op==Tok!"creal") return Type.get!creal(); } // imaginary + 2's complement integer if(strength[bt.op]<7){ if(op==Tok!"ifloat") return Type.get!cfloat(); if(op==Tok!"idouble") return Type.get!cdouble(); if(op==Tok!"ireal") return Type.get!creal(); } // imaginary + 'real' if(op==Tok!"ifloat" && bt.op==Tok!"float") return Type.get!cfloat(); if(op!=Tok!"ireal" && bt.op!=Tok!"real") return Type.get!cdouble(); return Type.get!creal(); } private BasicType complCombine(BasicType bt)in{assert(strength[op]==-2);}body{ if(strength[bt.op]==-2){ if(op==Tok!"cfloat" && bt.op==Tok!"cfloat") return this; else if(op!=Tok!"creal" && bt.op!=Tok!"creal") return Type.get!cdouble(); else return Type.get!creal(); } // complex + imaginary if(strength[bt.op]==-1){ if(op==Tok!"cfloat" && bt.op==Tok!"ifloat") return Type.get!cfloat(); if(op!=Tok!"creal" && bt.op!=Tok!"ireal") return Type.get!cdouble(); if(op==Tok!"creal" || bt.op==Tok!"ireal") return Type.get!creal(); } // complex + 2's complement integer if(strength[bt.op]<7){ if(op==Tok!"cfloat") return Type.get!cfloat(); if(op==Tok!"cdouble") return Type.get!cdouble(); if(op==Tok!"creal") return Type.get!creal(); } // complex + 'real' if(op==Tok!"cfloat" && bt.op==Tok!"float") return Type.get!cfloat(); if(op!=Tok!"creal" && bt.op!=Tok!"real") return Type.get!cdouble(); return Type.get!creal(); } override IntRange getIntRange(){ switch(op){ mixin({ string r; foreach(x;["dchar", "uint"]) r~=mixin(X!q{case Tok!"@(x)": return IntRange(@(x).min,@(x).max,false);}); foreach(x;["bool","byte","ubyte","char","short","ushort","wchar","int"]) r~=mixin(X!q{case Tok!"@(x)": return IntRange(@(x).min,@(x).max,true);}); return r; }()); default: return super.getIntRange(); } } override LongRange getLongRange(){ switch(op){ case Tok!"ulong": return LongRange(ulong.min,ulong.max,false); mixin({ string r; foreach(x;["bool","byte","ubyte", "char","short","ushort","wchar","int","dchar","uint","long"]) r~=mixin(X!q{case Tok!"@(x)": return LongRange(@(x).min,@(x).max,true);}); return r; }()); default: return super.getLongRange(); } } } mixin template Semantic(T) if(is(T==ConstTy)||is(T==ImmutableTy)||is(T==SharedTy)||is(T==InoutTy)){ private enum qual = T.stringof[0..$-2]; /* directly create a semantically analyzed instance */ static Type create(Type next)in{ assert(next.sstate == SemState.completed); }body{ auto tt = mixin(`next.in`~qual~`Context()`); if(tt is next){ assert(!mixin(`next.`~lowerf(qual)~`Type`)); auto r = New!T(tt); r.ty = tt; r.sstate = SemState.completed; return r; }else return mixin(`tt.get`~qual)(); } invariant(){assert(sstate < SemState.started || ty); mixin(_restOfInvariant);} Type ty; // the 'T' in 'qualified(T)', the "qualifyee" override void semantic(Scope sc){ mixin(SemPrlg); ty=e.typeSemantic(sc); mixin(SemProp!q{e}); Type r; static if(is(T==ConstTy)) r=ty.getConst(); else static if(is(T==ImmutableTy)) r=ty.getImmutable(); else static if(is(T==SharedTy)) r=ty.getShared(); else static if(is(T==InoutTy)) r=ty.getInout(); else static assert(0); sstate = SemState.begin; needRetry=false; r.semantic(sc); mixin(RewEplg!q{r}); } static if(is(T==ConstTy)||is(T==ImmutableTy)||is(T==InoutTy)) override bool isMutable(){return false;} else static if(is(T==SharedTy)) override bool isMutable(){return ty.isMutable();} else static assert(0); /* some general notes: the order of qualifiers is shared(inout(const(T))) or immutable(T) if sstate == SemState.completed. 'create' and 'semantic' establish this dented invariant. some of the code below relies on this order. it does not operate correctly on incorrectly ordered input. */ private enum _restOfInvariant=q{ // TODO: fix this as soon as muliple invariants allowed import std.typetuple; alias TypeTuple!("ImmutableTy","SharedTy","InoutTy","ConstTy") Order; if(sstate == SemState.completed){ foreach(x; Order){ static if(!is(T==ImmutableTy)) if(x==T.stringof) break; assert(!mixin(`(cast()ty).is`~x)(), to!string(cast()ty)); } } }; static if(is(T==InoutTy)){ override Type adaptToImpl(Type from, ref InoutRes res){ if(auto imm = from.isImmutableTy()){ res = mergeIR(res, InoutRes.immutable_); }else if(auto con = from.isConstTy()){ assert(!con.ty.isInoutTy()); // normal form: inout(const(T)) res = mergeIR(res, InoutRes.const_); }else if(auto sha = from.isSharedTy()){ // information could be burried, eg shared(const(int)) return adaptToImpl(sha.ty, res); }else if(auto ino = from.isInoutTy()){ res = mergeIR(res, ino.ty.isConstTy() ? InoutRes.inoutConst : InoutRes.inout_); }else res = mergeIR(res, InoutRes.mutable); return ty.getTailInout().adaptToImpl(from.getHeadUnqual(), res).getInout(); } override Type resolveInout(InoutRes res){ // Spec is ambiguous here. this assertion is not valid for // the implementation chosen: // assert(ty.resolveInout(res).equals(ty)); auto rty=ty.resolveInout(res); final switch(res){ case InoutRes.none, InoutRes.inout_: return this; case InoutRes.mutable: return rty; case InoutRes.immutable_: return rty.getImmutable(); case InoutRes.const_: return rty.getConst(); case InoutRes.inoutConst: return rty.getConst().getInout(); } } }else{ /* hand through adaptTo and resolveInout calls */ override Type adaptToImpl(Type from, ref InoutRes res){ return mixin(`ty.getTail`~qual~`().adaptToImpl(from, res).get`~qual)(); } override Type resolveInout(InoutRes res){ return mixin(`ty.resolveInout(res).get`~qual)(); } } override Dependent!void typeMatch(Type from){ assert(!!from); static if(is(T==ConstTy)||is(T==InoutTy)){ if(auto im=from.isImmutableTy()) from=im.ty; else{ from=from.inConstContext(); static if(is(T==InoutTy)) from=from.inInoutContext(); } }else if(auto ccc = mixin(`from.is`~qual~`Ty()`)) from=ccc.ty; mixin(TypeMatch!q{_;mixin(`ty.getTail`~qual~`()`), from}); return indepvoid; } override Dependent!Type unify(Type rhs){ auto stc=getHeadSTC(); auto rstc=rhs.getHeadSTC(); mixin(Unify!q{auto unqual;getHeadUnqual(),rhs.getHeadUnqual()}); return unqual.applySTC(stc).refCombine(unqual.applySTC(rstc),0); } override bool hasPseudoTypes(){ return ty.hasPseudoTypes(); } override bool equals(Type rhs){ if(auto d=mixin(`rhs.is`~T.stringof)()) return ty.equals(d.ty); return false; } override Dependent!bool implicitlyConvertsTo(Type rhs){ // TODO: aggregate types if(cast(AggregateTy)this||cast(AggregateTy)rhs) return super.implicitlyConvertsTo(rhs); // getHeadUnqual never returns a qualified type ==> no recursion return getHeadUnqual().implicitlyConvertsTo(rhs.getHeadUnqual()); } override Dependent!bool convertsTo(Type rhs){ // TODO: reference types return getUnqual().convertsTo(rhs); } override Dependent!bool refConvertsTo(Type rhs, int num){ // TODO: reference types if(this is rhs) return true.independent; if(auto d=mixin(`rhs.is`~T.stringof)()){ static if(is(T==ConstTy) || is(T==ImmutableTy)){ // const and immutable imply covariance return mixin(`ty.getTail`~qual)().refConvertsTo(mixin(`d.ty.getTail`~qual)(), 0); }else{ // shared and inout do not imply covariance unless they are also const: auto nn = this is getConst() ? 0 : num; return mixin(`ty.getTail`~qual)().refConvertsTo(mixin(`d.ty.getTail`~qual)(),nn); } } static if(is(T==ImmutableTy)||is(T==InoutTy))if(num < 2){ static if(is(T==ImmutableTy)){ if(rhs is rhs.getConst()){ // immutable(Sub)* implicitly converts to // [const|inout const|shared const|shared inout const](Super)* return ty.getTailImmutable().refConvertsTo(rhs.getHeadUnqual(), 0); } }else static if(is(T==InoutTy)){ // inout(Sub)* implicitly converts to const(Super)* if(auto d=rhs.isConstTy()){ return ty.inConstContext().getTailInout().refConvertsTo(d.ty.getTailConst(), 0); } } } return false.independent; } override Dependent!Type combine(Type rhs){ // TODO: reference types if(this is rhs) return this.independent!Type; // special rules apply to basic types: if(rhs.isBasicType()) return getHeadUnqual().combine(rhs); if(auto r = mostGeneral(rhs).prop) return r; auto lhs = getHeadUnqual(); rhs = rhs.getHeadUnqual(); if(auto r = lhs.combine(rhs).prop) return r; return null.independent!Type; } override Dependent!Type refCombine(Type rhs, int num){ // TODO: reference types if(auto r = refMostGeneral(rhs, num).prop) return r; if(num<2){ static if(is(T==ConstTy)||is(T==ImmutableTy)){ auto r = rhs.getConst(); if(rhs is r) return null.independent!Type; // stop recursion return refCombine(r,num); }else{ auto l=getConst(), r=rhs.getConst(); if(this is l && rhs is r) return null.independent!Type; // stop recursion return l.refCombine(r,num); } } return null.independent!Type; } /* members */ override Scope getMemberScope(){ return getUnqual().getMemberScope(); } override ulong getSizeof(){return ty.getSizeof();} override IntRange getIntRange(){return ty.getIntRange();} override LongRange getLongRange(){return ty.getLongRange();} /* the following methods are overridden in order to keep the qualifier order straight */ override protected Type getConstImpl() { static if(is(T==ConstTy)||is(T==ImmutableTy)) return this; else static if(is(T==SharedTy)) return ty.getConst().getShared(); else static if(is(T==InoutTy)) return ty.getConst().getInout(); else static assert(0); } override protected Type getImmutableImpl(){ static if(is(T==ImmutableTy)) return this; else return ty.getImmutable(); } override protected Type getSharedImpl(){ static if(is(T==ImmutableTy) || is(T==SharedTy)) return this; else return super.getSharedImpl(); } static if(!is(T==ConstTy)){ override protected Type getInoutImpl(){ static if(is(T==InoutTy)||is(T==ImmutableTy)) return this; else static if(is(T==SharedTy)) return ty.getInout().getShared(); else static assert(0); } } /* getHeadUnqual needs to tail-qualify the qualifyee */ override Type getHeadUnqual(){ if(hunqualType) return hunqualType; return hunqualType=mixin(`ty.getHeadUnqual().getTail`~qual)(); } override Type getUnqual(){ if(unqualType) return unqualType; return unqualType=ty.getUnqual(); } override Type getElementType(){ return getHeadUnqual().getElementType(); } override STC getHeadSTC(){ return ty.getHeadSTC()|mixin("STC"~lowerf(qual)); } /* tail-qualifying is done by tail-qualifying the qualifyee and then head-qualifying back the result appropriately */ private static string __dgliteralTail(){ // TODO: maybe memoize this? string r; foreach(q;typeQualifiers){ r~=mixin(X!q{ override Type getTail@(upperf(q))(){ return ty.getTail@(upperf(q))().get@(qual)(); } }); } return r; } mixin(__dgliteralTail()); /* any part of the type may be transitively qualified by some qualifier at most once. since immutable implies const (and shared) and it is stronger than unqualified, immutable(inout(T-)-) is simplified to immutable(T--) */ // TODO: analyze whether or not memoizing these is worthwhile override Type inConstContext(){ static if(is(T==ConstTy)) return ty.inConstContext(); else return mixin(`ty.inConstContext().get`~qual)(); } override Type inImmutableContext(){ return ty.inImmutableContext(); } override Type inSharedContext(){ static if(is(T==SharedTy)) return ty.inSharedContext(); else return mixin(`ty.inSharedContext().get`~qual)(); } override Type inInoutContext(){ static if(is(T==InoutTy)) return ty.inInoutContext(); else return mixin(`ty.inInoutContext().get`~qual)(); } override Type stripDefaultArguments(){ return mixin(`ty.stripDefaultArguments().get`~qual); } private: Type hunqualType; Type unqualType; } /* helper for Semantic![PointerTy|DynArrTy|ArrayTy] creates the members getTail[Qualified] and in[Qualified]Context parameters: tail: string evaluating to the tail of the type puthead: string evaluating to a member that puts the head back on the tail */ mixin template GetTailOperations(string tail, string puthead){ static string __dgliteralTailQualified(){// "delegate literals cannot be class members..." string r; foreach(q;typeQualifiers){ r~=mixin(X!q{ Type tail@(upperf(q))Type; override Type getTail@(upperf(q))(){ if(tail@(upperf(q))Type) return tail@(upperf(q))Type; return tail@(upperf(q))Type=@(tail).get@(upperf(q))().@(puthead); } override Type in@(upperf(q))Context(){ // TODO: analyze if memoizing worthwhile assert(@(tail)&&1); return @(tail).in@(upperf(q))Context().@(puthead); } }); } return r; } mixin(__dgliteralTailQualified()); } // TODO: make sure static arrays are treated like real value types mixin template Semantic(T) if(is(T==PointerTy)||is(T==DynArrTy)||is(T==ArrayTy)){ static if(is(T==ArrayTy)){ static T create(Type next, long size)in{ assert(next.sstate == SemState.completed); }body{ auto r = New!T(next, size); r.ty = next; r.sstate = SemState.completed; return r; } }else{ static T create(Type next)in{ assert(next.sstate == SemState.completed); }body{ auto r = New!T(next); r.ty = next; r.sstate = SemState.completed; return r; } } Type ty; override void semantic(Scope sc){ mixin(SemPrlg); ty=e.typeSemantic(sc); mixin(SemProp!q{e}); if(ty.isTypeTuple()){ static if(is(T==PointerTy)){ // TODO: propose expansion behaviour sc.error(format("cannot create pointer type for sequence '%s'", e), loc); mixin(ErrEplg); }else{ // (there's no syntax for this) assert(0,format("cannot create array type for sequence '%s'", e)); } } assert(ty.sstate==SemState.completed,text(e," ",ty," ",e.sstate," ",ty.sstate," ",e.needRetry," ",ty.needRetry)); Type r; static if(is(T==ArrayTy)) r=ty.getArray(length); else r = mixin("ty.get"~T.stringof[0..$-2]~"()"); mixin(RewEplg!q{r}); } override Type adaptToImpl(Type from, ref InoutRes res){ if(auto tt = mixin(`from.getHeadUnqual().is`~T.stringof)()){ return mixin(`ty.adaptToImpl(tt.ty,res).`~puthead); }else return this; } override Type resolveInout(InoutRes res){ return mixin(`ty.resolveInout(res).`~puthead); } override Dependent!void typeMatch(Type from){ Type tt = from.getHeadUnqual().isPointerTy(); // TODO: match static array dimension if(!tt) tt = from.getElementType(); if(tt) mixin(TypeMatch!q{_; ty, tt});//ty.typeMatch(tt); return indepvoid; } override bool hasPseudoTypes(){ return ty.hasPseudoTypes(); } override bool equals(Type rhs){ if(auto c=mixin(`rhs.is`~T.stringof)()){ static if(is(T==ArrayTy)) if(c.length!=length) return false; return ty.equals(c.ty); } return false; } static if(is(T==ArrayTy)){ override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; return ty.getDynArr().implicitlyConvertsTo(rhs); } } override Dependent!bool convertsTo(Type rhs){ if(auto t=super.convertsTo(rhs).prop) return t; rhs = rhs.getHeadUnqual(); static if(is(T==PointerTy)) return (rhs.isPointerTy() || rhs.isBasicType()).independent; else static if(is(T==DynArrTy)) return (cast(bool)rhs.isDynArrTy()).independent; else return implicitlyConvertsTo(rhs); } // this adds one indirection for pointers and dynamic arrays override Dependent!bool refConvertsTo(Type rhs, int num){ // dynamic and static arrays can implicitly convert to void[] // pointer types can implicitly convert to void* static if(is(T==DynArrTy)||is(T==ArrayTy)||is(T==PointerTy)){ static if(is(T==PointerTy)) auto vtt = Type.get!(void*)(); else auto vtt = Type.get!(void[])(); if(rhs.getUnqual() is vtt){ static if(is(T==PointerTy)){ auto c=rhs.isPointerTy(); if(!c) goto Lsuper; auto elr=c.ty; }else{ auto elr = rhs.getElementType(); assert(!!elr); } auto ell = ty; auto stcr = elr.getHeadSTC(), stcl=ell.getHeadSTC(); if(auto t=ell.refConvertsTo(ell.applySTC(stcr),num+1).prop) return t; } } static if(is(T==ArrayTy)) if(auto tt = rhs.isDynArrTy()){ // intuition for num+1: // auto dynamic = fixedsize; // assert(dynamic.ptr is &fixedsize[0]); if(auto t=ty.refConvertsTo(tt.ty, num+1).prop) return t; } if(auto c=mixin(`rhs.is`~T.stringof)()){ static if(is(T==ArrayTy)) return c.length!=length?false.independent:ty.refConvertsTo(c.ty,num); else return ty.refConvertsTo(c.ty,num+1); } Lsuper: return super.refConvertsTo(rhs,num); } override Dependent!Type combine(Type rhs){ if(auto r = mostGeneral(rhs).prop) return r; auto unqual = rhs.getHeadUnqual(); return unqual.refCombine(this,0); } override Dependent!Type refCombine(Type rhs, int num){ if(auto c=mixin(`rhs.is`~T.stringof)()){ mixin(RefCombine!q{Type rcomb; ty, c.ty, num+!is(T==ArrayTy)}); if(rcomb){ static if(is(T==ArrayTy)) if(c.length!=length) return rcomb.getDynArr().independent!Type; return mixin(`rcomb.`~puthead).independent!Type; } } return super.refCombine(rhs,num); } override Dependent!Type unify(Type rhs){ if(auto c=mixin(`rhs.is`~T.stringof)()){ static if(is(T==ArrayTy)) if(c.length!=length) return Type.init.independent; mixin(Unify!q{Type unf; ty, c.ty}); if(unf) return mixin(`unf.`~puthead).independent!Type; } static if(is(T==PointerTy)){ if(auto b = rhs.getFunctionTy()){ auto a = getFunctionTy(); if(!a) return null.independent!Type; mixin(Unify!q{Type c; a,b}); if(c){ assert(cast(FunctionTy)c); auto r = rhs.isDelegateTy() ? (cast(FunctionTy)cast(void*)c).getDelegate() : c.getPointer(); return r.independent!Type; } } } return super.unify(rhs); } private enum puthead = "get"~(is(T==ArrayTy)?"Array(length)":typeof(this).stringof[0..$-2]~"()"); mixin GetTailOperations!("ty", puthead); override Type getUnqual(){ return mixin(`ty.getUnqual().`~puthead); } override Type stripDefaultArguments(){ return mixin(`ty.stripDefaultArguments().`~puthead); } override ulong getSizeof(){ // TODO: this is not true for all machines static if(is(T==PointerTy) || is(T==DynArrTy)) auto s_ts = Type.get!Size_t().getSizeof(); static if(is(T==PointerTy)) return s_ts; else static if(is(T==DynArrTy)) return s_ts * 2; else{ static assert(is(T==ArrayTy)); return length * ty.getSizeof(); } } static if(is(T==PointerTy)) override Dependent!Expression matchCallHelper(Scope sc, const ref Location loc, Type this_, Expression[] args, ref MatchContext context){ if(auto ft=ty.getHeadUnqual().isFunctionTy()){ auto rd=ft.matchCallHelper(sc, loc, this_, args, context); if(rd.value) rd.value = this; // valid for dependee is null and dependee !is null return rd; } return null.independent!Expression; } static if(is(T==ArrayTy) || is(T==DynArrTy)): override Type getElementType(){return ty;} } mixin template Semantic(T) if(is(T==NullPtrTy)){ override Dependent!bool refConvertsTo(Type rhs, int num){ if(!num && rhs.isPointerTy()) return true.independent; if(auto at=rhs.isAggregateTy()) if(at.decl.isReferenceAggregateDecl()) return true.independent; return super.refConvertsTo(rhs, num); } override Dependent!bool implicitlyConvertsTo(Type rhs){ if(auto t=super.implicitlyConvertsTo(rhs).prop) return t; auto rhsu = rhs.getHeadUnqual(); return (rhsu.isDynArrTy() || rhsu is Type.get!EmptyArray() || rhsu.isDelegateTy()).independent; } override ulong getSizeof(){ // TODO: this is not true for all machines return Type.get!Size_t().getSizeof(); } } mixin template Semantic(T) if(is(T==EmptyArrTy)){ override Dependent!bool refConvertsTo(Type rhs, int num){ if(!num){ if(rhs.isDynArrTy()) return true.independent; if(auto arr = rhs.isArrayTy()) return (!arr.length).independent; } return super.refConvertsTo(rhs, num); } override Type getElementType(){ assert(type is Type.get!void()); return type; } override ulong getSizeof(){ // TODO: this is not true for all machines return Type.get!Size_t().getSizeof() * 2; } } mixin template Semantic(T) if(is(T==TypeofExp)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!f) f = e; f.weakenAccessCheck(AccessCheck.none); mixin(SemChld!q{f}); mixin(FinishDeductionProp!q{f}); //f = f.constFold(sc); // TODO: should this be done at all? if(f.isType()){ sc.error(format("typeof argument '%s' is not an expression",e.loc.rep),e.loc); mixin(ErrEplg); }else e=f; /+ if(!e.type){ auto r=Type.get!void(); mixin(RewEplg!q{r}); }+/ assert(!!f.type && f.type.sstate == SemState.completed,to!string(e)~" : "~to!string(f.type)); auto r=f.type; mixin(RewEplg!q{r}); } private: Expression f; // semantically analyzed 'e', needed for nice error handling } mixin template Semantic(T) if(is(T==TypeofReturnExp)){ override void semantic(Scope sc){ mixin(SemPrlg); auto fun=sc.getFunction(); if(!fun){ sc.error("'typeof(return)' must be inside function",loc); mixin(ErrEplg); } fun.analyzeType(); if(fun.type.hasUnresolvedReturn()){ sc.error("'typeof(return)' cannot be used before return type is deduced",loc); mixin(ErrEplg); } auto r=fun.type.ret; if(!r) mixin(ErrEplg); mixin(RewEplg!q{r}); } } mixin template Semantic(T) if(is(T==AggregateTy)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemEplg); } override Type checkVarDecl(Scope sc, VarDecl me){ if(!decl.isReferenceAggregateDecl()&&!decl.bdy){ if(me.name) sc.error(format("%s '%s' has incomplete type '%s'", me.kind, me.name, this), me.loc); else sc.error(format("%s has incomplete type '%s'", me.kind, this), me.loc); return New!ErrorTy(); } return this; } override AggregateScope getMemberScope(){ return decl.asc; } override string toString(){ TemplateInstanceDecl tmpl; if(auto nsts=cast(NestedScope)decl.scope_) if(auto tmps=cast(TemplateScope)nsts.parent) tmpl=tmps.tmpl; if(tmpl && decl.name.name is tmpl.name.name) return decl.name.name~"!("~join(map!(to!string)(tmpl.args),",")~")"; return decl.name.name; } override Dependent!bool refConvertsTo(Type rhs, int num){ if(this is rhs) return true.independent; if(!num){ if(auto raggrd=decl.isReferenceAggregateDecl()) if(auto at=rhs.isAggregateTy()) if(auto atraggrd=at.decl.isReferenceAggregateDecl()) return raggrd.isSubtypeOf(atraggrd); } return super.refConvertsTo(rhs, num); } override Dependent!Type combine(Type rhs){ if(auto t=super.combine(rhs).prop) return t; return refCombine(rhs,0); } override Dependent!Type refCombine(Type rhs, int num){ if(!num) if(auto cd1=decl.isClassDecl()){ if(auto rat=rhs.isAggregateTy()){ if(auto cd2=rat.decl.isClassDecl()){ auto sup = cd1.commonSuperType(cd2); if(auto d=sup.dependee) return d.dependent!Type; if(sup.value) return sup.value.getType().independent!Type; } } } return super.refCombine(rhs,num); } } mixin template Semantic(T) if(is(T==EnumTy)){ override Scope getMemberScope(){ return decl.msc; } override string toString(){ assert(!!decl.name); return decl.name.toString(); } // (remove this for strongly typed enums) override Dependent!bool implicitlyConvertsTo(Type to){ if(auto t=super.implicitlyConvertsTo(to).prop) return t; mixin(GetEnumBase!q{auto base;decl}); return base.implicitlyConvertsTo(to); } override Dependent!bool convertsTo(Type to){ if(auto t=super.convertsTo(to).prop) return t; mixin(GetEnumBase!q{auto base;decl}); return base.convertsTo(to); } string valueToString(Variant value){ foreach(m;decl.members){ if(m.sstate!=SemState.completed) continue; assert(m.rinit&&m.rinit.isConstant()); if(m.rinit.interpretV().opBinary!"is"(value)) return toString()~"."~m.name.name; } assert(!!decl.base); auto rv=value.convertTo(decl.base); return "cast("~type.toString()~")"~rv.toString(); } } // statements mixin template Semantic(T) if(is(T==Statement)){ override void semantic(Scope sc){ mixin(SemPrlg); sc.error("feature not implemented",loc); mixin(ErrEplg); } } mixin template Semantic(T) if(is(T==EmptyStm)){ override void semantic(Scope sc){ sstate = SemState.completed; } } mixin template Semantic(T) if(is(T==CompoundStm)){ override void semantic(Scope sc){ mixin(SemPrlg); //mixin(SemChld!q{s}); size_t initial = current; foreach(i,ref x; s[initial..$]){ mixin(SemChldPar!q{x}); current = max(current, initial+1+i); } mixin(PropErr!q{s}); mixin(SemEplg); } invariant(){assert(sstate!=SemState.completed || current == s.length);} private: size_t current = 0; // points to the next child to be semantically analyzed } mixin template Semantic(T) if(is(T==BlockStm)){ override void semantic(Scope sc){ if(!mysc) mysc = New!BlockScope(sc); super.semantic(mysc); } private: Scope mysc = null; } mixin template Semantic(T) if(is(T==LabeledStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(sstate == SemState.pre){ sc.insertLabel(this); sstate = SemState.begin; } mixin(SemChld!q{s}); mixin(SemEplg); } private: bool inserted = false; } mixin template Semantic(T) if(is(T==ExpressionStm)){ override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChldExp!q{e}); mixin(FinishDeductionProp!q{e}); mixin(SemEplg); } } // TODO: those all should use implicit explicit conversion AST nodes mixin template Semantic(T) if(is(T==IfStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!tsc) tsc = New!BlockScope(sc); mixin(SemChldExpPar!q{sc=tsc;e}); mixin(FinishDeduction!q{e}); auto bl = Type.get!bool(); if(e.sstate == SemState.completed){e=e.convertTo(bl); e.semantic(tsc);} // TODO: get rid of direct call if(e.sstate == SemState.completed) mixin(ConstFold!q{e}); mixin(PropRetry!q{sc=tsc;e}); mixin(SemChldPar!q{sc=tsc;s1}); if(s2){ if(!esc) esc = New!BlockScope(sc); mixin(SemChld!q{sc=esc;s2}); } mixin(SemProp!q{sc=tsc;e}); mixin(SemProp!q{sc=tsc;s1}); mixin(SemEplg); } private: BlockScope tsc, esc; } mixin template Semantic(T) if(is(T==BreakableStm)){ } mixin template Semantic(T) if(is(T==LoopingStm)){ } mixin template Semantic(T) if(is(T==WhileStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!lsc){lsc = New!BlockScope(sc); lsc.setLoopingStm(this);} auto bl = Type.get!bool(); mixin(SemChldExpPar!q{sc=lsc;e}); mixin(FinishDeduction!q{e}); if(e.sstate == SemState.completed){e=e.convertTo(bl);e.semantic(lsc);} // TODO: ditto if(e.sstate == SemState.completed) mixin(ConstFold!q{e}); mixin(SemChld!q{sc=lsc;s}); mixin(SemProp!q{sc=lsc;e}); mixin(SemEplg); } private: BlockScope lsc; } mixin template Semantic(T) if(is(T==DoStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!lsc){lsc = New!BlockScope(sc); lsc.setLoopingStm(this);} mixin(SemChldPar!q{sc=lsc;s}); mixin(SemChldPar!q{e});// TODO: propose SemChld!q{sc=lsc;e} mixin(FinishDeduction!q{e}); auto bl = Type.get!bool(); if(e.sstate == SemState.completed){e=e.convertTo(bl);e.semantic(lsc);} // TODO: get rid of direct call if(e.sstate == SemState.completed) mixin(ConstFold!q{sc=lsc;e}); mixin(SemProp!q{sc=lsc;s}); mixin(SemProp!q{e}); mixin(SemEplg); } private: BlockScope lsc; } mixin template Semantic(T) if(is(T==ForStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!lscs1){lscs1 = New!BlockScope(sc);} if(s1) mixin(SemChldPar!q{sc=lscs1;s1}); if(!lsc){ lsc = New!BlockScope(lscs1); lsc.setLoopingStm(this); } if(e1){ mixin(SemChldExpPar!q{sc=lsc;e1}); auto bl = Type.get!bool(); mixin(FinishDeduction!q{e1}); if(e1.sstate == SemState.completed){e1=e1.convertTo(bl);e1.semantic(lsc);}// TODO: ditto if(e1.sstate == SemState.completed) mixin(ConstFold!q{sc=lsc;e1}); mixin(PropRetry!q{sc=lsc;e1}); } if(e2){ e2.semantic(lsc); // TODO: ditto if(e2.sstate == SemState.completed) mixin(ConstFold!q{sc=lsc;e2}); mixin(PropRetry!q{sc=lsc;e2}); mixin(FinishDeduction!q{e2}); } mixin(SemChldPar!q{sc=lsc;s2}); if(s1) mixin(PropErr!q{s1}); if(e1) mixin(PropErr!q{e1}); if(e2) mixin(PropErr!q{e2}); mixin(PropErr!q{s2}); mixin(SemEplg); } private: BlockScope lscs1; BlockScope lsc; } // TODO: this OO approach for opApply is a little verbose. better options? class OpApplyFunctionLiteralExp: FunctionLiteralExp{ ForeachStm lstm; this(FunctionTy ft, CompoundStm b, ForeachStm lstm)in{ assert(!!lstm.retVar); }body{ super(ft,b); this.lstm=lstm; } protected override FunctionDef createFunctionDef(FunctionTy fty,Identifier name, CompoundStm bdy){ return New!OpApplyFunctionDef(STC.init,fty,name,bdy,lstm); } mixin DownCastMethod; mixin Visitors; } template Semantic(T) if(is(T==OpApplyFunctionLiteralExp)){ } class OpApplyFunctionDef: FunctionDef{ ForeachStm lstm; this(STC stc, FunctionTy fty, Identifier name, CompoundStm bdy, ForeachStm lstm)in{ assert(!!lstm.retVar); }body{ super(stc,fty,name,cast(BlockStm)null,cast(BlockStm)null,cast(Identifier)null,bdy); this.lstm=lstm; lstm.setOpApplyFunctionDef(this); } Statement[] gotos; int addGoto(Statement gto){ gotos~=gto; return ForeachStm.opApplyReturnCode+cast(int)gotos.length; } protected override FunctionScope buildFunctionScope(){ return New!FunctionScope(scope_, this); } protected override void undeclaredLabel(GotoStm gto){ assert(cast(Identifier)gto.e); if(!gto.lower){ auto ngto=New!GotoStm(gto.t,gto.e); ngto.loc=gto.loc; gto.lower=ForeachStm.createOpApplyReturn(addGoto(ngto),gto.loc); } mixin(SemChld!q{sc=gto.scope_;gto.lower}); } mixin DownCastMethod; mixin Visitors; } template Semantic(T) if(is(T==OpApplyFunctionDef)){ } mixin template Semantic(T) if(is(T==ForeachStm)){ Statement lower; GaggingScope gsc=null; Identifier[] checkMembership; override void semantic(Scope sc){ mixin(SemPrlg); if(lower) goto Llowered; if(!lsc){lsc = New!BlockScope(sc); lsc.setLoopingStm(this);} mixin(SemChld!q{aggregate}); mixin(FinishDeductionProp!q{aggregate}); auto ty = aggregate.type; auto tyu = aggregate.type.getHeadUnqual(); // foreach over built-in arrays Type et = null; if(auto tt = tyu.isArrayTy()) et = tt.ty; if(auto tt = tyu.isDynArrTy()) et = tt.ty; if(et){ needRetry=false; lower=createArrayForeach(sc,ty,et); mixin(SemCheck); goto Llowered; } // TODO: foreach over string types with automatic decoding // TODO: foreach over associative arrays // TODO: finish: foreach with opApply if(!gsc){ auto msc=aggregate.getMemberScope(); if(msc) gsc=New!GaggingScope(msc); } void createMembershipTest(string s){ checkMembership~=New!Identifier(s); checkMembership[$-1].willAlias(); checkMembership[$-1].accessCheck=AccessCheck.none; if(!gsc) checkMembership[$-1].sstate=SemState.error; } if(!checkMembership.length) createMembershipTest(isReverse?"opApplyReverse":"opApply"); mixin(SemChldPar!q{sc=gsc;checkMembership[0]}); if(checkMembership[0].sstate==SemState.completed){ needRetry=false; lower=createOpApplyForeach(sc); mixin(SemCheck); goto Llowered; } // TODO: finish: foreach over ranges if(checkMembership.length==1){ createMembershipTest(isReverse?"back":"front"); // 1 createMembershipTest("empty"); // 2 createMembershipTest(isReverse?"popBack":"popFront"); // 3 } assert(checkMembership.length>=4); foreach(i;1..4) mixin(SemChldPar!q{sc=gsc;checkMembership[i]}); alias util.all all; if(all!(a=>a.sstate==SemState.completed)(checkMembership[1..4])){ needRetry=false; lower=createRangeForeach(sc); mixin(SemCheck); goto Llowered; } // TODO: foreach over delegates // TODO: foreach over Tuples // TODO: EXTENSION: foreach using opApply/range primitives with UFCS Llowered: if(lower) mixin(SemChld!q{lower}); else{ // TODO: assert(lower) instead foreach(var; vars) var.semantic(lsc); // TODO: fix? //mixin(SemChld!q{scope=lsc, bdy}); // TODO: implement this bdy.semantic(lsc); // TODO: get rid of direct call mixin(SemProp!q{sc=lsc;bdy}); mixin(PropErr!q{vars, aggregate}); } mixin(SemEplg); } private ForStm createArrayForeach(Scope sc,Type ty,Type et)in{ assert(ty is aggregate.type); assert(et is ty.getElementType); }body{ if(vars.length>2){ sc.error("at most two loop variables allowed for array foreach", vars[0].loc.to(vars[$-1].loc)); mixin(ErrEplg); } ForeachVarDecl var=null; auto s_t = Type.get!Size_t(); if(vars.length == 2){ if(vars[0].rtype){ vars[0].type = vars[0].rtype.typeSemantic(lsc); auto rtype=vars[0].rtype; mixin(SemProp!q{sc=lsc;rtype}); if(!vars[0].type.equals(s_t)){ // TODO: This is a stub sc.error(format("invalid type '%s' for index variable '%s'", vars[0].rtype.loc.rep, vars[0].name.toString()), vars[0].rtype.loc); sstate = SemState.error; } }else vars[0].type = s_t; var=vars[0]; } assert(vars.length); if(vars[$-1].rtype){ vars[$-1].type = vars[$-1].rtype.typeSemantic(lsc); mixin(SemProp!q{sc=lsc;vars[$-1].rtype}); mixin(ImplConvertsTo!q{auto iconv; et, vars[$-1].type}); if(!iconv){ sc.error(format("cannot implicitly convert from element type '%s' to '%s'", et.toString(), vars[$-1].rtype.loc.rep),vars[$-1].rtype.loc); sstate = SemState.error; } }else vars[$-1].type = et; auto agvar=New!ForeachVarDecl(STC.init,ty,null,aggregate); agvar.loc=aggregate.loc; agvar.presemantic(sc); scope Statement[] mdecls=[agvar]; scope Statement[] mups=[vars[$-1]]; import variant; auto left=LiteralExp.factory(Variant(0,s_t)); left.loc=aggregate.loc; auto agsym=New!Symbol(agvar); agsym.loc=agvar.loc; auto lenid=New!Identifier("length"); lenid.loc=agsym.loc; auto right=New!(BinaryExp!(Tok!"."))(agsym,lenid); right.loc=agsym.loc; auto agsymi=New!Symbol(agvar); agsymi.loc=vars[$-1].loc; auto indexvar=New!ForeachVarDecl(STC.init,s_t,null,isReverse?right:left); indexvar.loc=(vars.length==2?vars[0]:vars[$-1]).loc; auto symidx=New!Symbol(indexvar); symidx.loc=indexvar.loc; auto index=New!IndexExp(agsymi,[cast(Expression)symidx]); symidx.loc=agsym.loc; vars[$-1].init=index; auto f=ForeachRangeStm.createForStmForRange(sc,var,indexvar,s_t,isReverse,left,right,bdy,mdecls,mups); f.loc=loc; return f; } private{ // TODO: this uses space in every ForeachStm instance: Expression opApplyExp=null; OpApplyFunctionDef oafun=null; } VarDecl retVar=null; void setOpApplyFunctionDef(OpApplyFunctionDef oafun)in{assert(!this.oafun);}body{ this.oafun=oafun; } bool isOpApplyForeach(){ return !!opApplyExp; } enum opApplyReturnCode=2; public static ReturnStm createOpApplyReturn(int returnCode, Location loc){ import variant; auto val=LiteralExp.factory(Variant(returnCode,Type.get!int())); auto ret=New!ReturnStm(val); ret.loc=loc; ret.isOpApplyReturn=true; return ret; } private Statement createOpApplyForeach(Scope sc){ enum SemRet=q{ return null; }; if(!opApplyExp){ auto be=New!(BinaryExp!(Tok!"."))(aggregate,New!Identifier(isReverse?"opApplyReverse":"opApply")); be.loc=aggregate.loc; // GC: auto fty=New!FunctionTy(STC.init,null,vars.map!(a=>cast(Parameter)a).array,VarArgs.none); auto ret=createOpApplyReturn(0,loc); auto cbdy=New!CompoundStm([bdy,ret]); cbdy.loc=bdy.loc; assert(!retVar); retVar=New!VarDecl(STC.init,null,null,New!VoidInitializerExp()); retVar.presemantic(sc); Expression lmb=New!OpApplyFunctionLiteralExp(fty,cbdy,this); lmb.loc=loc; // TODO: fix diagnostics! opApplyExp=New!CallExp(be,[lmb]); opApplyExp.loc=aggregate.loc; } mixin(SemChld!q{opApplyExp}); mixin(ImplConvertsTo!q{auto conv;Type.get!byte(),opApplyExp.type}); if(!conv){ sc.error(format("opApply must return an integral type, not '%s'",opApplyExp.type),aggregate.loc); mixin(ErrEplg); } assert(!retVar.type || retVar.sstate==SemState.completed); // TODO: locations? Statement[] cases; import variant; // default: break; cases~=New!DefaultStm([cast(Statement)New!BreakStm(null)]); if(retVar.type){ // case 2: return retVar; cases~=New!CaseStm([cast(Expression)LiteralExp.factory(Variant(opApplyReturnCode,Type.get!int()))], [cast(Statement)New!ReturnStm(New!Symbol(retVar))]); } assert(!!oafun); foreach(i,gto;oafun.gotos){ cases~=New!CaseStm([cast(Expression)LiteralExp.factory(Variant(opApplyReturnCode+1+i,Type.get!int()))],[gto]); } // TODO: more cases for goto and labelled break/continue auto swbdy=New!CompoundStm(cases); swbdy.loc=loc; auto sw=New!SwitchStm(false,opApplyExp,swbdy); sw.loc=loc; Statement r=sw; if(retVar.type){ r=New!CompoundStm([cast(Statement)retVar,sw]); r.loc=loc; } return r; } private ForStm createRangeForeach(Scope sc){ if(vars.length>1){ assert(vars.length); sc.error("only one loop variable allowed for range foreach",vars[1].loc.to(vars[$-1].loc)); mixin(ErrEplg); } //for(auto =rng;!rng.empty;rng.popFront); auto s1=New!ForeachVarDecl(STC.init,null,null,aggregate); s1.presemantic(sc); auto sym=New!Symbol(s1); sym.loc=vars[0].loc; auto iempty=New!Identifier("empty"); iempty.loc=aggregate.loc; auto empty=New!(BinaryExp!(Tok!"."))(sym,iempty); empty.loc=iempty.loc; auto e1=New!(UnaryExp!(Tok!"!"))(empty); e1.loc=empty.loc; auto ipop=New!Identifier(isReverse?"popBack":"popFront"); ipop.loc=aggregate.loc; auto pop=New!(BinaryExp!(Tok!"."))(sym,ipop); pop.loc=ipop.loc; auto e2=New!CallExp(pop,(Expression[]).init); e2.loc=pop.loc; auto ielem=New!Identifier(isReverse?"back":"front"); ielem.loc=vars[0].loc; auto elem=New!(BinaryExp!(Tok!"."))(sym,ielem); elem.loc=ielem.loc; vars[0].init=elem; auto s2=New!BlockStm([cast(Statement)vars[0],bdy]); auto f=New!ForStm(s1,e1,e2,s2); f.loc=loc; return f; } private: BlockScope lsc; } mixin template Semantic(T) if(is(T==ForeachRangeStm)){ ForStm lower; override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{left,right}); mixin(TypeCombine!q{auto type;left,right}); if(!type){ sc.error(format("incompatible types '%s' and '%s' for foreach range",left.type,right.type),left.loc.to(right.loc)); mixin(ErrEplg); } if(!lower){ lower=createForStmForRange(sc,var,null,type,isReverse,left,right,bdy); lower.loc=loc; } mixin(SemChld!q{lower}); mixin(SemEplg); } static ForStm createForStmForRange(Scope sc,ForeachVarDecl var,ForeachVarDecl idxvar,Type type,bool isReverse,Expression left, Expression right, Statement bdy, scope Statement[] mdecls=[],scope Statement[] mups=[]){ if(var){ assert(!var.init); var.init=left; } if(!idxvar){ idxvar=New!ForeachVarDecl(STC.init, type, null, isReverse?right:left); idxvar.loc=idxvar.init.loc; } auto boundvar=New!ForeachVarDecl(STC.init, type, null, isReverse?left:right); boundvar.loc=boundvar.init.loc; auto tmpl=isReverse?boundvar:idxvar; tmpl.presemantic(sc); auto tmpr=isReverse?idxvar:boundvar; tmpr.presemantic(sc); auto s1=New!CompoundStm(mdecls~[cast(Statement)tmpl,tmpr]); s1.loc=(var?var:left).loc.to(right.loc); auto syml=New!Symbol(tmpl); syml.loc=left.loc; auto symr=New!Symbol(tmpr); symr.loc=right.loc; auto e1=type.isBasicType()? // DMD seems to do this. Is this documented? New!(BinaryExp!(Tok!"<"))(syml,symr): New!(BinaryExp!(Tok!"!="))(syml,symr); e1.loc=syml.loc.to(symr.loc); Expression e2=null; Statement s2; if(!isReverse){ e2=New!(UnaryExp!(Tok!"++"))(syml); e2.loc=e1.loc; if(var) var.init=syml; s2=New!BlockStm((var?[cast(Statement)var]:[])~mups~[bdy]); }else{ auto edec=New!(UnaryExp!(Tok!"--"))(symr); edec.loc=e1.loc; auto sdec=New!ExpressionStm(edec); sdec.loc=edec.loc; if(var) var.init=symr; s2=New!BlockStm((var?[sdec,var]:[cast(Statement)sdec])~mups~[bdy]); } s2.loc=bdy.loc; return New!ForStm(s1,e1,e2,s2); } } import bst; struct DisjointIntervalSet(T, alias l=(auto ref x)=>x.l,alias r=(auto ref x)=>x.r) if(is(typeof((T a,T b)=>l(a)<l(a)&&l(a)<l(b)&&l(b)<l(a)&&l(b)<l(b)&& r(a)<r(a)&&r(a)<r(b)&&r(b)<r(a)&&r(b)<r(b)))) { private static struct CompareR{ T payload; int opCmp(CompareR rhs){ return opCmp(rhs); } int opCmp(ref CompareR rhs){ static if(is(typeof(r(payload).opCmp(r(rhs.payload))))) return r(payload).opCmp(r(rhs.payload)); else{ auto a=r(payload),b=r(rhs.payload); return a<b?-1:a>b?1:0; } } int opCmp(typeof(r(payload)) rhs){ return opCmp(rhs); } int opCmp(ref typeof(r(payload)) rhs){ static if(is(typeof(r(payload).opCmp(rhs)))) return r(payload).opCmp(rhs); else{ auto a=r(payload),b=rhs; return a<b?-1:a>b?1:0; } } } private Set!CompareR right; auto range(){ return right.range.map!(a=>a.payload); } alias range opSlice; private size_t _length; @property size_t length(){ return _length; } auto S tryIntersect(S)( T toIntersect, scope S delegate(T) intersected, scope S delegate() noneFound) { auto rng=right.from(l(toIntersect)); if(!rng.empty && l(rng.front.payload)<=r(toIntersect)) return intersected(rng.front.payload); return noneFound(); } // TODO: how to accept both ref and non-ref delegates without using alias? auto S insertOrIntersect(S)( T toInsert, scope S delegate() inserted, scope S delegate(T)intersected) { return tryIntersect(toInsert, intersected, (){ right.insert(CompareR(toInsert)); _length++; return inserted(); }); } } mixin template Semantic(T) if(is(T==SwitchStm)){ BlockScope lsc; SwitchLabelStm[] cases; DefaultStm theDefault; VarDecl tmpVarDecl, tmpVarDeclStr; // store temporary value and it's length/characters import variant; private struct ComparisonValue{ Variant value; int opCmp(ComparisonValue rhs){ return opCmp(rhs); } int opCmp(ref ComparisonValue rhs){ return value.opBinary!"<"(rhs.value)?-1:value.opBinary!">"(rhs.value)?1:0; } } private struct CaseRange{ ComparisonValue l,r; SwitchLabelStm stm; size_t index; } private DisjointIntervalSet!CaseRange casesInOrder; bool addCase(CaseStm c, Scope sc){ bool err=false; foreach(i,e;c.e){ auto cv=ComparisonValue(e.interpretV()); auto cr=CaseRange(cv,cv,c,i); CaseRange pr; casesInOrder.insertOrIntersect(cr, {}, (CaseRange p){ pr=p; }); auto prev = pr.stm; if(!prev) continue; err=true; if(auto p=prev.isCaseStm()){ sc.error(format("duplicate case '%s' in switch statement", c.e[cr.index]), c.e[cr.index].loc); sc.note("previous case is here",p.e[pr.index].loc); }else if(auto p=prev.isCaseRangeStm()){ sc.error(format("case '%s' already occurs in case range '%s..%s'", c.e[0], p.e1, p.e2), c.e[0].loc); sc.note("this case range is here",p.loc); }else assert(0); } if(err) return false; cases ~= c; resolveGotoCase(c); return true; } bool addCaseRange(CaseRangeStm c, Scope sc){ if(f){ if(sc){ sc.error("final switch statement cannot include a case range", c.loc); sc.note("enclosing final switch statement is here", loc); } return false; } auto cr=CaseRange(ComparisonValue(c.e1.interpretV()), ComparisonValue(c.e2.interpretV()), c); CaseRange pr; casesInOrder.insertOrIntersect(cr, {}, (CaseRange p){ pr=p; }); auto prev = pr.stm; if(!prev){cases ~= c; resolveGotoCase(c); return true; } if(auto p=prev.isCaseStm()){ sc.error(format("case range '%s..%s' includes duplicate case '%s'", c.e1, c.e2, p.e[pr.index]), c.e1.loc.to(c.e2.loc)); sc.note("previous case is here",p.e[0].loc); }else if(auto p=prev.isCaseRangeStm()){ auto l=pr.l.value.opBinary!">="(cr.l.value)?pr.l.value:cr.l.value, r=pr.r.value.opBinary!"<="(cr.r.value)?pr.r.value:cr.r.value; assert(l.opBinary!"<="(r)); if(l==r){ auto ce = pr.l.value.opBinary!">"(cr.l.value)?c.e2:c.e1; sc.error(format("case '%s' already occurs in case range '%s..%s' (case ranges are inclusive)", ce, p.e1, p.e2), ce.loc); sc.note("this case range is here", p.loc); }else{ auto le=pr.l.value.opBinary!">="(cr.l.value)?p.e1:c.e1, re=pr.r.value.opBinary!">="(cr.l.value)?p.e2:c.e2; sc.error(format("case range '%s..%s' overlaps with previous case range '%s..%s' in cases '%s..%s'", c.e1, c.e2, p.e1, p.e2, le, re), c.e1.loc.to(c.e2.loc)); sc.note("previous case range was here",p.loc); } } return false; } bool addDefault(DefaultStm d, Scope sc){ if(!theDefault){ theDefault = d; if(f){ sc.error("final switch statement cannot have a default clause", theDefault.loc); sc.note("enclosing final switch statement is here", loc); return false; } return true; } if(sc){ sc.error("switch statement already has a default branch", d.loc); sc.note("previous default branch is here", theDefault.loc); } return false; } GotoStm[][] switchGotos; private bool tryResolveGoto(GotoStm gto){ if(gto.t == WhichGoto.caseExp){ auto cv=ComparisonValue(gto.e.interpretV()); auto cr=CaseRange(cv,cv); ILabeledStm target; casesInOrder.tryIntersect(cr, (CaseRange x){ target=x.stm; }, (){}); if(target){ gto.resolveLabel(target); return true; } }else if(gto.t == WhichGoto.default_){ if(theDefault){ gto.resolveLabel(theDefault); return true; } } return false; } private void resolveGotoCase(SwitchLabelStm stm){ if(!switchGotos.length) return; assert(switchGotos.length==2); foreach(gto;switchGotos[1]){ assert(gto.t == WhichGoto.case_); gto.resolveLabel(stm); } switchGotos[1]=[]; } private bool resolveAllGotos(Scope sc){ if(!switchGotos.length) return false; assert(switchGotos.length==2); bool err=false; foreach(gto;switchGotos[1]){ sc.error("no further case statements after 'goto case'",gto.loc); err=true; } foreach(gto;switchGotos[0]){ if(tryResolveGoto(gto)) continue; err=true; if(gto.t==WhichGoto.caseExp) sc.error(format("case '%s' cannot be found in switch statement",gto.e),gto.loc); else{ assert(gto.t==WhichGoto.default_); if(f) sc.error("no default case in final switch statement",gto.loc); } } switchGotos=[]; return err; } void addGoto(GotoStm gto)in{ with(WhichGoto){ assert(gto.t.among(caseExp,case_,default_)); assert(gto.t !is caseExp||gto.e&&gto.e.sstate==SemState.completed&&gto.e.isConstant()); } }body{ if(!switchGotos.length) switchGotos.length=2; // GC allocations if(!tryResolveGoto(gto)) switchGotos[gto.t==WhichGoto.case_]~=gto; } enum Kind{ invalid, sintegral, uintegral, string, wstring, dstring, } Kind kind; bool isIntegral(){ return kind==kind.uintegral||kind==kind.sintegral; } bool isString(){ return kind==Kind.string||kind==Kind.wstring||kind==Kind.dstring; } private static Kind determineStringKind(Type tt){ return tt is Type.get!string() ? Kind.string : tt is Type.get!wstring() ? Kind.wstring : tt is Type.get!dstring() ? Kind.dstring : Kind.invalid ; } override void semantic(Scope sc){ mixin(SemPrlg); if(!lsc){lsc = New!BlockScope(sc); lsc.setSwitchStm(this);} mixin(SemChldPar!q{e}); void expErr(lazy string err){ sc.error(err, e.loc); e.sstate = SemState.error; } Type etyu; if(e.sstate==SemState.completed){ assert(!!e.type); etyu=e.type.getHeadUnqual(); kind = determineStringKind(etyu); if(kind==Kind.invalid){ if(auto i=etyu.isIntegral()){ kind = i.isSigned()?kind.sintegral:kind.uintegral; }else{ if(auto et=etyu.isEnumTy()){ assert(!!et.decl); Type base; do{ mixin(GetEnumBase!q{base;et.decl}); et=base.isEnumTy(); }while(et&&base); if(!base) e.sstate=SemState.error; else{ kind = determineStringKind(base); if(kind == Kind.invalid){ if(auto i=base.isIntegral()){ kind = i.isSigned()?kind.sintegral:kind.uintegral; }else{ expErr("enum base of switch expression type should be a built-in string or integral type"); e.sstate=SemState.error; } } } }else{ sc.error(format("switch expression should be of built-in string or integral type instead of '%s'",e.type), e.loc); e.sstate=SemState.error; } } } } if(f&&e.sstate==SemState.completed&&!etyu.isEnumTy()){ expErr(format("final switch expression should be of enumeration type instead of '%s'",e.type)); } mixin(SemChldPar!q{sc=lsc;s}); bool err=false; if(f&&e.sstate==SemState.completed){ assert(!!cast(EnumTy)etyu); auto et=cast(EnumTy)cast(void*)etyu; if(et.decl){ mixin(SemChld!q{et.decl}); foreach(m;et.decl.members){ assert(m.init&&m.init.isConstant()); auto v=ComparisonValue(m.init.interpretV()); auto cr=CaseRange(v,v); if(!casesInOrder.tryIntersect(cr, (CaseRange _)=>true, ()=>false)){ if(!err){ sc.error("non-exhaustive final switch", loc); err=true; } sc.note(format("enum member '%s' not represented",m.name), m.loc); } } }else err=true; } if(!f&&!theDefault){ sc.error("non-final switch statement requires a default clause", loc); err=true; } err|=resolveAllGotos(sc); if(err) mixin(ErrEplg); mixin(SemProp!q{e,s}); assert(!tmpVarDecl); if(!tmpVarDecl){ tmpVarDecl = New!TmpVarDecl(STC.init, null, null, e); tmpVarDecl.presemantic(sc); } if(!tmpVarDeclStr && this.isString()){ tmpVarDeclStr = New!TmpVarDecl(STC.init, null, null, New!LengthExp(e)); tmpVarDeclStr.presemantic(sc); } if(tmpVarDeclStr) mixin(SemChld!q{tmpVarDeclStr}); mixin(SemChld!q{tmpVarDecl}); mixin(SemEplg); } } mixin template Semantic(T) if(is(T==SwitchLabelStm)) { } mixin template Semantic(T) if(is(T==CaseStm)||is(T==CaseRangeStm)||is(T==DefaultStm)){ static if(is(T==CaseStm)) Expression eLeftover=null; enum _which = is(T==CaseStm)?"case":is(T==CaseRangeStm)?"case range":"default"; override void semantic(Scope sc){ mixin(SemPrlg); auto sw = sc.getSwitchStm(); if(!sw){ sc.error(_which~" statement must occur in switch statement", loc); mixin(ErrEplg); } static if(is(T==CaseRangeStm)){ alias SwitchStm.Kind K; if(sw.kind!=K.invalid&&!sw.kind.among(K.sintegral,K.uintegral)){ sc.error("cannot use a case range within a "~to!string(sw.kind)~" switch statement", loc); mixin(SemChld!q{s}); mixin(ErrEplg); } } static if(is(T==CaseStm)){ foreach(x;e) x.prepareInterpret(); mixin(SemChldPar!q{e}); // TODO: use chain and only foreach(ref x;e) if(x.sstate == SemState.completed){ x.interpret(sc); mixin(PropRetry!q{x}); } if(eLeftover && eLeftover.sstate == SemState.completed){ eLeftover.interpret(sc); mixin(PropRetry!q{eLeftover}); } }else static if(is(T==CaseRangeStm)){ e1.prepareInterpret(); e2.prepareInterpret(); mixin(SemChldPar!q{e1,e2}); e1.interpret(sc); e2.interpret(sc); mixin(PropRetry!q{e1,e2}); } else static assert(is(T==DefaultStm)); static if(!is(T==DefaultStm)){ if(sw.e.sstate==SemState.completed){ static if(is(T==CaseStm)) foreach(ref ee;e){ if(ee.sstate==SemState.completed) mixin(ImplConvertToPar!q{ee,sw.e.type}); }else static if(is(T==CaseRangeStm)){ if(e1.sstate==SemState.completed) mixin(ImplConvertToPar!q{e1,sw.e.type}); if(e2.sstate==SemState.completed) mixin(ImplConvertToPar!q{e2,sw.e.type}); }else static assert(0); } } bool shouldInsert=true; static if(is(T==CaseStm)) shouldInsert&=util.all!(a=>a.sstate==SemState.completed)(e); static if(is(T==CaseRangeStm)){ if(e1.sstate==SemState.completed&&e2.sstate==SemState.completed){ if(e1.interpretV().opBinary!">"(e2.interpretV())){ sc.error(format("lower bound '%s' exceeds upper bound '%s' in case range", e1, e2), e1.loc.to(e2.loc)); mixin(SetErr!q{e1}); shouldInsert=false; } }else shouldInsert=false; } if(shouldInsert&&addedToSwitch==SwInsState.notAdded) addedToSwitch=mixin(`sw.add`~__traits(identifier,T)[0..$-3])(this,sc)? SwInsState.added:SwInsState.error; mixin(SemChld!q{s}); static if(is(T==CaseStm)) mixin(PropErr!q{e}); static if(is(T==CaseRangeStm)) mixin(PropErr!q{e1,e2}); if(SwInsState.added==SwInsState.error) mixin(ErrEplg); mixin(SemEplg); } private: enum SwInsState{ notAdded, added, error, } auto addedToSwitch=SwInsState.notAdded; } mixin template Semantic(T) if(is(T==ReturnStm)){ bool performedAccessCheck=false; bool isOpApplyReturn=false; override void semantic(Scope sc){ mixin(SemPrlg); if(e){ mixin(SemChldExpPar!q{e}); if(auto et=e.isExpTuple()){ if(!performedAccessCheck){ auto exps=new Expression[et.length]; size_t i=0; foreach(Expression exp;et){ exps[i]=exp.clone(sc, InContext.none, AccessCheck.all, e.loc); exps[i].checkAccess(sc, AccessCheck.all); i++; } performedAccessCheck=true; e=New!ExpTuple(exps); mixin(SemChldExpPar!q{e}); } } } auto fun = sc.getFunction(); VarDecl retVar=null; if(!isOpApplyReturn) for(;;){ // TODO: this results in total runtime quadratic // in nesting depth of opApply foreach loops if(auto oafun=fun.isOpApplyFunctionDef()){ if(!retVar) retVar=oafun.lstm.retVar; fun=oafun.scope_.getFunction(); }else break; } assert(fun && fun.type,text(fun," ",fun?fun.type:null," ",sc," ",this)); if(fun.type.hasUnresolvedReturn()){ if(!e) fun.type.resolveReturn(Type.get!void()); else if(e.sstate == SemState.completed && fun.sstate != SemState.error){ fun.type.resolveReturn(e.type); mixin(RetryEplg); }else{ fun.type.ret = New!ErrorTy(); fun.type.sstate = SemState.error; fun.sstate = SemState.error; fun.needRetry = false; mixin(ErrEplg); } }else if(e){ mixin(PropErr!q{e}); if(fun.type.rret) mixin(PropErr!q{fun.type.rret}); assert(!!fun.type.ret); mixin(PropErr!q{fun.type.ret}); mixin(ImplConvertTo!q{e,fun.type.ret}); }else if(fun.type.ret !is Type.get!void()){ sc.error(format("non-void function '%s' should return a value",fun.name),loc); mixin(ErrEplg); } // TODO: auto ref isRefReturn = cast(bool)(fun.type.stc&STCref); if(isRefReturn && e){ // TODO: ref return should probably be banned for void returning functions if(!e.checkLvalue(sc,e.loc)) mixin(ErrEplg); } if(e&&!e.finishDeduction(sc)) mixin(ErrEplg); if(retVar){ assert(!isOpApplyReturn); assert(!!fun.type.ret); if(!retVar.rtype) retVar.rtype=fun.type.ret; mixin(SemChldPar!q{sc=retVar.scope_;retVar}); assert(retVar.sstate==SemState.completed); auto sym=New!Symbol(retVar); sym.loc=loc; // TODO: make sure no destructor will be called on retVar once destructors are implemented // TODO: make sure this will pass @safe-ty checks auto asng=New!(BinaryExp!(Tok!"="))(sym,e); asng.loc=loc; Statement astm=New!ExpressionStm(asng); astm.loc=loc; auto ret=ForeachStm.createOpApplyReturn(ForeachStm.opApplyReturnCode,loc); auto r=New!CompoundStm([astm,ret]); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } mixin(SemEplg); } bool isRefReturn; } mixin template Semantic(T) if(is(T==ContinueStm)||is(T==BreakStm)){ private enum _which = is(T==ContinueStm)?"continue":"break"; private enum _enc = "loop"~(is(T==ContinueStm)?"":" or switch"); private enum _name = is(T==ContinueStm)?"theLoop":"brokenOne"; private enum _query = is(T==ContinueStm)?"LoopingStm":"BreakableStm"; override void semantic(Scope sc){ mixin(SemPrlg); if(!e){ if(!mixin(_name)) mixin(_name) = mixin(`sc.get`~_query)(); if(!mixin(_name)){ sc.error(_which~" statement must occur in "~_enc~" statement",loc); mixin(ErrEplg); } }else{ if(!mixin(_name)){ auto lstm = sc.lookupLabel(e); if(!lstm) goto Lerr; if(auto lp = mixin(`lstm.s.is`~_query)()){ mixin(_name) = lp; }else goto Lerr; if(!sc.isEnclosing(getLoweredEnclosingStatement())) goto Lerr; } } auto fun=sc.getFunction(); if(auto oafun=fun.isOpApplyFunctionDef()){ if(oafun.lstm is mixin(_name)){ auto r=ForeachStm.createOpApplyReturn(is(T==BreakStm),loc); r.semantic(sc); mixin(RewEplg!q{r}); }else if(oafun.scope_.isEnclosing(mixin(_name))){ auto ngto=New!(typeof(this))(e); ngto.loc=loc; auto r=ForeachStm.createOpApplyReturn(oafun.addGoto(ngto),loc); r.semantic(sc); mixin(RewEplg!q{r}); } } assert(!!mixin(_name)); mixin(SemEplg); Lerr: sc.error(format("enclosing label '%s' for "~_which~" statement not found",e.toString()),e.loc); mixin(ErrEplg); } final getLoweredEnclosingStatement(){ auto enc=mixin(_name); assert(!!enc); typeof(enc) processLower(Statement lower){ if(auto l=lower.isLoopingStm()) return l; return enc; } if(auto fr=enc.isForeachStm()){ if(fr.lower) return processLower(fr.lower); assert(fr.isOpApplyForeach()); return enc; } if(auto fr=enc.isForeachRangeStm()) return processLower(fr.lower); return enc; } private: static if(is(T==ContinueStm)) LoopingStm theLoop; else static if(is(T==BreakStm)) BreakableStm brokenOne; else static assert(0); } mixin template Semantic(T) if(is(T==GotoStm)){ override void semantic(Scope sc){ mixin(SemPrlg); if(!scope_) scope_=sc; final switch(t) with(WhichGoto){ case identifier: assert(cast(Identifier)e); sc.registerForLabel(this, cast(Identifier)cast(void*)e); break; case caseExp: case case_: case default_: if(e){ assert(t==caseExp); mixin(SemChld!q{e}); mixin(IntChld!q{e}); } if(!theSwitch) theSwitch=sc.getSwitchStm(); if(theSwitch){ if(!lower) theSwitch.addGoto(this); auto fun=sc.getFunction(); if(auto oafun=fun.isOpApplyFunctionDef()){ if(oafun.scope_.isEnclosing(theSwitch)){ if(!lower){ auto ngto=New!(typeof(this))(t,e); ngto.loc=loc; ngto.theSwitch=theSwitch; lower=ForeachStm.createOpApplyReturn(oafun.addGoto(ngto),loc); } mixin(SemChld!q{lower}); } } break; } sc.error(format("'%s' outside switch statement",this),loc); mixin(ErrEplg); } mixin(SemEplg); } void resolveLabel(ILabeledStm tgt){ target = tgt; } // gotos may need to be rewritten when they have already been fully analyzed due to opApply: Scope scope_; Statement lower; private: ILabeledStm target; SwitchStm theSwitch; // used for lowering opApply, there is no surface syntax } class WithBaseScope: Scope{ Scope other; Expression sym; this(Scope other,Expression sym){ this.other=other; this.sym=sym; } private AliasDecl createAliasToDecl(Declaration decl){ return New!AliasDecl(STC.init,New!VarDecl(STC.init,New!(BinaryExp!(Tok!"."))(sym,New!Symbol(decl)),New!Identifier(decl.name.name),Expression.init)); } private Declaration getAlias(Declaration decl){ if(!decl||typeid(decl) is typeid(DoesNotExistDecl)) return decl; if(auto odecl=symtabLookup(this,decl.name)) return odecl; auto a = createAliasToDecl(decl); a.semantic(this); return a; } override @property ErrorHandler handler(){ return other.handler; } override Dependent!Declaration lookupHereImpl(Scope view,Identifier name,bool onlyMixins){ return other.lookupHereImpl(view,name,onlyMixins).depmap!(a=>getAlias(a)); } override Dependent!IncompleteScope getUnresolvedHereImpl(Scope view, Identifier ident, bool onlyMixins, bool noHope){ return other.getUnresolvedHereImpl(view,ident,onlyMixins,noHope); } } mixin template Semantic(T) if(is(T==WithStm)){ BlockScope bsc; Expression exp = null; TmpVarExp tmp = null; Expression sym = null; private Expression createSymbol(Expression e,Expression this_){ if(!this_) return e; if(e is this_) return tmp?tmp.sym:Type.get!void(); if(auto fld=e.isFieldExp()) return New!(BinaryExp!(Tok!"."))(createSymbol(fld.e1,this_),fld.e2); assert(0,text(e)); } override void semantic(Scope sc){ mixin(SemPrlg); if(!exp) exp=e; mixin(SemChld!q{exp}); // TODO: maybe do not ignore s if error, but only lookup failures within it auto msc=exp.getMemberScope(); if(!msc){ // TODO: fix getMemberScope for built-in types sc.error("invalid 'with' expression",e.loc); mixin(ErrEplg); } auto this_=exp.extractThis(); // silly special casing of void if(!tmp&&this_&&this_.type !is Type.get!void()) tmp=New!TmpVarExp(this_); if(tmp) mixin(SemChld!q{tmp}); if(!sym) sym=createSymbol(exp,this_); mixin(SemChld!q{sym}); if(!bsc){ bsc=New!BlockScope(sc); if(tmp) msc=New!WithBaseScope(msc,sym); if(!bsc.addImport(msc,ImportKind.mixin_)) mixin(ErrEplg); } mixin(SemChld!q{sc=bsc;s}); mixin(SemEplg); } } mixin template Semantic(T) if(is(T==CatchStm)){ override void semantic(Scope sc){ mixin(SemPrlg); sc.error("unimplemented feature CatchStm",loc); mixin(ErrEplg); } } mixin template Semantic(T) if(is(T==TryStm)){ override void semantic(Scope sc){ mixin(SemPrlg); sc.error("unimplemented feature TryStm",loc); mixin(ErrEplg); } } // declarations mixin template Semantic(T) if(is(T==Declaration)){ Scope scope_ = null; invariant(){assert(sstate != SemState.pre || !scope_, to!string(typeid(this)));} void pickupSTC(STC stc){ this.stc|=~conflictingSTC(this.stc)&stc; } void potentialInsert(Scope sc, Declaration dependee){ if(name) sc.potentialInsert(name, dependee, this); } void potentialRemove(Scope sc, Declaration dependee){ if(name) sc.potentialRemove(name, dependee, this); } // TODO: reduce DMD bug in presence of the out contract void presemantic(Scope sc){//out(result){ //assert(result is this); // TODO: remove return type? //}body{ // insert into symbol table, but don't do the heavy processing yet if(sstate != SemState.pre) return; sstate = SemState.begin; if(!name){sc.error("feature "~to!string(typeid(this))~" not implemented",loc); sstate = SemState.error; return;} // TODO: obvious if(!sc.insert(this)){mixin(ErrEplg);} } override void semantic(Scope sc){ if(sstate==SemState.pre) presemantic(sc); mixin(SemPrlg); mixin(SemEplg); } final bool isMember(){ if(stc&STCstatic) return false; auto fd=isFunctionDecl(); if(fd && fd.isConstructor()){ // constructors are logically members of the enclosing scope auto decl=scope_.getDeclaration(); if(!decl||!decl.isAggregateDecl()||decl.stc&STCstatic) return false; if(auto decl2=decl.scope_.getDeclaration) return !!decl2.isAggregateDecl(); } if(auto decl=scope_.getDeclaration()) return !!decl.isAggregateDecl(); return false; } /* Returns true if the declaration has to be checked for accessibility at the given access check level. */ bool needsAccessCheck(AccessCheck check)in{assert(check!=AccessCheck.init);}body{ return !(stc&STCstatic) && check == AccessCheck.all; } Dependent!Declaration matchCall(Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args, ref MatchContext context){ return null.independent!Declaration; } void matchError(Scope sc, Location loc, Type this_, Expression[] args){ sc.error(format("%s '%s' is not callable",kind,name.toString()),loc); } Declaration matchInstantiation(Scope sc, const ref Location loc, bool gagged, bool isMixin, Expression owner, TemplArgsWithTypes args){ if(sc) sc.error(format("can only instantiate templates, not %s%ss",kind,kind[$-1]=='s'?"e":""),loc); return null; } Declaration matchIFTI(Scope sc, const ref Location loc, Type this_, Expression func, TemplArgsWithTypes args, Expression[] funargs){ if(sc) sc.error(format("%s '%s' is not a function template",kind, name.name),loc); return null; } // TODO: make OO instead of functional? static Dependent!bool isDeclAccessible(Declaration from, Declaration decl, Declaration mfun=null)in{ assert(decl.sstate != SemState.pre); }body{ bool show = from&&decl&&from.name&&decl.name&&from.name.name=="compare"&&decl.name.name=="o"; // TODO: this check might be redundant if(decl.stc&STCstatic || decl.stc&STCenum && decl.isVarDecl() || decl.isTmpVarDecl()) // TODO: ok? return true.independent; // constructors have special lookup rules if(auto fd=decl.isFunctionDecl()){ if(fd.isConstructor()) return isDeclAccessible(from, fd.scope_.getDeclaration()); } if(!decl.scope_){ // parameters inside function types // do not have a scope assert(!!cast(Parameter)decl); return true.independent; } auto enc = decl.scope_.getDeclaration(); if(!enc) return true.independent; // eg. delegate literals at module scope for(Declaration dl=from;;dl=dl.scope_.getDeclaration()){ if(dl is null) return false.independent; if(dl is enc){ return (!from.isAggregateDecl()||mfun&&mfun.isFunctionDecl()).independent; } if(auto raggr=dl.isReferenceAggregateDecl()){ mixin(AggregateParentsInOrderTraversal!q{ mixin(IsDeclAccessible!q{auto b; Declaration, parent, decl, mfun}); if(b) return true.independent; }); } if(from is enc) return (!from.isAggregateDecl()).independent; if(dl.stc & STCstatic) return false.independent; if(auto fn=dl.isFunctionDef()){ if(auto fn2=decl.isFunctionDef()){ fn2.notifyIfNot(STCstatic,fn); }else fn.canBeStatic = false; } // TODO: infer whether a template instantiation needs to be local or not mfun=dl; } assert(0); // silence DMD. TODO: report bug } void nestedTemplateInstantiation(TemplateInstanceDecl decl){ assert(0,"TODO: nestedTemplateInstantiation for "~to!string(typeid(this))); } void nestedFunctionLiteral(FunctionDef def){ assert(0,"TODO: nestedDelegateLiteral for "~to!string(typeid(this))); } protected mixin template HandleNestedDeclarations(){ override void nestedTemplateInstantiation(TemplateInstanceDecl decl){ ndecls~=decl; } override void nestedFunctionLiteral(FunctionDef def){ ndecls~=def; } private: Declaration[] ndecls; } int traverseInOrder(scope int delegate(Declaration) dg){ return dg(this); } } class TupleContext{ VarDecl[] vds; Expression[] syms=null; AliasDecl tupleAlias=null; Expression initLeftover=null; } mixin template Semantic(T) if(is(T==VarDecl)){ Type type; TupleContext tupleContext; bool isField=false; // TODO: would rather not store these override void presemantic(Scope sc){ if(sstate != SemState.pre) return; if(!name){ scope_ = sc; sstate = SemState.begin; }else super.presemantic(sc); if(sstate == SemState.error) type = null; // TODO: why is this here? if(auto decl=sc.getDeclaration()) if(auto aggr = decl.isAggregateDecl()) isField=true; } // used in Symbol to get the correct storage classes for the variable decl // TODO: this duplicates logic present in VarDecl.semantic enum SymbolResolve = q{ assert(!!vd.type); vd.type.semantic(meaning.scope_); mixin(Rewrite!q{vd.type}); mixin(CircErrMsg); mixin(SemProp!q{vd.type}); type=vd.type; if(vd.type.sstate != SemState.error && vd.type.isTypeTuple()){ mixin(MeaningSemantic); // TODO: does this generate invalid circ. dependencies? mixin(CircErrMsg); mixin(PropRetry!q{sc=meaning.scope_;meaning}); if(vd.tupleContext){ assert(!!vd.tupleContext && !!vd.tupleContext.tupleAlias); meaning = vd.tupleContext.tupleAlias; sstate = SemState.begin; semantic(sc); return; } } if(type.sstate == SemState.completed) type = type.applySTC(meaning.stc); else assert(type.needRetry||type.sstate == SemState.error); vd.stc|=type.getHeadSTC(); // TODO: this is controversial, and should only be done for fields // if(vd.stc&(STCimmutable|STCconst) && vd.init) vd.stc|=STCstatic; }; final bool willInterpretInit()in{assert(!!init);}body{ return stc&(STCenum|STCstatic) || isField; } protected void defaultInit(){ // convention: init is null means that the type should be zeroed out if(!init && type && type.sstate == SemState.completed){ // default initializers if(auto aggr=type.getUnqual().isAggregateTy()) if(auto strd=aggr.decl.isStructDecl()){ init = New!StructConsExp(type,(Expression[]).init); init.loc = loc; init.initOfVar(this); } } } // allow EnumVarDecl to continue semantic void doSemEplg(){ mixin(SemEplg); } override void semantic(Scope sc){ mixin(SemPrlg); if(rtype){ type=rtype.typeSemantic(sc); mixin(PropRetry!q{rtype}); } if(init){ init.initOfVar(this); if(init.sstate!=SemState.completed){ if(willInterpretInit()) init.prepareInterpret(); mixin(SemChldExpPar!q{init}); } // deduce type if(!type && init.sstate!=SemState.error) type=init.type; }else if(!rtype && !type){ sc.error(format("initializer required for '%s' declaration",STCtoString(stc)),loc); mixin(ErrEplg); } if(sstate == SemState.pre && name){ // insert into scope presemantic(sc); mixin(SemCheck); sstate = SemState.begin; } if(!type||type.sstate==SemState.error||rtype&&rtype.sstate==SemState.error){ type=null; mixin(ErrEplg); } assert(type.sstate == SemState.completed); {scope(exit) if(sstate==SemState.error) type=null; needRetry=false; mixin(SemProp!q{type}); mixin(SemCheck); } type = type.applySTC(stc); // add appropriate storage classes according to type stc |= type.getHeadSTC(); // TODO: this is controversial, and should only be done for fields // if(stc&(STCimmutable|STCconst) && init) stc|=STCstatic; if(!init) defaultInit(); // TODO: this is a hack (and incorrect, since some code relies on init==null) if(init){ mixin(SemChldPar!q{init}); if(willInterpretInit()&&init.sstate==SemState.completed){ mixin(ImplConvertsTo!q{bool iconv;init, type}); // type deduction should finish before interpretation // expressions with no deduced type have type 'void' if(!iconv||type is Type.get!void()) mixin(FinishDeductionProp!q{init}); assert(init.sstate == SemState.completed, to!string(init)); init.interpret(sc); mixin(PropRetry!q{init}); // TODO: is there a more elegant way to handle array initialization? } }else if(stc&STCenum){ sc.error("manifest constants must have initializers",loc); mixin(ErrEplg); } if(auto tp = type.isTypeTuple()){ alias tupleContext tc; auto len = tp.length; if(!tc) tc = New!TupleContext(); ExpTuple et = null; TypeTuple tt = null; if(init && init.type){ et=init.isExpTuple(); if(!et) tt=init.type.isTypeTuple(); if(et||tt){ if(len!=(et?et.length:tt.length)){ sc.error(format("tuple of %d elements cannot initialize tuple of %d elements",et.length,len),loc); mixin(ErrEplg); } }else{ et = New!ExpTuple(len, init); et.loc = init.loc; init = et; mixin(SemChldPar!q{init}); } // better error message for type mismatch: if(!init.isVoidInitializerExp()&&init.sstate==SemState.completed){ mixin(ImplConvertsTo!q{bool iconv; init, type}); if(!iconv) mixin(ImplConvertTo!q{init, type}); } /// } if(init) assert(tt || init.sstate == SemState.error || et && et.length==len); // TODO: gc allocations if(!tc.vds && !tc.initLeftover){ tc.vds = new VarDecl[cast(size_t)len]; Expression commaLeft=null; if(init){ if(auto ce=init.isCommaExp()){ commaLeft=ExpTuple.splitCommaExp(ce, et); commaLeft.semantic(sc); assert(commaLeft.sstate == SemState.completed); init = et; } assert(et || !willInterpretInit()); } if(commaLeft && !tc.vds.length) tc.initLeftover=commaLeft; foreach(i, ref x;tc.vds){ auto id = name?New!Identifier("__tuple_"~name.name~"_"~to!string(i)):null; auto ini = et?et.index(sc,InContext.none,init.loc,i):null; if(!i && commaLeft){ assert(ini); auto nini=New!(BinaryExp!(Tok!","))(commaLeft, ini); nini.loc=nini.e1.loc.to(nini.e2.loc); ini=nini; } x = newVarDecl(stc, tp.index(sc,InContext.none,loc,i), id, ini); x.sstate = SemState.begin; x.loc = loc; x.scope_=scope_; x.isField=isField; } } mixin(SemChld!q{tc.vds}); if(!tc.syms){ tc.syms = new Expression[cast(size_t)len]; foreach(i, ref x;tc.syms){ auto sym = New!Symbol(tc.vds[i]); sym.accessCheck = AccessCheck.none; sym.loc = loc; // TODO: fix sym.scope_=scope_; sym.willAlias(); x = sym; } } foreach(x;tc.syms) mixin(SemChldPar!q{x}); if(!tc.tupleAlias){ auto stpl = New!ExpTuple(tc.syms); // TODO: can directly transfer ownership stpl.loc = loc; tc.tupleAlias = New!AliasDecl(STC.init, newVarDecl(STC.init, stpl, name, null)); tc.tupleAlias.sstate = SemState.begin; tc.tupleAlias.loc = loc; tc.tupleAlias.scope_=scope_; } mixin(SemChld!q{tc.tupleAlias}); if(init) mixin(SemProp!q{init}); return doSemEplg(); // Symbol will rewrite the meaning } if(init){ mixin(SemProp!q{init}); // order is significant: fully interpreted expressions might carry information // that allows more implicit conversions if(!init.isVoidInitializerExp()){ mixin(ImplConvertTo!q{init,type}); } if(!willInterpretInit()) mixin(FinishDeductionProp!q{init}); else{ mixin(IntChld!q{init}); if(stc&STCenum){ prepareEnumInitializer(); //mixin(SemCheck); } } } type = type.checkVarDecl(sc,this); mixin(SemProp!q{type}); if(stc&STCref){ mixin(NoRetry); handleRef(sc); mixin(SemCheck); } if(isField){ auto aggr = sc.getDeclaration().isAggregateDecl(); assert(!!aggr); if(!(stc&(STCstatic|STCenum))) aggr.layoutChanged(); } return doSemEplg(); } private void prepareEnumInitializer(){ assert(init.isConstant()||init.isArrayLiteralExp()); // re-allocate mutable dynamic array constants everywhere: if(init.type.isDynArrTy()&&init.type.getElementType().isMutable()){ if(auto lexp=init.isLiteralExp()){ init=lexp.toArrayLiteral(); } } } protected void handleRef(Scope sc){ sc.error("local variables and fields cannot be ref", loc); mixin(ErrEplg); } final protected void actuallyHandleRef(Scope sc){ if(init&&!init.checkLvalue(sc, init.loc)) mixin(ErrEplg); } override @property string kind(){ return isField?"field":"variable"; } protected: VarDecl newVarDecl(STC stc, Expression rtype, Identifier name, Expression initializer){ return New!VarDecl(stc,rtype,name,initializer); } } mixin template Semantic(T) if(is(T==Parameter)){ override void presemantic(Scope sc){ // NOTE: cannot rely on being in a function // parameters might be analyzed in the // template constraint scope as well if(name&&!name.length) return; // TODO: why is this here? super.presemantic(sc); } final bool mustBeTypeDeduced(){ return !type && !rtype && !init; } override void defaultInit(){} // parameters are not default-initialized override protected void handleRef(Scope sc){ return actuallyHandleRef(sc); } protected: override Parameter newVarDecl(STC stc, Expression rtype, Identifier name, Expression initializer){ return New!Parameter(stc,rtype,name,initializer); } } mixin template Semantic(T) if(is(T==ForeachVarDecl)){ protected: override ForeachVarDecl newVarDecl(STC stc, Expression rtype, Identifier name, Expression initializer){ return New!ForeachVarDecl(stc,rtype,name,initializer); } } mixin template Semantic(T) if(is(T==CArrayDecl)||is(T==CArrayParam)){ final void computeRtype(){ for(;;)if(auto id=postfix.isIndexExp()){ postfix = id.e; id.e = rtype; rtype = id; }else break; } override void semantic(Scope sc){ computeRtype(); super.semantic(sc); } } mixin template Semantic(T) if(is(T==EmptyDecl)){ override void presemantic(Scope sc){ if(sstate != SemState.pre) return; sstate = SemState.begin; scope_ = sc; } override void semantic(Scope sc){ mixin(SemEplg); } } mixin template Semantic(T) if(is(T==ImportDecl)){ override void potentialInsert(Scope sc, Declaration dependee){ sc.potentialInsertArbitrary(dependee, this); } override void potentialRemove(Scope sc, Declaration dependee){ sc.potentialRemoveArbitrary(dependee, this); } private string path; override void presemantic(Scope sc){ assert(symbols.length); if(symbols.length>1){ auto decls=new Declaration[symbols.length]; foreach(i,ref x;decls){ x = New!ImportDecl(stc, symbols[i..i+1]); x.loc = loc; } auto r=New!BlockDecl(STC.init,decls); r.loc=loc; r.semantic(sc); mixin(RewEplg!q{r}); } if(sstate != SemState.pre) return; if(!(stc&STCvisibility)) stc|=STCprivate; sstate = SemState.begin; scope_ = sc; potentialInsert(sc, this); string computePath(Expression e){ if(auto fe=e.isFieldExp()){ assert(cast(Identifier)fe.e2); auto id=cast(Identifier)cast(void*)fe.e2; return computePath(fe.e1)~'/'~id.name; }else if(auto id=e.isIdentifier()) return id.name; else if(auto ib=e.isImportBindingsExp()){ stc|=STCstatic; return computePath(ib.symbol); }else if(auto ass=e.isAssignExp()){ stc|=STCstatic; return computePath(ass.e2); }else assert(0,text("TODO: ",e,typeid(e))); } path = computePath(symbols[0]); } override void semantic(Scope sc){ mixin(SemPrlg); if(sstate == SemState.pre){ presemantic(sc); if(rewrite) return; } scope(exit) if(!needRetry) potentialRemove(sc, this); auto cm = sc.getModule(); assert(!!cm); auto repo = cm.repository; string err; auto m = repo.getModule(path, true, err); if(!m){ if(err) sc.error(err, symbols[0].loc); mixin(ErrEplg); } if(!(stc&STCstatic)&&!sc.addImport(m.sc,importKindFromSTC(stc))) mixin(ErrEplg);; mixin(SemEplg); } } mixin template Semantic(T) if(is(T==EnumVarDecl)){ EnumDecl enc; Expression rinit; EnumVarDecl prec; override void doSemEplg(){ } override void semantic(Scope sc){ assert(enc.name&&sc is enc.msc||sc is enc.scope_); mixin(SemPrlg); if(!init){ if(!prec){ init = LiteralExp.factory(Variant(0, Type.get!int())); init.loc=loc; }else{ mixin(SemChld!q{prec}); assert(prec.rinit); if(!rtype) type=prec.type; auto previnit=prec.rinit.cloneConstant(); auto one=LiteralExp.factory(Variant(1,Type.get!int())); // TODO: prettier error messages? init=New!(BinaryExp!(Tok!"+"))(previnit,one); init.loc=previnit.loc=one.loc=loc; } } needRetry=false; if(!rinit) super.semantic(sc); mixin(SemCheck); if(!prec&&!enc.base) enc.base=type; if(!rinit) rinit=init; if(enc.name){ auto ty=enc.getType(); assert(!!ty); mixin(GetEnumBase!q{auto base;enc}); assert(init.type is type && base); mixin(ImplConvertsTo!q{auto b; type, base}); if(!b){ sc.error(format("incompatible initializer '%s' of type '%s' for enum member of base type '%s'",init, init.type, base), loc); mixin(ErrEplg); } mixin(ConvertTo!q{init,ty}); } mixin(SemEplg); } } mixin CreateBinderForDependent!("GetEnumBase"); mixin template Semantic(T) if(is(T==EnumDecl)){ Type base; EnumTy type; final Type getType(){ return type; } final Dependent!Type getEnumBase()in{assert(rbase||!!name);}body{ if(!base){ if(!rbase){ assert(!!msc); members[0].semantic(msc); mixin(Rewrite!q{members[0]}); if(members[0].sstate != SemState.completed) return Dependee(members[0],msc).dependent!Type; }else{ base=rbase.typeSemantic(msc); if(rbase.needRetry||rbase.sstate==SemState.error) return Dependee(members[0],msc).dependent!Type; } assert(!!base); } return base.independent; } override void presemantic(Scope sc){ if(sstate != SemState.pre) return; if(name){ super.presemantic(sc); type = New!EnumTy(this); msc = New!NestedScope(sc); }else scope_ = sc; foreach(m;members){ m.enc=this; m.presemantic(msc?msc:sc); } sstate = SemState.begin; if(!members.length){ sc.error("enumeration must have at least one member",loc); mixin(ErrEplg); } foreach(i,x;members[1..$]) x.prec=members[i]; if(name||rbase){ foreach(x;members){ if(x.rtype){ sc.error("explicit type only allowed in anonymous enum declarations"~(rbase?" without base type":""),x.rtype.loc); x.sstate=SemState.error; } } } } NestedScope msc; override void semantic(Scope sc){ if(sstate == SemState.pre) presemantic(sc); mixin(SemPrlg); if(rbase&&(!base||base.sstate!=SemState.completed)){ base=rbase.typeSemantic(sc); mixin(SemProp!q{rbase}); } mixin(SemChld!q{sc=msc?msc:sc;members[0]}); assert(members[0].init.isConstant()); if(name && !base) base=members[0].rinit.type; foreach(i,ref m;members[1..$]) mixin(SemChldPar!q{sc=msc?msc:sc;m}); mixin(PropErr!q{members[1..$]}); mixin(SemEplg); } } mixin template Semantic(T) if(is(T==GenerativeDecl)){ } mixin template Semantic(T) if(is(T==ConditionalDecl)){ override void potentialInsert(Scope sc, Declaration decl){ if(auto d = bdy.isDeclaration()) d.potentialInsert(sc, decl); if(els)if(auto d = els.isDeclaration()) d.potentialInsert(sc, decl); } override void potentialRemove(Scope sc, Declaration decl){ if(auto d = bdy.isDeclaration()) d.potentialRemove(sc, decl); if(els)if(auto d = els.isDeclaration()) d.potentialRemove(sc, decl); } } mixin template Semantic(T) if(is(T==StaticIfDecl)){ override void presemantic(Scope sc){ if(sstate != SemState.pre) return; scope_=sc; sstate = SemState.begin; needRetry = true; potentialInsert(sc, this); } private Statement evaluate(Scope sc){ mixin(SemPrlg); scope(exit) if(sstate==SemState.error) potentialRemove(sc, this); cond.prepareInterpret(); cond.prepareLazyConditionalSemantic(); mixin(SemChld!q{cond}); mixin(FinishDeductionProp!q{cond}); mixin(ConvertTo!q{cond,Type.get!bool()}); //cond = evaluateCondition(sc, cond); mixin(IntChld!q{cond}); needRetry = false; potentialRemove(sc, this); if(cond.interpretV()){ if(lazyDup) { lazyDup = false; bdy = bdy.ddup(); } if(auto d=bdy.isDeclaration()) d.pickupSTC(stc); if(auto decl = bdy.isDeclaration()) decl.presemantic(sc); return bdy; }else if(els){ if(lazyDup) { lazyDup = false; els = els.ddup(); } if(auto d=els.isDeclaration()) d.pickupSTC(stc); if(auto decl = els.isDeclaration()) decl.presemantic(sc); return els; }else{ lazyDup = false; mixin(SemEplg); } } override void semantic(Scope sc){ mixin(SemPrlg); if(sstate == SemState.pre) presemantic(sc); auto res = evaluate(sc); if(!res||res is this) return; assert(!!res); auto r=res; r.semantic(sc); mixin(RewEplg!q{r}); } private: bool lazyDup = false; } mixin template Semantic(T) if(is(T==StaticAssertDecl)){ Expression a0Leftover=null, a1Leftover=null; override void presemantic(Scope sc){ if(sstate != SemState.pre) return; sstate = SemState.begin; scope_=sc; } override void semantic(Scope sc){ mixin(SemPrlg); do{ if(a.length<1){ sc.error("missing arguments to static assert", loc); mixin(ErrEplg); } a[0].prepareInterpret(); a[0].prepareLazyConditionalSemantic(); mixin(SemChldExp!q{a[0]}); a=Tuple.expand(sc, AccessCheck.none, a, a0Leftover); }while(a.length<1||a[0].sstate!=SemState.completed); if(a.length>2){ Ltoomany: sc.error("too many arguments to static assert", loc); mixin(ErrEplg); }else if(a.length==2) a[1].prepareInterpret(); foreach(x; a) mixin(FinishDeduction!q{x}); mixin(PropErr!q{a}); auto bl=Type.get!bool(); mixin(ConvertTo!q{a[0],bl}); a[0].interpret(sc); if(a0Leftover) a0Leftover.interpret(sc); mixin(SemProp!q{a[0]}); if(a0Leftover) mixin(SemProp!q{a0Leftover}); if(!a[0].interpretV()){ // work around finally block goto limitation... void printMessage(){ sc.error(format("static assertion failure: '%s' is false",a[0].loc.rep), loc); } if(a.length == 1) printMessage(); else try{ mixin(SemChld!q{a[1]}); a=Tuple.expand(sc, AccessCheck.none, a, a1Leftover); if(a.length>2) goto Ltoomany; if(a.length == 1) printMessage(); else if(!a[1].isType()){ a[1].interpret(sc); if(a1Leftover) a1Leftover.interpret(sc); mixin(SemProp!q{a[1]}); if(a1Leftover) mixin(SemProp!q{a1Leftover}); sc.error(a[1].interpretV().get!string(), loc); }else sc.error(a[1].toString(), loc); }finally if(sstate == SemState.error) printMessage(); mixin(ErrEplg); } mixin(SemEplg); } } mixin template Semantic(T) if(is(T==AliasDecl)){ override void semantic(Scope sc){ if(sstate == SemState.pre) presemantic(sc); mixin(SemPrlg); if(!aliasee){ if(auto vd = decl.isVarDecl()){ if(vd.init){ sc.error("alias declarations cannot have initializers",loc); mixin(ErrEplg); } if(auto cad=vd.isCArrayDecl()) cad.computeRtype(); aliasee = vd.rtype; }else if(auto fd = decl.isFunctionDecl()){ aliasee = fd.type; }else assert(0);} aliasee.weakenAccessCheck(AccessCheck.none); aliasee.willAlias(); mixin(SemChld!q{aliasee}); TemplateDecl.finishArgumentPreparation(sc, aliasee); // EXTENSION if(!isAliasable(aliasee)){ sc.error("cannot alias an expression",loc); mixin(ErrEplg); } if(set){ assert(set.scope_ is scope_); auto add=getAliasedDecl(); if(!add||!add.isOverloadableDecl()&&!add.isOverloadSet()){ scope_.redefinitionError(this, set); mixin(ErrEplg); } } mixin(SemEplg); } private static auto checkAliasImpl(bool wantSymbol=false)(Expression aliasee){ static if(wantSymbol) alias Symbol R; else alias bool R; if(auto ae=aliasee.isAddressExp()) if(aliasee.type.getFunctionTy()) if(auto sym=ae.e.isSymbol()){ static if(wantSymbol) return sym; else return true; } R go(Expression aliasee){ if(auto sym=aliasee.isSymbol()){ static if(wantSymbol) return sym; else return true; } static if(!wantSymbol) if(aliasee.isType()||aliasee.isConstant()||aliasee.isExpTuple()) return true; if(auto fld=aliasee.isFieldExp()){ auto r=go(fld.e1); if(!r && fld.e1.isCurrentExp){ static if(wantSymbol) return fld.e2; else return true; } return r; } static if(wantSymbol) return null; else return false; } return go(aliasee); } static Symbol getAliasBase(Expression aliasee){ return checkAliasImpl!true(aliasee); } static bool isAliasable(Expression aliasee){ return checkAliasImpl!false(aliasee); } Declaration simpleAliasedDecl()in{ assert(sstate == SemState.completed); }body{ if(auto sym = aliasee.isSymbol()){ assert(!!sym.meaning); return sym.meaning; } return null; } Declaration getAliasedDecl(){ if(auto sym = aliasee.isSymbol()){ assert(!!sym.meaning); return sym.meaning; } if(auto fd = aliasee.isFieldExp()){ assert(!!fd.e2.meaning); return fd.e2.meaning; } assert(sstate != SemState.completed); return null; } Expression getAliasee(Scope sc, AccessCheck check, InContext inContext, const ref Location loc)in{ assert(sstate == SemState.completed); assert(!aliasee.isSymbol()); }body{ auto r=aliasee.clone(sc, inContext, check, loc); if(auto et=r.isExpTuple()) et.accessCheck=check; else r.restoreAccessCheck(sc, check); return r; } void setOverloadSet(OverloadSet set)in{assert(this.set is null);}body{ this.set=set; } private: Expression aliasee; OverloadSet set; } mixin template Semantic(T) if(is(T==BlockDecl)){ override void potentialInsert(Scope sc, Declaration decl){ foreach(x; decls) x.potentialInsert(sc, decl); } override void potentialRemove(Scope sc, Declaration decl){ foreach(x; decls) x.potentialRemove(sc, decl); } override void pickupSTC(STC stc){ super.pickupSTC(stc); foreach(x;decls) x.pickupSTC(stc); } override void presemantic(Scope sc){ if(sstate!=SemState.pre) return; scope_ = sc; foreach(ref x; decls){ x.pickupSTC(stc); x.presemantic(sc); } sstate = SemState.begin; } override void semantic(Scope sc){ if(sstate == SemState.pre) presemantic(sc); mixin(SemPrlg); if(!addedToScheduler){ foreach(x; decls) Scheduler().add(x, sc); addedToScheduler = true; } foreach(ref x; decls){ x.semantic(sc); mixin(Rewrite!q{x}); } foreach(x; decls) mixin(SemProp!q{x}); //mixin(SemChld!q{decls}); mixin(SemEplg); } override int traverseInOrder(scope int delegate(Declaration) dg){ foreach(x; decls) if(auto r = x.traverseInOrder(dg)) return r; return 0; } private: bool addedToScheduler = false; } mixin template Semantic(T) if(is(T==ReferenceAggregateDecl)){ Expression[] rparents = null; // the expressions that the current parents originated from ShortcutScope shortcutScope; // store for forbidden inherited symbols // TODO: could be used to look up inherited members faster private static class ShortcutScope : NestedScope{ ReferenceAggregateDecl raggr; this(ReferenceAggregateDecl raggr, Scope parent){ super(parent); this.raggr=raggr; } public override void potentialAmbiguity(Identifier decl, Identifier lookup){ error(format("declaration of '%s' "~suspiciousDeclDesc, decl), decl.loc); note(format("this lookup on subclass '%s' should have %s if it was valid", raggr.name,lookup.meaning?"resolved to it":"succeeded"), lookup.loc); } } void initShortcutScope(Scope parent){ shortcutScope = new ShortcutScope(this, parent); } private Dependent!void fillShortcutScope(){ if(!shortcutScope) return indepvoid; mixin(AggregateParentsInOrderTraversal!(q{ foreach(decl; &parent.bdy.traverseInOrder){ if(decl.name && decl.name.ptr){ // TODO: check visibility! // TODO: handle the case where the meaning of a symbol does not // change due to inheritance, eg. due to imports or alias if(auto d=shortcutScope.lookupHere(shortcutScope, decl.name, false).value){ if(typeid(d) is typeid(DoesNotExistDecl)) shortcutScope.potentialAmbiguity(decl.name, d.name); } } } },"this")); return indepvoid; } enum VtblState{ fresh, inherited, overridden, needsOverride, } static struct VtblEntry{ FunctionDecl fun; VtblState state; } struct Vtbl{ VtblEntry[] vtbl; size_t[FunctionDecl] vtblIndex; @property size_t length(){ return vtbl.length; } Vtbl dup(){ return Vtbl(vtbl.dup, vtblIndex.dup); } void setInherited(){ foreach(ref x;vtbl) x.state = VtblState.inherited; } void addFresh(FunctionDecl fun){ vtblIndex[fun]=vtbl.length; vtbl~=VtblEntry(fun, VtblState.fresh); } void addOverride(FunctionDecl old, FunctionDecl fresh)in{ assert(old in vtblIndex); auto oldSt = vtbl[vtblIndex[old]].state; assert(oldSt == VtblState.inherited || oldSt == VtblState.needsOverride); }body{ size_t index = vtblIndex[old]; vtblIndex.remove(old); vtblIndex[fresh]=index; vtbl[index]=VtblEntry(fresh, VtblState.overridden); } void needOverride(FunctionDecl old)in{ if(old in vtblIndex){ auto oldSt = vtbl[vtblIndex[old]].state; assert(oldSt == VtblState.inherited||oldSt == VtblState.needsOverride); } }body{ if(old !in vtblIndex) return; static void doIt(ref VtblState st){ st = VtblState.needsOverride; } doIt(vtbl[vtblIndex[old]].state); } bool needsOverride(FunctionDecl fun){ return fun in vtblIndex && vtbl[vtblIndex[fun]].state == VtblState.needsOverride; } bool has(FunctionDecl fun){ return !!(fun in vtblIndex); } } Vtbl vtbl; private Dependent!ClassDecl inheritVtbl(){ ClassDecl parent; if(isClassDecl()){ if(parents.length) findFirstNParents(1); if(parents.length){ if(parents[0].needRetry||parents[0].sstate==SemState.error) return Dependee(parents[0], scope_).dependent!ClassDecl; if(rparents[0].sstate == SemState.error) return Dependee(rparents[0], scope_).dependent!ClassDecl; assert(parents[0].sstate==SemState.completed); assert(cast(AggregateTy)parents[0]&&cast(ReferenceAggregateDecl)(cast(AggregateTy)parents[0]).decl); auto parentc = cast(ReferenceAggregateDecl)cast(void*)(cast(AggregateTy)cast(void*)parents[0]).decl; if(auto cdecl=parentc.isClassDecl()){ parent = cdecl; assert(!!parent.scope_); parent.semantic(parent.scope_); if(parent.needRetry||parent.sstate==SemState.error) return Dependee(parent, parent.scope_).dependent!ClassDecl; if(!vtbl.length){ vtbl=parent.vtbl.dup; vtbl.setInherited(); } } } } return parent.independent; } final ClassDecl parentClass(){ if(!parents.length||!parents[0]||parents[0].sstate!=SemState.completed) return null; assert(!!cast(AggregateTy)parents[0]); return (cast(AggregateTy)cast(void*)parents[0]).decl.isClassDecl(); } private mixin CreateBinderForDependent!("InheritVtbl"); private Identifier[const(char)*] sealedLookups; Dependent!(std.typecons.Tuple!(OverloadSet,ubyte)) lookupSealedOverloadSetWithRetry(Scope view, Identifier name){ mixin(LookupHere!q{auto ovsc; asc, view, name, true}); if(!ovsc){ auto ident = sealedLookups.get(name.ptr, null); if(!ident){ ident=New!Identifier(name.name); ident.recursiveLookup = false; ident.onlyMixins = true; ident.loc=name.loc; sealedLookups[name.ptr]=ident; } mixin(Lookup!q{_; ident, view, asc}); if(auto nr=ident.needRetry) { return q(OverloadSet.init,nr).independent; } ovsc = ident.meaning; } return q(ovsc?ovsc.isOverloadSet():null,ubyte.init).independent; } Dependent!OverloadSet lookupSealedOverloadSet(Scope view, Identifier name){ mixin(LookupSealedOverloadSetWithRetry!q{auto setnr;this,view,name}); if(!setnr[1]) return setnr[0].independent; static class OverloadSetSealer : Expression{ ReferenceAggregateDecl self; Scope view; Identifier name; this(ReferenceAggregateDecl self, Scope view, Identifier name, ubyte nr){ this.self=self; this.view=view; this.name=name; needRetry = nr; } void semantic(Scope sc){ mixin(SemPrlg); mixin(LookupSealedOverloadSetWithRetry!q{auto setnr;self,view,name}); if(setnr[1]) { needRetry=setnr[1]; return; } mixin(SemEplg); } } return Dependee(New!OverloadSetSealer(this,view,name,setnr[1]), null).dependent!OverloadSet; } private Dependent!void addToVtbl(FunctionDecl decl){ // inherit vtbl (need to wait until parent is finished with semantic) mixin(InheritVtbl!q{ClassDecl parent; this}); if(!parent) goto Lfresh; mixin(LookupSealedOverloadSetWithRetry!q{auto setnr; parent, asc, decl.name}); if(setnr[1]){ needRetry=setnr[1]; return indepvoid; } auto set=setnr[0]; if(!set) goto Lfresh; // need to provide new/aliased versions for ALL overloads if(!(decl.stc&STCnonvirtualprotection)) foreach(x; set.decls){ if(x.stc&STCstatic) continue; auto fun = x.isFunctionDecl(); if(vtbl.needsOverride(fun)) break; // already performed operation for this set if(!fun) continue; vtbl.needOverride(fun); } if(decl.stc & STCoverride){ mixin(DetermineOverride!q{auto ovr; set, decl}); if(ovr){ if(!vtbl.has(ovr)){ decl.scope_.error("multiple overrides of the same function",decl.loc); mixin(SetErr!q{decl}); return Dependee(ErrorDecl(), null).dependent!void; } vtbl.addOverride(ovr, decl); return indepvoid; } } Lfresh: if(!set && decl.stc & STCoverride){ // this error message is duplicated in OverloadSet.determineOverride decl.scope_.error(format("method '%s' does not override anything", decl.name), decl.loc); mixin(SetErr!q{decl}); return Dependee(ErrorDecl(), null).dependent!void; } if(!(decl.stc&STCnonvirtual)) vtbl.addFresh(decl); return indepvoid; } // invariant(){ foreach(x;parents) assert(x !is null); } final override void findParents(){ findFirstNParents(parents.length); } private size_t knownParents = 0; invariant(){ assert(knownParents<=parents.length); } private void updateKnownParents(){ foreach(x; parents[knownParents..$]){ if((x.sstate != SemState.completed||x.needRetry) && x.sstate != SemState.error) break; knownParents++; } } // scopes need access to this. (maybe those should be moved here instead) public final void findFirstNParents(size_t n,bool weak=false)in{ assert(n<=parents.length); }body{ if(!rparents) rparents = parents.map!(a=>a.ddup).array; // uncontrolled gc allocation if(n<=knownParents) return; alias scope_ sc; foreach(i,ref x; parents[knownParents..n]){ if(x.sstate == SemState.error) continue; if(!weak) x.semantic(sc); mixin(Rewrite!q{x}); } Expression dummyLeftover=null; parents = Tuple.expand(scope_, AccessCheck.none, parents, dummyLeftover, rparents); assert(!dummyLeftover); auto knownBefore = knownParents; updateKnownParents(); // valid because only prior unknown parents can cause expansion foreach(i, ref x; parents[knownBefore..knownParents]){ if(x.sstate == SemState.error) continue; assert(x.sstate == SemState.completed); auto ty = x.typeSemantic(sc); static bool checkInheritance(Type ty, Scope sc, const ref Location loc){ auto agg = ty.isAggregateTy(); if(!agg && ty.sstate == SemState.completed || agg && !agg.decl.isReferenceAggregateDecl()){ sc.error("base specifier must name a class or interface",loc); return false; } if(agg && !agg.decl.bdy){ sc.error(format("base '%s' is incomplete",agg),loc); return false; } return true; } if(ty && !checkInheritance(ty,sc,rparents[knownBefore+i].loc)) x = New!ErrorTy(); } assert(parents.length==rparents.length,text(parents," ",rparents)); } final override Expression unresolvedParent()out(x){ //assert(!x||x.needRetry); // !!!!? }body{ updateKnownParents(); if(knownParents == parents.length) return null; return parents[knownParents]; /+ foreach(x;parents) if(x.needRetry) return x; return null;+/ } /* Check validity of parents - Detect circular inheritance - Constrain max. number of base classes - It is possible that circular template instance dependencies have prevented the analysis to propagate errors in a template instance to the instantiation expression located in a parent list. This function validates all error-free parent locations by analyzing the expression they originated from again. At this point, all the circular template instance dependencies have been resolved and the result can be trusted. TODOs: * avoid duplicate CTFE-invocation for eg. the class C: D!(foo()) case */ final override void finishInheritance(){ mixin CreateBinderForDependent!("CheckCircularInheritance",); mixin CreateBinderForDependent!("FillShortcutScope",); mixin(CheckCircularInheritance!q{_;this}); mixin(InheritVtbl!q{ClassDecl _; this}); if(!parents.length) goto Lvtbl; assert(parents[0].sstate==SemState.error||!!cast(AggregateTy)parents[0]); bool hasExplicitBaseClass = false; if(parents[0].sstate != SemState.error){ {alias scope_ sc;mixin(SemChld!q{rparents[0]});} hasExplicitBaseClass = !!(cast(AggregateTy)cast(void*)parents[0]).decl.isClassDecl(); }else rparents[0].sstate = SemState.error; foreach(i, x;parents[1..$]){ if(x.sstate == SemState.error){rparents[i].sstate=SemState.error; continue;} assert(x.sstate == SemState.completed); assert(!!cast(AggregateTy)x); if((cast(AggregateTy)cast(void*)x).decl.isClassDecl()){ scope_.error(hasExplicitBaseClass ? "only one base class allowed": "base class must appear first in the super type list", rparents[1+i].loc, ); mixin(SetErr!q{rparents[1+i]}); } {alias scope_ sc;mixin(SemChldPar!q{rparents[1+i]});} } Lvtbl: enum SemRet = q{ return; }; if(bdy) foreach(decl; &bdy.traverseInOrder){ if(auto fd = decl.isFunctionDecl()){ if(vtbl.has(fd)) continue; mixin CreateBinderForDependent!("AddToVtbl"); mixin(AddToVtbl!(q{_;this,fd},false)); mixin(SemCheck); } } bool[FunctionDecl] hiders; foreach(x; vtbl.vtbl){ if(x.state != VtblState.needsOverride) continue; // TODO: one could maybe optimize this: mixin(LookupSealedOverloadSetWithRetry!q{auto ovsnr; this, asc, x.fun.name}); if(ovsnr[1]){ needRetry=ovsnr[1]; return; } auto ovs=ovsnr[0]; assert(!!ovs); FunctionDecl fun; foreach(y; ovs.decls){ if(y.stc & (STCnonvirtualprotection|STCstatic)) continue; if(auto fd=y.isFunctionDecl()){ // if(!vtbl.has(fd)) continue; fun = fd; break; } } assert(!!fun); if(fun in hiders) continue; hiders[fun] = true; // TODO: investigate the issue further and give more helpful error message string hint = fun.stc & STCoverride ? " (either override all overloads or alias missing ones into the child class scope)": " (did you forget to specify 'override'?)"; string kind = fun.stc & STCoverride ?" override":""; scope_.error(format("method%s '%s' illegally shadows a method in the parent class%s", kind, fun.name, hint),fun.loc); mixin(SetErr!q{fun}); x.state = VtblState.inherited; } //if(auto parent = parentClass()) //mixin(PropRetry!q{parent}); mixin(FillShortcutScope!q{_;this}); mixin(PropErr!q{rparents}); if(bdy) foreach(decl; &bdy.traverseInOrder) mixin(PropErr!q{decl}); } // TODO: make resolution faster (?) final Dependent!bool isSubtypeOf(ReferenceAggregateDecl rhs) in{ assert(rhs!is null); }body{ auto stack=SupertypeStack.init, dummy = false; return isSubtypeOfImpl(rhs, stack, dummy); } final Dependent!void checkCircularInheritance(){ auto stack=SupertypeStack.init, dummy = false; if(auto d=isSubtypeOfImpl(null, stack, dummy).dependee) return d.dependent!void; return indepvoid; } private final Dependent!bool isSubtypeOfImpl(ReferenceAggregateDecl rhs, ref SupertypeStack stack, out bool failed){ if(this is rhs) return true.independent; if(stack.has(this)){ failed=true; return false.independent; } stack.insert(this); scope(exit) stack.remove(this); findParents(); foreach(i,ref x;parents){ if(rparents[i].sstate == SemState.error) continue; ReferenceAggregateDecl rad; if(x.sstate == SemState.completed){ assert(!!cast(AggregateTy)x&&cast(ReferenceAggregateDecl)(cast(AggregateTy)x).decl,text(typeid(x)," ",x.sstate)); rad = cast(ReferenceAggregateDecl)cast(void*) (cast(AggregateTy)cast(void*)x) .decl; }else if(auto fe=x.isFieldExp()){ //hack: peek into ongoing template instantiations if(fe.e2.meaning) if(auto rd = fe.e2.meaning.isReferenceAggregateDecl()) rad = rd; if(!rad) continue; }else continue; assert(!!rad); auto t=rad.isSubtypeOfImpl(rhs,stack,failed).prop; if(failed){ stack.circularInheritanceError(scope_,rad); mixin(SetErr!q{rparents[i]}); failed = false; continue; } if(t) return t; } // TODO: template instances should wake up their dependees when meanings become clear if(auto x=unresolvedParent()) return multidep(cast(Node[])parents, scope_).dependent!bool; return false.independent; } protected: // faster for super type stacks smaller than 17 elements. // this is usually the case struct SupertypeStack{ void insert(ReferenceAggregateDecl decl){ if(num<16) initial[num++]=decl; else overrun[decl]=num++; } void remove(ReferenceAggregateDecl decl){ if(num<=16){ assert(num&&initial[num-1]==decl); initial[--num]=null; }else{ --num; assert(overrun[decl]==num); overrun.remove(decl); } } bool has(ReferenceAggregateDecl decl){ foreach(x;initial[0..min(num,$)]) if(x is decl) return true; if(overrun !is null) return overrun.get(decl,-1)!=-1; return false; } void circularInheritanceError(Scope sc, ReferenceAggregateDecl start){ // TODO: uncontrolled allocations auto arr = initial[0..min(num,$)].dup; auto k = overrun.keys, v = overrun.values; //import std.algorithm; sort!"a[1]<b[1]"(zip(k,v)); arr~=k; arr=arr.find(start); /+ auto first=iota(0,arr.length).reduce!((a,b)=>arr[a].sourcePriority<arr[b].sourcePriority?a:b); +/ // TODO: report DMD bug size_t j=0; foreach(i;1..arr.length) if(arr[i].sourcePriority<arr[j].sourcePriority) j=i; auto rdecls=chain(arr[j+1..$],arr[0..j+1]); bool first = true; foreach(x;zip(chain(rdecls[1..rdecls.length],rdecls[0..1]),rdecls).retro){ // TODO: dollar alias util.all all; assert(all!(a=>cast(AggregateTy)a)(x[1].parents)); auto rparent = zip(x[1].parents,x[1].rparents) .find!((a,b)=>(cast(AggregateTy)cast(void*)a[0]).decl is b)(x[0]) .front[1]; mixin(SetErr!q{rparent}); if(first) sc.error("circular inheritance",rparent.loc); else sc.note("part of inheritance cycle",rparent.loc); first = false; } } private: ReferenceAggregateDecl[16] initial = null; size_t num = 0; size_t[ReferenceAggregateDecl] overrun; } } mixin template Semantic(T) if(is(T==ClassDecl)){ // TODO: O(n+m*log n) least common ancestor possible? final Dependent!ClassDecl commonSuperType(ClassDecl rhs){ SupertypeStack s1, s2; return commonSuperTypeImpl(rhs,s1,s2); } // braindead implementation final Dependent!ClassDecl commonSuperTypeImpl(ClassDecl rhs, ref SupertypeStack s1, ref SupertypeStack s2){ if(this is rhs) return this.independent; if(s1.has(rhs)) return rhs.independent; if(s2.has(this)) return this.independent; if(!parents.length&&!rhs.parents.length) return null.independent!ClassDecl; if(parents.length) findFirstNParents(1); if(rhs.parents.length) rhs.findFirstNParents(1); if(parents.length&& (parents[0].needRetry||parents[0].sstate == SemState.error)) return Dependee(parents[0], scope_).dependent!ClassDecl; if(rhs.parents.length&& (rhs.parents[0].needRetry||rhs.parents[0].sstate == SemState.error)) return Dependee(rhs.parents[0], scope_).dependent!ClassDecl; assert((!parents.length||cast(AggregateTy)parents[0])&& (!rhs.parents.length||cast(AggregateTy)rhs.parents[0])); auto c1 = !parents.length?this: (cast(AggregateTy)cast(void*)parents[0]).decl.isClassDecl(); auto c2 = !rhs.parents.length?rhs: (cast(AggregateTy)cast(void*)rhs.parents[0]).decl.isClassDecl(); if(!c1||!c2) return null.independent!ClassDecl; s1.insert(this); s2.insert(rhs); return c1.commonSuperTypeImpl(c2,s1,s2); } } mixin template Semantic(T) if(is(T==InterfaceDecl)){} mixin template Semantic(T) if(is(T==ValueAggregateDecl)){} mixin template Semantic(T) if(is(T==StructDecl)){} mixin template Semantic(T) if(is(T==UnionDecl)){ override void presemantic(Scope sc){ if(name) stc|=STCstatic; super.presemantic(sc); } } mixin template Semantic(T) if(is(T==AggregateDecl)){ /* overridden in ReferenceAggregateDecl */ protected void findParents(){ } protected Expression unresolvedParent(){ return null; } protected void finishInheritance()in{assert(!unresolvedParent());}body{ } override void presemantic(Scope sc){ if(sstate != SemState.pre) return; if(auto decl=sc.getDeclaration()) if(auto aggr=decl.isAggregateDecl()) if(aggr.isValueAggregateDecl()||isValueAggregateDecl()) stc|=STCstatic; super.presemantic(sc); scope_ = sc; // this is not a factory method because of a DMD bug. if(!asc) asc = isReferenceAggregateDecl()? New!InheritScope(cast(ReferenceAggregateDecl)cast(void*)this) : New!AggregateScope(this); if(bdy) bdy.presemantic(asc); } override void semantic(Scope sc){ if(sstate == SemState.pre) presemantic(sc); mixin(SemPrlg); if(bdy) mixin(SemChld!q{sc=asc;bdy}); findParents(); if(auto exp=unresolvedParent()){mixin(PropRetry!q{exp});} needRetry=false; finishInheritance(); mixin(SemCheck); mixin(SemEplg); } AggregateTy getType(){ if(type) return type; return type=New!AggregateTy(this); } AggregateScope asc; mixin HandleNestedDeclarations; private: AggregateTy type; } mixin template Semantic(T) if(is(T==Declarators)){ override void presemantic(Scope sc){ if(sstate!=SemState.pre) return; scope_=sc; foreach(ref x; decls) x.presemantic(sc); sstate=SemState.begin; } override void semantic(Scope sc){ mixin(SemPrlg); mixin(SemChld!q{decls}); mixin(SemEplg); } override int traverseInOrder(scope int delegate(Declaration) dg){ foreach(x; decls) if(auto r=x.traverseInOrder(dg)) return r; return 0; } } abstract class OverloadableDecl: Declaration{ this(STC stc,Identifier name){super(stc,name);} override OverloadableDecl isOverloadableDecl(){return this;} } class OverloadSet: Declaration{ // A lookup that sealed this overloadset: // TODO: less conservative strategy only forbidding inserting overloads // that are superior matches to prior lookups / overrides? Identifier sealingLookup = null; this(OverloadableDecl[] args...)in{ assert(args.length); foreach(d; args) assert(!!d.scope_); }body{ super(STC.init,args[0].name); foreach(d;args) add(d); sstate = SemState.begin; // do not insert into scope } this(Identifier name){super(STC.init,name);} void add(OverloadableDecl decl)in{ assert(!sealingLookup); assert(!decls.length||decls[0].name.name is decl.name.name); assert(!tdecls.length||tdecls[0].name.name is decl.name.name); assert(!adecls.length||adecls[0].name.name is decl.name.name); }body{ if(!loc.line) loc=decl.loc; if(auto td=decl.isTemplateDecl()) tdecls~=td; else decls~=decl; // TODO: check that all overloads are @property or non-property (?) // TODO: detect @property function templates (?) if(decl.stc&STCproperty) stc|=STCproperty; if(auto v=decl.stc&STCvisibility) stc|=v; // TODO: detect conflicts } void addAlias(AliasDecl decl)in{ assert(!sealingLookup); assert(!decls.length||decls[0].name.name is decl.name.name); assert(!tdecls.length||tdecls[0].name.name is decl.name.name); assert(!adecls.length||adecls[0].name.name is decl.name.name); }body{ decl.setOverloadSet(this); adecls~=decl; } bool hasFunctions(){ alias util.any any; return any!(a=>a.isFunctionDecl())(decls)|| any!(a=>a.iftiDecl())(tdecls); } /* accessibility of overloads is checked after they have been resolved */ override bool needsAccessCheck(AccessCheck check){ return false; } override string toString(){ return join(map!(to!string)(decls~cast(OverloadableDecl[])tdecls),"\n");} override OverloadSet isOverloadSet(){return this;} final bool isConstructor(){ foreach(x;decls) if(auto fd=x.isFunctionDecl()) return fd.isConstructor(); foreach(x;tdecls) if(auto ep = x.iftiDecl()) return ep.isConstructor(); return false; } private static struct Matched{ MatchContext context; // context for matching of function call FunctionDecl decl; Match tmatch; // match level of template instantiation Declaration tdecl; /+ //just for documentation for now bool isMatch(){ return context.match!=Match.none && (decl || tdecl); } bool isFunctionMatch(){ return decl && !tdecl; } bool isTemplateMatch(){ return tdecl && !decl; } bool isIftiMatch(){ return decl && tdecl; }+/ } private mixin CreateBinderForDependent!("CanOverride"); // TODO: make this a public member function of function decl instead private static Dependent!bool canOverride(FunctionDecl fd, FunctionDecl fun){ alias util.all all; import std.range; if(fd.stc & STCnonvirtual) return false.independent; // analyze function types fun.analyzeType(); mixin(Rewrite!q{fun.type}); fd.analyzeType(); mixin(Rewrite!q{fd.type}); if(fun.type.sstate==SemState.error) return Dependee(fun.type, fd.scope_).dependent!bool; if(fd.type.sstate==SemState.error) return Dependee(fd.type, fd.scope_).dependent!bool; if(fun.type.needRetry) return Dependee(fun.type, fd.scope_).dependent!bool; if(fd.type.needRetry) return Dependee(fd.type, fd.scope_).dependent!bool; // end analyzing types // STC parent may be freely introduced, but will be here to stay bool mayOverride(STC parent, STC child){ return !(fd.type.stc&parent) || fun.type.stc&child; } auto helper = Type.get!void.getPointer(); if(fun.type.params.length == fd.type.params.length && !((fun.type.stc^fd.type.stc)&STCinvariantunderoverride) && // reuse the type system for determining valid type constructor overrides // TODO: put these in the same implementation as the implicit conversion rules // for function pointers and delegates ? helper.applySTC(fd.type.stc&STCtypeconstructor) .refConvertsTo(helper.applySTC(fun.type.stc&STCtypeconstructor), 0) .force && mayOverride(STCsafe, STCsafe|STCtrusted) && mayOverride(STCpure, STCpure) && mayOverride(STCnothrow, STCnothrow) && mayOverride(STCdisable, STCdisable) && // STCdeprecated ? all!(a=>a[0].type.equals(a[1].type) && !((a[0].stc^a[1].stc)&STCmattersforparamoverride)) (zip(fun.type.params, fd.type.params)) ){ // TODO: resolve inout according to STC of parent //mixin(RefConvertsTo!q{bool rconv; fun.type.ret, fd.type.ret, 0}); return fun.type.ret.refConvertsTo(fd.type.ret,0); } return false.independent; } /* find a function decl that may override fun, or return null */ final Dependent!FunctionDecl findOverrider(FunctionDecl fun)in{ assert(fun.scope_.getDeclaration().maybe!(a=>a.isFunctionDef())||!!sealingLookup); }body{ // TODO: multi-dep foreach(ref decl; decls){ auto fd = decl.isFunctionDecl(); if(!fd) continue; mixin(CanOverride!q{auto co; OverloadSet, fun, fd}); if(co) return fd.independent; } return null.independent!FunctionDecl; } /* find the function decl that fun overrides, or display an error and return null */ final Dependent!FunctionDecl determineOverride(FunctionDecl fun)in{ assert(fun.scope_.getDeclaration().maybe!(a=>a.isFunctionDef())||!!sealingLookup); }body{ size_t num = 0; foreach(ref decl; decls){ decl.semantic(decl.scope_); mixin(Rewrite!q{decl}); auto fd=decl.isFunctionDecl(); if(!fd) continue; /* if(fd.needRetry||fd.sstate == SemState.error) return Dependee(fd,fd.scope_).dependent!FunctionDecl;// TODO: check if we really do not need this*/ mixin(CanOverride!q{auto covr; OverloadSet, fd, fun}); if(covr) swap(decl, decls[num++]); } //dw((cast(FunctionDecl)decls[0]).type.params.map!(a=>a.type)[0].equals(fun.type.params.map!(a=>a.type)[0])); if(!num){ // this error message is duplicated in OverloadSet.determineOverride fun.scope_.error(format("method '%s' does not override anything", fun.name), fun.loc); }else{ if(fun.type.stc&STCconst) thisSTCIsBetter!"a.type.stc"(cast(FunctionDecl[])decls, STCconst, num); if(num == 1) return (cast(FunctionDecl)cast(void*)decls[0]).independent; fun.scope_.error("method override is ambiguous", fun.loc); foreach(i;0..num) fun.scope_.note("candidate overridden function", decls[i].loc); } mixin(SetErr!q{fun}); return null.independent!FunctionDecl; } private static void thisSTCIsBetter(alias str, R)(R stcr, STC stc, ref size_t num){ auto s(ElementType!R a){ return mixin(str); } alias util.any any; bool found = false; foreach(x; stcr[0..num]) if((s(x)&stc)==stc){found=true; break; } if(!found) return; //if(any!((a)=>!!(s(a)&stc))(stcr)){ for(size_t i=0;i<num;i++) if((s(stcr[i])&stc)!=stc) swap(stcr[i], stcr[--num]); //} } override Dependent!Declaration matchCall(Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args, ref MatchContext context){ if(tdecls.length||adecls.length) return New!FunctionOverloadMatcher(this, sc, loc, this_, func, args).independent!Declaration; if(decls.length == 1) return decls[0].matchCall(sc, loc, this_, func, args, context); auto matches = new Matched[decls.length]; // pointless GC allocation foreach(i,decl; decls){ if(decl.sstate == SemState.error){ auto fd=decl.isFunctionDecl(); if(!fd||fd.type.errorsInParams()) return Dependee(decl,decl.scope_).dependent!Declaration; } mixin(MatchCall!q{auto matched; decls[i], null, loc, this_, func, args, matches[i].context}); assert(!matched||cast(FunctionDecl)matched); matches[i].decl = cast(FunctionDecl)cast(void*)matched; } // TODO: some work is lost if this kicks in. significant? mixin(DetermineMostSpecialized!q{FunctionDecl r; this, matches, this_, context}); if(!r) foreach(a;args) if(auto ae = a.isAddressExp()) if(ae.isUndeducedFunctionLiteral()){ return New!FunctionOverloadMatcher(this, sc, loc, this_, func, args).independent!Declaration; } return r.independent!Declaration; } final Dependent!FunctionDecl determineMostSpecialized(Matched[] matches, Type this_, out MatchContext context)in{ alias util.all all; //assert(all!(_=>!_.decl||_.decl.sstate!=SemState.error)(matches)); assert(matches.length<cast(size_t)-1); }body{ cand = altCand = null; foreach(ref m; matches) if(m.decl is null) m.context.match = Match.none; auto best = reduce!max(Match.none, map!(_=>_.context.match)(matches)); if(best == Match.none){ context.match = Match.none; return FunctionDecl.init.independent; } //TODO: the following line causes an ICE, reduce. //auto bestMatches = matches.partition!(_=>_.context.match!=best)(); //auto numBest = bestMatches.length; size_t numBest = 0; for(size_t i=0;i<matches.length;i++){ if(matches[i].context.match==best) swap(matches[numBest++], matches[i]); } if(this_){ STC hstc = this_.getHeadSTC(); if(hstc&STCconst) thisSTCIsBetter!"a.decl.stc"(matches, STCconst, numBest); if(hstc&STCinout) thisSTCIsBetter!"a.decl.stc"(matches, STCinout, numBest); if(hstc&STCimmutable){ thisSTCIsBetter!"a.decl.stc"(matches, STCimmutable, numBest); thisSTCIsBetter!"a.decl.stc"(matches, STCconst|STCinout, numBest); } } assert(numBest); if(numBest == 1){ context = matches[0].context; return matches[0].decl.independent; } auto bestMatches = matches[0..numBest]; // find the most specialized match size_t candidate = 0; foreach(i, match; bestMatches[1..$]){ // if there is a declaration that is at least as specialized // then it cannot be the unique best match //if(match.decl.atLeastAsSpecialized(bestMatches[candidate].decl)) mixin(AtLeastAsSpecialized!q{bool alas; match.decl, bestMatches[candidate].decl}); if(alas) candidate = i+1; } swap(bestMatches[0], bestMatches[candidate]); scope(exit){ context = bestMatches[0].context; cand = bestMatches[0].decl; } foreach(i, match; bestMatches[1..$]){ //if(!cand.atLeastAsSpecialized(match.decl) //|| match.decl.atLeastAsSpecialized(bestMatches[0].decl)){ mixin(AtLeastAsSpecialized!q{bool alas1; bestMatches[0].decl, match.decl}); mixin(AtLeastAsSpecialized!q{bool alas2; match.decl, bestMatches[0].decl}); if(alas1){ // matching static the right way is better if(!(bestMatches[0].decl.stc&STCstatic) != !this_ && !(match.decl.stc&STCstatic) == !this_) continue; if(!(bestMatches[0].decl.stc&STCstatic) == !this_ && !(match.decl.stc&STCstatic) != !this_){ swap(bestMatches[0], bestMatches[i+1]); continue; } // inout functions are less specialized if(bestMatches[0].context.inoutRes==InoutRes.none&&match.context.inoutRes!=InoutRes.none) continue; if(alas2 && bestMatches[0].context.inoutRes!=InoutRes.none&&match.context.inoutRes==InoutRes.none){ swap(bestMatches[0], bestMatches[i+1]); continue; } } if(!alas1||alas2){ // at least two identically good matches altCand = match.decl; return FunctionDecl.init.independent; } } return bestMatches[0].decl.independent; } static Dependent!void eliminateLessSpecializedTemplateMatches(Matched[] tmatches){ auto best = reduce!max(Match.none, map!(a=>a.tmatch)(tmatches)); if(best == Match.none) return indepvoid; TemplateDecl cand = null; size_t cpos; foreach(i,ref c; tmatches){ if(c.tmatch!=best){ c.tdecl = c.decl = null; continue; } assert(cast(TemplateInstanceDecl)c.tdecl); cand = c.tdecl.isTemplateInstanceDecl().parent; cpos = i; break; } if(!cand) return indepvoid; foreach(ref c; tmatches[cpos+1..$]){ if(c.tmatch!=best){ c.tdecl = c.decl = null; continue; } assert(cast(TemplateInstanceDecl)c.tdecl); auto altCand = c.tdecl.isTemplateInstanceDecl().parent; mixin(AtLeastAsSpecialized!q{bool alas; altCand, cand}); if(alas) { cand = altCand; } } foreach(ref c; tmatches){ if(!c.tdecl) continue; assert(cast(TemplateInstanceDecl)c.tdecl); auto altCand = c.tdecl.isTemplateInstanceDecl().parent; mixin(AtLeastAsSpecialized!q{bool alas; altCand, cand}); if(!alas) { c.tdecl = c.decl = null; } } return indepvoid; } private FunctionDecl cand; // TODO: somewhat fragile, maybe better to just recompute private FunctionDecl altCand; final override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ if(count == 1){ if(!adecls.length) return (decls.length?decls[0]:tdecls[0]).matchError(sc,loc,this_,args); } if(altCand is null){ sc.error(format("no matching function for call to '%s(%s)'",name,join(map!"a.type.toString()"(args),",")), loc); // TODO: better criterium for filter foreach(decl; chain(decls,tdecls.filter!(a=>!!a.iftiDecl))){ if(auto fdef = decl.isFunctionDecl()) if(fdef.type.sstate == SemState.error) continue; sc.note(format("candidate %s not viable", decl.kind), decl.loc); // TODO: say why } foreach(decl; adecls){ auto add = decl.getAliasedDecl(); if(add){ if(auto fdef = add.isFunctionDecl()) if(fdef.type.sstate == SemState.error) continue; }else continue; sc.note("candidate alias not viable", decl.loc); sc.note(format("this is the aliased %s", add.kind), add.loc); } }else{ assert(cand !is altCand); // TODO: list all of the most specialized functions sc.error(format("call to '%s' is ambiguous",name), loc); sc.note("candidate function",cand.loc); sc.note("candidate function",altCand.loc); } } override Declaration matchInstantiation(Scope sc, const ref Location loc, bool gagged, bool isMixin, Expression owner, TemplArgsWithTypes args){ if(tdecls.length==0) return decls[0].matchInstantiation(sc, loc, gagged, isMixin, owner, args); if(tdecls.length==1) return tdecls[0].matchInstantiation(sc, loc, gagged, isMixin, owner, args); return New!TemplateOverloadMatcher(this, sc, loc, gagged, isMixin, owner, args); } final void instantiationError(Scope sc, const ref Location loc, TemplateInstanceDecl[] insts, TemplArgsWithTypes args){ size_t c=0; foreach(x;insts) if(x) c++; assert(c!=1); if(!c){ sc.error(format("no matching template for instantiation '%s!(%s)'",name,join(map!"a.toString()"(args.args),",")),loc); foreach(i, tdecl; tdecls){ if(tdecl.sstate == SemState.error) continue; sc.note("candidate template not viable", tdecl.loc); // TODO: say why } }else{ sc.error(format("instantiation of template '%s' is ambiguous", name), loc); foreach(i, tdecl; tdecls){ if(!insts[i]||tdecl.sstate == SemState.error) continue; sc.note("candidate template",tdecl.loc); } } } override Declaration matchIFTI(Scope sc, const ref Location loc, Type this_, Expression func, TemplArgsWithTypes args, Expression[] funargs){ if(tdecls.length==0) return decls[0].matchIFTI(sc, loc, this_, func, args, funargs); if(tdecls.length==1) return tdecls[0].matchIFTI(sc, loc, this_, func, args, funargs); return New!FunctionOverloadMatcher(this, sc, loc, this_, func, args, funargs); } override @property string kind(){ if(count==1) return decls.length?decls[0].kind:tdecls[0].kind; return "overload set"; } public final @property size_t count(){ return decls.length + tdecls.length + adecls.length; } // private: // TODO: introduce again OverloadableDecl[] decls; TemplateDecl[] tdecls; AliasDecl[] adecls; } class CrossScopeOverloadSet : Declaration{ Declaration[] decls; private static void removeDuplicates(ref Declaration[] decls){ // TODO: optimize bool[Declaration] has; foreach(ref d;decls){ if(d in has){ swap(d,decls[$-1]); decls=decls[0..$-1]; } has[d]=true; } } static Declaration buildDecl(Scope sc, Declaration[] decls, Declaration alt){ if(!decls.length) return alt; removeDuplicates(decls); if(decls.length==1) return decls[0]; alias util.all all; if(all!(a=>!a.isCrossScopeOverloadSet())(decls)){ auto r=New!CrossScopeOverloadSet(decls); r.scope_=sc; return r; } Declaration[] ndecls; foreach(d;decls){ if(auto ov=d.isCrossScopeOverloadSet()) ndecls~=ov.decls; else ndecls~=d; } return buildDecl(sc, ndecls, alt); } /+private+/ this(Declaration[] decls)in{ assert(decls.length>1); foreach(x;decls[1..$]) assert(x.name.name == decls[0].name.name); }body{ this.decls=decls; super(STC.init, decls[0].name); sstate = SemState.completed; loc=decls[0].loc; } static class OverloadResolver(string op,TT...) : Declaration{ // TODO: report DMD bug. This does not work if TT is called T instead static if(TT.length) TT args; Declaration[] decls; this(Scope sc, TT args, Declaration[] decls){ static if(TT.length) this.args=args; this.decls=decls; super(STC.init, decls[0].name); } override void semantic(Scope sc){ mixin(SemPrlg); mixin(op); if(sstate == SemState.pre){scope_=sc; sstate = SemState.begin; } Declaration r=null; foreach(decl;decls){ if(!decl) continue; if(!r){ r=decl; continue; } // TODO: report DMD bug, filter should obviously work auto numMatches = 0; for(size_t i=0;i<decls.length;i++){ if(decls[i]) swap(decls[numMatches++], decls[i]); } if(sc) reportConflict(sc, loc, decls[0..numMatches]);//filter!(function(a)=>!!a)(decls)); mixin(ErrEplg); } mixin(RewEplg!q{r}); } final override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ // TODO: get rid of this override. } } override Dependent!Declaration matchCall(Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args, ref MatchContext context){ enum op=q{ foreach(ref decl;decls){ if(decl&&decl.sstate!=SemState.error){ MatchContext dummy; mixin(MatchCall!q{decl;decl,null,loc,args, dummy}); } } }; auto r=New!(OverloadResolver!(op,Type,Expression,Expression[]))(sc, this_, func, args, decls.dup); r.loc=loc; r.semantic(sc); return r.independent!Declaration; } override Declaration matchInstantiation(Scope sc, const ref Location loc, bool gagged, bool isMixin, Expression owner, TemplArgsWithTypes args){ auto insts=decls.dup; foreach(ref ifti;insts) ifti = ifti.matchInstantiation(sc, loc, gagged, isMixin, owner, args); auto r=New!(OverloadResolver!(instOp))(sc,insts); r.loc=loc; r.semantic(sc); return r; } enum instOp=q{ foreach(ref decl; decls){ mixin(SemChld!q{decl}); if(decl.sstate == SemState.error) decl = null; } }; override Declaration matchIFTI(Scope sc, const ref Location loc, Type this_, Expression func, TemplArgsWithTypes args, Expression[] funargs){ auto iftis=decls.dup; foreach(ref ifti;iftis) ifti = ifti.matchIFTI(null, loc, this_, func, args, funargs); auto r=New!(OverloadResolver!(instOp))(sc, iftis); r.loc=loc; r.semantic(sc); return r; } static void reportConflict(R)(Scope sc, const ref Location loc, R decls)in{ assert(!!sc&&!decls.empty); }body{ // TODO: improve error messages sc.error(format("conflicting declarations for a lookup of '%s'",decls.front.name),loc); foreach(decl;decls) sc.note("part of conflict", decl.loc); } final void reportConflict()(Scope sc, Location loc){ // workaround for DMD bug reportConflict(sc, loc, decls); } override @property string kind(){ return "cross-scope overload set"; } override bool needsAccessCheck(AccessCheck check){ return false; } override string toString(){ return join(map!(to!string)(decls)); } mixin DownCastMethod; } // TODO: should those be nested classes of OverloadSet? Silly indentation... abstract class SymbolMatcher: Declaration{ OverloadSet set; Expression func; MatchContext context; // will be picked up by Symbol private bool _hasFailedToMatch = false; final @property bool hasFailedToMatch(){ return _hasFailedToMatch; } protected void failMatching(){ _hasFailedToMatch = true; mixin(SemEplg); } abstract void emitError(Scope sc_); // in{ assert(hasFailedToMatch()); } this(OverloadSet set, const ref Location loc, Expression func){ super(set.stc,set.name); this.set=set; this.func = func; this.loc=loc; } mixin DownCastMethod; } class TemplateOverloadMatcher: SymbolMatcher{ OverloadSet.Matched[] insts; TemplArgsWithTypes args; this(OverloadSet set, Scope sc, const ref Location loc, bool gagged, bool isMixin, Expression func, TemplArgsWithTypes args){ this.args=args; super(set, loc, func); // TODO: gc allocation insts = new OverloadSet.Matched[](set.tdecls.length); foreach(i, ref x; insts) x.tdecl=set.tdecls[i].matchInstantiation(sc, loc, false, isMixin, func, args); enum SemRet = q{return;}; // TODO: remove mixin(RetryEplg); } override void semantic(Scope sc){ mixin(SemPrlg); foreach(ref x; insts){ if(!x.tdecl) continue; mixin(SemChldPar!q{x.tdecl}); auto inst=x.tdecl.isTemplateInstanceDecl(); assert(!!inst); if(inst.hasFailedToMatch()){ x.tmatch = Match.none; x.tdecl = null; }else x.tmatch=inst.match; assert(!x.tdecl||x.tdecl.sstate==SemState.error||inst.completedMatching); } mixin(EliminateLessSpecializedTemplateMatches!q{_;OverloadSet,insts}); size_t c = 0; foreach(x; insts) if(x.tdecl){ mixin(PropErr!q{x.tdecl}); c++; } if(c==1) foreach(r; insts) if(r.tdecl) mixin(RewEplg!q{r.tdecl}); failMatching(); } override void emitError(Scope sc_){ if(sc_) set.instantiationError(sc_, loc, cast(TemplateInstanceDecl[])insts, args); } } /* This class matches function calls of the form fun( ), (first constructor) in which case it resolves into a function declaration upon success. (this implements the matchCall return value interface.) as well as function calls of the form fun!( )( ), in which case it resolves into the template declaration upon success. (this implements the matchIFTI return value interface.) It makes sense to use the same implementation for those two operations, because they need to exhibit very similar behaviour. */ class FunctionOverloadMatcher: SymbolMatcher{ Expression[] args; Type this_; UnaryExp!(Tok!"&")[][] literals; OverloadSet.Matched[] matches; OverloadSet.Matched[] tmatches; Declaration[] iftis; // match the eponymous declaration // if it was not determined by IFTI. Expression[] eponymous; size_t[] positions; this(OverloadSet set, Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args)in{ assert(set.count>0); }body{ this.this_=this_; this.args=args; super(set, loc, func); // TODO: GC allocations matches = new OverloadSet.Matched[](set.decls.length); tmatches = new OverloadSet.Matched[](set.tdecls.length); iftis = new Declaration[](set.tdecls.length); foreach(i, ref x; iftis){ tmatches[i].tmatch=Match.none; x=set.tdecls[i].matchIFTI(sc, loc, this_, func, templArgs, args); } size_t numfunclit; foreach(a;args) if(auto ae = a.isAddressExp()) if(ae.isUndeducedFunctionLiteral()) numfunclit++; literals = new UnaryExp!(Tok!"&")[][](set.decls.length+1, numfunclit); positions = new size_t[numfunclit]; size_t i=0; foreach(pos,a;args){ if(auto ae = a.isAddressExp()){ if(ae.isUndeducedFunctionLiteral()){ // (not very cache friendly for huge number of function literal args // but that is not a case worth optimizing for) foreach(j;0..set.decls.length) literals[j][i] = ae.ddup(); literals[$-1][i] = ae; positions[i]=pos; i++; } } } enum SemRet=q{return;};// TODO: remove mixin(RetryEplg); } bool matchATemplate = false; TemplArgsWithTypes templArgs; this(OverloadSet set, Scope sc, const ref Location loc, Type this_, Expression func, TemplArgsWithTypes templArgs, Expression[] args){ matchATemplate = true; this.templArgs = templArgs; this(set, sc, loc, this_, func, args); } TemplateInstanceDecl waitFor = null; FunctionDecl rewriteIfOk = null; override void semantic(Scope sc){ mixin(SemPrlg); if(waitFor){ if(waitFor.sstate != SemState.started){ mixin(SemChld!q{sc=waitFor.scope_;waitFor}); } assert(!!rewriteIfOk); auto r=rewriteIfOk; mixin(RewEplg!q{r}); } foreach(ad; set.adecls){ if(ad.sstate == SemState.error) continue; ad.semantic(set.scope_); mixin(PropRetry!q{ad}); } assert(iftis.length == set.tdecls.length); foreach(i, ref x; iftis){ if(!x) continue; if(eponymous.length && eponymous[i]) continue; auto tid=x.isTemplateInstanceDecl(); if(!tid || !tid.completedMatching){ x.semantic(sc); mixin(SemProp!q{x}); } assert(!!cast(TemplateInstanceDecl)x); auto inst = cast(TemplateInstanceDecl)cast(void*)x; assert(!!inst.completedMatching); if(inst.hasFailedToMatch()){ x=null; continue; } tmatches[i].tmatch=inst.match; if(!inst.finishedInstantiation()){ inst.finishInstantiation(false); mixin(Rewrite!q{inst}); x=inst; } auto fd = inst.iftiDecl(); if(!fd){ // if(!matchATemplate) continue; // TODO: do we want this? if(inst.sstate != SemState.completed && inst.sstate != SemState.started){ if(inst.isGagged()&&sc&&sc.handler.showsEffect()) inst.ungag(); inst.startAnalysis(); x.semantic(sc); } mixin(SemProp!q{x}); // TODO: show instantiation site fd = inst.iftiDecl(); if(!fd){ // TODO: gc allocation if(!eponymous.length) eponymous = new Expression[](iftis.length); // this creates identifiers without location, as we don't want those // to show up in circular dependency traces // TODO: accessCheck? auto id=New!Identifier(x.name.name); id.errorOnMatchingFailure=false; auto be=New!(BinaryExp!(Tok!"."))(New!Symbol(x), id); (eponymous[i]=be).willCall(); continue; } } assert(!!fd); fd.analyzeType(); if(auto nr=fd.type.needRetry) { needRetry = nr; return; } } // resolve the eponymous declarations that are not determined by IFTI. foreach(ref x; eponymous) if(x){ x.semantic(sc); if(x.sstate==SemState.error){ if(auto sym=x.isSymbol()){ if(sym.isSymbolMatcher){ assert(!sym.errorOnMatchingFailure); x=null; continue; } } } mixin(SemProp!q{x}); auto sym = x.isSymbol(); if(!sym || !sym.meaning.isFunctionDecl()){ mixin(MatchCall!q{x; x, sc, loc, args}); if(!x) continue; mixin(PropRetry!q{sc=null;x}); } } if(!matchATemplate){ mixin(DetermineFunctionMatches!q{_;this, sc}); foreach(l1;literals[0..$-1]) foreach(ref l2;l1){mixin(SemChldPar!q{l2});} } MatchContext tcontext; mixin(DetermineTemplateMatches!q{_;this}); // TODO: error handling FunctionDecl r=null; mixin(DetermineMostSpecialized!q{auto t; set, tmatches, this_, tcontext}); auto cand = set.cand, altCand = set.altCand; mixin(DetermineMostSpecialized!q{auto f; set, matches, this_, context}); TemplateInstanceDecl inst; if(context.match>=tcontext.match) r=f; else if(t){ r=t; context = tcontext; inst = r.extractTemplateInstance(); if(inst.sstate != SemState.completed && inst.sstate != SemState.started){ if(inst.isGagged()&&sc&&sc.handler.showsEffect) inst.ungag(); inst.startAnalysis(); inst.semantic(sc); } if(matchATemplate){mixin(RewEplg!q{inst});} } // TODO: could re-use the function literal arguments of the most specialized function if(!r){ if(!set.cand && !set.altCand || tcontext.match>context.match) set.cand = cand, set.altCand = altCand; // TODO: more adequate error message in the matchATemplate case failMatching(); }else{ if(inst&&inst.sstate != SemState.completed){ waitFor = inst; rewriteIfOk = r; }else mixin(RewEplg!q{r}); } } void emitError(Scope sc){ if(sc) set.matchError(sc, loc, this_, args); } private: mixin CreateBinderForDependent!("DetermineFunctionMatches"); mixin CreateBinderForDependent!("DetermineTemplateMatches"); mixin CreateBinderForDependent!("ConvertLiterals"); Dependent!void determineFunctionMatches(Scope sc){ enum SemRet = q{ return indepvoid }; trymatch: foreach(i,decl; set.decls){ adjustArgs(args, i); foreach(a; args) if(a.sstate == SemState.error) continue trymatch; //auto matched=set.decls[i].matchCall(null, loc, args, matches[i].context); mixin(MatchCall!q{auto matched; set.decls[i], null, loc, this_, func, args, matches[i].context}); assert(!matched||cast(FunctionDecl)matched); matches[i].decl = cast(FunctionDecl)cast(void*)matched; if(matches[i].decl){ mixin(ConvertLiterals!q{_;this,sc, args, matches[i].decl}); if(hasErrors(args)) matches[i].decl=null; } } restoreArgs(args); return indepvoid; } Dependent!void determineTemplateMatches()in{ assert(set.tdecls.length == iftis.length); }body{ MatchContext tcontext; foreach(i,ref x; iftis){ scope(success) if(!tmatches[i].tdecl) tmatches[i].tmatch=Match.none; if(!x) continue; assert(!!cast(TemplateInstanceDecl)x); auto inst = cast(TemplateInstanceDecl)cast(void*)x; assert(inst.finishedInstantiation()); auto fd = inst.iftiDecl(); if(!fd){ if(eponymous.length<=i || !eponymous[i]) continue; assert(eponymous[i].sstate == SemState.completed && cast(Symbol)eponymous[i],text(eponymous)); auto sym = (cast(Symbol)cast(void*)eponymous[i]); fd = sym.meaning.isFunctionDecl(); }else{ if(fd.type.sstate==SemState.error) return Dependee(fd.type,null).dependent!void; mixin(MatchCall!q{auto tmp; fd, null, loc, this_, func, args, tcontext}); assert(!tmp||cast(FunctionDecl)tmp); fd = cast(FunctionDecl)cast(void*)tmp; } if(!fd) continue; assert(fd.type.sstate == SemState.completed || (!fd.type.ret || fd.type.ret.sstate == SemState.error) && !fd.type.errorsInParams(), text(fd.type.sstate)); tmatches[i].decl = fd; tmatches[i].tdecl = fd.extractTemplateInstance(); tmatches[i].context = tcontext; } mixin(EliminateLessSpecializedTemplateMatches!q{_;OverloadSet,tmatches}); return indepvoid; } void adjustArgs(Expression[] args, size_t j){ foreach(k,i;positions) args[i] = literals[j][k]; } void restoreArgs(Expression[] args){ adjustArgs(args, literals.length-1); } bool hasErrors(Expression[] args){ foreach(i;positions) if(args[i].sstate == SemState.error) return true; return false; } GaggingScope gscope; Dependent!void convertLiterals(Scope sc,Expression[] args, FunctionDecl decl){ if(positions.length&&!gscope) gscope=New!GaggingScope(sc); foreach(i;positions){ if(args[i].sstate == SemState.error) continue; if(auto ae=args[i].isAddressExp()){ if(ae.isUndeducedFunctionLiteral()){ if(decl.type.params[i].type){ args[i]=args[i].implicitlyConvertTo(decl.type.params[i].type); args[i].semantic(gscope); if(args[i].needRetry) return Dependee(args[i], gscope).dependent!void; mixin(FinishDeduction!q{args[i]}); } } } } return indepvoid; } } mixin template Semantic(T) if(is(T==FunctionDecl)){ final bool isConstructor(){ return name && name.name == "this"; } /* this is general enough to be in Declaration, but it is at the moment not needed for anything else than function declarations. therefore it is declared here in order not to clutter the vtables */ TemplateInstanceDecl extractTemplateInstance(){ assert(!!cast(NestedScope)scope_); assert(!!cast(TemplateScope)(cast(NestedScope)scope_).parent); auto tsc = cast(TemplateScope)cast(void*)(cast(NestedScope)cast(void*)scope_).parent; assert(!!tsc.tmpl); return tsc.tmpl; } final public void propagateSTC(){ // TODO: constructors shouldn't pick up some of those // TODO: what to do about @property? enum mask = function{ STC r; // TODO: ToTuple is a workaround, is there a bug here? foreach(x;ToTuple!(functionSTC~attributeSTC)) static if(x!="@disable") r|=mixin("STC"~x); return r; }(); type.stc|=mask&stc&~(STCauto); } void analyzeType(){ propagateSTC(); if(isConstructor()) type.ret=Type.get!void(); type.semantic(scope_); } override void semantic(Scope sc){ mixin(SemPrlg); if(sstate == SemState.pre) presemantic(sc); analyzeType(); if(!type.ret&&type.hasAutoReturn()){ sc.error("function body required for return type inference",loc); mixin(ErrEplg); } mixin(SemProp!q{type}); mixin(SemEplg); } override bool needsAccessCheck(AccessCheck check){ return super.needsAccessCheck(check); } // TODO: would like Dependent!FunctionDecl for return type override Dependent!Declaration matchCall(Scope sc, const ref Location loc, Type this_, Expression func, Expression[] args, ref MatchContext context){ enum SemRet = q{ return this.independent!Declaration; }; // semantically analyze the type if necessary type.semantic(scope_); // TODO: get rid of direct call //mixin(SemProp!q{type}); if(auto nr=type.needRetry) { needRetry = nr; mixin(SemRet); } mixin(PropErr!q{type}); if(!isMember()&&!isConstructor()) this_ = null; mixin(MatchCallHelper!q{auto r; type, sc, loc, this_, args, context}); return (r ? this : Declaration.init).independent; } Dependent!bool atLeastAsSpecialized(FunctionDecl rhs)in{ assert(type.sstate == SemState.completed, text(type.sstate," ",type.needRetry)); assert(rhs.type.sstate == SemState.completed, text(rhs.type.sstate," ",rhs.type.needRetry)); }body{ MatchContext dummy; // GC allocations, unneeded // TODO: allocate this on the stack auto pt = new Expression[](type.params.length); foreach(i,x; type.params) pt[i] = new StubExp(x.type,!!(x.stc&STCbyref)); auto aggr = scope_.getAggregate(); auto this_ = aggr ? aggr.getType().applySTC(stc) : null; // TODO: reduce DMD bug /+auto pt = array(map!(function Expression (_)=> new StubExp(_.type,!!(_.stc&STCbyref)))(type.params));+/ mixin(MatchCall!q{auto rr; rhs, null, loc, this_, null, pt, dummy}); assert(!rr||cast(FunctionDecl)rr); auto r=cast(FunctionDecl)cast(void*)rr; assert(!r||r.type.sstate == SemState.completed); // prefer function definitions to their own forward declarations if(r && !isFunctionDef() && rhs.isFunctionDef() && type.equals(rhs.type) && stc == rhs.stc && scope_ is rhs.scope_) // TODO: consider linkage return false.independent; return (cast(bool)r).independent; } override void matchError(Scope sc, Location loc, Type this_, Expression[] args){ alias util.any any; // TODO: file bug if(args.length > type.params.length || any!(_=>_.init is null)(type.params[args.length..type.params.length])){ sc.error(format("too %s arguments to %s '%s'",args.length<type.params.length?"few":"many", kind, signatureString()[0..$-1]),loc); sc.note("declared here",this.loc); return; } int num=0; InoutRes inoutRes; if(this_&&stc&STCinout) inoutRes = irFromSTC(this_.getHeadSTC()); auto at = new Type[args.length]; foreach(i,p; type.params){ at[i] = p.type.adaptTo(args[i].type, inoutRes); } foreach(ref x;at) x = x.resolveInout(inoutRes); auto compatd=!this_?true.independent: this_.refConvertsTo( this_.getHeadUnqual() .applySTC(type.stc&STCtypeconstructor) .resolveInout(inoutRes), 0 ); if(!compatd.dependee&&!compatd.value) num++; foreach(i,p; type.params){ auto iconvd = args[i].implicitlyConvertsTo(at[i]); if(!iconvd.dependee && !iconvd.value) num++; } if(num>1){ sc.error(format("incompatible argument types (%s)%s to %s '%s'", join(map!"a.type.toString()"(args),","),this_?STCtoString(this_.getHeadSTC()):"",kind,signatureString()[0..$-1]),loc); sc.note("declared here",this.loc); }else{ if(!compatd.value){ incompatibleThisError(sc, loc, this_.getHeadSTC(), type.stc&STCtypeconstructor,this); } foreach(i,p; type.params){ void displayNote(){ if(p.name) sc.note(format("while matching function parameter '%s'",p.name),p.loc); else sc.note("while matching function parameter",p.loc); } if(!(p.stc & STCbyref)){ if(p.stc&STClazy && at[i].getHeadUnqual() is Type.get!void()) continue; auto iconvd = args[i].implicitlyConvertsTo(at[i]); if(!iconvd.dependee && !iconvd.value){ if(args[i].sstate == SemState.error) continue; // trigger consistent error message args[i].implicitlyConvertTo(at[i]).semantic(sc); displayNote(); break; } }else if(p.stc&STCref){ if(!args[i].checkLvalue(sc, args[i].loc)){ displayNote(); break; } auto irconvd = args[i].type.refConvertsTo(p.type,1); if(!irconvd.dependee && !irconvd.value){ sc.error(format("incompatible argument type '%s' for 'ref' parameter of type '%s'",args[i].type.toString(),p.type.toString()),args[i].loc); displayNote(); break; } }else{// if(p.stc&STCout){ assert(p.stc&STCout); if(!args[i].checkMutate(sc, args[i].loc)){ displayNote(); break; } auto irconvd = p.type.refConvertsTo(args[i].type,1); if(!irconvd.dependee && !irconvd.value){ sc.error(format("incompatible argument type '%s' for 'out' parameter of type '%s'", args[i].type, p.type),args[i].loc); displayNote(); break; } } } } } static void incompatibleThisError(Scope sc, Location loc, STC hstc, STC fstc, FunctionDecl fd){ // TODO: this allocates if(fd.isConstructor()){ string stcstr(STC stc){ return stc?"'"~STCtoString(stc)~"'-qualified":"unqualified"; } string n(string stcstr){ return stcstr[1].among('a','e','i','o','u')?"n":""; } auto hstcstr=stcstr(hstc), fstcstr=stcstr(fstc); auto n1=n(hstcstr), n2=n(fstcstr); sc.error(format("cannot construct a%s %s object using a%s %s constructor",n1,hstcstr,n2,fstcstr), loc); }else{ auto hstcstr=hstc?"'"~STCtoString(hstc)~"'":"mutable"; auto fstcstr=fstc?"'"~STCtoString(fstc)~"'":"mutable"; sc.error(format("receiver for %s '%s' is %s, but %s is required", fd.kind, fd.name, hstcstr, fstcstr), loc); } } final TemplateDecl templatizeLiteral(Scope sc, const ref Location loc)in{ assert(sstate == SemState.pre); size_t nump = 0; assert(type.hasUnresolvedParameters()); }body{ type.reset(); size_t nump = 0; foreach(x;type.params) if(x.mustBeTypeDeduced()) nump++; // TODO: gc allocations TemplateParameter[] tparams = new TemplateParameter[nump]; immutable static string namebase = "__T"; size_t j=-1; // TODO: can the scope be kept clean by using some tricks? foreach(i,ref x; tparams){ while(!type.params[++j].mustBeTypeDeduced()) {} string name = namebase~to!string(i+1); auto which = WhichTemplateParameter.type; x = New!TemplateParameter(which, Expression.init, New!Identifier(name), Expression.init, Expression.init); type.params[j].rtype = New!Identifier(name); } auto tmplname = name.name; // TODO: GC allocation name.name~="Impl"; auto ident = New!Identifier(name.name); ident.loc = loc; auto uexp = New!(UnaryExp!(Tok!"&"))(ident); uexp.loc = loc; uexp.brackets++; auto alias_ = New!AliasDecl(STC.init, New!VarDecl(STC.init,uexp,New!Identifier(tmplname),Expression.init)); static class FunclitTemplateDecl: TemplateDecl{ this(STC stc, Identifier name, TemplateParameter[] prm, BlockDecl b, Scope sc){ super(false,stc,name,prm,Expression.init,b); sstate=SemState.begin; scope_=sc; } // OO FTW! override FunctionDecl iftiDecl(){ assert(!!cast(FunctionDecl)bdy.decls[0]); return cast(FunctionDecl)cast(void*)bdy.decls[0]; } } auto t=New!FunclitTemplateDecl(stc&STCstatic, New!Identifier(tmplname), tparams, New!BlockDecl(STC.init,[cast(Declaration)this,alias_]),sc); t.loc = loc; return t; } } mixin template Semantic(T) if(is(T==FunctionDef)){ FunctionScope fsc; protected FunctionScope buildFunctionScope(){ return New!FunctionScope(scope_, this); } override void analyzeType(){ assert(!!scope_); propagateSTC(); if(isConstructor()) type.ret=Type.get!void(); if(!fsc){ if(auto ti=scope_.getTemplateInstance()) if(!ti.isMixin) inferAttributes=true; fsc = buildFunctionScope(); foreach(p; type.params){ if(p.sstate == SemState.pre) p.sstate = SemState.begin; if(p.name) if(!fsc.insert(p)) p.sstate = SemState.error; } } foreach(x; type.params){ x.semantic(fsc); assert(!x.rewrite); if(auto nr=x.needRetry){ Scheduler().await(this, x, fsc); type.needRetry = nr; return; } } type.semantic(scope_); if(type.needRetry) Scheduler().await(this, type, scope_); } override void semantic(Scope sc){ mixin(SemPrlg); propagateSTC(); if(sstate == SemState.pre){ presemantic(sc); // add self to parent scope if(sstate == SemState.error){ needRetry=false; scope_=sc; } } analyzeType(); if(auto nr=type.needRetry) { needRetry = nr; return; } mixin(PropErr!q{type}); if(type.sstate == SemState.error) sstate = SemState.error, needRetry=false; mixin(SemChldPar!q{sc=fsc; bdy}); if(type.hasUnresolvedReturn()){ type.resolveReturn(Type.get!void()); } needRetry=false; resolveForwardReferencedLabels(); mixin(SemCheck); mixin(PropErr!q{type, bdy}); auto infer=possibleSTCs&inferredSTCs; if(infer&STCstatic) infer&=~STCimmutable; stc |= infer; propagateSTC(); mixin(SemEplg); } private void resolveForwardReferencedLabels(){ foreach(gto;&fsc.unresolvedLabels){ assert(cast(Identifier)gto.e); if(auto lbl = fsc.lookupLabelHere(cast(Identifier)cast(void*)gto.e)) gto.resolveLabel(lbl); else undeclaredLabel(gto); } } protected void undeclaredLabel(GotoStm gto){ fsc.error(format("use of undeclared label '%s'",gto.e.toString()), gto.e.loc); sstate = SemState.error; } mixin HandleNestedDeclarations; /* specifies whether or not to infer the 'static' qualifier */ bool inferStatic; bool inferAttributes; @property STC inferredSTCs(){ auto infer=(inferStatic?STCstatic:STC.init)|(inferAttributes?STCinferrable:STC.init); if(isMember()||isConstructor()) infer&=~STCimmutable; return infer; } bool finishedInference(){ return sstate==SemState.completed||!inferredSTCs(); } void cancelInference(){ inferStatic=false; inferAttributes=false; } private STC possibleSTCs; // DMD does not allow initialization here. TODO: fix this @property bool canBeStatic(){ return !!(possibleSTCs&STCstatic); } @property void canBeStatic(bool b)in{assert(!b||canBeStatic);}body{ if(!b) impossibleSTCs(STCstatic); } final void addContextPointer() in{ assert(sstate == SemState.completed); assert(inferredSTCs()&STCstatic); assert(stc&STCstatic); }body{ assert(canBeStatic); stc&=~STCstatic; } void rescope(Scope sc){ if(scope_ !is sc){ scope_=sc; // eg. matching overloads if(fsc) fsc.parent=scope_; } } void notifyIfNot(STC stc,FunctionDef other){ if(other is this) return; other.possibleSTCs=other.possibleSTCs&(~stc|stc&possibleSTCs); if(finishedInference()) return; // assert(0, text("TODO ",this)); // TODO! } private void impossibleSTCs(STC stc){ possibleSTCs&=~stc; } } mixin template Semantic(T) if(is(T==UnittestDecl)){ static bool enabled = false; Scope utsc; override void presemantic(Scope sc){ if(sstate!=SemState.pre) return; scope_=sc; sstate=SemState.begin; } override void semantic(Scope sc){ if(enabled) super.semantic(sc); else mixin(SemEplg); } } mixin template Semantic(T) if(is(T==PragmaDecl)){ override void presemantic(Scope sc){ if(sstate != SemState.pre) return; if(auto b=bdy.isDeclaration()) b.presemantic(sc); sstate = SemState.begin; } int c; override void semantic(Scope sc){ mixin(SemPrlg); if(args.length<1){sc.error("missing arguments to pragma",loc); mixin(ErrEplg);} if(auto id=args[0].isIdentifier()){ bool intprt = true; switch(id.name){ case "__p": intprt = false; goto case; case "msg": if(args.length<2){if(bdy)mixin(SemChld!q{bdy}); mixin(SemEplg);} //foreach(ref x; args[1..$]) x = x.semantic(sc); //mixin(SemChldPar!q{args[1..$]}); auto a = args[1..$]; foreach(x; a) x.prepareInterpret(); foreach(ref x;a){ mixin(SemChldPar!q{x}); mixin(FinishDeduction!q{x}); } mixin(PropErr!q{a}); foreach(ref x; a) if(!x.isType() && !x.isExpTuple() && intprt){ mixin(IntChld!q{x}); } // TODO: this should use the scope's error handler for output import std.stdio; // if(!sc.handler.showsEffect) stderr.write("(gagged:) "); foreach(x; a) if(x.type.getHeadUnqual().isSomeString()) sc.handler.message(x.interpretV().get!string()); else sc.handler.message(x.toString()); sc.handler.message("\n"); if(bdy) mixin(SemChld!q{bdy}); mixin(SemEplg); default: break; // some vendor specific pragmas case "__range": if(args.length!=2) break; mixin(SemChld!q{args[1]}); mixin(PropErr!q{args[1]}); sstate = args[1].sstate; if(sstate == SemState.completed){ import std.stdio; auto ty=args[1].type.getHeadUnqual().isIntegral(); if(ty&&ty.bitSize()<=32) stderr.writeln(args[1].getIntRange()); else stderr.writeln(args[1].getLongRange()); } mixin(SemEplg); } } sc.error(format("unrecognized pragma '%s'",args[0].loc.rep),args[0].loc); // TODO: option to ignore mixin(SemChld!q{bdy}); mixin(ErrEplg); } } // string mixins mixin template Semantic(T) if(is(T==MixinExp)||is(T==MixinStm)||is(T==MixinDecl)){ Expression aLeftover=null; static if(is(T==MixinExp)) alias Expression R; // workaround else static if(is(T==MixinStm)) alias Statement R; else static if(is(T==MixinDecl)) alias Declaration R; static if(is(T==MixinDecl)){ override void potentialInsert(Scope sc, Declaration dependee){ sc.potentialInsertArbitrary(dependee,this); } override void potentialRemove(Scope sc, Declaration dependee){ sc.potentialRemoveArbitrary(dependee,this); } override void presemantic(Scope sc){ if(sstate != SemState.pre) return; scope_ = sc; sstate = SemState.begin; potentialInsert(sc, this); } Declaration mixedin; }else static if(is(T==MixinExp)){ AccessCheck accessCheck = accessCheck.all; mixin ContextSensitive; } private R evaluate(Scope sc){ mixin(SemPrlg); foreach(x;a) x.prepareInterpret(); mixin(SemChld!q{a}); if(a.length<1){ sc.error("missing argument for string mixin", loc); mixin(ErrEplg); }else if(a.length>1){ sc.error("too many arguments for string mixin", loc); mixin(ErrEplg); } mixin(FinishDeductionProp!q{a[0]}); int which; Type[3] types = [Type.get!(const(char)[])(), Type.get!(const(wchar)[])(), Type.get!(const(dchar)[])()]; foreach(i,t;types) if(!which){ mixin(ImplConvertsTo!q{bool icd; a[0], t}); if(icd) which=cast(int)i+1; } if(!which){ sc.error("expected string argument for string mixin", a[0].loc); mixin(ErrEplg); } foreach(i,t; types) if(i+1==which) mixin(ImplConvertTo!q{a[0],t}); assert(a[0].sstate == SemState.completed); a[0].interpret(sc); if(aLeftover) aLeftover.interpret(sc); mixin(SemProp!q{a[0]}); if(aLeftover) mixin(SemProp!q{aLeftover}); auto str = a[0].interpretV().convertTo(Type.get!string()).get!string(); //str~=(is(T==MixinStm)&&str[$-1]!=';'?";":"")~"\0\0\0\0"; str~="\0\0\0\0"; Source src = New!Source(format("<mixin@%s:%d>",loc.source.name,loc.line), str); // TODO: column? import parser; //auto handler = sc.handler; /+ auto handler = New!StringMixinErrorHandler(); auto ohan = sc.handler; sc.handler = handler;+/ auto nerrors = sc.handler.nerrors; static if(is(T==MixinExp)){ auto r=parseExpression(src,sc.handler); r.weakenAccessCheck(accessCheck); transferContext(r); }else static if(is(T==MixinStm)) auto r=New!CompoundStm(parseStatements(src,sc.handler)); // TODO: use CompoundStm instead else static if(is(T==MixinDecl)) auto r=New!BlockDecl(STC.init,parseDeclDefs(src,sc.handler)); else static assert(0); if(sc.handler.nerrors != nerrors) mixin(ErrEplg); else static if(is(T==MixinDecl)) r.pickupSTC(stc); r.semantic(sc); // ohan.note("mixed in here", loc); // TODO: do we want something like this? /+ sc.handler = ohan; if(handler.errors.length){ sc.error("mixed in code contained errors",loc); foreach(x; handler.errors) sc.handler.playErrorRecord(x); mixin(ErrEplg); }+/ mixin(Rewrite!q{r}); needRetry = false; return r; } override void semantic(Scope sc){ auto r=evaluate(sc); static if(is(T==MixinDecl)){ scope(success) if(rewrite||sstate==SemState.error) potentialRemove(sc, this); } mixin(SemCheck); mixin(RewEplg!q{r}); } } /+ // TODO: do we want something like this? class StringMixinErrorHandler: ErrorHandler{ ErrorRecord[] errors; override void error(lazy string err, Location loc){ errors~=ErrorRecord(err,loc); } override void note(lazy string err, Location loc){ errors~=ErrorRecord(err,loc,true); } }+/
D
import avr.io; import avr.util.delay; // this example assumes you wired 8 LEDs to PB0:PB7 // adjust values to your actual setup // Port registers for LED access alias LED_DDR = DDRB; alias LED_PORT = PORTB; alias Delay = FrequencyDelay!(1 * MHz); extern (C) void main() { // set Data Direction Register to output for all 8 bits // change only the bits you have LEDs on LED_DDR = 0xFF; while (true) { // set all 8 LEDs to on LED_PORT = 0xFF; // or alternatively turn of all LEDs, except for the 3rd one //LED_PORT = (1 << 2); Delay.delayMsecs!(1000); // turn all LEDs off again LED_PORT = 0; Delay.delayMsecs!(1000); } }
D
/** * Contains the garbage collector implementation. * * Copyright: Copyright Digital Mars 2001 - 2013. * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Walter Bright, David Friedman, Sean Kelly */ /* Copyright Digital Mars 2005 - 2013. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ module gc.gc; // D Programming Language Garbage Collector implementation /************** Debugging ***************************/ //debug = PRINTF; // turn on printf's //debug = COLLECT_PRINTF; // turn on printf's //debug = PRINTF_TO_FILE; // redirect printf's ouptut to file "gcx.log" //debug = LOGGING; // log allocations / frees //debug = MEMSTOMP; // stomp on memory //debug = SENTINEL; // add underrun/overrrun protection // NOTE: this needs to be enabled globally in the makefiles // (-debug=SENTINEL) to pass druntime's unittests. //debug = PTRCHECK; // more pointer checking //debug = PTRCHECK2; // thorough but slow pointer checking //debug = INVARIANT; // enable invariants //debug = PROFILE_API; // profile API calls for config.profile > 1 /*************** Configuration *********************/ version = STACKGROWSDOWN; // growing the stack means subtracting from the stack pointer // (use for Intel X86 CPUs) // else growing the stack means adding to the stack pointer /***************************************************/ import gc.bits; import gc.stats; import gc.os; import gc.config; import rt.util.container.treap; import cstdlib = core.stdc.stdlib : calloc, free, malloc, realloc; import core.stdc.string : memcpy, memset, memmove; import core.bitop; import core.sync.mutex; import core.thread; static import core.memory; private alias BlkAttr = core.memory.GC.BlkAttr; private alias BlkInfo = core.memory.GC.BlkInfo; version (GNU) import gcc.builtins; debug (PRINTF_TO_FILE) import core.stdc.stdio : sprintf, fprintf, fopen, fflush, FILE; else import core.stdc.stdio : sprintf, printf; // needed to output profiling results import core.time; alias currTime = MonoTime.currTime; debug(PRINTF_TO_FILE) { private __gshared MonoTime gcStartTick; private __gshared FILE* gcx_fh; private int printf(ARGS...)(const char* fmt, ARGS args) nothrow { if (!gcx_fh) gcx_fh = fopen("gcx.log", "w"); if (!gcx_fh) return 0; int len; if (MonoTime.ticksPerSecond == 0) { len = fprintf(gcx_fh, "before init: "); } else { if (gcStartTick == MonoTime.init) gcStartTick = MonoTime.currTime; immutable timeElapsed = MonoTime.currTime - gcStartTick; immutable secondsAsDouble = timeElapsed.total!"hnsecs" / cast(double)convert!("seconds", "hnsecs")(1); len = fprintf(gcx_fh, "%10.6lf: ", secondsAsDouble); } len += fprintf(gcx_fh, fmt, args); fflush(gcx_fh); return len; } } debug(PRINTF) void printFreeInfo(Pool* pool) nothrow { uint nReallyFree; foreach(i; 0..pool.npages) { if(pool.pagetable[i] >= B_FREE) nReallyFree++; } printf("Pool %p: %d really free, %d supposedly free\n", pool, nReallyFree, pool.freepages); } // Track total time spent preparing for GC, // marking, sweeping and recovering pages. __gshared Duration prepTime; __gshared Duration markTime; __gshared Duration sweepTime; __gshared Duration recoverTime; __gshared Duration maxPauseTime; __gshared size_t numCollections; __gshared size_t maxPoolMemory; __gshared long numMallocs; __gshared long numFrees; __gshared long numReallocs; __gshared long numExtends; __gshared long numOthers; __gshared long mallocTime; // using ticks instead of MonoTime for better performance __gshared long freeTime; __gshared long reallocTime; __gshared long extendTime; __gshared long otherTime; __gshared long lockTime; private { extern (C) { // to allow compilation of this module without access to the rt package, // make these functions available from rt.lifetime void rt_finalizeFromGC(void* p, size_t size, uint attr) nothrow; int rt_hasFinalizerInSegment(void* p, size_t size, uint attr, in void[] segment) nothrow; // Declared as an extern instead of importing core.exception // to avoid inlining - see issue 13725. void onInvalidMemoryOperationError() nothrow; void onOutOfMemoryErrorNoGC() @nogc nothrow; } enum { OPFAIL = ~cast(size_t)0 } } alias GC gc_t; /* ======================= Leak Detector =========================== */ debug (LOGGING) { struct Log { void* p; size_t size; size_t line; char* file; void* parent; void print() nothrow { printf(" p = %p, size = %zd, parent = %p ", p, size, parent); if (file) { printf("%s(%u)", file, line); } printf("\n"); } } struct LogArray { size_t dim; size_t allocdim; Log *data; void Dtor() nothrow { if (data) cstdlib.free(data); data = null; } void reserve(size_t nentries) nothrow { assert(dim <= allocdim); if (allocdim - dim < nentries) { allocdim = (dim + nentries) * 2; assert(dim + nentries <= allocdim); if (!data) { data = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); if (!data && allocdim) onOutOfMemoryErrorNoGC(); } else { Log *newdata; newdata = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof); if (!newdata && allocdim) onOutOfMemoryErrorNoGC(); memcpy(newdata, data, dim * Log.sizeof); cstdlib.free(data); data = newdata; } } } void push(Log log) nothrow { reserve(1); data[dim++] = log; } void remove(size_t i) nothrow { memmove(data + i, data + i + 1, (dim - i) * Log.sizeof); dim--; } size_t find(void *p) nothrow { for (size_t i = 0; i < dim; i++) { if (data[i].p == p) return i; } return OPFAIL; // not found } void copy(LogArray *from) nothrow { reserve(from.dim - dim); assert(from.dim <= allocdim); memcpy(data, from.data, from.dim * Log.sizeof); dim = from.dim; } } } /* ============================ GC =============================== */ const uint GCVERSION = 1; // increment every time we change interface // to GC. // This just makes Mutex final to de-virtualize member function calls. final class GCMutex : Mutex { final override void lock() nothrow @trusted @nogc { super.lock_nothrow(); } final override void unlock() nothrow @trusted @nogc { super.unlock_nothrow(); } } struct GC { // For passing to debug code (not thread safe) __gshared size_t line; __gshared char* file; uint gcversion = GCVERSION; Gcx *gcx; // implementation // We can't allocate a Mutex on the GC heap because we are the GC. // Store it in the static data segment instead. __gshared GCMutex gcLock; // global lock __gshared void[__traits(classInstanceSize, GCMutex)] mutexStorage; __gshared Config config; void initialize() { config.initialize(); mutexStorage[] = typeid(GCMutex).initializer[]; gcLock = cast(GCMutex) mutexStorage.ptr; gcLock.__ctor(); gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof); if (!gcx) onOutOfMemoryErrorNoGC(); gcx.initialize(); if (config.initReserve) gcx.reserve(config.initReserve << 20); if (config.disable) gcx.disabled++; } void Dtor() { version (linux) { //debug(PRINTF) printf("Thread %x ", pthread_self()); //debug(PRINTF) printf("GC.Dtor()\n"); } if (gcx) { gcx.Dtor(); cstdlib.free(gcx); gcx = null; } } /** * */ void enable() { gcLock.lock(); scope(exit) gcLock.unlock(); assert(gcx.disabled > 0); gcx.disabled--; } /** * */ void disable() { gcLock.lock(); scope(exit) gcLock.unlock(); gcx.disabled++; } auto runLocked(alias func, alias time, alias count, Args...)(auto ref Args args) { debug(PROFILE_API) immutable tm = (GC.config.profile > 1 ? currTime.ticks : 0); gcLock.lock(); debug(PROFILE_API) immutable tm2 = (GC.config.profile > 1 ? currTime.ticks : 0); static if (is(typeof(func(args)) == void)) func(args); else auto res = func(args); debug(PROFILE_API) if (GC.config.profile > 1) { count++; immutable now = currTime.ticks; lockTime += tm2 - tm; time += now - tm2; } gcLock.unlock(); static if (!is(typeof(func(args)) == void)) return res; } /** * */ uint getAttr(void* p) nothrow { if (!p) { return 0; } static uint go(Gcx* gcx, void* p) nothrow { Pool* pool = gcx.findPool(p); uint oldb = 0; if (pool) { p = sentinel_sub(p); auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; oldb = pool.getBits(biti); } return oldb; } return runLocked!(go, otherTime, numOthers)(gcx, p); } /** * */ uint setAttr(void* p, uint mask) nothrow { if (!p) { return 0; } static uint go(Gcx* gcx, void* p, uint mask) nothrow { Pool* pool = gcx.findPool(p); uint oldb = 0; if (pool) { p = sentinel_sub(p); auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; oldb = pool.getBits(biti); pool.setBits(biti, mask); } return oldb; } return runLocked!(go, otherTime, numOthers)(gcx, p, mask); } /** * */ uint clrAttr(void* p, uint mask) nothrow { if (!p) { return 0; } static uint go(Gcx* gcx, void* p, uint mask) nothrow { Pool* pool = gcx.findPool(p); uint oldb = 0; if (pool) { p = sentinel_sub(p); auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; oldb = pool.getBits(biti); pool.clrBits(biti, mask); } return oldb; } return runLocked!(go, otherTime, numOthers)(gcx, p, mask); } /** * */ void *malloc(size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow { if (!size) { if(alloc_size) *alloc_size = 0; return null; } size_t localAllocSize = void; if(alloc_size is null) alloc_size = &localAllocSize; auto p = runLocked!(mallocNoSync, mallocTime, numMallocs)(size, bits, *alloc_size, ti); if (!(bits & BlkAttr.NO_SCAN)) { memset(p + size, 0, *alloc_size - size); } return p; } // // // private void *mallocNoSync(size_t size, uint bits, ref size_t alloc_size, const TypeInfo ti = null) nothrow { assert(size != 0); //debug(PRINTF) printf("GC::malloc(size = %d, gcx = %p)\n", size, gcx); assert(gcx); //debug(PRINTF) printf("gcx.self = %x, pthread_self() = %x\n", gcx.self, pthread_self()); if (gcx.running) onInvalidMemoryOperationError(); auto p = gcx.alloc(size + SENTINEL_EXTRA, alloc_size, bits); if (!p) onOutOfMemoryErrorNoGC(); debug (SENTINEL) { p = sentinel_add(p); sentinel_init(p, size); alloc_size = size; } gcx.log_malloc(p, size); return p; } /** * */ void *calloc(size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow { if (!size) { if(alloc_size) *alloc_size = 0; return null; } size_t localAllocSize = void; if(alloc_size is null) alloc_size = &localAllocSize; auto p = runLocked!(mallocNoSync, mallocTime, numMallocs)(size, bits, *alloc_size, ti); memset(p, 0, size); if (!(bits & BlkAttr.NO_SCAN)) { memset(p + size, 0, *alloc_size - size); } return p; } /** * */ void *realloc(void *p, size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow { size_t localAllocSize = void; auto oldp = p; if(alloc_size is null) alloc_size = &localAllocSize; p = runLocked!(reallocNoSync, mallocTime, numMallocs)(p, size, bits, *alloc_size, ti); if (p !is oldp && !(bits & BlkAttr.NO_SCAN)) { memset(p + size, 0, *alloc_size - size); } return p; } // // bits will be set to the resulting bits of the new block // private void *reallocNoSync(void *p, size_t size, ref uint bits, ref size_t alloc_size, const TypeInfo ti = null) nothrow { if (gcx.running) onInvalidMemoryOperationError(); if (!size) { if (p) { freeNoSync(p); p = null; } alloc_size = 0; } else if (!p) { p = mallocNoSync(size, bits, alloc_size, ti); } else { void *p2; size_t psize; //debug(PRINTF) printf("GC::realloc(p = %p, size = %zu)\n", p, size); debug (SENTINEL) { sentinel_Invariant(p); psize = *sentinel_size(p); if (psize != size) { if (psize) { Pool *pool = gcx.findPool(p); if (pool) { auto biti = cast(size_t)(sentinel_sub(p) - pool.baseAddr) >> pool.shiftBy; if (bits) { pool.clrBits(biti, ~BlkAttr.NONE); pool.setBits(biti, bits); } else { bits = pool.getBits(biti); } } } p2 = mallocNoSync(size, bits, alloc_size, ti); if (psize < size) size = psize; //debug(PRINTF) printf("\tcopying %d bytes\n",size); memcpy(p2, p, size); p = p2; } } else { auto pool = gcx.findPool(p); if (pool.isLargeObject) { auto lpool = cast(LargeObjectPool*) pool; psize = lpool.getSize(p); // get allocated size if (size <= PAGESIZE / 2) goto Lmalloc; // switching from large object pool to small object pool auto psz = psize / PAGESIZE; auto newsz = (size + PAGESIZE - 1) / PAGESIZE; if (newsz == psz) { alloc_size = psize; return p; } auto pagenum = lpool.pagenumOf(p); if (newsz < psz) { // Shrink in place debug (MEMSTOMP) memset(p + size, 0xF2, psize - size); lpool.freePages(pagenum + newsz, psz - newsz); } else if (pagenum + newsz <= pool.npages) { // Attempt to expand in place foreach (binsz; lpool.pagetable[pagenum + psz .. pagenum + newsz]) if (binsz != B_FREE) goto Lmalloc; debug (MEMSTOMP) memset(p + psize, 0xF0, size - psize); debug(PRINTF) printFreeInfo(pool); memset(&lpool.pagetable[pagenum + psz], B_PAGEPLUS, newsz - psz); gcx.usedLargePages += newsz - psz; lpool.freepages -= (newsz - psz); debug(PRINTF) printFreeInfo(pool); } else goto Lmalloc; // does not fit into current pool lpool.updateOffsets(pagenum); if (bits) { immutable biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; pool.clrBits(biti, ~BlkAttr.NONE); pool.setBits(biti, bits); } alloc_size = newsz * PAGESIZE; return p; } psize = (cast(SmallObjectPool*) pool).getSize(p); // get allocated size if (psize < size || // if new size is bigger psize > size * 2) // or less than half { Lmalloc: if (psize && pool) { auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; if (bits) { pool.clrBits(biti, ~BlkAttr.NONE); pool.setBits(biti, bits); } else { bits = pool.getBits(biti); } } p2 = mallocNoSync(size, bits, alloc_size, ti); if (psize < size) size = psize; //debug(PRINTF) printf("\tcopying %d bytes\n",size); memcpy(p2, p, size); p = p2; } else alloc_size = psize; } } return p; } /** * Attempt to in-place enlarge the memory block pointed to by p by at least * minsize bytes, up to a maximum of maxsize additional bytes. * This does not attempt to move the memory block (like realloc() does). * * Returns: * 0 if could not extend p, * total size of entire memory block if successful. */ size_t extend(void* p, size_t minsize, size_t maxsize, const TypeInfo ti = null) nothrow { return runLocked!(extendNoSync, extendTime, numExtends)(p, minsize, maxsize, ti); } // // // private size_t extendNoSync(void* p, size_t minsize, size_t maxsize, const TypeInfo ti = null) nothrow in { assert(minsize <= maxsize); } body { if (gcx.running) onInvalidMemoryOperationError(); //debug(PRINTF) printf("GC::extend(p = %p, minsize = %zu, maxsize = %zu)\n", p, minsize, maxsize); debug (SENTINEL) { return 0; } else { auto pool = gcx.findPool(p); if (!pool || !pool.isLargeObject) return 0; auto lpool = cast(LargeObjectPool*) pool; auto psize = lpool.getSize(p); // get allocated size if (psize < PAGESIZE) return 0; // cannot extend buckets auto psz = psize / PAGESIZE; auto minsz = (minsize + PAGESIZE - 1) / PAGESIZE; auto maxsz = (maxsize + PAGESIZE - 1) / PAGESIZE; auto pagenum = lpool.pagenumOf(p); size_t sz; for (sz = 0; sz < maxsz; sz++) { auto i = pagenum + psz + sz; if (i == lpool.npages) break; if (lpool.pagetable[i] != B_FREE) { if (sz < minsz) return 0; break; } } if (sz < minsz) return 0; debug (MEMSTOMP) memset(pool.baseAddr + (pagenum + psz) * PAGESIZE, 0xF0, sz * PAGESIZE); memset(lpool.pagetable + pagenum + psz, B_PAGEPLUS, sz); lpool.updateOffsets(pagenum); lpool.freepages -= sz; gcx.usedLargePages += sz; return (psz + sz) * PAGESIZE; } } /** * */ size_t reserve(size_t size) nothrow { if (!size) { return 0; } gcLock.lock(); auto rc = reserveNoSync(size); gcLock.unlock(); return rc; } // // // private size_t reserveNoSync(size_t size) nothrow { assert(size != 0); assert(gcx); if (gcx.running) onInvalidMemoryOperationError(); return gcx.reserve(size); } /** * */ void free(void *p) nothrow { if (!p) { return; } return runLocked!(freeNoSync, freeTime, numFrees)(p); } // // // private void freeNoSync(void *p) nothrow { debug(PRINTF) printf("Freeing %p\n", cast(size_t) p); assert (p); if (gcx.running) onInvalidMemoryOperationError(); Pool* pool; size_t pagenum; Bins bin; size_t biti; // Find which page it is in pool = gcx.findPool(p); if (!pool) // if not one of ours return; // ignore pagenum = pool.pagenumOf(p); debug(PRINTF) printf("pool base = %p, PAGENUM = %d of %d, bin = %d\n", pool.baseAddr, pagenum, pool.npages, pool.pagetable[pagenum]); debug(PRINTF) if(pool.isLargeObject) printf("Block size = %d\n", pool.bPageOffsets[pagenum]); bin = cast(Bins)pool.pagetable[pagenum]; // Verify that the pointer is at the beginning of a block, // no action should be taken if p is an interior pointer if (bin > B_PAGE) // B_PAGEPLUS or B_FREE return; if ((sentinel_sub(p) - pool.baseAddr) & (binsize[bin] - 1)) return; sentinel_Invariant(p); p = sentinel_sub(p); biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy; pool.clrBits(biti, ~BlkAttr.NONE); if (pool.isLargeObject) // if large alloc { assert(bin == B_PAGE); auto lpool = cast(LargeObjectPool*) pool; // Free pages size_t npages = lpool.bPageOffsets[pagenum]; debug (MEMSTOMP) memset(p, 0xF2, npages * PAGESIZE); lpool.freePages(pagenum, npages); } else { // Add to free list List *list = cast(List*)p; debug (MEMSTOMP) memset(p, 0xF2, binsize[bin]); list.next = gcx.bucket[bin]; list.pool = pool; gcx.bucket[bin] = list; } gcx.log_free(sentinel_add(p)); } /** * Determine the base address of the block containing p. If p is not a gc * allocated pointer, return null. */ void* addrOf(void *p) nothrow { if (!p) { return null; } return runLocked!(addrOfNoSync, otherTime, numOthers)(p); } // // // void* addrOfNoSync(void *p) nothrow { if (!p) { return null; } auto q = gcx.findBase(p); if (q) q = sentinel_add(q); return q; } /** * Determine the allocated size of pointer p. If p is an interior pointer * or not a gc allocated pointer, return 0. */ size_t sizeOf(void *p) nothrow { if (!p) { return 0; } return runLocked!(sizeOfNoSync, otherTime, numOthers)(p); } // // // private size_t sizeOfNoSync(void *p) nothrow { assert (p); debug (SENTINEL) { p = sentinel_sub(p); size_t size = gcx.findSize(p); // Check for interior pointer // This depends on: // 1) size is a power of 2 for less than PAGESIZE values // 2) base of memory pool is aligned on PAGESIZE boundary if (cast(size_t)p & (size - 1) & (PAGESIZE - 1)) size = 0; return size ? size - SENTINEL_EXTRA : 0; } else { size_t size = gcx.findSize(p); // Check for interior pointer // This depends on: // 1) size is a power of 2 for less than PAGESIZE values // 2) base of memory pool is aligned on PAGESIZE boundary if (cast(size_t)p & (size - 1) & (PAGESIZE - 1)) return 0; return size; } } /** * Determine the base address of the block containing p. If p is not a gc * allocated pointer, return null. */ BlkInfo query(void *p) nothrow { if (!p) { BlkInfo i; return i; } return runLocked!(queryNoSync, otherTime, numOthers)(p); } // // // BlkInfo queryNoSync(void *p) nothrow { assert(p); BlkInfo info = gcx.getInfo(p); debug(SENTINEL) { if (info.base) { info.base = sentinel_add(info.base); info.size = *sentinel_size(info.base); } } return info; } /** * Verify that pointer p: * 1) belongs to this memory pool * 2) points to the start of an allocated piece of memory * 3) is not on a free list */ void check(void *p) nothrow { if (!p) { return; } return runLocked!(checkNoSync, otherTime, numOthers)(p); } // // // private void checkNoSync(void *p) nothrow { assert(p); sentinel_Invariant(p); debug (PTRCHECK) { Pool* pool; size_t pagenum; Bins bin; size_t size; p = sentinel_sub(p); pool = gcx.findPool(p); assert(pool); pagenum = pool.pagenumOf(p); bin = cast(Bins)pool.pagetable[pagenum]; assert(bin <= B_PAGE); size = binsize[bin]; assert((cast(size_t)p & (size - 1)) == 0); debug (PTRCHECK2) { if (bin < B_PAGE) { // Check that p is not on a free list List *list; for (list = gcx.bucket[bin]; list; list = list.next) { assert(cast(void*)list != p); } } } } } /** * add p to list of roots */ void addRoot(void *p) nothrow { if (!p) { return; } static void go(Gcx* gcx, void* p) nothrow { gcx.addRoot(p); } return runLocked!(go, otherTime, numOthers)(gcx, p); } /** * remove p from list of roots */ void removeRoot(void *p) nothrow { if (!p) { return; } static void go(Gcx* gcx, void* p) nothrow { gcx.removeRoot(p); } return runLocked!(go, otherTime, numOthers)(gcx, p); } private auto rootIterImpl(scope int delegate(ref Root) nothrow dg) nothrow { gcLock.lock(); auto res = gcx.roots.opApply(dg); gcLock.unlock(); return res; } /** * */ @property auto rootIter() @nogc { return &rootIterImpl; } /** * add range to scan for roots */ void addRange(void *p, size_t sz, const TypeInfo ti = null) nothrow @nogc { if (!p || !sz) { return; } static void go(Gcx* gcx, void* p, size_t sz, const TypeInfo ti) nothrow @nogc { gcx.addRange(p, p + sz, ti); } return runLocked!(go, otherTime, numOthers)(gcx, p, sz, ti); } /** * remove range */ void removeRange(void *p) nothrow @nogc { if (!p) { return; } static void go(Gcx* gcx, void* p) nothrow @nogc { gcx.removeRange(p); } return runLocked!(go, otherTime, numOthers)(gcx, p); } /** * run finalizers */ void runFinalizers(in void[] segment) nothrow { static void go(Gcx* gcx, in void[] segment) nothrow { gcx.runFinalizers(segment); } return runLocked!(go, otherTime, numOthers)(gcx, segment); } private auto rangeIterImpl(scope int delegate(ref Range) nothrow dg) nothrow { gcLock.lock(); auto res = gcx.ranges.opApply(dg); gcLock.unlock(); return res; } /** * */ @property auto rangeIter() @nogc { return &rangeIterImpl; } /** * Do full garbage collection. * Return number of pages free'd. */ size_t fullCollect() nothrow { debug(PRINTF) printf("GC.fullCollect()\n"); size_t result; // Since a finalizer could launch a new thread, we always need to lock // when collecting. { gcLock.lock(); result = gcx.fullcollect(); gcLock.unlock(); } version (none) { GCStats stats; getStats(stats); debug(PRINTF) printf("poolsize = %zx, usedsize = %zx, freelistsize = %zx\n", stats.poolsize, stats.usedsize, stats.freelistsize); } gcx.log_collect(); return result; } /** * do full garbage collection ignoring roots */ void fullCollectNoStack() nothrow { // Since a finalizer could launch a new thread, we always need to lock // when collecting. { gcLock.lock(); gcx.fullcollect(true); gcLock.unlock(); } } /** * minimize free space usage */ void minimize() nothrow { gcLock.lock(); gcx.minimize(); gcLock.unlock(); } /** * Retrieve statistics about garbage collection. * Useful for debugging and tuning. */ void getStats(out GCStats stats) nothrow { gcLock.lock(); getStatsNoSync(stats); gcLock.unlock(); } // // // private void getStatsNoSync(out GCStats stats) nothrow { size_t psize = 0; size_t usize = 0; size_t flsize = 0; size_t n; size_t bsize = 0; //debug(PRINTF) printf("getStats()\n"); memset(&stats, 0, GCStats.sizeof); for (n = 0; n < gcx.npools; n++) { Pool *pool = gcx.pooltable[n]; psize += pool.npages * PAGESIZE; for (size_t j = 0; j < pool.npages; j++) { Bins bin = cast(Bins)pool.pagetable[j]; if (bin == B_FREE) stats.freeblocks++; else if (bin == B_PAGE) stats.pageblocks++; else if (bin < B_PAGE) bsize += PAGESIZE; } } for (n = 0; n < B_PAGE; n++) { //debug(PRINTF) printf("bin %d\n", n); for (List *list = gcx.bucket[n]; list; list = list.next) { //debug(PRINTF) printf("\tlist %p\n", list); flsize += binsize[n]; } } usize = bsize - flsize; stats.poolsize = psize; stats.usedsize = bsize - flsize; stats.freelistsize = flsize; } } /* ============================ Gcx =============================== */ enum { PAGESIZE = 4096, POOLSIZE = (4096*256), } enum { B_16, B_32, B_64, B_128, B_256, B_512, B_1024, B_2048, B_PAGE, // start of large alloc B_PAGEPLUS, // continuation of large alloc B_FREE, // free page B_MAX } alias ubyte Bins; struct List { List *next; Pool *pool; } struct Range { void *pbot; void *ptop; alias pbot this; // only consider pbot for relative ordering (opCmp) } struct Root { void *proot; alias proot this; } immutable uint[B_MAX] binsize = [ 16,32,64,128,256,512,1024,2048,4096 ]; immutable size_t[B_MAX] notbinsize = [ ~(16-1),~(32-1),~(64-1),~(128-1),~(256-1), ~(512-1),~(1024-1),~(2048-1),~(4096-1) ]; alias PageBits = GCBits.wordtype[PAGESIZE / 16 / GCBits.BITS_PER_WORD]; static assert(PAGESIZE % (GCBits.BITS_PER_WORD * 16) == 0); private void set(ref PageBits bits, size_t i) @nogc pure nothrow { assert(i < PageBits.sizeof * 8); bts(bits.ptr, i); } /* ============================ Gcx =============================== */ struct Gcx { Treap!Root roots; Treap!Range ranges; bool log; // turn on logging debug(INVARIANT) bool initialized; bool running; uint disabled; // turn off collections if >0 import gc.pooltable; @property size_t npools() pure const nothrow { return pooltable.length; } PoolTable!Pool pooltable; List*[B_PAGE] bucket; // free list for each small size // run a collection when reaching those thresholds (number of used pages) float smallCollectThreshold, largeCollectThreshold; uint usedSmallPages, usedLargePages; // total number of mapped pages uint mappedPages; void initialize() { (cast(byte*)&this)[0 .. Gcx.sizeof] = 0; log_init(); roots.initialize(); ranges.initialize(); smallCollectThreshold = largeCollectThreshold = 0.0f; usedSmallPages = usedLargePages = 0; mappedPages = 0; //printf("gcx = %p, self = %x\n", &this, self); debug(INVARIANT) initialized = true; } void Dtor() { if (GC.config.profile) { printf("\tNumber of collections: %llu\n", cast(ulong)numCollections); printf("\tTotal GC prep time: %lld milliseconds\n", prepTime.total!("msecs")); printf("\tTotal mark time: %lld milliseconds\n", markTime.total!("msecs")); printf("\tTotal sweep time: %lld milliseconds\n", sweepTime.total!("msecs")); printf("\tTotal page recovery time: %lld milliseconds\n", recoverTime.total!("msecs")); long maxPause = maxPauseTime.total!("msecs"); printf("\tMax Pause Time: %lld milliseconds\n", maxPause); long gcTime = (recoverTime + sweepTime + markTime + prepTime).total!("msecs"); printf("\tGrand total GC time: %lld milliseconds\n", gcTime); long pauseTime = (markTime + prepTime).total!("msecs"); char[30] apitxt; apitxt[0] = 0; debug(PROFILE_API) if (GC.config.profile > 1) { static Duration toDuration(long dur) { return MonoTime(dur) - MonoTime(0); } printf("\n"); printf("\tmalloc: %llu calls, %lld ms\n", cast(ulong)numMallocs, toDuration(mallocTime).total!"msecs"); printf("\trealloc: %llu calls, %lld ms\n", cast(ulong)numReallocs, toDuration(reallocTime).total!"msecs"); printf("\tfree: %llu calls, %lld ms\n", cast(ulong)numFrees, toDuration(freeTime).total!"msecs"); printf("\textend: %llu calls, %lld ms\n", cast(ulong)numExtends, toDuration(extendTime).total!"msecs"); printf("\tother: %llu calls, %lld ms\n", cast(ulong)numOthers, toDuration(otherTime).total!"msecs"); printf("\tlock time: %lld ms\n", toDuration(lockTime).total!"msecs"); long apiTime = mallocTime + reallocTime + freeTime + extendTime + otherTime + lockTime; printf("\tGC API: %lld ms\n", toDuration(apiTime).total!"msecs"); sprintf(apitxt.ptr, " API%5ld ms", toDuration(apiTime).total!"msecs"); } printf("GC summary:%5lld MB,%5lld GC%5lld ms, Pauses%5lld ms <%5lld ms%s\n", cast(long) maxPoolMemory >> 20, cast(ulong)numCollections, gcTime, pauseTime, maxPause, apitxt.ptr); } debug(INVARIANT) initialized = false; for (size_t i = 0; i < npools; i++) { Pool *pool = pooltable[i]; mappedPages -= pool.npages; pool.Dtor(); cstdlib.free(pool); } assert(!mappedPages); pooltable.Dtor(); roots.removeAll(); ranges.removeAll(); toscan.reset(); } void Invariant() const { } debug(INVARIANT) invariant() { if (initialized) { //printf("Gcx.invariant(): this = %p\n", &this); pooltable.Invariant(); foreach (range; ranges) { assert(range.pbot); assert(range.ptop); assert(range.pbot <= range.ptop); } for (size_t i = 0; i < B_PAGE; i++) { for (auto list = cast(List*)bucket[i]; list; list = list.next) { } } } } /** * */ void addRoot(void *p) nothrow { roots.insert(Root(p)); } /** * */ void removeRoot(void *p) nothrow { roots.remove(Root(p)); } /** * */ void addRange(void *pbot, void *ptop, const TypeInfo ti) nothrow @nogc { //debug(PRINTF) printf("Thread %x ", pthread_self()); debug(PRINTF) printf("%p.Gcx::addRange(%p, %p)\n", &this, pbot, ptop); ranges.insert(Range(pbot, ptop)); } /** * */ void removeRange(void *pbot) nothrow @nogc { //debug(PRINTF) printf("Thread %x ", pthread_self()); debug(PRINTF) printf("Gcx.removeRange(%p)\n", pbot); ranges.remove(Range(pbot, pbot)); // only pbot is used, see Range.opCmp // debug(PRINTF) printf("Wrong thread\n"); // This is a fatal error, but ignore it. // The problem is that we can get a Close() call on a thread // other than the one the range was allocated on. //assert(zero); } /** * */ void runFinalizers(in void[] segment) nothrow { foreach (pool; pooltable[0 .. npools]) { if (!pool.finals.nbits) continue; if (pool.isLargeObject) { auto lpool = cast(LargeObjectPool*) pool; lpool.runFinalizers(segment); } else { auto spool = cast(SmallObjectPool*) pool; spool.runFinalizers(segment); } } } Pool* findPool(void* p) pure nothrow { return pooltable.findPool(p); } /** * Find base address of block containing pointer p. * Returns null if not a gc'd pointer */ void* findBase(void *p) nothrow { Pool *pool; pool = findPool(p); if (pool) { size_t offset = cast(size_t)(p - pool.baseAddr); size_t pn = offset / PAGESIZE; Bins bin = cast(Bins)pool.pagetable[pn]; // Adjust bit to be at start of allocated memory block if (bin <= B_PAGE) { return pool.baseAddr + (offset & notbinsize[bin]); } else if (bin == B_PAGEPLUS) { auto pageOffset = pool.bPageOffsets[pn]; offset -= pageOffset * PAGESIZE; pn -= pageOffset; return pool.baseAddr + (offset & (offset.max ^ (PAGESIZE-1))); } else { // we are in a B_FREE page assert(bin == B_FREE); return null; } } return null; } /** * Find size of pointer p. * Returns 0 if not a gc'd pointer */ size_t findSize(void *p) nothrow { Pool* pool = findPool(p); if (pool) return pool.slGetSize(p); return 0; } /** * */ BlkInfo getInfo(void* p) nothrow { Pool* pool = findPool(p); if (pool) return pool.slGetInfo(p); return BlkInfo(); } /** * Computes the bin table using CTFE. */ static byte[2049] ctfeBins() nothrow { byte[2049] ret; size_t p = 0; for (Bins b = B_16; b <= B_2048; b++) for ( ; p <= binsize[b]; p++) ret[p] = b; return ret; } static const byte[2049] binTable = ctfeBins(); /** * Allocate a new pool of at least size bytes. * Sort it into pooltable[]. * Mark all memory in the pool as B_FREE. * Return the actual number of bytes reserved or 0 on error. */ size_t reserve(size_t size) nothrow { size_t npages = (size + PAGESIZE - 1) / PAGESIZE; // Assume reserve() is for small objects. Pool* pool = newPool(npages, false); if (!pool) return 0; return pool.npages * PAGESIZE; } /** * Update the thresholds for when to collect the next time */ void updateCollectThresholds() nothrow { static float max(float a, float b) nothrow { return a >= b ? a : b; } // instantly increases, slowly decreases static float smoothDecay(float oldVal, float newVal) nothrow { // decay to 63.2% of newVal over 5 collections // http://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter enum alpha = 1.0 / (5 + 1); immutable decay = (newVal - oldVal) * alpha + oldVal; return max(newVal, decay); } immutable smTarget = usedSmallPages * GC.config.heapSizeFactor; smallCollectThreshold = smoothDecay(smallCollectThreshold, smTarget); immutable lgTarget = usedLargePages * GC.config.heapSizeFactor; largeCollectThreshold = smoothDecay(largeCollectThreshold, lgTarget); } /** * Minimizes physical memory usage by returning free pools to the OS. */ void minimize() nothrow { debug(PRINTF) printf("Minimizing.\n"); foreach (pool; pooltable.minimize()) { debug(PRINTF) printFreeInfo(pool); mappedPages -= pool.npages; pool.Dtor(); cstdlib.free(pool); } debug(PRINTF) printf("Done minimizing.\n"); } private @property bool lowMem() const nothrow { return isLowOnMem(mappedPages * PAGESIZE); } void* alloc(size_t size, ref size_t alloc_size, uint bits) nothrow { return size <= 2048 ? smallAlloc(binTable[size], alloc_size, bits) : bigAlloc(size, alloc_size, bits); } void* smallAlloc(Bins bin, ref size_t alloc_size, uint bits) nothrow { alloc_size = binsize[bin]; void* p; bool tryAlloc() nothrow { if (!bucket[bin]) { bucket[bin] = allocPage(bin); if (!bucket[bin]) return false; } p = bucket[bin]; return true; } if (!tryAlloc()) { if (!lowMem && (disabled || usedSmallPages < smallCollectThreshold)) { // disabled or threshold not reached => allocate a new pool instead of collecting if (!newPool(1, false)) { // out of memory => try to free some memory fullcollect(); if (lowMem) minimize(); } } else { fullcollect(); if (lowMem) minimize(); } // tryAlloc will succeed if a new pool was allocated above, if it fails allocate a new pool now if (!tryAlloc() && (!newPool(1, false) || !tryAlloc())) // out of luck or memory onOutOfMemoryErrorNoGC(); } assert(p !is null); // Return next item from free list bucket[bin] = (cast(List*)p).next; auto pool = (cast(List*)p).pool; if (bits) pool.setBits((p - pool.baseAddr) >> pool.shiftBy, bits); //debug(PRINTF) printf("\tmalloc => %p\n", p); debug (MEMSTOMP) memset(p, 0xF0, alloc_size); return p; } /** * Allocate a chunk of memory that is larger than a page. * Return null if out of memory. */ void* bigAlloc(size_t size, ref size_t alloc_size, uint bits, const TypeInfo ti = null) nothrow { debug(PRINTF) printf("In bigAlloc. Size: %d\n", size); LargeObjectPool* pool; size_t pn; immutable npages = (size + PAGESIZE - 1) / PAGESIZE; bool tryAlloc() nothrow { foreach (p; pooltable[0 .. npools]) { if (!p.isLargeObject || p.freepages < npages) continue; auto lpool = cast(LargeObjectPool*) p; if ((pn = lpool.allocPages(npages)) == OPFAIL) continue; pool = lpool; return true; } return false; } bool tryAllocNewPool() nothrow { pool = cast(LargeObjectPool*) newPool(npages, true); if (!pool) return false; pn = pool.allocPages(npages); assert(pn != OPFAIL); return true; } if (!tryAlloc()) { if (!lowMem && (disabled || usedLargePages < largeCollectThreshold)) { // disabled or threshold not reached => allocate a new pool instead of collecting if (!tryAllocNewPool()) { // disabled but out of memory => try to free some memory fullcollect(); minimize(); } } else { fullcollect(); minimize(); } // If alloc didn't yet succeed retry now that we collected/minimized if (!pool && !tryAlloc() && !tryAllocNewPool()) // out of luck or memory return null; } assert(pool); debug(PRINTF) printFreeInfo(&pool.base); pool.pagetable[pn] = B_PAGE; if (npages > 1) memset(&pool.pagetable[pn + 1], B_PAGEPLUS, npages - 1); pool.updateOffsets(pn); usedLargePages += npages; pool.freepages -= npages; debug(PRINTF) printFreeInfo(&pool.base); auto p = pool.baseAddr + pn * PAGESIZE; debug(PRINTF) printf("Got large alloc: %p, pt = %d, np = %d\n", p, pool.pagetable[pn], npages); debug (MEMSTOMP) memset(p, 0xF1, size); alloc_size = npages * PAGESIZE; //debug(PRINTF) printf("\tp = %p\n", p); if (bits) pool.setBits(pn, bits); return p; } /** * Allocate a new pool with at least npages in it. * Sort it into pooltable[]. * Return null if failed. */ Pool *newPool(size_t npages, bool isLargeObject) nothrow { //debug(PRINTF) printf("************Gcx::newPool(npages = %d)****************\n", npages); // Minimum of POOLSIZE size_t minPages = (GC.config.minPoolSize << 20) / PAGESIZE; if (npages < minPages) npages = minPages; else if (npages > minPages) { // Give us 150% of requested size, so there's room to extend auto n = npages + (npages >> 1); if (n < size_t.max/PAGESIZE) npages = n; } // Allocate successively larger pools up to 8 megs if (npools) { size_t n; n = GC.config.minPoolSize + GC.config.incPoolSize * npools; if (n > GC.config.maxPoolSize) n = GC.config.maxPoolSize; // cap pool size n *= (1 << 20) / PAGESIZE; // convert MB to pages if (npages < n) npages = n; } //printf("npages = %d\n", npages); auto pool = cast(Pool *)cstdlib.calloc(1, isLargeObject ? LargeObjectPool.sizeof : SmallObjectPool.sizeof); if (pool) { pool.initialize(npages, isLargeObject); if (!pool.baseAddr || !pooltable.insert(pool)) { pool.Dtor(); cstdlib.free(pool); return null; } } mappedPages += npages; if (GC.config.profile) { if (mappedPages * PAGESIZE > maxPoolMemory) maxPoolMemory = mappedPages * PAGESIZE; } return pool; } /** * Allocate a page of bin's. * Returns: * head of a single linked list of new entries */ List* allocPage(Bins bin) nothrow { //debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin); for (size_t n = 0; n < npools; n++) { Pool* pool = pooltable[n]; if(pool.isLargeObject) continue; if (List* p = (cast(SmallObjectPool*)pool).allocPage(bin)) { ++usedSmallPages; return p; } } return null; } static struct ToScanStack { nothrow: @disable this(this); void reset() { _length = 0; os_mem_unmap(_p, _cap * Range.sizeof); _p = null; _cap = 0; } void push(Range rng) { if (_length == _cap) grow(); _p[_length++] = rng; } Range pop() in { assert(!empty); } body { return _p[--_length]; } ref inout(Range) opIndex(size_t idx) inout in { assert(idx < _length); } body { return _p[idx]; } @property size_t length() const { return _length; } @property bool empty() const { return !length; } private: void grow() { enum initSize = 64 * 1024; // Windows VirtualAlloc granularity immutable ncap = _cap ? 2 * _cap : initSize / Range.sizeof; auto p = cast(Range*)os_mem_map(ncap * Range.sizeof); if (p is null) onOutOfMemoryErrorNoGC(); if (_p !is null) { p[0 .. _length] = _p[0 .. _length]; os_mem_unmap(_p, _cap * Range.sizeof); } _p = p; _cap = ncap; } size_t _length; Range* _p; size_t _cap; } ToScanStack toscan; /** * Search a range of memory values and mark any pointers into the GC pool. */ void mark(void *pbot, void *ptop) nothrow { void **p1 = cast(void **)pbot; void **p2 = cast(void **)ptop; // limit the amount of ranges added to the toscan stack enum FANOUT_LIMIT = 32; size_t stackPos; Range[FANOUT_LIMIT] stack = void; Lagain: size_t pcache = 0; //printf("marking range: [%p..%p] (%#zx)\n", p1, p2, cast(size_t)p2 - cast(size_t)p1); for (; p1 < p2 && stackPos != stack.length; p1++) { auto p = cast(byte *)(*p1); //if (log) debug(PRINTF) printf("\tmark %p\n", p); if (p >= pooltable.minAddr && p < pooltable.maxAddr) { if ((cast(size_t)p & ~cast(size_t)(PAGESIZE-1)) == pcache) continue; auto pool = findPool(p); if (pool) { size_t offset = cast(size_t)(p - pool.baseAddr); size_t biti = void; size_t pn = offset / PAGESIZE; Bins bin = cast(Bins)pool.pagetable[pn]; void* base = void; //debug(PRINTF) printf("\t\tfound pool %p, base=%p, pn = %zd, bin = %d, biti = x%x\n", pool, pool.baseAddr, pn, bin, biti); // Adjust bit to be at start of allocated memory block if (bin < B_PAGE) { // We don't care abou setting pointsToBase correctly // because it's ignored for small object pools anyhow. auto offsetBase = offset & notbinsize[bin]; biti = offsetBase >> pool.shiftBy; base = pool.baseAddr + offsetBase; //debug(PRINTF) printf("\t\tbiti = x%x\n", biti); if (!pool.mark.set(biti) && !pool.noscan.test(biti)) stack[stackPos++] = Range(base, base + binsize[bin]); } else if (bin == B_PAGE) { auto offsetBase = offset & notbinsize[bin]; base = pool.baseAddr + offsetBase; biti = offsetBase >> pool.shiftBy; //debug(PRINTF) printf("\t\tbiti = x%x\n", biti); pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1); // For the NO_INTERIOR attribute. This tracks whether // the pointer is an interior pointer or points to the // base address of a block. bool pointsToBase = (base == sentinel_sub(p)); if(!pointsToBase && pool.nointerior.nbits && pool.nointerior.test(biti)) continue; if (!pool.mark.set(biti) && !pool.noscan.test(biti)) stack[stackPos++] = Range(base, base + pool.bPageOffsets[pn] * PAGESIZE); } else if (bin == B_PAGEPLUS) { pn -= pool.bPageOffsets[pn]; base = pool.baseAddr + (pn * PAGESIZE); biti = pn * (PAGESIZE >> pool.shiftBy); pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1); if(pool.nointerior.nbits && pool.nointerior.test(biti)) continue; if (!pool.mark.set(biti) && !pool.noscan.test(biti)) stack[stackPos++] = Range(base, base + pool.bPageOffsets[pn] * PAGESIZE); } else { // Don't mark bits in B_FREE pages assert(bin == B_FREE); continue; } } } } Range next=void; if (p1 < p2) { // local stack is full, push it to the global stack assert(stackPos == stack.length); toscan.push(Range(p1, p2)); // reverse order for depth-first-order traversal foreach_reverse (ref rng; stack[0 .. $ - 1]) toscan.push(rng); stackPos = 0; next = stack[$-1]; } else if (stackPos) { // pop range from local stack and recurse next = stack[--stackPos]; } else if (!toscan.empty) { // pop range from global stack and recurse next = toscan.pop(); } else { // nothing more to do return; } p1 = cast(void**)next.pbot; p2 = cast(void**)next.ptop; // printf(" pop [%p..%p] (%#zx)\n", p1, p2, cast(size_t)p2 - cast(size_t)p1); goto Lagain; } // collection step 1: prepare freebits and mark bits void prepare() nothrow { size_t n; Pool* pool; for (n = 0; n < npools; n++) { pool = pooltable[n]; pool.mark.zero(); if(!pool.isLargeObject) pool.freebits.zero(); } debug(COLLECT_PRINTF) printf("Set bits\n"); // Mark each free entry, so it doesn't get scanned for (n = 0; n < B_PAGE; n++) { for (List *list = bucket[n]; list; list = list.next) { pool = list.pool; assert(pool); pool.freebits.set(cast(size_t)(cast(byte*)list - pool.baseAddr) / 16); } } debug(COLLECT_PRINTF) printf("Marked free entries.\n"); for (n = 0; n < npools; n++) { pool = pooltable[n]; if(!pool.isLargeObject) { pool.mark.copy(&pool.freebits); } } } // collection step 2: mark roots and heap void markAll(bool nostack) nothrow { if (!nostack) { debug(COLLECT_PRINTF) printf("\tscan stacks.\n"); // Scan stacks and registers for each paused thread thread_scanAll(&mark); } // Scan roots[] debug(COLLECT_PRINTF) printf("\tscan roots[]\n"); foreach (root; roots) { mark(cast(void*)&root.proot, cast(void*)(&root.proot + 1)); } // Scan ranges[] debug(COLLECT_PRINTF) printf("\tscan ranges[]\n"); //log++; foreach (range; ranges) { debug(COLLECT_PRINTF) printf("\t\t%p .. %p\n", range.pbot, range.ptop); mark(range.pbot, range.ptop); } //log--; } // collection step 3: free all unreferenced objects size_t sweep() nothrow { // Free up everything not marked debug(COLLECT_PRINTF) printf("\tfree'ing\n"); size_t freedLargePages; size_t freed; for (size_t n = 0; n < npools; n++) { size_t pn; Pool* pool = pooltable[n]; if(pool.isLargeObject) { for(pn = 0; pn < pool.npages; pn++) { Bins bin = cast(Bins)pool.pagetable[pn]; if(bin > B_PAGE) continue; size_t biti = pn; if (!pool.mark.test(biti)) { byte *p = pool.baseAddr + pn * PAGESIZE; void* q = sentinel_add(p); sentinel_Invariant(q); if (pool.finals.nbits && pool.finals.clear(biti)) { size_t size = pool.bPageOffsets[pn] * PAGESIZE - SENTINEL_EXTRA; uint attr = pool.getBits(biti); rt_finalizeFromGC(q, size, attr); } pool.clrBits(biti, ~BlkAttr.NONE ^ BlkAttr.FINALIZE); debug(COLLECT_PRINTF) printf("\tcollecting big %p\n", p); log_free(q); pool.pagetable[pn] = B_FREE; if(pn < pool.searchStart) pool.searchStart = pn; freedLargePages++; pool.freepages++; debug (MEMSTOMP) memset(p, 0xF3, PAGESIZE); while (pn + 1 < pool.npages && pool.pagetable[pn + 1] == B_PAGEPLUS) { pn++; pool.pagetable[pn] = B_FREE; // Don't need to update searchStart here because // pn is guaranteed to be greater than last time // we updated it. pool.freepages++; freedLargePages++; debug (MEMSTOMP) { p += PAGESIZE; memset(p, 0xF3, PAGESIZE); } } pool.largestFree = pool.freepages; // invalidate } } } else { for (pn = 0; pn < pool.npages; pn++) { Bins bin = cast(Bins)pool.pagetable[pn]; if (bin < B_PAGE) { immutable size = binsize[bin]; byte *p = pool.baseAddr + pn * PAGESIZE; byte *ptop = p + PAGESIZE; immutable base = pn * (PAGESIZE/16); immutable bitstride = size / 16; bool freeBits; PageBits toFree; for (size_t i; p < ptop; p += size, i += bitstride) { immutable biti = base + i; if (!pool.mark.test(biti)) { void* q = sentinel_add(p); sentinel_Invariant(q); if (pool.finals.nbits && pool.finals.test(biti)) rt_finalizeFromGC(q, size - SENTINEL_EXTRA, pool.getBits(biti)); freeBits = true; toFree.set(i); debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p); log_free(sentinel_add(p)); debug (MEMSTOMP) memset(p, 0xF3, size); freed += size; } } if (freeBits) pool.freePageBits(pn, toFree); } } } } assert(freedLargePages <= usedLargePages); usedLargePages -= freedLargePages; debug(COLLECT_PRINTF) printf("\tfree'd %u bytes, %u pages from %u pools\n", freed, freedLargePages, npools); return freedLargePages; } // collection step 4: recover pages with no live objects, rebuild free lists size_t recover() nothrow { // init tail list List**[B_PAGE] tail = void; foreach (i, ref next; tail) next = &bucket[i]; // Free complete pages, rebuild free list debug(COLLECT_PRINTF) printf("\tfree complete pages\n"); size_t freedSmallPages; for (size_t n = 0; n < npools; n++) { size_t pn; Pool* pool = pooltable[n]; if(pool.isLargeObject) continue; for (pn = 0; pn < pool.npages; pn++) { Bins bin = cast(Bins)pool.pagetable[pn]; size_t biti; size_t u; if (bin < B_PAGE) { size_t size = binsize[bin]; size_t bitstride = size / 16; size_t bitbase = pn * (PAGESIZE / 16); size_t bittop = bitbase + (PAGESIZE / 16); byte* p; biti = bitbase; for (biti = bitbase; biti < bittop; biti += bitstride) { if (!pool.freebits.test(biti)) goto Lnotfree; } pool.pagetable[pn] = B_FREE; if(pn < pool.searchStart) pool.searchStart = pn; pool.freepages++; freedSmallPages++; continue; Lnotfree: p = pool.baseAddr + pn * PAGESIZE; for (u = 0; u < PAGESIZE; u += size) { biti = bitbase + u / 16; if (!pool.freebits.test(biti)) continue; auto elem = cast(List *)(p + u); elem.pool = pool; *tail[bin] = elem; tail[bin] = &elem.next; } } } } // terminate tail list foreach (ref next; tail) *next = null; assert(freedSmallPages <= usedSmallPages); usedSmallPages -= freedSmallPages; debug(COLLECT_PRINTF) printf("\trecovered pages = %d\n", freedSmallPages); return freedSmallPages; } /** * Return number of full pages free'd. */ size_t fullcollect(bool nostack = false) nothrow { MonoTime start, stop, begin; if (GC.config.profile) { begin = start = currTime; } debug(COLLECT_PRINTF) printf("Gcx.fullcollect()\n"); //printf("\tpool address range = %p .. %p\n", minAddr, maxAddr); if (running) onInvalidMemoryOperationError(); running = true; thread_suspendAll(); prepare(); if (GC.config.profile) { stop = currTime; prepTime += (stop - start); start = stop; } markAll(nostack); thread_processGCMarks(&isMarked); thread_resumeAll(); if (GC.config.profile) { stop = currTime; markTime += (stop - start); Duration pause = stop - begin; if (pause > maxPauseTime) maxPauseTime = pause; start = stop; } immutable freedLargePages = sweep(); if (GC.config.profile) { stop = currTime; sweepTime += (stop - start); start = stop; } immutable freedSmallPages = recover(); if (GC.config.profile) { stop = currTime; recoverTime += (stop - start); ++numCollections; } running = false; // only clear on success updateCollectThresholds(); return freedLargePages + freedSmallPages; } /** * Returns true if the addr lies within a marked block. * * Warning! This should only be called while the world is stopped inside * the fullcollect function. */ int isMarked(void *addr) nothrow { // first, we find the Pool this block is in, then check to see if the // mark bit is clear. auto pool = findPool(addr); if(pool) { auto offset = cast(size_t)(addr - pool.baseAddr); auto pn = offset / PAGESIZE; auto bins = cast(Bins)pool.pagetable[pn]; size_t biti = void; if(bins <= B_PAGE) { biti = (offset & notbinsize[bins]) >> pool.shiftBy; } else if(bins == B_PAGEPLUS) { pn -= pool.bPageOffsets[pn]; biti = pn * (PAGESIZE >> pool.shiftBy); } else // bins == B_FREE { assert(bins == B_FREE); return IsMarked.no; } return pool.mark.test(biti) ? IsMarked.yes : IsMarked.no; } return IsMarked.unknown; } /***** Leak Detector ******/ debug (LOGGING) { LogArray current; LogArray prev; void log_init() { //debug(PRINTF) printf("+log_init()\n"); current.reserve(1000); prev.reserve(1000); //debug(PRINTF) printf("-log_init()\n"); } void log_malloc(void *p, size_t size) nothrow { //debug(PRINTF) printf("+log_malloc(p = %p, size = %zd)\n", p, size); Log log; log.p = p; log.size = size; log.line = GC.line; log.file = GC.file; log.parent = null; GC.line = 0; GC.file = null; current.push(log); //debug(PRINTF) printf("-log_malloc()\n"); } void log_free(void *p) nothrow { //debug(PRINTF) printf("+log_free(%p)\n", p); auto i = current.find(p); if (i == OPFAIL) { debug(PRINTF) printf("free'ing unallocated memory %p\n", p); } else current.remove(i); //debug(PRINTF) printf("-log_free()\n"); } void log_collect() nothrow { //debug(PRINTF) printf("+log_collect()\n"); // Print everything in current that is not in prev debug(PRINTF) printf("New pointers this cycle: --------------------------------\n"); size_t used = 0; for (size_t i = 0; i < current.dim; i++) { auto j = prev.find(current.data[i].p); if (j == OPFAIL) current.data[i].print(); else used++; } debug(PRINTF) printf("All roots this cycle: --------------------------------\n"); for (size_t i = 0; i < current.dim; i++) { void* p = current.data[i].p; if (!findPool(current.data[i].parent)) { auto j = prev.find(current.data[i].p); debug(PRINTF) printf(j == OPFAIL ? "N" : " "); current.data[i].print(); } } debug(PRINTF) printf("Used = %d-------------------------------------------------\n", used); prev.copy(&current); debug(PRINTF) printf("-log_collect()\n"); } void log_parent(void *p, void *parent) nothrow { //debug(PRINTF) printf("+log_parent()\n"); auto i = current.find(p); if (i == OPFAIL) { debug(PRINTF) printf("parent'ing unallocated memory %p, parent = %p\n", p, parent); Pool *pool; pool = findPool(p); assert(pool); size_t offset = cast(size_t)(p - pool.baseAddr); size_t biti; size_t pn = offset / PAGESIZE; Bins bin = cast(Bins)pool.pagetable[pn]; biti = (offset & notbinsize[bin]); debug(PRINTF) printf("\tbin = %d, offset = x%x, biti = x%x\n", bin, offset, biti); } else { current.data[i].parent = parent; } //debug(PRINTF) printf("-log_parent()\n"); } } else { void log_init() nothrow { } void log_malloc(void *p, size_t size) nothrow { } void log_free(void *p) nothrow { } void log_collect() nothrow { } void log_parent(void *p, void *parent) nothrow { } } } /* ============================ Pool =============================== */ struct Pool { byte* baseAddr; byte* topAddr; GCBits mark; // entries already scanned, or should not be scanned GCBits freebits; // entries that are on the free list GCBits finals; // entries that need finalizer run on them GCBits structFinals;// struct entries that need a finalzier run on them GCBits noscan; // entries that should not be scanned GCBits appendable; // entries that are appendable GCBits nointerior; // interior pointers should be ignored. // Only implemented for large object pools. size_t npages; size_t freepages; // The number of pages not in use. ubyte* pagetable; bool isLargeObject; uint shiftBy; // shift count for the divisor used for determining bit indices. // This tracks how far back we have to go to find the nearest B_PAGE at // a smaller address than a B_PAGEPLUS. To save space, we use a uint. // This limits individual allocations to 16 terabytes, assuming a 4k // pagesize. uint* bPageOffsets; // This variable tracks a conservative estimate of where the first free // page in this pool is, so that if a lot of pages towards the beginning // are occupied, we can bypass them in O(1). size_t searchStart; size_t largestFree; // upper limit for largest free chunk in large object pool void initialize(size_t npages, bool isLargeObject) nothrow { this.isLargeObject = isLargeObject; size_t poolsize; shiftBy = isLargeObject ? 12 : 4; //debug(PRINTF) printf("Pool::Pool(%u)\n", npages); poolsize = npages * PAGESIZE; assert(poolsize >= POOLSIZE); baseAddr = cast(byte *)os_mem_map(poolsize); // Some of the code depends on page alignment of memory pools assert((cast(size_t)baseAddr & (PAGESIZE - 1)) == 0); if (!baseAddr) { //debug(PRINTF) printf("GC fail: poolsize = x%zx, errno = %d\n", poolsize, errno); //debug(PRINTF) printf("message = '%s'\n", sys_errlist[errno]); npages = 0; poolsize = 0; } //assert(baseAddr); topAddr = baseAddr + poolsize; auto nbits = cast(size_t)poolsize >> shiftBy; mark.alloc(nbits); // pagetable already keeps track of what's free for the large object // pool. if(!isLargeObject) { freebits.alloc(nbits); } noscan.alloc(nbits); appendable.alloc(nbits); pagetable = cast(ubyte*)cstdlib.malloc(npages); if (!pagetable) onOutOfMemoryErrorNoGC(); if(isLargeObject) { bPageOffsets = cast(uint*)cstdlib.malloc(npages * uint.sizeof); if (!bPageOffsets) onOutOfMemoryErrorNoGC(); } memset(pagetable, B_FREE, npages); this.npages = npages; this.freepages = npages; this.searchStart = 0; this.largestFree = npages; } void Dtor() nothrow { if (baseAddr) { int result; if (npages) { result = os_mem_unmap(baseAddr, npages * PAGESIZE); assert(result == 0); npages = 0; } baseAddr = null; topAddr = null; } if (pagetable) { cstdlib.free(pagetable); pagetable = null; } if(bPageOffsets) cstdlib.free(bPageOffsets); mark.Dtor(); if(isLargeObject) { nointerior.Dtor(); } else { freebits.Dtor(); } finals.Dtor(); structFinals.Dtor(); noscan.Dtor(); appendable.Dtor(); } /** * */ uint getBits(size_t biti) nothrow { uint bits; if (finals.nbits && finals.test(biti)) bits |= BlkAttr.FINALIZE; if (structFinals.nbits && structFinals.test(biti)) bits |= BlkAttr.STRUCTFINAL; if (noscan.test(biti)) bits |= BlkAttr.NO_SCAN; if (nointerior.nbits && nointerior.test(biti)) bits |= BlkAttr.NO_INTERIOR; if (appendable.test(biti)) bits |= BlkAttr.APPENDABLE; return bits; } /** * */ void clrBits(size_t biti, uint mask) nothrow { immutable dataIndex = biti >> GCBits.BITS_SHIFT; immutable bitOffset = biti & GCBits.BITS_MASK; immutable keep = ~(GCBits.BITS_1 << bitOffset); if (mask & BlkAttr.FINALIZE && finals.nbits) finals.data[dataIndex] &= keep; if (structFinals.nbits && (mask & BlkAttr.STRUCTFINAL)) structFinals.data[dataIndex] &= keep; if (mask & BlkAttr.NO_SCAN) noscan.data[dataIndex] &= keep; if (mask & BlkAttr.APPENDABLE) appendable.data[dataIndex] &= keep; if (nointerior.nbits && (mask & BlkAttr.NO_INTERIOR)) nointerior.data[dataIndex] &= keep; } /** * */ void setBits(size_t biti, uint mask) nothrow { // Calculate the mask and bit offset once and then use it to // set all of the bits we need to set. immutable dataIndex = biti >> GCBits.BITS_SHIFT; immutable bitOffset = biti & GCBits.BITS_MASK; immutable orWith = GCBits.BITS_1 << bitOffset; if (mask & BlkAttr.STRUCTFINAL) { if (!structFinals.nbits) structFinals.alloc(mark.nbits); structFinals.data[dataIndex] |= orWith; } if (mask & BlkAttr.FINALIZE) { if (!finals.nbits) finals.alloc(mark.nbits); finals.data[dataIndex] |= orWith; } if (mask & BlkAttr.NO_SCAN) { noscan.data[dataIndex] |= orWith; } // if (mask & BlkAttr.NO_MOVE) // { // if (!nomove.nbits) // nomove.alloc(mark.nbits); // nomove.data[dataIndex] |= orWith; // } if (mask & BlkAttr.APPENDABLE) { appendable.data[dataIndex] |= orWith; } if (isLargeObject && (mask & BlkAttr.NO_INTERIOR)) { if(!nointerior.nbits) nointerior.alloc(mark.nbits); nointerior.data[dataIndex] |= orWith; } } void freePageBits(size_t pagenum, in ref PageBits toFree) nothrow { assert(!isLargeObject); assert(!nointerior.nbits); // only for large objects import core.internal.traits : staticIota; immutable beg = pagenum * (PAGESIZE / 16 / GCBits.BITS_PER_WORD); foreach (i; staticIota!(0, PageBits.length)) { immutable w = toFree[i]; if (!w) continue; immutable wi = beg + i; freebits.data[wi] |= w; noscan.data[wi] &= ~w; appendable.data[wi] &= ~w; } if (finals.nbits) { foreach (i; staticIota!(0, PageBits.length)) if (toFree[i]) finals.data[beg + i] &= ~toFree[i]; } if (structFinals.nbits) { foreach (i; staticIota!(0, PageBits.length)) if (toFree[i]) structFinals.data[beg + i] &= ~toFree[i]; } } /** * Given a pointer p in the p, return the pagenum. */ size_t pagenumOf(void *p) const nothrow in { assert(p >= baseAddr); assert(p < topAddr); } body { return cast(size_t)(p - baseAddr) / PAGESIZE; } @property bool isFree() const pure nothrow { return npages == freepages; } size_t slGetSize(void* p) nothrow { if (isLargeObject) return (cast(LargeObjectPool*)&this).getSize(p); else return (cast(SmallObjectPool*)&this).getSize(p); } BlkInfo slGetInfo(void* p) nothrow { if (isLargeObject) return (cast(LargeObjectPool*)&this).getInfo(p); else return (cast(SmallObjectPool*)&this).getInfo(p); } void Invariant() const {} debug(INVARIANT) invariant() { //mark.Invariant(); //scan.Invariant(); //freebits.Invariant(); //finals.Invariant(); //structFinals.Invariant(); //noscan.Invariant(); //appendable.Invariant(); //nointerior.Invariant(); if (baseAddr) { //if (baseAddr + npages * PAGESIZE != topAddr) //printf("baseAddr = %p, npages = %d, topAddr = %p\n", baseAddr, npages, topAddr); assert(baseAddr + npages * PAGESIZE == topAddr); } if(pagetable !is null) { for (size_t i = 0; i < npages; i++) { Bins bin = cast(Bins)pagetable[i]; assert(bin < B_MAX); } } } } struct LargeObjectPool { Pool base; alias base this; void updateOffsets(size_t fromWhere) nothrow { assert(pagetable[fromWhere] == B_PAGE); size_t pn = fromWhere + 1; for(uint offset = 1; pn < npages; pn++, offset++) { if(pagetable[pn] != B_PAGEPLUS) break; bPageOffsets[pn] = offset; } // Store the size of the block in bPageOffsets[fromWhere]. bPageOffsets[fromWhere] = cast(uint) (pn - fromWhere); } /** * Allocate n pages from Pool. * Returns OPFAIL on failure. */ size_t allocPages(size_t n) nothrow { if(largestFree < n || searchStart + n > npages) return OPFAIL; //debug(PRINTF) printf("Pool::allocPages(n = %d)\n", n); size_t largest = 0; if (pagetable[searchStart] == B_PAGEPLUS) { searchStart -= bPageOffsets[searchStart]; // jump to B_PAGE searchStart += bPageOffsets[searchStart]; } while (searchStart < npages && pagetable[searchStart] == B_PAGE) searchStart += bPageOffsets[searchStart]; for (size_t i = searchStart; i < npages; ) { assert(pagetable[i] == B_FREE); size_t p = 1; while (p < n && i + p < npages && pagetable[i + p] == B_FREE) p++; if (p == n) return i; if (p > largest) largest = p; i += p; while(i < npages && pagetable[i] == B_PAGE) { // we have the size information, so we skip a whole bunch of pages. i += bPageOffsets[i]; } } // not enough free pages found, remember largest free chunk largestFree = largest; return OPFAIL; } /** * Free npages pages starting with pagenum. */ void freePages(size_t pagenum, size_t npages) nothrow { //memset(&pagetable[pagenum], B_FREE, npages); if(pagenum < searchStart) searchStart = pagenum; for(size_t i = pagenum; i < npages + pagenum; i++) { if(pagetable[i] < B_FREE) { freepages++; } pagetable[i] = B_FREE; } largestFree = freepages; // invalidate } /** * Get size of pointer p in pool. */ size_t getSize(void *p) const nothrow in { assert(p >= baseAddr); assert(p < topAddr); } body { size_t pagenum = pagenumOf(p); Bins bin = cast(Bins)pagetable[pagenum]; assert(bin == B_PAGE); return bPageOffsets[pagenum] * PAGESIZE; } /** * */ BlkInfo getInfo(void* p) nothrow { BlkInfo info; size_t offset = cast(size_t)(p - baseAddr); size_t pn = offset / PAGESIZE; Bins bin = cast(Bins)pagetable[pn]; if (bin == B_PAGEPLUS) pn -= bPageOffsets[pn]; else if (bin != B_PAGE) return info; // no info for free pages info.base = baseAddr + pn * PAGESIZE; info.size = bPageOffsets[pn] * PAGESIZE; info.attr = getBits(pn); return info; } void runFinalizers(in void[] segment) nothrow { foreach (pn; 0 .. npages) { Bins bin = cast(Bins)pagetable[pn]; if (bin > B_PAGE) continue; size_t biti = pn; if (!finals.test(biti)) continue; auto p = sentinel_add(baseAddr + pn * PAGESIZE); size_t size = bPageOffsets[pn] * PAGESIZE - SENTINEL_EXTRA; uint attr = getBits(biti); if(!rt_hasFinalizerInSegment(p, size, attr, segment)) continue; rt_finalizeFromGC(p, size, attr); clrBits(biti, ~BlkAttr.NONE); if (pn < searchStart) searchStart = pn; debug(COLLECT_PRINTF) printf("\tcollecting big %p\n", p); //log_free(sentinel_add(p)); size_t n = 1; for (; pn + n < npages; ++n) if (pagetable[pn + n] != B_PAGEPLUS) break; debug (MEMSTOMP) memset(baseAddr + pn * PAGESIZE, 0xF3, n * PAGESIZE); freePages(pn, n); } } } struct SmallObjectPool { Pool base; alias base this; /** * Get size of pointer p in pool. */ size_t getSize(void *p) const nothrow in { assert(p >= baseAddr); assert(p < topAddr); } body { size_t pagenum = pagenumOf(p); Bins bin = cast(Bins)pagetable[pagenum]; assert(bin < B_PAGE); return binsize[bin]; } BlkInfo getInfo(void* p) nothrow { BlkInfo info; size_t offset = cast(size_t)(p - baseAddr); size_t pn = offset / PAGESIZE; Bins bin = cast(Bins)pagetable[pn]; if (bin >= B_PAGE) return info; info.base = cast(void*)((cast(size_t)p) & notbinsize[bin]); info.size = binsize[bin]; offset = info.base - baseAddr; info.attr = getBits(cast(size_t)(offset >> shiftBy)); return info; } void runFinalizers(in void[] segment) nothrow { foreach (pn; 0 .. npages) { Bins bin = cast(Bins)pagetable[pn]; if (bin >= B_PAGE) continue; immutable size = binsize[bin]; auto p = baseAddr + pn * PAGESIZE; const ptop = p + PAGESIZE; immutable base = pn * (PAGESIZE/16); immutable bitstride = size / 16; bool freeBits; PageBits toFree; for (size_t i; p < ptop; p += size, i += bitstride) { immutable biti = base + i; if (!finals.test(biti)) continue; auto q = sentinel_add(p); uint attr = getBits(biti); if(!rt_hasFinalizerInSegment(q, size, attr, segment)) continue; rt_finalizeFromGC(q, size, attr); freeBits = true; toFree.set(i); debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p); //log_free(sentinel_add(p)); debug (MEMSTOMP) memset(p, 0xF3, size); } if (freeBits) freePageBits(pn, toFree); } } /** * Allocate a page of bin's. * Returns: * head of a single linked list of new entries */ List* allocPage(Bins bin) nothrow { size_t pn; for (pn = searchStart; pn < npages; pn++) if (pagetable[pn] == B_FREE) goto L1; return null; L1: searchStart = pn + 1; pagetable[pn] = cast(ubyte)bin; freepages--; // Convert page to free list size_t size = binsize[bin]; void* p = baseAddr + pn * PAGESIZE; void* ptop = p + PAGESIZE - size; auto first = cast(List*) p; for (; p < ptop; p += size) { (cast(List *)p).next = cast(List *)(p + size); (cast(List *)p).pool = &base; } (cast(List *)p).next = null; (cast(List *)p).pool = &base; return first; } } unittest // bugzilla 14467 { int[] arr = new int[10]; assert(arr.capacity); arr = arr[$..$]; assert(arr.capacity); } /* ============================ SENTINEL =============================== */ debug (SENTINEL) { const size_t SENTINEL_PRE = cast(size_t) 0xF4F4F4F4F4F4F4F4UL; // 32 or 64 bits const ubyte SENTINEL_POST = 0xF5; // 8 bits const uint SENTINEL_EXTRA = 2 * size_t.sizeof + 1; inout(size_t*) sentinel_size(inout void *p) nothrow { return &(cast(inout size_t *)p)[-2]; } inout(size_t*) sentinel_pre(inout void *p) nothrow { return &(cast(inout size_t *)p)[-1]; } inout(ubyte*) sentinel_post(inout void *p) nothrow { return &(cast(inout ubyte *)p)[*sentinel_size(p)]; } void sentinel_init(void *p, size_t size) nothrow { *sentinel_size(p) = size; *sentinel_pre(p) = SENTINEL_PRE; *sentinel_post(p) = SENTINEL_POST; } void sentinel_Invariant(const void *p) nothrow { debug { assert(*sentinel_pre(p) == SENTINEL_PRE); assert(*sentinel_post(p) == SENTINEL_POST); } else if(*sentinel_pre(p) != SENTINEL_PRE || *sentinel_post(p) != SENTINEL_POST) onInvalidMemoryOperationError(); // also trigger in release build } void *sentinel_add(void *p) nothrow { return p + 2 * size_t.sizeof; } void *sentinel_sub(void *p) nothrow { return p - 2 * size_t.sizeof; } } else { const uint SENTINEL_EXTRA = 0; void sentinel_init(void *p, size_t size) nothrow { } void sentinel_Invariant(const void *p) nothrow { } void *sentinel_add(void *p) nothrow { return p; } void *sentinel_sub(void *p) nothrow { return p; } } debug (MEMSTOMP) unittest { import core.memory; auto p = cast(uint*)GC.malloc(uint.sizeof*3); assert(*p == 0xF0F0F0F0); p[2] = 0; // First two will be used for free list GC.free(p); assert(p[2] == 0xF2F2F2F2); } debug (SENTINEL) unittest { import core.memory; auto p = cast(ubyte*)GC.malloc(1); assert(p[-1] == 0xF4); assert(p[ 1] == 0xF5); /* p[1] = 0; bool thrown; try GC.free(p); catch (Error e) thrown = true; p[1] = 0xF5; assert(thrown); */ }
D
#as: -march=rv64ima_zqinx #source: zqinx.s #objdump: -dr .*:[ ]+file format .* Disassembly of section .text: 0+000 <target>: [ ]+[0-9a-f]+:[ ]+06c5f553[ ]+fadd.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+0ec5f553[ ]+fsub.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+16c5f553[ ]+fmul.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+1ec5f553[ ]+fdiv.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+5e057553[ ]+fsqrt.q[ ]+a0,a0 [ ]+[0-9a-f]+:[ ]+2ec58553[ ]+fmin.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+2ec59553[ ]+fmax.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+6ec5f543[ ]+fmadd.q[ ]+a0,a1,a2,a3 [ ]+[0-9a-f]+:[ ]+6ec5f54f[ ]+fnmadd.q[ ]+a0,a1,a2,a3 [ ]+[0-9a-f]+:[ ]+6ec5f547[ ]+fmsub.q[ ]+a0,a1,a2,a3 [ ]+[0-9a-f]+:[ ]+6ec5f54b[ ]+fnmsub.q[ ]+a0,a1,a2,a3 [ ]+[0-9a-f]+:[ ]+c605f553[ ]+fcvt.w.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+c615f553[ ]+fcvt.wu.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+c625f553[ ]+fcvt.l.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+c635f553[ ]+fcvt.lu.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+4035f553[ ]+fcvt.s.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+4235f553[ ]+fcvt.d.q[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+46058553[ ]+fcvt.q.s[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+46158553[ ]+fcvt.q.d[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+d6058553[ ]+fcvt.q.w[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+d6158553[ ]+fcvt.q.wu[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+d625f553[ ]+fcvt.q.l[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+d635f553[ ]+fcvt.q.lu[ ]+a0,a1 [ ]+[0-9a-f]+:[ ]+26c58553[ ]+fsgnj.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+26c59553[ ]+fsgnjn.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+26c5a553[ ]+fsgnjx.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+a6c5a553[ ]+feq.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+a6c59553[ ]+flt.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+a6c58553[ ]+fle.q[ ]+a0,a1,a2 [ ]+[0-9a-f]+:[ ]+a6b61553[ ]+flt.q[ ]+a0,a2,a1 [ ]+[0-9a-f]+:[ ]+a6b60553[ ]+fle.q[ ]+a0,a2,a1 [ ]+[0-9a-f]+:[ ]+26a51553[ ]+fneg.q[ ]+a0,a0 [ ]+[0-9a-f]+:[ ]+26a52553[ ]+fabs.q[ ]+a0,a0 [ ]+[0-9a-f]+:[ ]+e6059553[ ]+fclass.q[ ]+a0,a1
D
module c.openssl.ec; import core.stdc.stdio; import core.stdc.config; public import c.openssl.asn1; // public import c.openssl.bn; public import c.openssl.evp; extern (C): enum OPENSSL_ECC_MAX_FIELD_BITS = 661; enum OPENSSL_EC_NAMED_CURVE = 0x001; /+ // Commented out to reduce dependency creep. Put it back if the ASN1 header gets converted. auto d2i_ECPKParameters_bio(BIO* bp, void** x) { return ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x); } auto i2d_ECPKParameters_bio(BIO* bp, void** x) { return ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x); } auto d2i_ECPKParameters_fp(FILE* fp, void** x) { return (EC_GROUP *)ASN1_d2i_fp(NULL, (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)); } auto i2d_ECPKParameters_fp(FILE* fp, void** x) { return ASN1_i2d_fp(i2d_ECPKParameters,(fp), (unsigned char *)(x)); } +/ /* some values for the encoding_flag */ enum EC_PKEY_NO_PARAMETERS = 0x001; enum EC_PKEY_NO_PUBKEY = 0x002; /* some values for the flags field */ enum EC_FLAG_NON_FIPS_ALLOW = 0x1; enum EC_FLAG_FIPS_CHECKED = 0x2; extern(D) int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX* ctx, int nid) { return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, null); } enum EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID = (EVP_PKEY_ALG_CTRL + 1); struct ec_key_st; struct ec_method_st; struct ec_point_st; struct ecpk_parameters_st; struct ec_group_st; alias ec_method_st EC_METHOD; alias ec_group_st EC_GROUP; alias ec_point_st EC_POINT; alias ecpk_parameters_st ECPKPARAMETERS; alias ec_key_st EC_KEY; enum point_conversion_form_t { POINT_CONVERSION_COMPRESSED = 2, POINT_CONVERSION_UNCOMPRESSED = 4, POINT_CONVERSION_HYBRID = 6 } struct EC_builtin_curve { int nid; const(char)* comment; } const(EC_METHOD)* EC_GFp_simple_method (); const(EC_METHOD)* EC_GFp_mont_method (); const(EC_METHOD)* EC_GFp_nist_method (); const(EC_METHOD)* EC_GF2m_simple_method (); EC_GROUP* EC_GROUP_new (const(EC_METHOD)* meth); void EC_GROUP_free (EC_GROUP* group); void EC_GROUP_clear_free (EC_GROUP* group); int EC_GROUP_copy (EC_GROUP* dst, const(EC_GROUP)* src); EC_GROUP* EC_GROUP_dup (const(EC_GROUP)* src); const(EC_METHOD)* EC_GROUP_method_of (const(EC_GROUP)* group); int EC_METHOD_get_field_type (const(EC_METHOD)* meth); int EC_GROUP_set_generator (EC_GROUP* group, const(EC_POINT)* generator, const(BIGNUM)* order, const(BIGNUM)* cofactor); const(EC_POINT)* EC_GROUP_get0_generator (const(EC_GROUP)* group); int EC_GROUP_get_order (const(EC_GROUP)* group, BIGNUM* order, BN_CTX* ctx); int EC_GROUP_get_cofactor (const(EC_GROUP)* group, BIGNUM* cofactor, BN_CTX* ctx); void EC_GROUP_set_curve_name (EC_GROUP* group, int nid); int EC_GROUP_get_curve_name (const(EC_GROUP)* group); void EC_GROUP_set_asn1_flag (EC_GROUP* group, int flag); int EC_GROUP_get_asn1_flag (const(EC_GROUP)* group); void EC_GROUP_set_point_conversion_form (EC_GROUP* group, point_conversion_form_t form); point_conversion_form_t EC_GROUP_get_point_conversion_form (const(EC_GROUP)*); ubyte* EC_GROUP_get0_seed (const(EC_GROUP)* x); size_t EC_GROUP_get_seed_len (const(EC_GROUP)*); size_t EC_GROUP_set_seed (EC_GROUP*, const(ubyte)*, size_t len); int EC_GROUP_set_curve_GFp (EC_GROUP* group, const(BIGNUM)* p, const(BIGNUM)* a, const(BIGNUM)* b, BN_CTX* ctx); int EC_GROUP_get_curve_GFp (const(EC_GROUP)* group, BIGNUM* p, BIGNUM* a, BIGNUM* b, BN_CTX* ctx); int EC_GROUP_set_curve_GF2m (EC_GROUP* group, const(BIGNUM)* p, const(BIGNUM)* a, const(BIGNUM)* b, BN_CTX* ctx); int EC_GROUP_get_curve_GF2m (const(EC_GROUP)* group, BIGNUM* p, BIGNUM* a, BIGNUM* b, BN_CTX* ctx); int EC_GROUP_get_degree (const(EC_GROUP)* group); int EC_GROUP_check (const(EC_GROUP)* group, BN_CTX* ctx); int EC_GROUP_check_discriminant (const(EC_GROUP)* group, BN_CTX* ctx); int EC_GROUP_cmp (const(EC_GROUP)* a, const(EC_GROUP)* b, BN_CTX* ctx); EC_GROUP* EC_GROUP_new_curve_GFp (const(BIGNUM)* p, const(BIGNUM)* a, const(BIGNUM)* b, BN_CTX* ctx); EC_GROUP* EC_GROUP_new_curve_GF2m (const(BIGNUM)* p, const(BIGNUM)* a, const(BIGNUM)* b, BN_CTX* ctx); EC_GROUP* EC_GROUP_new_by_curve_name (int nid); size_t EC_get_builtin_curves (EC_builtin_curve* r, size_t nitems); const(char)* EC_curve_nid2nist (int nid); int EC_curve_nist2nid (const(char)* name); EC_POINT* EC_POINT_new (const(EC_GROUP)* group); void EC_POINT_free (EC_POINT* point); void EC_POINT_clear_free (EC_POINT* point); int EC_POINT_copy (EC_POINT* dst, const(EC_POINT)* src); EC_POINT* EC_POINT_dup (const(EC_POINT)* src, const(EC_GROUP)* group); const(EC_METHOD)* EC_POINT_method_of (const(EC_POINT)* point); int EC_POINT_set_to_infinity (const(EC_GROUP)* group, EC_POINT* point); int EC_POINT_set_Jprojective_coordinates_GFp (const(EC_GROUP)* group, EC_POINT* p, const(BIGNUM)* x, const(BIGNUM)* y, const(BIGNUM)* z, BN_CTX* ctx); int EC_POINT_get_Jprojective_coordinates_GFp (const(EC_GROUP)* group, const(EC_POINT)* p, BIGNUM* x, BIGNUM* y, BIGNUM* z, BN_CTX* ctx); int EC_POINT_set_affine_coordinates_GFp (const(EC_GROUP)* group, EC_POINT* p, const(BIGNUM)* x, const(BIGNUM)* y, BN_CTX* ctx); int EC_POINT_get_affine_coordinates_GFp (const(EC_GROUP)* group, const(EC_POINT)* p, BIGNUM* x, BIGNUM* y, BN_CTX* ctx); int EC_POINT_set_compressed_coordinates_GFp (const(EC_GROUP)* group, EC_POINT* p, const(BIGNUM)* x, int y_bit, BN_CTX* ctx); int EC_POINT_set_affine_coordinates_GF2m (const(EC_GROUP)* group, EC_POINT* p, const(BIGNUM)* x, const(BIGNUM)* y, BN_CTX* ctx); int EC_POINT_get_affine_coordinates_GF2m (const(EC_GROUP)* group, const(EC_POINT)* p, BIGNUM* x, BIGNUM* y, BN_CTX* ctx); int EC_POINT_set_compressed_coordinates_GF2m (const(EC_GROUP)* group, EC_POINT* p, const(BIGNUM)* x, int y_bit, BN_CTX* ctx); size_t EC_POINT_point2oct (const(EC_GROUP)* group, const(EC_POINT)* p, point_conversion_form_t form, ubyte* buf, size_t len, BN_CTX* ctx); int EC_POINT_oct2point (const(EC_GROUP)* group, EC_POINT* p, const(ubyte)* buf, size_t len, BN_CTX* ctx); BIGNUM* EC_POINT_point2bn (const(EC_GROUP)*, const(EC_POINT)*, point_conversion_form_t form, BIGNUM*, BN_CTX*); EC_POINT* EC_POINT_bn2point (const(EC_GROUP)*, const(BIGNUM)*, EC_POINT*, BN_CTX*); char* EC_POINT_point2hex (const(EC_GROUP)*, const(EC_POINT)*, point_conversion_form_t form, BN_CTX*); EC_POINT* EC_POINT_hex2point (const(EC_GROUP)*, const(char)*, EC_POINT*, BN_CTX*); int EC_POINT_add (const(EC_GROUP)* group, EC_POINT* r, const(EC_POINT)* a, const(EC_POINT)* b, BN_CTX* ctx); int EC_POINT_dbl (const(EC_GROUP)* group, EC_POINT* r, const(EC_POINT)* a, BN_CTX* ctx); int EC_POINT_invert (const(EC_GROUP)* group, EC_POINT* a, BN_CTX* ctx); int EC_POINT_is_at_infinity (const(EC_GROUP)* group, const(EC_POINT)* p); int EC_POINT_is_on_curve (const(EC_GROUP)* group, const(EC_POINT)* point, BN_CTX* ctx); int EC_POINT_cmp (const(EC_GROUP)* group, const(EC_POINT)* a, const(EC_POINT)* b, BN_CTX* ctx); int EC_POINT_make_affine (const(EC_GROUP)* group, EC_POINT* point, BN_CTX* ctx); // TODO: SMELL: IS D's "T** x" binary compatible with C's "T *x[]"? // int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); // int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); int EC_POINTs_make_affine (const(EC_GROUP)* group, size_t num, EC_POINT** points, BN_CTX* ctx); int EC_POINTs_mul (const(EC_GROUP)* group, EC_POINT* r, const(BIGNUM)* n, size_t num, const(EC_POINT)** p, const(BIGNUM)** m, BN_CTX *ctx); int EC_POINT_mul (const(EC_GROUP)* group, EC_POINT* r, const(BIGNUM)* n, const(EC_POINT)* q, const(BIGNUM)* m, BN_CTX* ctx); int EC_GROUP_precompute_mult (EC_GROUP* group, BN_CTX* ctx); int EC_GROUP_have_precompute_mult (const(EC_GROUP)* group); int EC_GROUP_get_basis_type (const(EC_GROUP)*); int EC_GROUP_get_trinomial_basis (const(EC_GROUP)*, uint* k); int EC_GROUP_get_pentanomial_basis (const(EC_GROUP)*, uint* k1, uint* k2, uint* k3); EC_GROUP* d2i_ECPKParameters (EC_GROUP**, const(ubyte*)* in_, c_long len); int i2d_ECPKParameters (const(EC_GROUP)*, ubyte** out_); int ECPKParameters_print (BIO* bp, const(EC_GROUP)* x, int off); int ECPKParameters_print_fp (FILE* fp, const(EC_GROUP)* x, int off); EC_KEY* EC_KEY_new (); int EC_KEY_get_flags (const(EC_KEY)* key); void EC_KEY_set_flags (EC_KEY* key, int flags); void EC_KEY_clear_flags (EC_KEY* key, int flags); EC_KEY* EC_KEY_new_by_curve_name (int nid); void EC_KEY_free (EC_KEY* key); EC_KEY* EC_KEY_copy (EC_KEY* dst, const(EC_KEY)* src); EC_KEY* EC_KEY_dup (const(EC_KEY)* src); int EC_KEY_up_ref (EC_KEY* key); const(EC_GROUP)* EC_KEY_get0_group (const(EC_KEY)* key); int EC_KEY_set_group (EC_KEY* key, const(EC_GROUP)* group); const(BIGNUM)* EC_KEY_get0_private_key (const(EC_KEY)* key); int EC_KEY_set_private_key (EC_KEY* key, const(BIGNUM)* prv); const(EC_POINT)* EC_KEY_get0_public_key (const(EC_KEY)* key); int EC_KEY_set_public_key (EC_KEY* key, const(EC_POINT)* pub); uint EC_KEY_get_enc_flags (const(EC_KEY)* key); void EC_KEY_set_enc_flags (EC_KEY* eckey, uint flags); point_conversion_form_t EC_KEY_get_conv_form (const(EC_KEY)* key); void EC_KEY_set_conv_form (EC_KEY* eckey, point_conversion_form_t cform); void* EC_KEY_get_key_method_data (EC_KEY* key, void* function (void*) dup_func, void function (void*) free_func, void function (void*) clear_free_func); void* EC_KEY_insert_key_method_data (EC_KEY* key, void* data, void* function (void*) dup_func, void function (void*) free_func, void function (void*) clear_free_func); void EC_KEY_set_asn1_flag (EC_KEY* eckey, int asn1_flag); int EC_KEY_precompute_mult (EC_KEY* key, BN_CTX* ctx); int EC_KEY_generate_key (EC_KEY* key); int EC_KEY_check_key (const(EC_KEY)* key); int EC_KEY_set_public_key_affine_coordinates (EC_KEY* key, BIGNUM* x, BIGNUM* y); EC_KEY* d2i_ECPrivateKey (EC_KEY** key, const(ubyte*)* in_, c_long len); int i2d_ECPrivateKey (EC_KEY* key, ubyte** out_); EC_KEY* d2i_ECParameters (EC_KEY** key, const(ubyte*)* in_, c_long len); int i2d_ECParameters (EC_KEY* key, ubyte** out_); EC_KEY* o2i_ECPublicKey (EC_KEY** key, const(ubyte*)* in_, c_long len); int i2o_ECPublicKey (EC_KEY* key, ubyte** out_); int ECParameters_print (BIO* bp, const(EC_KEY)* key); int EC_KEY_print (BIO* bp, const(EC_KEY)* key, int off); int ECParameters_print_fp (FILE* fp, const(EC_KEY)* key); int EC_KEY_print_fp (FILE* fp, const(EC_KEY)* key, int off); EC_KEY* ECParameters_dup (EC_KEY* key); void ERR_load_EC_strings (); /* Error codes for the EC functions. */ /* Function codes. */ enum EC_F_BN_TO_FELEM = 224; enum EC_F_COMPUTE_WNAF = 143; enum EC_F_D2I_ECPARAMETERS = 144; enum EC_F_D2I_ECPKPARAMETERS = 145; enum EC_F_D2I_ECPRIVATEKEY = 146; enum EC_F_DO_EC_KEY_PRINT = 221; enum EC_F_ECKEY_PARAM2TYPE = 223; enum EC_F_ECKEY_PARAM_DECODE = 212; enum EC_F_ECKEY_PRIV_DECODE = 213; enum EC_F_ECKEY_PRIV_ENCODE = 214; enum EC_F_ECKEY_PUB_DECODE = 215; enum EC_F_ECKEY_PUB_ENCODE = 216; enum EC_F_ECKEY_TYPE2PARAM = 220; enum EC_F_ECPARAMETERS_PRINT = 147; enum EC_F_ECPARAMETERS_PRINT_FP = 148; enum EC_F_ECPKPARAMETERS_PRINT = 149; enum EC_F_ECPKPARAMETERS_PRINT_FP = 150; enum EC_F_ECP_NIST_MOD_192 = 203; enum EC_F_ECP_NIST_MOD_224 = 204; enum EC_F_ECP_NIST_MOD_256 = 205; enum EC_F_ECP_NIST_MOD_521 = 206; enum EC_F_EC_ASN1_GROUP2CURVE = 153; enum EC_F_EC_ASN1_GROUP2FIELDID = 154; enum EC_F_EC_ASN1_GROUP2PARAMETERS = 155; enum EC_F_EC_ASN1_GROUP2PKPARAMETERS = 156; enum EC_F_EC_ASN1_PARAMETERS2GROUP = 157; enum EC_F_EC_ASN1_PKPARAMETERS2GROUP = 158; enum EC_F_EC_EX_DATA_SET_DATA = 211; enum EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY = 208; enum EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT = 159; enum EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE = 195; enum EC_F_EC_GF2M_SIMPLE_OCT2POINT = 160; enum EC_F_EC_GF2M_SIMPLE_POINT2OCT = 161; enum EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES = 162; enum EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES = 163; enum EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES = 164; enum EC_F_EC_GFP_MONT_FIELD_DECODE = 133; enum EC_F_EC_GFP_MONT_FIELD_ENCODE = 134; enum EC_F_EC_GFP_MONT_FIELD_MUL = 131; enum EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE = 209; enum EC_F_EC_GFP_MONT_FIELD_SQR = 132; enum EC_F_EC_GFP_MONT_GROUP_SET_CURVE = 189; enum EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP = 135; enum EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE = 225; enum EC_F_EC_GFP_NISTP224_POINTS_MUL = 228; enum EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES = 226; enum EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE = 230; enum EC_F_EC_GFP_NISTP256_POINTS_MUL = 231; enum EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES = 232; enum EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE = 233; enum EC_F_EC_GFP_NISTP521_POINTS_MUL = 234; enum EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES = 235; enum EC_F_EC_GFP_NIST_FIELD_MUL = 200; enum EC_F_EC_GFP_NIST_FIELD_SQR = 201; enum EC_F_EC_GFP_NIST_GROUP_SET_CURVE = 202; enum EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT = 165; enum EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE = 166; enum EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP = 100; enum EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR = 101; enum EC_F_EC_GFP_SIMPLE_MAKE_AFFINE = 102; enum EC_F_EC_GFP_SIMPLE_OCT2POINT = 103; enum EC_F_EC_GFP_SIMPLE_POINT2OCT = 104; enum EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE = 137; enum EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES = 167; enum EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP = 105; enum EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES = 168; enum EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP = 128; enum EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES = 169; enum EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP = 129; enum EC_F_EC_GROUP_CHECK = 170; enum EC_F_EC_GROUP_CHECK_DISCRIMINANT = 171; enum EC_F_EC_GROUP_COPY = 106; enum EC_F_EC_GROUP_GET0_GENERATOR = 139; enum EC_F_EC_GROUP_GET_COFACTOR = 140; enum EC_F_EC_GROUP_GET_CURVE_GF2M = 172; enum EC_F_EC_GROUP_GET_CURVE_GFP = 130; enum EC_F_EC_GROUP_GET_DEGREE = 173; enum EC_F_EC_GROUP_GET_ORDER = 141; enum EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS = 193; enum EC_F_EC_GROUP_GET_TRINOMIAL_BASIS = 194; enum EC_F_EC_GROUP_NEW = 108; enum EC_F_EC_GROUP_NEW_BY_CURVE_NAME = 174; enum EC_F_EC_GROUP_NEW_FROM_DATA = 175; enum EC_F_EC_GROUP_PRECOMPUTE_MULT = 142; enum EC_F_EC_GROUP_SET_CURVE_GF2M = 176; enum EC_F_EC_GROUP_SET_CURVE_GFP = 109; enum EC_F_EC_GROUP_SET_EXTRA_DATA = 110; enum EC_F_EC_GROUP_SET_GENERATOR = 111; enum EC_F_EC_KEY_CHECK_KEY = 177; enum EC_F_EC_KEY_COPY = 178; enum EC_F_EC_KEY_GENERATE_KEY = 179; enum EC_F_EC_KEY_NEW = 182; enum EC_F_EC_KEY_PRINT = 180; enum EC_F_EC_KEY_PRINT_FP = 181; enum EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES = 229; enum EC_F_EC_POINTS_MAKE_AFFINE = 136; enum EC_F_EC_POINT_ADD = 112; enum EC_F_EC_POINT_CMP = 113; enum EC_F_EC_POINT_COPY = 114; enum EC_F_EC_POINT_DBL = 115; enum EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M = 183; enum EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP = 116; enum EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP = 117; enum EC_F_EC_POINT_INVERT = 210; enum EC_F_EC_POINT_IS_AT_INFINITY = 118; enum EC_F_EC_POINT_IS_ON_CURVE = 119; enum EC_F_EC_POINT_MAKE_AFFINE = 120; enum EC_F_EC_POINT_MUL = 184; enum EC_F_EC_POINT_NEW = 121; enum EC_F_EC_POINT_OCT2POINT = 122; enum EC_F_EC_POINT_POINT2OCT = 123; enum EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M = 185; enum EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP = 124; enum EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M = 186; enum EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP = 125; enum EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP = 126; enum EC_F_EC_POINT_SET_TO_INFINITY = 127; enum EC_F_EC_PRE_COMP_DUP = 207; enum EC_F_EC_PRE_COMP_NEW = 196; enum EC_F_EC_WNAF_MUL = 187; enum EC_F_EC_WNAF_PRECOMPUTE_MULT = 188; enum EC_F_I2D_ECPARAMETERS = 190; enum EC_F_I2D_ECPKPARAMETERS = 191; enum EC_F_I2D_ECPRIVATEKEY = 192; enum EC_F_I2O_ECPUBLICKEY = 151; enum EC_F_NISTP224_PRE_COMP_NEW = 227; enum EC_F_NISTP256_PRE_COMP_NEW = 236; enum EC_F_NISTP521_PRE_COMP_NEW = 237; enum EC_F_O2I_ECPUBLICKEY = 152; enum EC_F_OLD_EC_PRIV_DECODE = 222; enum EC_F_PKEY_EC_CTRL = 197; enum EC_F_PKEY_EC_CTRL_STR = 198; enum EC_F_PKEY_EC_DERIVE = 217; enum EC_F_PKEY_EC_KEYGEN = 199; enum EC_F_PKEY_EC_PARAMGEN = 219; enum EC_F_PKEY_EC_SIGN = 218; /* Reason codes. */ enum EC_R_ASN1_ERROR = 115; enum EC_R_ASN1_UNKNOWN_FIELD = 116; enum EC_R_BIGNUM_OUT_OF_RANGE = 144; enum EC_R_BUFFER_TOO_SMALL = 100; enum EC_R_COORDINATES_OUT_OF_RANGE = 146; enum EC_R_D2I_ECPKPARAMETERS_FAILURE = 117; enum EC_R_DECODE_ERROR = 142; enum EC_R_DISCRIMINANT_IS_ZERO = 118; enum EC_R_EC_GROUP_NEW_BY_NAME_FAILURE = 119; enum EC_R_FIELD_TOO_LARGE = 143; enum EC_R_GF2M_NOT_SUPPORTED = 147; enum EC_R_GROUP2PKPARAMETERS_FAILURE = 120; enum EC_R_I2D_ECPKPARAMETERS_FAILURE = 121; enum EC_R_INCOMPATIBLE_OBJECTS = 101; enum EC_R_INVALID_ARGUMENT = 112; enum EC_R_INVALID_COMPRESSED_POINT = 110; enum EC_R_INVALID_COMPRESSION_BIT = 109; enum EC_R_INVALID_CURVE = 141; enum EC_R_INVALID_DIGEST_TYPE = 138; enum EC_R_INVALID_ENCODING = 102; enum EC_R_INVALID_FIELD = 103; enum EC_R_INVALID_FORM = 104; enum EC_R_INVALID_GROUP_ORDER = 122; enum EC_R_INVALID_PENTANOMIAL_BASIS = 132; enum EC_R_INVALID_PRIVATE_KEY = 123; enum EC_R_INVALID_TRINOMIAL_BASIS = 137; enum EC_R_KEYS_NOT_SET = 140; enum EC_R_MISSING_PARAMETERS = 124; enum EC_R_MISSING_PRIVATE_KEY = 125; enum EC_R_NOT_A_NIST_PRIME = 135; enum EC_R_NOT_A_SUPPORTED_NIST_PRIME = 136; enum EC_R_NOT_IMPLEMENTED = 126; enum EC_R_NOT_INITIALIZED = 111; enum EC_R_NO_FIELD_MOD = 133; enum EC_R_NO_PARAMETERS_SET = 139; enum EC_R_PASSED_NULL_PARAMETER = 134; enum EC_R_PKPARAMETERS2GROUP_FAILURE = 127; enum EC_R_POINT_AT_INFINITY = 106; enum EC_R_POINT_IS_NOT_ON_CURVE = 107; enum EC_R_SLOT_FULL = 108; enum EC_R_UNDEFINED_GENERATOR = 113; enum EC_R_UNDEFINED_ORDER = 128; enum EC_R_UNKNOWN_GROUP = 129; enum EC_R_UNKNOWN_ORDER = 114; enum EC_R_UNSUPPORTED_FIELD = 131; enum EC_R_WRONG_CURVE_PARAMETERS = 145; enum EC_R_WRONG_ORDER = 130;
D
module dparse.lexer; import std.typecons; import std.typetuple; import std.array; import std.algorithm; import std.range; import std.experimental.lexer; import core.cpuid : sse42; version (D_InlineAsm_X86_64) { version (Windows) {} else version = iasm64NotWindows; } /// Operators private enum operators = [ ",", ".", "..", "...", "/", "/=", "!", "!<", "!<=", "!<>", "!<>=", "!=", "!>", "!>=", "$", "%", "%=", "&", "&&", "&=", "(", ")", "*", "*=", "+", "++", "+=", "-", "--", "-=", ":", ";", "<", "<<", "<<=", "<=", "<>", "<>=", "=", "==", "=>", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[", "]", "^", "^=", "^^", "^^=", "{", "|", "|=", "||", "}", "~", "~=" ]; /// Kewords private enum keywords = [ "abstract", "alias", "align", "asm", "assert", "auto", "body", "bool", "break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat", "char", "class", "const", "continue", "creal", "dchar", "debug", "default", "delegate", "delete", "deprecated", "do", "double", "else", "enum", "export", "extern", "false", "final", "finally", "float", "for", "foreach", "foreach_reverse", "function", "goto", "idouble", "if", "ifloat", "immutable", "import", "in", "inout", "int", "interface", "invariant", "ireal", "is", "lazy", "long", "macro", "mixin", "module", "new", "nothrow", "null", "out", "override", "package", "pragma", "private", "protected", "public", "pure", "real", "ref", "return", "scope", "shared", "short", "static", "struct", "super", "switch", "synchronized", "template", "this", "throw", "true", "try", "typedef", "typeid", "typeof", "ubyte", "ucent", "uint", "ulong", "union", "unittest", "ushort", "version", "void", "volatile", "wchar", "while", "with", "__DATE__", "__EOF__", "__FILE__", "__FUNCTION__", "__gshared", "__LINE__", "__MODULE__", "__parameters", "__PRETTY_FUNCTION__", "__TIME__", "__TIMESTAMP__", "__traits", "__vector", "__VENDOR__", "__VERSION__" ]; /// Other tokens private enum dynamicTokens = [ "specialTokenSequence", "comment", "identifier", "scriptLine", "whitespace", "doubleLiteral", "floatLiteral", "idoubleLiteral", "ifloatLiteral", "intLiteral", "longLiteral", "realLiteral", "irealLiteral", "uintLiteral", "ulongLiteral", "characterLiteral", "dstringLiteral", "stringLiteral", "wstringLiteral" ]; private enum pseudoTokenHandlers = [ "\"", "lexStringLiteral", "`", "lexWysiwygString", "//", "lexSlashSlashComment", "/*", "lexSlashStarComment", "/+", "lexSlashPlusComment", ".", "lexDot", "'", "lexCharacterLiteral", "0", "lexNumber", "1", "lexDecimal", "2", "lexDecimal", "3", "lexDecimal", "4", "lexDecimal", "5", "lexDecimal", "6", "lexDecimal", "7", "lexDecimal", "8", "lexDecimal", "9", "lexDecimal", "q\"", "lexDelimitedString", "q{", "lexTokenString", "r\"", "lexWysiwygString", "x\"", "lexHexString", " ", "lexWhitespace", "\t", "lexWhitespace", "\r", "lexWhitespace", "\n", "lexWhitespace", "\v", "lexWhitespace", "\f", "lexWhitespace", "\u2028", "lexLongNewline", "\u2029", "lexLongNewline", "#!", "lexScriptLine", "#line", "lexSpecialTokenSequence" ]; /// Token ID type for the D lexer. public alias IdType = TokenIdType!(operators, dynamicTokens, keywords); /** * Function used for converting an IdType to a string. * * Examples: * --- * IdType c = tok!"case"; * assert (str(c) == "case"); * --- */ public alias str = tokenStringRepresentation!(IdType, operators, dynamicTokens, keywords); /** * Template used to refer to D token types. * * See the $(B operators), $(B keywords), and $(B dynamicTokens) enums for * values that can be passed to this template. * Example: * --- * import dparse.lexer; * IdType t = tok!"floatLiteral"; * --- */ public template tok(string token) { alias tok = TokenId!(IdType, operators, dynamicTokens, keywords, token); } private enum extraFields = q{ string comment; string trailingComment; int opCmp(size_t i) const pure nothrow @safe { if (index < i) return -1; if (index > i) return 1; return 0; } int opCmp(ref const typeof(this) other) const pure nothrow @safe { return opCmp(other.index); } }; /// The token type in the D lexer public alias Token = std.experimental.lexer.TokenStructure!(IdType, extraFields); /** * Configure whitespace handling */ public enum WhitespaceBehavior : ubyte { include = 0b0000_0000, skip = 0b0000_0001, } /** * Configure string lexing behavior */ public enum StringBehavior : ubyte { /// Do not include quote characters, process escape sequences compiler = 0b0000_0000, /// Opening quotes, closing quotes, and string suffixes are included in the /// string token includeQuoteChars = 0b0000_0001, /// String escape sequences are not replaced notEscaped = 0b0000_0010, /// Not modified at all. Useful for formatters or highlighters source = includeQuoteChars | notEscaped } /** * Lexer configuration struct */ public struct LexerConfig { string fileName; StringBehavior stringBehavior; WhitespaceBehavior whitespaceBehavior; } /** * Returns: true if the given ID is for a basic type. */ public bool isBasicType(IdType type) nothrow pure @safe @nogc { switch (type) { case tok!"int": case tok!"uint": case tok!"double": case tok!"idouble": case tok!"float": case tok!"ifloat": case tok!"short": case tok!"ushort": case tok!"long": case tok!"ulong": case tok!"char": case tok!"wchar": case tok!"dchar": case tok!"bool": case tok!"void": case tok!"cent": case tok!"ucent": case tok!"real": case tok!"ireal": case tok!"byte": case tok!"ubyte": case tok!"cdouble": case tok!"cfloat": case tok!"creal": return true; default: return false; } } /** * Returns: true if the given ID type is for a number literal. */ public bool isNumberLiteral(IdType type) nothrow pure @safe @nogc { switch (type) { case tok!"doubleLiteral": case tok!"floatLiteral": case tok!"idoubleLiteral": case tok!"ifloatLiteral": case tok!"intLiteral": case tok!"longLiteral": case tok!"realLiteral": case tok!"irealLiteral": case tok!"uintLiteral": case tok!"ulongLiteral": return true; default: return false; } } /** * Returns: true if the given ID type is for an operator. */ public bool isOperator(IdType type) nothrow pure @safe @nogc { switch (type) { case tok!",": case tok!".": case tok!"..": case tok!"...": case tok!"/": case tok!"/=": case tok!"!": case tok!"!<": case tok!"!<=": case tok!"!<>": case tok!"!<>=": case tok!"!=": case tok!"!>": case tok!"!>=": case tok!"$": case tok!"%": case tok!"%=": case tok!"&": case tok!"&&": case tok!"&=": case tok!"(": case tok!")": case tok!"*": case tok!"*=": case tok!"+": case tok!"++": case tok!"+=": case tok!"-": case tok!"--": case tok!"-=": case tok!":": case tok!";": case tok!"<": case tok!"<<": case tok!"<<=": case tok!"<=": case tok!"<>": case tok!"<>=": case tok!"=": case tok!"==": case tok!"=>": case tok!">": case tok!">=": case tok!">>": case tok!">>=": case tok!">>>": case tok!">>>=": case tok!"?": case tok!"@": case tok!"[": case tok!"]": case tok!"^": case tok!"^=": case tok!"^^": case tok!"^^=": case tok!"{": case tok!"|": case tok!"|=": case tok!"||": case tok!"}": case tok!"~": case tok!"~=": return true; default: return false; } } /** * Returns: true if the given ID type is for a keyword. */ public bool isKeyword(IdType type) pure nothrow @safe @nogc { switch (type) { case tok!"abstract": case tok!"alias": case tok!"align": case tok!"asm": case tok!"assert": case tok!"auto": case tok!"body": case tok!"break": case tok!"case": case tok!"cast": case tok!"catch": case tok!"class": case tok!"const": case tok!"continue": case tok!"debug": case tok!"default": case tok!"delegate": case tok!"delete": case tok!"deprecated": case tok!"do": case tok!"else": case tok!"enum": case tok!"export": case tok!"extern": case tok!"false": case tok!"final": case tok!"finally": case tok!"for": case tok!"foreach": case tok!"foreach_reverse": case tok!"function": case tok!"goto": case tok!"if": case tok!"immutable": case tok!"import": case tok!"in": case tok!"inout": case tok!"interface": case tok!"invariant": case tok!"is": case tok!"lazy": case tok!"macro": case tok!"mixin": case tok!"module": case tok!"new": case tok!"nothrow": case tok!"null": case tok!"out": case tok!"override": case tok!"package": case tok!"pragma": case tok!"private": case tok!"protected": case tok!"public": case tok!"pure": case tok!"ref": case tok!"return": case tok!"scope": case tok!"shared": case tok!"static": case tok!"struct": case tok!"super": case tok!"switch": case tok!"synchronized": case tok!"template": case tok!"this": case tok!"throw": case tok!"true": case tok!"try": case tok!"typedef": case tok!"typeid": case tok!"typeof": case tok!"union": case tok!"unittest": case tok!"version": case tok!"volatile": case tok!"while": case tok!"with": case tok!"__DATE__": case tok!"__EOF__": case tok!"__FILE__": case tok!"__FUNCTION__": case tok!"__gshared": case tok!"__LINE__": case tok!"__MODULE__": case tok!"__parameters": case tok!"__PRETTY_FUNCTION__": case tok!"__TIME__": case tok!"__TIMESTAMP__": case tok!"__traits": case tok!"__vector": case tok!"__VENDOR__": case tok!"__VERSION__": return true; default: return false; } } /** * Returns: true if the given ID type is for a string literal. */ public bool isStringLiteral(IdType type) pure nothrow @safe @nogc { switch (type) { case tok!"dstringLiteral": case tok!"stringLiteral": case tok!"wstringLiteral": return true; default: return false; } } /** * Returns: true if the given ID type is for a protection attribute. */ public bool isProtection(IdType type) pure nothrow @safe @nogc { switch (type) { case tok!"export": case tok!"package": case tok!"private": case tok!"public": case tok!"protected": return true; default: return false; } } /** * Returns: an array of tokens lexed from the given source code to the output range. All * whitespace tokens are skipped and comments are attached to the token nearest * to them. */ const(Token)[] getTokensForParser(ubyte[] sourceCode, LexerConfig config, StringCache* cache) { enum CommentType : ubyte { notDoc, line, block } static CommentType commentType(string comment) pure nothrow @safe { if (comment.length < 3) return CommentType.notDoc; if (comment[0 ..3] == "///") return CommentType.line; if (comment[0 ..3] == "/++" || comment[0 ..3] == "/**") return CommentType.block; return CommentType.notDoc; } config.whitespaceBehavior = WhitespaceBehavior.skip; auto output = appender!(typeof(return))(); auto lexer = DLexer(sourceCode, config, cache); string blockComment; size_t tokenCount; loop: while (!lexer.empty) switch (lexer.front.type) { case tok!"specialTokenSequence": case tok!"whitespace": lexer.popFront(); break; case tok!"comment": final switch (commentType(lexer.front.text)) { case CommentType.block: if (tokenCount > 0 && lexer.front.line == output.data[tokenCount - 1].line) { (cast() output.data[tokenCount - 1]).trailingComment = lexer.front.text; } else { blockComment = lexer.front.text; } lexer.popFront(); break; case CommentType.line: if (tokenCount > 0 && lexer.front.line == output.data[tokenCount - 1].line) { (cast() output.data[tokenCount - 1]).trailingComment = lexer.front.text; } else { string c = lexer.front.text[3 .. $]; // just take the /// off entirely if(blockComment.length == 0) { blockComment = "/++" ~ c ~ "+/"; // just rewrite to this } else { import std.string; auto l = blockComment.lastIndexOf("\n"); string replacement; if(l != -1) { replacement = blockComment[l .. $]; blockComment = blockComment[0 .. l + 1]; } else { replacement = blockComment[$-2 .. $]; blockComment = blockComment[0 .. $-2]; // just cut off the */ or +/ } if(blockComment[0 .. 3] == "/**") blockComment ~= c ~ replacement; else if(blockComment[0 .. 3] == "/++") blockComment ~= c ~ replacement; else assert(0); } } lexer.popFront(); break; case CommentType.notDoc: lexer.popFront(); break; } break; case tok!"__EOF__": break loop; default: Token t = lexer.front; lexer.popFront(); tokenCount++; t.comment = blockComment; blockComment = null; output.put(t); break; } return output.data; } /** * The D lexer struct. */ public struct DLexer { mixin Lexer!(Token, lexIdentifier, isSeparating, operators, dynamicTokens, keywords, pseudoTokenHandlers); /// @disable this(); /** * Params: * range = the bytes that compose the source code that will be lexed. * config = the lexer configuration to use. * cache = the string interning cache for de-duplicating identifiers and * other token text. */ this(ubyte[] range, const LexerConfig config, StringCache* cache, bool haveSSE42 = sse42()) pure nothrow @safe { this.haveSSE42 = haveSSE42; auto r = (range.length >= 3 && range[0] == 0xef && range[1] == 0xbb && range[2] == 0xbf) ? range[3 .. $] : range; this.range = LexerRange(r); this.config = config; this.cache = cache; popFront(); } /// public void popFront()() pure nothrow @safe { do _popFront(); while (config.whitespaceBehavior == WhitespaceBehavior.skip && _front.type == tok!"whitespace"); } private pure nothrow @safe: bool isWhitespace() { switch (range.bytes[range.index]) { case ' ': case '\r': case '\n': case '\t': case '\v': case '\f': return true; case 0xe2: auto peek = range.peek(2); return peek.length == 2 && peek[0] == 0x80 && (peek[1] == 0xa8 || peek[1] == 0xa9); default: return false; } } void popFrontWhitespaceAware() { switch (range.bytes[range.index]) { case '\r': range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '\n') { range.popFront(); range.incrementLine(); } else range.incrementLine(); return; case '\n': range.popFront(); range.incrementLine(); return; case 0xe2: auto lookahead = range.peek(3); if (lookahead.length == 3 && lookahead[1] == 0x80 && (lookahead[2] == 0xa8 || lookahead[2] == 0xa9)) { range.index+=3; range.column+=3; range.incrementLine(); return; } else { range.popFront(); return; } default: range.popFront(); return; } } void lexWhitespace(ref Token token) @trusted { mixin (tokenStart); loop: do { version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { skip!(true, '\t', ' ', '\v', '\f')(range.bytes.ptr + range.index, &range.index, &range.column); } } switch (range.bytes[range.index]) { case '\r': range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '\n') { range.popFront(); } range.column = 1; range.line += 1; break; case '\n': range.popFront(); range.column = 1; range.line += 1; break; case ' ': case '\t': case '\v': case '\f': range.popFront(); break; case 0xe2: if (range.index + 2 >= range.bytes.length) break loop; if (range.bytes[range.index + 1] != 0x80) break loop; if (range.bytes[range.index + 2] == 0xa8 || range.bytes[range.index + 2] == 0xa9) { range.index += 3; range.column += 3; range.column = 1; range.line += 1; break; } break loop; default: break loop; } } while (!(range.index >= range.bytes.length)); end: string text = config.whitespaceBehavior == WhitespaceBehavior.include ? cache.intern(range.slice(mark)) : ""; token = Token(tok!"whitespace", text, line, column, index); } void lexNumber(ref Token token) { mixin (tokenStart); if (range.bytes[range.index] == '0' && range.index + 1 < range.bytes.length) { auto ahead = range.bytes[range.index + 1]; switch (ahead) { case 'x': case 'X': range.index += 2; range.column += 2; lexHex(token, mark, line, column, index); return; case 'b': case 'B': range.index += 2; range.column += 2; lexBinary(token, mark, line, column, index); return; default: lexDecimal(token, mark, line, column, index); return; } } else lexDecimal(token, mark, line, column, index); } void lexHex(ref Token token) { mixin (tokenStart); lexHex(token, mark, line, column, index); } void lexHex(ref Token token, size_t mark, size_t line, size_t column, size_t index) @trusted { IdType type = tok!"intLiteral"; bool foundDot; hexLoop: while (!(range.index >= range.bytes.length)) { switch (range.bytes[range.index]) { case 'a': .. case 'f': case 'A': .. case 'F': case '0': .. case '9': case '_': version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { immutable ulong i = rangeMatch!(false, '0', '9', 'a', 'f', 'A', 'F', '_', '_') (range.bytes.ptr + range.index); range.column += i; range.index += i; } else range.popFront(); } else range.popFront(); break; case 'u': case 'U': lexIntSuffix(type); break hexLoop; case 'i': if (foundDot) lexFloatSuffix(type); break hexLoop; case 'L': if (foundDot) lexFloatSuffix(type); else lexIntSuffix(type); break hexLoop; case 'p': case 'P': lexExponent(type); break hexLoop; case '.': if (foundDot || !(range.index + 1 < range.bytes.length) || range.peekAt(1) == '.') break hexLoop; else { // The following bit of silliness tries to tell the // difference between "int dot identifier" and // "double identifier". if ((range.index + 1 < range.bytes.length)) { switch (range.peekAt(1)) { case '0': .. case '9': case 'A': .. case 'F': case 'a': .. case 'f': goto doubleLiteral; default: break hexLoop; } } else { doubleLiteral: range.popFront(); foundDot = true; type = tok!"doubleLiteral"; } } break; default: break hexLoop; } } token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexBinary(ref Token token) { mixin (tokenStart); return lexBinary(token, mark, line, column, index); } void lexBinary(ref Token token, size_t mark, size_t line, size_t column, size_t index) @trusted { IdType type = tok!"intLiteral"; binaryLoop: while (!(range.index >= range.bytes.length)) { switch (range.bytes[range.index]) { case '0': case '1': case '_': version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { immutable ulong i = rangeMatch!(false, '0', '1', '_', '_')( range.bytes.ptr + range.index); range.column += i; range.index += i; } else range.popFront(); } else range.popFront(); break; case 'u': case 'U': case 'L': lexIntSuffix(type); break binaryLoop; default: break binaryLoop; } } token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexDecimal(ref Token token) { mixin (tokenStart); lexDecimal(token, mark, line, column, index); } void lexDecimal(ref Token token, size_t mark, size_t line, size_t column, size_t index) @trusted { bool foundDot = range.bytes[range.index] == '.'; IdType type = tok!"intLiteral"; if (foundDot) { range.popFront(); type = tok!"doubleLiteral"; } decimalLoop: while (!(range.index >= range.bytes.length)) { switch (range.bytes[range.index]) { case '0': .. case '9': case '_': version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { ulong i = rangeMatch!(false, '0', '9', '_', '_')(range.bytes.ptr + range.index); range.column += i; range.index += i; } else range.popFront(); } else range.popFront(); break; case 'u': case 'U': if (!foundDot) lexIntSuffix(type); break decimalLoop; case 'i': lexFloatSuffix(type); break decimalLoop; case 'L': if (foundDot) lexFloatSuffix(type); else lexIntSuffix(type); break decimalLoop; case 'f': case 'F': lexFloatSuffix(type); break decimalLoop; case 'e': case 'E': lexExponent(type); break decimalLoop; case '.': if (foundDot || !(range.index + 1 < range.bytes.length) || range.peekAt(1) == '.') break decimalLoop; else { // The following bit of silliness tries to tell the // difference between "int dot identifier" and // "double identifier". if ((range.index + 1 < range.bytes.length)) { auto ch = range.peekAt(1); if (ch <= 0x2f || (ch >= '0' && ch <= '9') || (ch >= ':' && ch <= '@') || (ch >= '[' && ch <= '^') || (ch >= '{' && ch <= '~') || ch == '`' || ch == '_') { goto doubleLiteral; } else break decimalLoop; } else { doubleLiteral: range.popFront(); foundDot = true; type = tok!"doubleLiteral"; } } break; default: break decimalLoop; } } token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexIntSuffix(ref IdType type) { bool secondPass; if (range.bytes[range.index] == 'u' || range.bytes[range.index] == 'U') { U: if (type == tok!"intLiteral") type = tok!"uintLiteral"; else type = tok!"ulongLiteral"; range.popFront(); if (secondPass) return; if (range.index < range.bytes.length && (range.bytes[range.index] == 'L' || range.bytes[range.index] == 'l')) goto L; return; } if (range.bytes[range.index] == 'L' || range.bytes[range.index] == 'l') { L: if (type == tok!"uintLiteral") type = tok!"ulongLiteral"; else type = tok!"longLiteral"; range.popFront(); if (!secondPass && range.index < range.bytes.length && (range.bytes[range.index] == 'U' || range.bytes[range.index] == 'u')) { secondPass = true; goto U; } return; } } void lexFloatSuffix(ref IdType type) pure nothrow @safe { switch (range.bytes[range.index]) { case 'L': range.popFront(); type = tok!"doubleLiteral"; break; case 'f': case 'F': range.popFront(); type = tok!"floatLiteral"; break; default: break; } if (!(range.index >= range.bytes.length) && range.bytes[range.index] == 'i') { warning("Complex number literals are deprecated"); range.popFront(); if (type == tok!"floatLiteral") type = tok!"ifloatLiteral"; else type = tok!"idoubleLiteral"; } } void lexExponent(ref IdType type) pure nothrow @safe { range.popFront(); bool foundSign = false; bool foundDigit = false; while (!(range.index >= range.bytes.length)) { switch (range.bytes[range.index]) { case '-': case '+': if (foundSign) { if (!foundDigit) error("Expected an exponent"); return; } foundSign = true; range.popFront(); break; case '0': .. case '9': case '_': foundDigit = true; range.popFront(); break; case 'L': case 'f': case 'F': case 'i': lexFloatSuffix(type); return; default: if (!foundDigit) error("Expected an exponent"); return; } } } void lexScriptLine(ref Token token) { mixin (tokenStart); while (!(range.index >= range.bytes.length) && !isNewline) { range.popFront(); } token = Token(tok!"scriptLine", cache.intern(range.slice(mark)), line, column, index); } void lexSpecialTokenSequence(ref Token token) { mixin (tokenStart); while (!(range.index >= range.bytes.length) && !isNewline) { range.popFront(); } token = Token(tok!"specialTokenSequence", cache.intern(range.slice(mark)), line, column, index); } void lexSlashStarComment(ref Token token) @trusted { mixin (tokenStart); IdType type = tok!"comment"; range.popFrontN(2); while (range.index < range.bytes.length) { version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) skip!(false, '\r', '\n', '/', '*', 0xe2)(range.bytes.ptr + range.index, &range.index, &range.column); } if (range.bytes[range.index] == '*') { range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '/') { range.popFront(); break; } } else popFrontWhitespaceAware(); } end: token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexSlashSlashComment(ref Token token) @trusted { mixin (tokenStart); IdType type = tok!"comment"; range.popFrontN(2); while (range.index < range.bytes.length) { version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { skip!(false, '\r', '\n', 0xe2)(range.bytes.ptr + range.index, &range.index, &range.column); } } if (range.bytes[range.index] == '\r' || range.bytes[range.index] == '\n') break; range.popFront(); } end: token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexSlashPlusComment(ref Token token) @trusted { mixin (tokenStart); IdType type = tok!"comment"; range.index += 2; range.column += 2; int depth = 1; while (depth > 0 && !(range.index >= range.bytes.length)) { version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { skip!(false, '+', '/', '\\', '\r', '\n', 0xe2)(range.bytes.ptr + range.index, &range.index, &range.column); } } if (range.bytes[range.index] == '+') { range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '/') { range.popFront(); depth--; } } else if (range.bytes[range.index] == '/') { range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '+') { range.popFront(); depth++; } } else popFrontWhitespaceAware(); } token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexStringLiteral(ref Token token) @trusted { mixin (tokenStart); range.popFront(); while (true) { if ((range.index >= range.bytes.length)) { error("Error: unterminated string literal"); token = Token(tok!""); return; } version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { skip!(false, '"', '\\', '\r', '\n', 0xe2)(range.bytes.ptr + range.index, &range.index, &range.column); } } if (range.bytes[range.index] == '"') { range.popFront(); break; } else if (range.bytes[range.index] == '\\') { lexEscapeSequence(); } else popFrontWhitespaceAware(); } IdType type = tok!"stringLiteral"; lexStringSuffix(type); token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexWysiwygString(ref Token token) @trusted { mixin (tokenStart); IdType type = tok!"stringLiteral"; bool backtick = range.bytes[range.index] == '`'; if (backtick) { range.popFront(); while (true) { if ((range.index >= range.bytes.length)) { error("Error: unterminated string literal"); token = Token(tok!""); return; } version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { skip!(false, '\r', '\n', 0xe2, '`')(range.bytes.ptr + range.index, &range.index, &range.column); } } if (range.bytes[range.index] == '`') { range.popFront(); break; } else popFrontWhitespaceAware(); } } else { range.popFront(); if ((range.index >= range.bytes.length)) { error("Error: unterminated string literal"); token = Token(tok!""); return; } range.popFront(); while (true) { if ((range.index >= range.bytes.length)) { error("Error: unterminated string literal"); token = Token(tok!""); return; } else if (range.bytes[range.index] == '"') { range.popFront(); break; } else popFrontWhitespaceAware(); } } lexStringSuffix(type); token = Token(type, cache.intern(range.slice(mark)), line, column, index); } private ubyte lexStringSuffix(ref IdType type) pure nothrow @safe { if ((range.index >= range.bytes.length)) { type = tok!"stringLiteral"; return 0; } else { switch (range.bytes[range.index]) { case 'w': range.popFront(); type = tok!"wstringLiteral"; return 'w'; case 'd': range.popFront(); type = tok!"dstringLiteral"; return 'd'; case 'c': range.popFront(); type = tok!"stringLiteral"; return 'c'; default: type = tok!"stringLiteral"; return 0; } } } void lexDelimitedString(ref Token token) { mixin (tokenStart); range.index += 2; range.column += 2; ubyte open; ubyte close; switch (range.bytes[range.index]) { case '<': open = '<'; close = '>'; range.popFront(); lexNormalDelimitedString(token, mark, line, column, index, open, close); break; case '{': open = '{'; close = '}'; range.popFront(); lexNormalDelimitedString(token, mark, line, column, index, open, close); break; case '[': open = '['; close = ']'; range.popFront(); lexNormalDelimitedString(token, mark, line, column, index, open, close); break; case '(': open = '('; close = ')'; range.popFront(); lexNormalDelimitedString(token, mark, line, column, index, open, close); break; default: lexHeredocString(token, mark, line, column, index); break; } } void lexNormalDelimitedString(ref Token token, size_t mark, size_t line, size_t column, size_t index, ubyte open, ubyte close) { int depth = 1; while (!(range.index >= range.bytes.length) && depth > 0) { if (range.bytes[range.index] == open) { depth++; range.popFront(); } else if (range.bytes[range.index] == close) { depth--; range.popFront(); if (depth <= 0) { if (range.bytes[range.index] == '"') { range.popFront(); } else { error("Error: \" expected to end delimited string literal"); token = Token(tok!""); return; } } } else popFrontWhitespaceAware(); } IdType type = tok!"stringLiteral"; lexStringSuffix(type); token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexHeredocString(ref Token token, size_t mark, size_t line, size_t column, size_t index) { Token ident; lexIdentifier(ident); if (isNewline()) popFrontWhitespaceAware(); else error("Newline expected"); while (!(range.index >= range.bytes.length)) { if (isNewline()) { popFrontWhitespaceAware(); if (!range.canPeek(ident.text.length)) { error(ident.text ~ " expected"); break; } if (range.peek(ident.text.length - 1) == ident.text) { range.popFrontN(ident.text.length); break; } } else { range.popFront(); } } if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '"') { range.popFront(); } else error(`" expected`); IdType type = tok!"stringLiteral"; lexStringSuffix(type); token = Token(type, cache.intern(range.slice(mark)), line, column, index); } void lexTokenString(ref Token token) { mixin (tokenStart); assert (range.bytes[range.index] == 'q'); range.popFront(); assert (range.bytes[range.index] == '{'); range.popFront(); auto app = appender!string(); app.put("q{"); int depth = 1; immutable WhitespaceBehavior oldWhitespace = config.whitespaceBehavior; immutable StringBehavior oldString = config.stringBehavior; config.whitespaceBehavior = WhitespaceBehavior.include; config.stringBehavior = StringBehavior.source; scope (exit) { config.whitespaceBehavior = oldWhitespace; config.stringBehavior = oldString; } advance(_front); while (depth > 0 && !empty) { auto t = front(); if (t.text is null) app.put(str(t.type)); else app.put(t.text); if (t.type == tok!"}") { depth--; if (depth > 0) popFront(); } else if (t.type == tok!"{") { depth++; popFront(); } else popFront(); } IdType type = tok!"stringLiteral"; auto b = lexStringSuffix(type); if (b != 0) app.put(b); token = Token(type, cache.intern(cast(const(ubyte)[]) app.data), line, column, index); } void lexHexString(ref Token token) { mixin (tokenStart); range.index += 2; range.column += 2; loop: while (true) { if ((range.index >= range.bytes.length)) { error("Error: unterminated hex string literal"); token = Token(tok!""); return; } else if (isWhitespace()) popFrontWhitespaceAware(); else switch (range.bytes[range.index]) { case '0': .. case '9': case 'A': .. case 'F': case 'a': .. case 'f': range.popFront(); break; case '"': range.popFront(); break loop; default: error("Error: invalid character in hex string"); token = Token(tok!""); return; } } IdType type = tok!"stringLiteral"; lexStringSuffix(type); token = Token(type, cache.intern(range.slice(mark)), line, column, index); } bool lexEscapeSequence() { range.popFront(); if ((range.index >= range.bytes.length)) { error("Error: non-terminated character escape sequence."); return false; } switch (range.bytes[range.index]) { case '\'': case '"': case '?': case '\\': case 'a': case 'b': case 'f': case 'n': case 'r': case 't': case 'v': range.popFront(); break; case 'x': range.popFront(); foreach (i; 0 .. 2) { if ((range.index >= range.bytes.length)) { error("Error: 2 hex digits expected."); return false; } switch (range.bytes[range.index]) { case '0': .. case '9': case 'a': .. case 'f': case 'A': .. case 'F': range.popFront(); break; default: error("Error: 2 hex digits expected."); return false; } } break; case '0': if (!(range.index + 1 < range.bytes.length) || ((range.index + 1 < range.bytes.length) && range.peekAt(1) == '\'')) { range.popFront(); break; } goto case; case '1': .. case '7': for (size_t i = 0; i < 3 && !(range.index >= range.bytes.length) && range.bytes[range.index] >= '0' && range.bytes[range.index] <= '7'; i++) range.popFront(); break; case 'u': range.popFront(); foreach (i; 0 .. 4) { if ((range.index >= range.bytes.length)) { error("Error: at least 4 hex digits expected."); return false; } switch (range.bytes[range.index]) { case '0': .. case '9': case 'a': .. case 'f': case 'A': .. case 'F': range.popFront(); break; default: error("Error: at least 4 hex digits expected."); return false; } } break; case 'U': range.popFront(); foreach (i; 0 .. 8) { if ((range.index >= range.bytes.length)) { error("Error: at least 8 hex digits expected."); return false; } switch (range.bytes[range.index]) { case '0': .. case '9': case 'a': .. case 'f': case 'A': .. case 'F': range.popFront(); break; default: error("Error: at least 8 hex digits expected."); return false; } } break; default: while (true) { if ((range.index >= range.bytes.length)) { error("Error: non-terminated character escape sequence."); return false; } if (range.bytes[range.index] == ';') { range.popFront(); break; } else { range.popFront(); } } } return true; } void lexCharacterLiteral(ref Token token) { mixin (tokenStart); range.popFront(); if (range.bytes[range.index] == '\\') { lexEscapeSequence(); goto close; } else if (range.bytes[range.index] == '\'') { range.popFront(); token = Token(tok!"characterLiteral", cache.intern(range.slice(mark)), line, column, index); } else if (range.bytes[range.index] & 0x80) { while (range.bytes[range.index] & 0x80) { range.popFront(); } goto close; } else { popFrontWhitespaceAware(); goto close; } close: if (range.bytes[range.index] == '\'') { range.popFront(); token = Token(tok!"characterLiteral", cache.intern(range.slice(mark)), line, column, index); } else { error("Error: Expected ' to end character literal"); token = Token(tok!""); } } void lexIdentifier(ref Token token) @trusted { mixin (tokenStart); if (isSeparating(0)) { error("Invalid identifier"); range.popFront(); } while (true) { version (iasm64NotWindows) { if (haveSSE42 && range.index + 16 < range.bytes.length) { immutable ulong i = rangeMatch!(false, 'a', 'z', 'A', 'Z', '_', '_') (range.bytes.ptr + range.index); range.column += i; range.index += i; } } if (isSeparating(0)) break; else range.popFront(); } token = Token(tok!"identifier", cache.intern(range.slice(mark)), line, column, index); } void lexDot(ref Token token) { mixin (tokenStart); if (!(range.index + 1 < range.bytes.length)) { range.popFront(); token = Token(tok!".", null, line, column, index); return; } switch (range.peekAt(1)) { case '0': .. case '9': lexNumber(token); return; case '.': range.popFront(); range.popFront(); if (!(range.index >= range.bytes.length) && range.bytes[range.index] == '.') { range.popFront(); token = Token(tok!"...", null, line, column, index); } else token = Token(tok!"..", null, line, column, index); return; default: range.popFront(); token = Token(tok!".", null, line, column, index); return; } } void lexLongNewline(ref Token token) @nogc { mixin (tokenStart); range.popFront(); range.popFront(); range.popFront(); range.incrementLine(); string text = config.whitespaceBehavior == WhitespaceBehavior.include ? cache.intern(range.slice(mark)) : ""; token = Token(tok!"whitespace", text, line, column, index); } bool isNewline() @nogc { if (range.bytes[range.index] == '\n') return true; if (range.bytes[range.index] == '\r') return true; return (range.bytes[range.index] & 0x80) && (range.index + 2 < range.bytes.length) && (range.peek(2) == "\u2028" || range.peek(2) == "\u2029"); } bool isSeparating(size_t offset) @nogc { enum : ubyte { n, y, m // no, yes, maybe } if (range.index + offset >= range.bytes.length) return true; auto c = range.bytes[range.index + offset]; static immutable ubyte[256] LOOKUP_TABLE = [ y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, y, n, n, n, n, n, n, n, n, n, n, y, y, y, y, y, y, y, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, y, y, y, y, n, y, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, y, y, y, y, y, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m, m ]; immutable ubyte result = LOOKUP_TABLE[c]; if (result == n) return false; if (result == y) return true; if (result == m) { auto r = range; range.popFrontN(offset); return (r.canPeek(2) && (r.peek(2) == "\u2028" || r.peek(2) == "\u2029")); } assert (false); } enum tokenStart = q{ size_t index = range.index; size_t column = range.column; size_t line = range.line; auto mark = range.mark(); }; void error(string message) { messages ~= Message(range.line, range.column, message, true); } void warning(string message) { messages ~= Message(range.line, range.column, message, false); assert (messages.length > 0); } static struct Message { size_t line; size_t column; string message; bool isError; } Message[] messages; StringCache* cache; LexerConfig config; bool haveSSE42; } /** * Creates a token range from the given source code. Creates a default lexer * configuration and a GC-managed string cache. */ public auto byToken(ubyte[] range) { LexerConfig config; StringCache* cache = new StringCache(StringCache.defaultBucketCount); return DLexer(range, config, cache); } /** * Creates a token range from the given source code. Uses the given string * cache. */ public auto byToken(ubyte[] range, StringCache* cache) { LexerConfig config; return DLexer(range, config, cache); } /** * Creates a token range from the given source code. Uses the provided lexer * configuration and string cache. */ public auto byToken(ubyte[] range, const LexerConfig config, StringCache* cache) { return DLexer(range, config, cache); } /** * Removes "decoration" such as leading whitespace, leading + and * characters, * and places the result into the given output range */ public void unDecorateComment(T)(string comment, auto ref T outputRange) if (isOutputRange!(T, string)) in { assert (comment.length >= 3); } body { switch (comment[0 .. 3]) { case "///": size_t i = 3; if (i < comment.length) { again: while (i < comment.length && (comment[i] == ' ' || comment[i] == '\t')) i++; size_t j = i + 1; while (j < comment.length) { if (comment[j] == '\r') j++; if (j >= comment.length) break; if (comment[j] == '\n') { outputRange.put(comment[i .. j]); j++; while (j < comment.length && comment[j] == '/') j++; outputRange.put('\n'); i = j; goto again; } j++; } if (i < comment.length && j <= comment.length) outputRange.put(comment[i .. j]); } break; case "/++": case "/**": size_t i = 3; immutable char c = comment[1]; // Skip leading * and + characters while (comment[i] == c) i++; // Skip trailing * and + characters size_t j = comment.length - 2; while (j > i && comment[j] == c) j--; while (j > i && (comment[j] == ' ' || comment[j] == '\t')) j--; j++; size_t k = i; while (k < j) { if (comment[k] == '\n') { k++; break; } k++; } outputRange.put(comment[i .. k]); i = k; if (comment[i] == '\r') i++; if (comment[i] == '\n') i++; while (comment[i] == ' ' || comment[i] == '\t') i++; immutable bool skipBeginningChar = comment[i] == c; if (skipBeginningChar) i++; size_t whitespaceToSkip; while (comment[i] == ' ' || comment[i] == '\t') { whitespaceToSkip++; i++; } size_t l = i; while (i < j) { if (comment[i++] == '\n') break; } outputRange.put(comment[l .. i]); while (true) { if (skipBeginningChar) { while (i < j && (comment[i] == ' ' || comment[i] == '\t')) i++; if (i < j && comment[i] == c) i++; } for (size_t s = 0; (i < j) && (s < whitespaceToSkip) && (comment[i] == ' ' || comment[i] == '\t');) { s++; i++; } k = i; inner: while (k < j) { if (comment[k] == '\n') { k++; break inner; } k++; } outputRange.put(comment[i .. k]); i = k; if (i >= j) break; } break; default: outputRange.put(comment); break; } } /** * The string cache is used for string interning. * * It will only store a single copy of any string that it is asked to hold. * Interned strings can be compared for equality by comparing their $(B .ptr) * field. * * Default and postbilt constructors are disabled. When a StringCache goes out * of scope, the memory held by it is freed. * * See_also: $(LINK http://en.wikipedia.org/wiki/String_interning) */ struct StringCache { public pure nothrow @nogc: @disable this(); @disable this(this); /** * Params: bucketCount = the initial number of buckets. Must be a * power of two */ this(size_t bucketCount) nothrow @trusted @nogc in { import core.bitop : popcnt; static if (size_t.sizeof == 8) { immutable low = popcnt(cast(uint) bucketCount); immutable high = popcnt(cast(uint) (bucketCount >> 32)); assert ((low == 0 && high == 1) || (low == 1 && high == 0)); } else { static assert (size_t.sizeof == 4); assert (popcnt(cast(uint) bucketCount) == 1); } } body { buckets = (cast(Node**) calloc((Node*).sizeof, bucketCount))[0 .. bucketCount]; } version(none) ~this() { Block* current = rootBlock; while (current !is null) { Block* prev = current; current = current.next; free(cast(void*) prev); } foreach (nodePointer; buckets) { Node* currentNode = nodePointer; while (currentNode !is null) { if (currentNode.mallocated) free(currentNode.str.ptr); Node* prev = currentNode; currentNode = currentNode.next; free(prev); } } rootBlock = null; free(buckets.ptr); buckets = null; } /** * Caches a string. */ string intern(const(ubyte)[] str) @safe { if (str is null || str.length == 0) return ""; return _intern(str); } /** * ditto */ string intern(string str) @trusted { return intern(cast(ubyte[]) str); } /** * The default bucket count for the string cache. */ static enum defaultBucketCount = 4096; private: string _intern(const(ubyte)[] bytes) @trusted { immutable uint hash = hashBytes(bytes); immutable size_t index = hash & (buckets.length - 1); Node* s = find(bytes, hash); if (s !is null) return cast(string) s.str; ubyte[] mem = void; bool mallocated = bytes.length > BIG_STRING; if (mallocated) mem = (cast(ubyte*) malloc(bytes.length))[0 .. bytes.length]; else mem = allocate(bytes.length); mem[] = bytes[]; Node* node = cast(Node*) malloc(Node.sizeof); node.str = mem; node.hash = hash; node.next = buckets[index]; node.mallocated = mallocated; buckets[index] = node; return cast(string) mem; } Node* find(const(ubyte)[] bytes, uint hash) @trusted { import std.algorithm : equal; immutable size_t index = hash & (buckets.length - 1); Node* node = buckets[index]; while (node !is null) { if (node.hash == hash && bytes == cast(ubyte[]) node.str) return node; node = node.next; } return node; } static uint hashBytes(const(ubyte)[] data) pure nothrow @trusted @nogc in { assert (data !is null); assert (data.length > 0); } body { immutable uint m = 0x5bd1e995; immutable int r = 24; uint h = cast(uint) data.length; while (data.length >= 4) { uint k = (cast(ubyte) data[3]) << 24 | (cast(ubyte) data[2]) << 16 | (cast(ubyte) data[1]) << 8 | (cast(ubyte) data[0]); k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; data = data[4 .. $]; } switch (data.length & 3) { case 3: h ^= data[2] << 16; goto case; case 2: h ^= data[1] << 8; goto case; case 1: h ^= data[0]; h *= m; break; default: break; } h ^= h >> 13; h *= m; h ^= h >> 15; return h; } ubyte[] allocate(size_t numBytes) pure nothrow @trusted @nogc in { assert (numBytes != 0); } out (result) { assert (result.length == numBytes); } body { Block* r = rootBlock; size_t i = 0; while (i <= 3 && r !is null) { immutable size_t available = r.bytes.length; immutable size_t oldUsed = r.used; immutable size_t newUsed = oldUsed + numBytes; if (newUsed <= available) { r.used = newUsed; return r.bytes[oldUsed .. newUsed]; } i++; r = r.next; } Block* b = cast(Block*) calloc(Block.sizeof, 1); b.used = numBytes; b.next = rootBlock; rootBlock = b; return b.bytes[0 .. numBytes]; } static struct Node { ubyte[] str = void; Node* next = void; uint hash = void; bool mallocated = void; } static struct Block { Block* next; size_t used; enum BLOCK_CAPACITY = BLOCK_SIZE - size_t.sizeof - (void*).sizeof; ubyte[BLOCK_CAPACITY] bytes; } static assert (BLOCK_SIZE == Block.sizeof); enum BLOCK_SIZE = 1024 * 16; // If a string would take up more than 1/4 of a block, allocate it outside // of the block. enum BIG_STRING = BLOCK_SIZE / 4; Node*[] buckets; Block* rootBlock; } private extern(C) void* calloc(size_t, size_t) nothrow pure @nogc @trusted; private extern(C) void* malloc(size_t) nothrow pure @nogc @trusted; private extern(C) void free(void*) nothrow pure @nogc @trusted; unittest { auto source = cast(ubyte[]) q{ import std.stdio;}c; auto tokens = getTokensForParser(source, LexerConfig(), new StringCache(StringCache.defaultBucketCount)); assert (tokens.map!"a.type"().equal([tok!"import", tok!"identifier", tok!".", tok!"identifier", tok!";"])); } /// Test \x char sequence unittest { auto toks = (string s) => byToken(cast(ubyte[])s); // valid enum hex = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F']; auto source = ""; foreach (h1; hex) foreach (h2; hex) source ~= "'\\x" ~ h1 ~ h2 ~ "'"; assert (toks(source).filter!(t => t.type != tok!"characterLiteral").empty); // invalid assert (toks(`'\x'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true)); assert (toks(`'\x_'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true)); assert (toks(`'\xA'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true)); assert (toks(`'\xAY'`).messages[0] == DLexer.Message(1,5,"Error: 2 hex digits expected.",true)); assert (toks(`'\xXX'`).messages[0] == DLexer.Message(1,4,"Error: 2 hex digits expected.",true)); } version (iasm64NotWindows) { /** * Returns: */ ushort newlineMask(const ubyte*) pure nothrow @trusted @nogc { asm pure nothrow @nogc { naked; movdqu XMM1, [RDI]; mov RAX, 3; mov RDX, 16; mov R8, 0x0d0d0d0d0d0d0d0dL; movq XMM2, R8; shufpd XMM2, XMM2, 0; pcmpeqb XMM2, XMM1; mov R9, 0x0a0a0a0a0a0a0a0aL; movq XMM3, R9; shufpd XMM3, XMM3, 0; pcmpeqb XMM3, XMM1; mov R10, 0xe280a8L; movq XMM4, R10; pcmpestrm XMM4, XMM1, 0b01001100; movdqa XMM4, XMM0; mov R11, 0xe280a9L; movq XMM5, R11; pcmpestrm XMM5, XMM1, 0b01001100; movdqa XMM5, XMM0; mov RCX, 0x0a0d; dec RAX; movq XMM6, RCX; pcmpestrm XMM6, XMM1, 0b01001100; movdqa XMM6, XMM0; movdqa XMM7, XMM6; pslldq XMM7, 1; movdqa XMM0, XMM4; por XMM0, XMM5; por XMM7, XMM6; movdqa XMM1, XMM2; por XMM1, XMM3; pxor XMM7, XMM1; por XMM7, XMM0; por XMM7, XMM6; pmovmskb RAX, XMM7; and RAX, 0b0011_1111_1111_1111; ret; } } /** * Skips between 0 and 16 bytes that match (or do not match) one of the * given $(B chars). */ void skip(bool matching, chars...)(const ubyte*, ulong*, ulong*) pure nothrow @trusted @nogc if (chars.length <= 8) { enum constant = ByteCombine!chars; enum charsLength = chars.length; static if (matching) enum flags = 0b0001_0000; else enum flags = 0b0000_0000; asm pure nothrow @nogc { naked; movdqu XMM1, [RDX]; mov R10, constant; movq XMM2, R10; mov RAX, charsLength; mov RDX, 16; pcmpestri XMM2, XMM1, flags; add [RSI], RCX; add [RDI], RCX; ret; } } /** * Returns: the number of bytes starting at the given location that match * (or do not match if $(B invert) is true) the byte ranges in $(B chars). */ ulong rangeMatch(bool invert, chars...)(const ubyte*) pure nothrow @trusted @nogc { static assert (chars.length % 2 == 0); enum constant = ByteCombine!chars; static if (invert) enum rangeMatchFlags = 0b0000_0100; else enum rangeMatchFlags = 0b0001_0100; enum charsLength = chars.length; asm pure nothrow @nogc { naked; movdqu XMM1, [RDI]; mov R10, constant; movq XMM2, R10; mov RAX, charsLength; mov RDX, 16; pcmpestri XMM2, XMM1, rangeMatchFlags; mov RAX, RCX; ret; } } template ByteCombine(c...) { static assert (c.length <= 8); static if (c.length > 1) enum ulong ByteCombine = c[0] | (ByteCombine!(c[1..$]) << 8); else enum ulong ByteCombine = c[0]; } }
D
<?xml version="1.0" encoding="ASCII" standalone="no"?> <di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0"> <pageList> <availablePage> <emfPageIdentifier href="VAR_14_banking-6176218889.notation#_copSALmGEeKQQp7P9cQvNQ"/> </availablePage> </pageList> <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> <windows> <children xsi:type="di:TabFolder"> <children> <emfPageIdentifier href="VAR_14_banking-6176218889.notation#_copSALmGEeKQQp7P9cQvNQ"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>
D
/* This file is part of BioD. Copyright (C) 2012-2013 Artem Tarasov <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ module bio.bam.bai.indexing; import bio.bam.reader; import bio.bam.readrange; import bio.bam.constants; import bio.bam.bai.bin; import bio.core.bgzf.chunk; import undead.stream; import std.array; import std.algorithm; import std.system; import std.exception; import core.stdc.string; // Suppose we have an alignment which covers bases on a reference, // starting from one position and ending at another position. // In order to build linear index, we need to find to which windows // the two positions correspond. // // // (K = 16384) // // [0, K)[K, 2K)[2K, 3K)... <- windows // [.......) <- alignment // private size_t toLinearIndexOffset(int position) { return position < 0 ? 0 : position / BAI_LINEAR_INDEX_WINDOW_SIZE; } /// struct IndexBuilder { private { // array of linear offsets for the current reference entry VirtualOffset[] _linear_index; // (maximum index in _linear_index where data was written) + 1 size_t _linear_index_write_length; static struct PreviousRead { int ref_id = -1; int position; int end_position; int basesCovered() { return end_position - position; } Bin bin; bool is_unmapped; private char[256] _name_buf; // by spec., name length is <= 255 chars string name; VirtualOffset start_virtual_offset; VirtualOffset end_virtual_offset; } PreviousRead _prev_read; Stream _stream; int _n_refs; ulong _no_coord = 0; // metadata for each reference ulong _beg_vo = -1UL; ulong _end_vo = 0; ulong _unmapped = 0; ulong _mapped = 0; bool _first_read = true; // map: bin ID -> array of chunks Chunk[][uint] _chunks; VirtualOffset _current_chunk_beg; // start of current chunk // no metadata for empty references void writeEmptyReference() { _stream.write(cast(int)0); // n_bins _stream.write(cast(int)0); // n_intv } void updateLastReadInfo(ref BamReadBlock read) { with (_prev_read) { ref_id = read.ref_id; position = read.position; end_position = position + read.basesCovered(); bin = read.bin; is_unmapped = read.is_unmapped; _name_buf[0 .. read.name.length] = read.name[]; name = cast(string)_name_buf[0 .. read.name.length]; start_virtual_offset = read.start_virtual_offset; end_virtual_offset = read.end_virtual_offset; } } void updateMetadata(ref BamReadBlock read) { if (read.ref_id == -1) { ++_no_coord; } else if (read.is_unmapped) { ++_unmapped; } else { ++_mapped; } if (_beg_vo == -1UL) _beg_vo = cast(ulong)read.start_virtual_offset; _end_vo = cast(ulong)read.end_virtual_offset; } void updateLinearIndex() { assert(_prev_read.ref_id >= 0); size_t beg, end; if (_prev_read.is_unmapped) { end = beg = toLinearIndexOffset(_prev_read.position); } else { beg = toLinearIndexOffset(_prev_read.position); end = toLinearIndexOffset(_prev_read.position + _prev_read.basesCovered() - 1); } debug { import std.stdio; if (end >= _linear_index.length) { writeln("beg: ", beg); writeln("end: ", end); writeln("pos: ", _prev_read.position); writeln("bases: ", _prev_read.basesCovered()); } } foreach (i; beg .. end + 1) if (_linear_index[i] == 0UL) _linear_index[i] = _prev_read.start_virtual_offset; if (end + 1 > _linear_index_write_length) _linear_index_write_length = end + 1; } void dumpCurrentLinearIndex() { _stream.write(cast(int)_linear_index_write_length); // // There might be untouched places in linear index // with virtual offset equal to zero. // However, it's not a good idea to leave those zeros, // since we can start lookup from the last non-zero virtual offset // encountered before the untouched window. // VirtualOffset last_voffset = 0; foreach (voffset; _linear_index[0 .. _linear_index_write_length]) { if (voffset == 0) voffset = last_voffset; else last_voffset = voffset; _stream.write(cast(ulong)voffset); } } void dumpCurrentReference() { // +1 because we output dummy bin, too _stream.write(cast(int)(_chunks.length + 1)); foreach (bin_id, bin_chunks; _chunks) { if (bin_chunks.length > 0) { _stream.write(cast(uint)bin_id); _stream.write(cast(int)bin_chunks.length); foreach (chunk; bin_chunks) { _stream.write(cast(ulong)chunk.beg); _stream.write(cast(ulong)chunk.end); } } } _stream.write(cast(uint)37450); _stream.write(cast(int)2); _stream.write(cast(ulong)_beg_vo); _stream.write(cast(ulong)_end_vo); _stream.write(cast(ulong)_mapped); _stream.write(cast(ulong)_unmapped); dumpCurrentLinearIndex(); // reset data memset(_linear_index.ptr, 0, _linear_index.length * ulong.sizeof); _linear_index_write_length = 0; _chunks = null; _current_chunk_beg = _prev_read.end_virtual_offset; _beg_vo = _end_vo = cast(ulong)_current_chunk_beg; _unmapped = 0; _mapped = 0; } // adds chunk to the current bin (which is determined from _prev_read) void updateChunks() { auto current_chunk_end = _prev_read.end_virtual_offset; auto bin_id = _prev_read.bin.id; if (bin_id !in _chunks) _chunks[bin_id] = []; auto cs = _chunks[bin_id]; bool canMergeWithPreviousChunk() { assert(cs.length > 0); auto last_chunk = cs[$ - 1]; if (last_chunk.end.coffset == _current_chunk_beg.coffset) return true; return false; } if (cs.length == 0 || !canMergeWithPreviousChunk()) { auto new_chunk = Chunk(_current_chunk_beg, current_chunk_end); _chunks[_prev_read.bin.id] ~= new_chunk; } else { _chunks[_prev_read.bin.id][$ - 1].end = current_chunk_end; } _current_chunk_beg = current_chunk_end; } void checkThatBinIsCorrect(ref BamReadBlock read) { if (!check_bins) return; auto expected = reg2bin(read.position, read.position + read.basesCovered()); enforce(read.bin.id == expected, "Bin in read with name '" ~ read.name ~ "' is set incorrectly (" ~ to!string(read.bin.id) ~ " instead of expected " ~ to!string(expected) ~ ")"); } void checkThatInputIsSorted(ref BamReadBlock read) { if (_first_read) return; if (read.ref_id == -1) return; // unmapped if (_prev_read.ref_id < read.ref_id) return; enforce(read.ref_id == _prev_read.ref_id && read.position >= _prev_read.position, "BAM file is not coordinate-sorted: " ~ "read '" ~ read.name ~ "' (" ~ read.ref_id.to!string ~ ":" ~ read.position.to!string ~ ")" ~ " must be after read '" ~ _prev_read.name ~ "' (" ~ _prev_read.ref_id.to!string ~ ":" ~ _prev_read.position.to!string ~ ")" ~ "' (at virtual offsets " ~ to!string(_prev_read.start_virtual_offset) ~ ", " ~ read.start_virtual_offset.to!string ~ ")"); } } /// this(Stream output_stream, int number_of_references) { _stream = new EndianStream(output_stream, Endian.littleEndian); _n_refs = number_of_references; size_t size = BAI_MAX_BIN_ID - BAI_MAX_NONLEAF_BIN_ID + 1; _linear_index = new VirtualOffset[](size); _stream.writeString(BAI_MAGIC); // write BAI magic string _stream.write(cast(int)_n_refs); // and number of references } /// Check that bins are correct. bool check_bins; /// Add a read. The reads must be put in coordinate-sorted order. void put(BamReadBlock read) { checkThatInputIsSorted(read); scope(exit) updateMetadata(read); if (read.ref_id < 0) return; // start position is unavailable, skip if (read.position < 0) return; if (_first_read) { updateLastReadInfo(read); _first_read = false; _current_chunk_beg = read.start_virtual_offset; if (read.ref_id > 0) foreach (i; 0 .. read.ref_id) writeEmptyReference(); return; } checkThatBinIsCorrect(read); // new reference, so write data for previous one(s) if (read.ref_id > _prev_read.ref_id) { updateLinearIndex(); updateChunks(); dumpCurrentReference(); foreach (i; _prev_read.ref_id + 1 .. read.ref_id) writeEmptyReference(); } if (read.ref_id == _prev_read.ref_id) { updateLinearIndex(); if (read.bin.id != _prev_read.bin.id) updateChunks(); } updateLastReadInfo(read); } /// Closes the stream void finish() { if (!_first_read) { // at least one was processed assert(_prev_read.ref_id >= 0); updateLinearIndex(); updateChunks(); dumpCurrentReference(); } // _prev_read.ref_id == -1 if all are unmapped foreach (i; _prev_read.ref_id + 1 .. _n_refs) writeEmptyReference(); _stream.write(cast(ulong)_no_coord); _stream.close(); } } /// Writes BAM index to the $(D stream) /// /// Accepts optional $(D progressBarFunc) void createIndex(BamReader bam, Stream stream, bool check_bins=false, void delegate(lazy float p) progressBarFunc=null) { auto n_refs = cast(int)bam.reference_sequences.length; auto index_builder = IndexBuilder(stream, n_refs); index_builder.check_bins = check_bins; auto reads = bam.readsWithProgress!withOffsets(progressBarFunc); foreach (read; reads) index_builder.put(read); index_builder.finish(); }
D
// An example building a binary heap. import std.container; import std.stdio; struct Load { int id, load; int opCmp(Load s2) { return load-s2.load; } Load inc() { load++; return this; } } void main() { // Test ordering relation Load s1 = {0, 10}; Load s2 = {1, 0}; assert(s2 < s1); auto s3 = s2.inc(); s3.load=20; writeln(s2, s3); // Initialize the array Load[] arr = new Load[3]; foreach (int i, ref Load a1; arr) { a1.id = i; a1.load = cast(int)(arr.length) - i; } writeln(arr); // Heapify auto h = heapify!"a>b"(arr,arr.length); writeln(arr); arr[0].load = 10; h = heapify!"a>b"(arr); writeln(arr); foreach(int i; 1..5) { writeln("---"); h.replaceFront(h.front().inc()); writeln(arr); } }
D