String
extension String
-
Given a string returned by
assemblySanitized, creates an instance decoding its contents.Declaration
Swift
public init?(assemblySanitized sanitized: String) -
trueiffselfis suitable as an identifier in LLVM assembly.Complexity
O(n) where n is the length ofself.Declaration
Swift
public var isAssemblySuitable: Bool { get } -
Returns an encoding of
selfsanitized for use as an identifier in LLVM assembly.selfis returned unchanged if and only if it does not contain any dollar sign (“$”) andself.isAssemblySuitableistrue. Otherwise, the returned value is the concatenation of two strings ofBase64Digitseparated by a unique occurrence of the dollar sign. The part on the LHS is called the payload, the other is called the instruction sequence.The payload contains a copy of the characters in
selfthat are allowed in LLVM assembly identifiers, in the same order. The instruction sequence is a list of pairs(d, p)wherepis a code point andddenotes the position at whichpshould be inserted to decode the string. Both values are encoded as instances ofBase64VarUInt.The decoding of a sanitized payload can be described as follows:
var offset = 0 for (d, p) in instructions { offset += d payload.insert(p, at: d) }For example, let the input be the mangled string “infix$5P91Pa”. The payload is “infix” and the instruction sequence is composed of the pairs (“5”, “P9”) and (“1”, “Pa”). The first indicates that the unicode point 60 must be inserted in the payload at offset 5. The second indicates that the unicode point 61 must be inserted in the payload at offset 5 + 1.
Declaration
Swift
public var assemblySanitized: String { get }
View on GitHub