[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [NSExceptional]\n"
  },
  {
    "path": ".gitignore",
    "content": "# Xcode\n.DS_Store\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\n!default.xcworkspace\nxcuserdata\nprofile\n*.moved-aside\nDerivedData\n.idea/\n\n*.xcbkptlist\n*.xccheckout\n*.hmap\n*.ipa\n\n*.swp\n*.lock\n*.xcuserstate\n\nLuna.xcworkspace/xcuserdata/tantan.xcuserdatad/UserInterfaceState.xcuserstate\n\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n# Thumbnails\n._*\n\n# Files that might appear on external disk\n.Spotlight-V100\n.Trashes\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk"
  },
  {
    "path": "README.md",
    "content": "# Runtime\n\nAn Objective-C simulator written in Swift.\n\n## Goals\n\nWith few exceptions, this project aims to simulate, in Swift, how Objective-C works under the hood (i.e. calls to `objc_msgSend`, inserted ARC functions, literal class-refs in class method calls, etc), as opposed to mirroring Objective-C style code and dynamism which Swift can accomplish already via `@objc` classes.\n\nThis project could theoretically be used as a dynamic runtime backend for a transpiled progamming language, and as such, this framework and its conventions were crafted with this idea in mind. Many of the constructs used here may seem to lack type-safety, but everything is perfectly safe if the code is generated by some other, more type-safe language. In short, this code is not meant to be written by hand if used for anything serious.\n\n## Features\n\n- Dynamic method dispatch\n- Method swizzling / replacing\n- Creating entire classes at runtime\n- Non-fragile ivars\n\nSee `Person.Swift` for an examples of everything mentioned in the readme.\n\n## Overview\n\nRuntime metadata types provided by this framework mirrors that of the public Objective-C runtime interface as closely as possible, declaring types such as `Class`, `Ivar`, `Method`, etc, all of which provide about as much information as their Objective-C counterparts.\n\n### Defining classes\n\nA base class, `RootObject`, is provided for other classes to inherit from if they wish. New classes are defined by declaring a `struct` type to enclose the `Class` object in, with the class object itself being declared as a `static let`, followed by method variables.\n\n```swift\nstruct Person {\n    static let `class` = Class(\n        isa: Person_meta.class,\n        superclass: RootObject.class,\n        name: \"Person\",\n        ivars: [\n            (name: \"_name\", type: .string),\n            (name: \"_age\", type: .integer)\n        ],\n        methods: [_init, name, setName_, age, setAge_, description],\n        properties: [\n            Property(name: \"name\", getter: name, setter: setName_),\n            Property(name: \"age\", getter: age, setter: setAge_),\n        ],\n        protocols: []\n    )\n    \n    // Methods go here as static vars\n    \n    static var _init = Method(\"init\", returns: .object(\"this\")) { this, _cmd, args in\n        func init$(_ this: id, _ _cmd: SEL) -> id {\n            _msgSend(this, \"setName_\", (\"Bob\"))\n            _msgSend(this, \"setAge_\", (18))\n\n            return msgSend(super: true, this, _cmd)\n        }\n\n        return init$(this, _cmd)\n    }\n    \n    static var name = Method(\"name\", returns: .string) ...\n    ...\n}\n\nprivate struct Person_meta {\n    static let `class` = Class(\n        isa: nil,\n        superclass: nil,\n        name: \"Person.meta\",\n        ...\n    )\n}\n```\n\nIt is good practice to declare a struct for the class itself and another for the metaclass, as above, to reduce ambiguity between class members and instance members (methods, properties, etc). The metaclass stores class members.\n\n`isa:` should be the class's metaclass (or `nil` if the class is a metaclass itself). `superclass:` should be the superclass.\n\n#### The Metaclass\n\nMetaclasses inherit from the super-metaclass, not the superclass. It is convention to declare the compile-time variable like `MyClass_meta` and name it `\"MyClass.meta\"`. So, `Person` inherits from `Object.class`, and `Person_meta` inherits from `Object_meta.class`.\n\nEach metaclass can be looked up by using `Class.named(\"Foo\").isa` or directly by name with `Class.named(\"Foo.meta\")`.\n\n#### Methods\n###### Declaration\n\n`Method`s should be defined as `static var/let` as well (as opposed to right inside the `methods:` argument to the `.class` initializer as I have done with `properties:`), in case you need to reference the method as an argument to a `Property` at compile-time. Declaring them inline also makes the initializer very hard to parse visually since method declarations are typically no less than 7 or 8 lines.\n\n###### Method.init() structure\n\nThe `Method` initializer takes the name of the method, the return and argument types (`Type`) an implementation (`IMP`). The return and argument types default to `.void` and `[]`. For initializers, it is convention to return `.object(\"self\")` where you would use `instancetype` in Objective-C. You could use `.object(\"anything you want\")`, but I find that `\"self\"` makes the most sense here. In cases where you return another object of a fixed type, use `.object(\"ClassName\")`. This runtime aims to provide as much metadata for method type signatures as Objective-C does for property type signatures.\n\n###### IMP arguments\n\nLike Objective-C, all methods take two fixed arguments: `this` in place of `self`, and `_cmd`. However, due to limitations in the Swift type system, all method `IMP`s must return the same thing, `Any`, and without using assembly, they must all take `Any` as the variable arguments, even if a method takes no other arguments. An `IMP` is invoked by passing `this`, `_cmd`, and `args` where `args` is a tuple of the non-fixed arguments to the method.\n\n###### Implementation conventions\n\nTo counteract the lack of type safety and enhance readability, I find it helpful to declare a function within the scope of the method `IMP` named with a traling `$` to represent the actual type signature of the method (and to hold the non-trivial implementation), like so:\n\n```swift\nstatic var add__ = Method(…) { this, _cmd, args in\n    // Actual implementation and type signature of method\n    func add__$(_ this: id, _ _cmd: SEL, a: Int, b: Int) -> Int {\n        return a + b\n    }\n        \n    // Cast out arguments and call method\n    let args = args as! (Int, Int)\n    return add__$(this, _cmd, args.0, args.1)\n}\n```\n\nArguments must be cast from `Any` to their actual types as a tuple before being used.\n\n###### Overriding methods\n\nTo override a method, simply give your subclass another method with the same name as the method you wish to override. If you need to call the `super` implementation, simply pass `super: true` to your call to `msgSend`:\n\n```swift\nstatic var _init = Method(\"init\", ...) { this, _cmd, args in\n    func init$(_ this: id, _ _cmd: SEL) -> id {\n        return msgSend(super: true, this, _cmd)\n        print(\"init override: \\(this)\")\n    }\n\n    return init$(this, _cmd)\n}\n```\n\n###### Init\n\nIf you're familiar with Swift, you may know that Swift doesn't allow you to use `self` before all ivars have been initialized. With some exceptions, the same is true here. That said, all ivars are initialized to `0` or `nil`, so it is not necessary to initialize primitive integral types to `nil` or `0`.\n\n> Technically, if a class has no stored complex Swift structures in it (such as `String`), it should be safe to use prior to ivar initialization. I plan to make a wrapper for `String` and `Array`, etc, to counteract these edge cases.\n\n\n#### Instance variables\n\nIvars are passed to the `Class` initializer as a tuple of their name and type. Their offset is detremined at runtime, and as a result, classes do not have fragile ivars.\n\n> Metaclasses can not have any instance variables; trying to use ivars on a metaclass is undefined behavior.\n\n#### Properties\n\nProperties take a name and one or two implementations. A property's `type` comes from its `getter`.\n\n--\n\n### Creating objects\n\nInstances of objects are allocated by calling `class.createInstance()`, i.e.:\n\n```swift\nlet instance1 = Person.class.createInstance()\nlet instance2 = Class.named(\"Person\").createInstance()\n```\n\n### Calling methods\n\nLike Objective-C, this runtime uses dynamic dispatch via the `msgSend` and `_msgSend` functions. `_msgSend` only exists as a shortcut for void-returning methods, or cases where you want to discard the return value.\n\n```swift\nlet bob: id = msgSend(Person.class.createInstance(), \"init\")\nlet name: String = msgSend(bob, \"name\")\nlet age: Int = msgSend(bob, \"age\")\nlet description: String = msgSend(bob, \"description\")\n```\n\n### Accessing ivars\n\nIvar access works similarly to how it works in Objective-C. You must retrieve the offset from the runtime and add it to `this` to access the ivar. A lot of casting is involved, and I've provided some operators to ease the pain:\n\n```swift\nlet offset = this|.getClass.getIvarOffset(\"_someInt\")!\nlet pointer: Pointer<Int> = ~pointer + offset\nlet ivarValue = pointer.pointee\n```\n\n`this|` is shorthand for `this.pointee`. `~pointer` is shorthand for `unsafeBitCast(pointer, to: T.self)`. Note that the runtime uses its own `Pointer` type, which allows `+` to offset it by bytes at at time.\n\nThe above is still pretty convoluted and heavily repeated, so I've provided yet another operator which returns `ivarValue` above:\n\n```swift\nlet ivarValue: Int = this|\"_someInt\"\n```\n\nIn general, `|` provides some form of dereferencing an object pointer. Here is another operator which can be used to set an ivar `_foo` to `5`:\n\n```swift\nthis |= (5, \"_foo\")\n```\n\n--\n\n### Type system \"gotchas\"\n\n#### You're stuck with `id`\nSince new classes are weakly defined as runtime metadata and not as concrete types in Swift code, you cannot declare a `Pointer` to a custom type directly. That is, all object references are typed as `Pointer<Object>` aka `id`, as defined by `Object.swift` (not to be confused with `RootObject`, which is akin to `NSObject`).\n\nIf you really want to declare a `Pointer<Vehicle>` for example, you could declare members on your `Vehicle ` struct like so, alongside the `static let class` declaration:\n\n```swift\nstruct Vehicle {\n    let _super: Object\n    let _capacity: Int\n    ...\n    \n    static let `class` = Class(isa: ...)\n}\n\n/// Vehicle subclass\nstruct Car {\n    let _super: Vehicle\n    let make: String\n    let model: String\n    let year: Int\n    ...\n    \n    static let `class` = Class(isa: ...)\n}\n```\n\nNow, you could possibly do the following:\n\n```swift\nlet fiesta: Pointer<Car> = msgSend(\n    Car.class.createInstance(),\n    \"init\",\n    (\"Ford\", \"Fiesta\", 2014, ...)\n)\nfiesta.year = 2017\n```\n\nBe sure to continue to declare all ivars and methods inside the `Class` variable. Statically declaring the layout like this is only useful for extra type-safety and direct ivar access if you wish to bypass non-fragile ivar lookup.\n\n#### Using `Class`es as objects\n\n`Class` instances could only be made possible by making `Class` a Swift `class` and not a `struct`, due to limitations in Swift's type system and several abstractions Swift imposes on the user. Therefore, they do not have the same underlying structure as `Object` does (that is, `Class` does not start with the `isa` defined by the `Object` declaration). To call a class method on a class, pass `.ref` as `this`:\n\n```swift\n_msgSend(Person.class.ref, \"someClassMethod\")\n```\n\nIn general, use `class.ref` whenever you wish to treat a `Class` as an object.\n    \n### Other caveats\n\n`Class` objects will not be available via `Class.named(_:)` until they have been accessed statically. You should \"load\" these classes manually by accessing all classes you define, like so:\n\n```swift\nfunc runtimeInit() {\n    // Runtime initialization\n    _ = RootObject.class\n    _ = Person.class\n    ...\n}\n```\n\nIdeally this shouldn't be necessary, or should be easier. Please submit a pull request if you have suggestions on how to make this easier or unnecessary!\n\n---\n\n## To-do\n\n- More tests\n- Zeroing deallocated references\n- Suggestions welcome!\n"
  },
  {
    "path": "Runtime/Class.swift",
    "content": "//\n//  Class.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic class Class {\n    public let isa: Class! // metaclass, nil for metaclasses\n    let magic: UInt = 0xAAAABBBBCCCCDDDD // for debugging purposes, will be removed\n    public let superclass: Class! // nil if no superclass\n    public let name: String\n    public let instanceSize: Int\n\n    /// Instance class property-backing variables\n    let ivars: [Ivar]\n    /// Instance or class methods\n    let methods: [SEL: Method]\n    /// Instance or class properties\n    let properties: [Property]\n    /// Protocols conformed to by instances; not applicable to classes\n    let protocols: [Protocol]\n\n    private static let __swobjSize = 16\n    /// Used to refer to the class as an object.\n    /// Temporary workaround since class objects themselves\n    /// already have an `isa` provided by Swift.\n    public var ref: id {\n        var ptr: id = ~self\n        ptr += Class.__swobjSize\n        return ptr\n    }\n\n    public init(isa: Class!, superclass: Class?, name: String,\n        ivars stubs: [Ivar.Stub] = [], methods: [Method] = [], properties: [Property] = [], protocols: [Protocol] = [], extraBytes: Int = 0) {\n        let offset = superclass?.instanceSize ?? Type.pointer(.class(\"\")).size\n\n        self.isa = isa\n        self.superclass = superclass\n        self.name = name\n        self.instanceSize = offset + stubs.map { return $0.type.size }.reduce(0, +) + extraBytes\n\n        self.ivars = Ivar.make(from: stubs, offset)\n        self.properties = properties\n        self.protocols = protocols\n        self.methods = {\n            var dict: [SEL: Method] = [:]\n            for method in methods {\n                dict[method.name] = method\n            }\n\n            return dict\n        }()\n\n        Class.classList.append(self)\n    }\n\n    public func createInstance() -> id {\n        let instance = Pointer<Object>.calloc(self.instanceSize)\n        instance.pointee.isa = self\n        return instance\n    }\n\n    public func method(named: String) -> Method! {\n        return self.methods[named]\n    }\n\n    public func ivar(named name: String) -> Ivar! {\n        return self.ivars.filter { $0.name == name }.first\n    }\n\n    public func property(named  name: String) -> Property! {\n        return self.properties.filter { $0.name == name }.first\n    }\n\n    public func conforms(to protocol: String) -> Bool {\n        return !self.protocols.filter { $0.name == name }.isEmpty\n    }\n\n    public func getIvarOffset(_ name: String) -> Int! {\n        return self.ivar(named: name)?.offset\n    }\n\n    public func getMethodIMP(_ sel: SEL) -> IMP? {\n        return self.method(named: sel)?.imp\n    }\n\n    public static func isClass(_ object: id) -> Bool {\n        if object|.isa == nil {\n            // Metaclass.isa -> nil\n            return true\n        } else if object|.isa.isa == nil {\n            // Class.isa -> metaclass.isa -> nil\n            return true\n        } else {\n            // Object.isa -> Class.isa -> metaclass.isa -> nil\n            return false\n        }\n    }\n}\n\npublic extension Class {\n    static var classList: [Class] = []\n\n    public static func named(_ name: String) -> Class! {\n        return Class.classList.filter { $0.name == name }.first\n    }\n}\n"
  },
  {
    "path": "Runtime/ClassBuilder.swift",
    "content": "//\n//  ClassBuilder.swift\n//  Runtime\n//\n//  Created by Tanner on 10/21/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic class ClassBuilder {\n    public var superclass: Class?\n    public var name: String\n    public var extraBytes: Int\n\n    private var final = false\n    private var methods: OrderedSet<Method> = []\n    private var classMethods: OrderedSet<Method> = []\n    private var ivars: OrderedSet<IvarStub> = []\n    private var properties: OrderedSet<Property> = []\n    private var classProperties: OrderedSet<Property> = []\n    private var protocols: OrderedSet<Protocol> = []\n\n    /// - Warning: returns nil if a class with the given name already exists.\n    public init?(name: String, superclass: Class? = RootObject.class, extraBytes: Int = 0) {\n        if Class.named(name) != nil {\n            return nil\n        }\n\n        self.superclass = superclass\n        self.name = name\n        self.extraBytes = extraBytes\n    }\n\n    /// Actually creates the class and adds it to the runtime.\n    ///\n    /// The class you are constructing cannot be used until it is finalized.\n    /// - Returns: The newly created class.\n    public func finalize() -> Class {\n        let metaclass = Class(\n            isa: nil,\n            superclass: self.superclass?.isa,\n            name: self.name + \".meta\",\n            ivars: [],\n            methods: self.classMethods.array,\n            properties: self.classProperties.array,\n            protocols: []\n        )\n        let cls = Class(\n            isa: metaclass,\n            superclass: self.superclass,\n            name: self.name,\n            ivars: self.ivars.array.map({ $0.stub }),\n            methods: self.methods.array,\n            properties: self.properties.array,\n            protocols: self.protocols.array,\n            extraBytes: self.extraBytes\n        )\n\n        self.final = true\n        Class.classList.append(cls)\n        return cls\n    }\n\n    public func add(_ methods: [Method], toClass: Bool = false) {\n        if toClass {\n            self.classMethods.addAll(methods)\n        } else {\n            self.methods.addAll(methods)\n        }\n    }\n\n    public func add(_ ivars: [IvarStub]) {\n        self.ivars.addAll(ivars)\n    }\n\n    public func add(_ properties: [Property], toClass: Bool = false) {\n        if toClass {\n            self.classProperties.addAll(properties)\n        } else {\n            self.properties.addAll(properties)\n        }\n    }\n\n    public func add(_ protocols: [Protocol]) {\n        self.protocols .addAll(protocols)\n    }\n\n    public struct IvarStub: Hashable {\n        let name: String\n        let type: Type\n\n        fileprivate var stub: Ivar.Stub { return (name, type) }\n\n        public var hashValue: Int {\n            return self.name.hashValue\n        }\n\n        public static func ==(lhs: IvarStub, rhs: IvarStub) -> Bool {\n            return lhs.name == rhs.name\n        }\n    }\n}\n"
  },
  {
    "path": "Runtime/DebugDescriptions.swift",
    "content": "//\n//  DebugDescriptions.swift\n//  Runtime\n//\n//  Created by Tanner on 10/21/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\nextension Class: CustomDebugStringConvertible, CustomStringConvertible, CustomPlaygroundQuickLookable {\n    public var customPlaygroundQuickLook: PlaygroundQuickLook {\n        return .text(self.name)\n    }\n    \n    public var description: String {\n        return self.name\n    }\n    \n    public var debugDescription: String {\n        var me = self\n        return \"\"\"\n<Class \\(self.name) (\\(|me))> {\n    isa:        \\(self.isa?.name ?? \"nil\"),\n    superclass: \\(self.superclass?.name ?? \"nil\"),\n    methods:    \\(self.methods.count),\n    properties: \\(self.properties.count),\n    protocols:  \\(self.protocols.count),\n}\n\"\"\"\n    }\n}\n"
  },
  {
    "path": "Runtime/Ivar.swift",
    "content": "//\n//  Ivar.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic struct Ivar: Hashable {\n    public typealias Stub = (name: String, type: Type)\n    \n    public let name: String\n    public let type: Type\n    public let offset: Int\n\n    public var hashValue: Int {\n        return self.name.hashValue\n    }\n\n    public static func ==(lhs: Ivar, rhs: Ivar) -> Bool {\n        return lhs.name == rhs.name\n    }\n}\n\nextension Ivar {\n    static func make(from stubs: [Stub], _ offset: Int) -> [Ivar] {\n        var offsett = offset\n        return stubs.map { stub -> Ivar in\n            defer { offsett += stub.type.size }\n            return Ivar(name: stub.name, type: stub.type, offset: offsett)\n        }\n    }\n}\n"
  },
  {
    "path": "Runtime/Method.swift",
    "content": "//\n//  Method.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic class Method: Hashable {\n    public typealias Signauture = (returnType: Type, argumentTypes: [Type])\n    \n    public let name: String\n    public var imp: IMP\n    public let returnType: Type\n    public let argumentTypes: [Type]\n\n    public var signature: Signauture {\n        return (self.returnType, self.argumentTypes)\n    }\n\n    public init(_ name: String, returns: Type = .void, args: [Type] = [], _ imp: @escaping IMP) {\n        self.name = name\n        self.returnType = returns\n        self.argumentTypes = args\n        self.imp = imp\n    }\n\n    convenience public init(name: String, signature: Signauture = (.void, []), _ imp: @escaping IMP) {\n        self.init(name, returns: signature.returnType, args: signature.argumentTypes, imp)\n    }\n\n    public var hashValue: Int {\n        return self.name.hashValue\n    }\n\n    public static func ==(lhs: Method, rhs: Method) -> Bool {\n        return lhs.name == rhs.name\n    }\n}\n"
  },
  {
    "path": "Runtime/Object.swift",
    "content": "//\n//  Object.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic struct Object {\n    var isa: Class!\n\n    public var getClass: Class {\n        return self.isa\n    }\n\n    public func respondsTo(_ selector: SEL) -> Bool {\n        return self.isa.getMethodIMP(selector) != nil\n    }\n}\n\nextension Pointer: CustomStringConvertible, CustomDebugStringConvertible {\n    public var debugDescription: String { return self.description }\n    public var description: String {\n        if Pointee.self is Object.Type {\n            let this: id = ~self\n            if this|.respondsTo(\"description\") {\n                return msgSend(this, \"description\")\n            } else {\n                return \"<\\(this|.getClass) \\(self.raw.debugDescription)>\"\n            }\n        }\n\n        return self.raw.debugDescription\n    }\n}\n"
  },
  {
    "path": "Runtime/OrderedSet.swift",
    "content": "//\n//  OrderedSet.swift\n//  Runtime\n//\n//  Created by Tanner on 10/23/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\nclass OrderedSet<T: Hashable>: ExpressibleByArrayLiteral {\n    var array: [T] = []\n    var set: Set<T> = []\n\n    init() { }\n\n    /// - Returns: true if the element was not already in the set, false otherwise\n    @discardableResult\n    func add(_ element: T) -> Bool {\n        if self.set.insert(element).inserted {\n            array.append(element)\n            return true\n        }\n\n        return false\n    }\n\n    /// - Returns: true if all elements were not already in the set, false otherwise\n    @discardableResult\n    func addAll(_ elements: [T]) -> Bool {\n        var allIn = true\n        for e in elements {\n            if !self.add(e) {\n                allIn = false\n            }\n        }\n\n        return allIn\n    }\n\n    required init(arrayLiteral elements: T...) {\n        self.addAll(elements)\n    }\n}\n"
  },
  {
    "path": "Runtime/Platform.swift",
    "content": "//\n//  Platform.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\nstruct Platform {\n    static let is64Bit = MemoryLayout<Int>.size == MemoryLayout<Int64>.size\n}\n"
  },
  {
    "path": "Runtime/Pointer.swift",
    "content": "//\n//  Pointer.swift\n//  MirrorKit.swift\n//\n//  Created by Tanner on 8/25/17.\n//\n\nimport Foundation\n\nextension UnsafeMutableRawPointer {\n    @inline(__always)\n    init<T>(to thing: inout T) {\n        self = withUnsafeMutablePointer(to: &thing) { UnsafeMutableRawPointer($0) }\n    }\n}\n\nprefix operator ~\npublic prefix func ~<T,U>(thing: T) -> U {\n    return unsafeBitCast(thing, to: U.self)\n}\n\ninfix operator |=\n/// Shorthand ivar set\npublic func |=<T>(pointer: id, change: (value: T, ivar: String)) {\n    let offset = pointer|.getClass.getIvarOffset(change.ivar)!\n    let pointer: Pointer<T> = ~pointer + offset\n    pointer.pointee = change.value\n}\n\ninfix operator |\n/// Shorthand ivar get\npublic func |<T>(pointer: id, ivar: String) -> T {\n    let offset = pointer|.getClass.getIvarOffset(ivar)!\n    let ivarPtr: Pointer<T> = ~(pointer + offset)\n    return ivarPtr.pointee\n}\n\npostfix operator |\n/// Shorthand for .pointee\npublic postfix func |<T>(pointer: Pointer<T>) -> T {\n    return pointer.pointee\n}\n\nprefix operator |\n/// Shorthand for .pointee\n@inline(__always)\npublic prefix func |<T>(pointee: inout T) -> Pointer<T> {\n    return Pointer(to: &pointee)\n}\n\npublic struct Pointer<Pointee>: Strideable, Hashable, Equatable {\n\n    // MARK: Public\n\n    public let raw: UnsafeMutableRawPointer\n    public var pointee: Pointee {\n        get { return self.read() }\n        nonmutating set { return self.write(newValue) }\n    }\n\n    // Get a Pointer to some variable\n    public init<T>(to thing: inout T) {\n        self.raw = UnsafeMutableRawPointer(to: &thing)\n    }\n\n    // Convert some variable, which is already a \"pointer\" itself, into a Pointer\n    public init(from pointer: inout Any) {\n        self.raw = ~pointer\n    }\n\n    public func read<T>(byteOffset: Int = 0) -> T {\n        return self.raw.load(fromByteOffset: byteOffset, as: T.self)\n    }\n\n    public func write<T>(_ value: T, byteOffset: Int = 0) {\n        self.raw.storeBytes(of: value, toByteOffset: byteOffset, as: T.self)\n    }\n\n    // MARK: Memory management\n\n    public static func alloc(_ count: Int) -> Pointer {\n        return Pointer(raw: UnsafeMutablePointer.allocate(capacity: count))\n    }\n\n    public static func calloc(_ count: Int) -> Pointer {\n        #if os(Linux)\n            return Pointer(raw: Glibc.calloc(count, 1))\n        #else\n            return Pointer(raw: Darwin.calloc(count, 1))\n        #endif\n    }\n\n    public func free() {\n        #if os(Linux)\n            Glibc.free(self.raw)\n        #else\n            Darwin.free(self.raw)\n        #endif\n    }\n\n    public func free(_ count: Int) {\n        self.raw.deallocate(bytes: count, alignedTo: MemoryLayout<Pointee>.alignment)\n    }\n\n    // MARK: Private\n\n    init(raw pointer: UnsafeMutableRawPointer) {\n        self.raw = pointer\n    }\n\n    // MARK: Strideable\n\n    public func distance(to other: Pointer) -> Int {\n        return self.raw.distance(to: other.raw)\n    }\n\n    public func advanced(by n: Int) -> Pointer {\n        return Pointer(raw: self.raw.advanced(by: n))\n    }\n\n    // MARK: Hashable\n\n    public var hashValue: Int {\n        return self.raw.hashValue\n    }\n\n    // MARK: Convenience\n\n    public static func +(lhs: Pointer, rhs: Int) -> Pointer {\n        return lhs.advanced(by: rhs)\n    }\n\n    public static func -(lhs: Pointer, rhs: Int) -> Pointer {\n        return lhs.advanced(by: -rhs)\n    }\n\n    public static func +=(lhs: inout Pointer, rhs: Int) {\n        lhs = lhs.advanced(by: rhs)\n    }\n\n    public static func -=(lhs: inout Pointer, rhs: Int) {\n        lhs = lhs.advanced(by: -rhs)\n    }\n\n    public static postfix func ++(pointer: inout Pointer) {\n        pointer = pointer.advanced(by: 1)\n    }\n\n    public static postfix func --(pointer: inout Pointer) {\n        pointer = pointer.advanced(by: -1)\n    }\n}\n"
  },
  {
    "path": "Runtime/Property.swift",
    "content": "//\n//  Property.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic struct Property: Hashable, Equatable {\n    public let name: String\n    public let getter: Method\n    public let setter: Method!\n\n    public var type: Type {\n        return self.getter.returnType\n    }\n\n    public var hashValue: Int {\n        return self.name.hashValue\n    }\n\n    public static func ==(lhs: Property, rhs: Property) -> Bool {\n        return lhs.name == rhs.name\n    }\n}\n"
  },
  {
    "path": "Runtime/Protocol.swift",
    "content": "//\n//  Protocol.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic class Protocol: Hashable {\n    public let name: String\n    public let methods: [Method]\n\n    public init(name: String, methods: [Method]) {\n        self.name = name\n        self.methods = methods\n    }\n\n    public var hashValue: Int {\n        return self.name.hashValue\n    }\n\n    public static func ==(lhs: Protocol, rhs: Protocol) -> Bool {\n        return lhs.name == rhs.name\n    }\n}\n\npublic extension Protocol {\n    static var protocolList: [Protocol] = []\n\n    public static func named(_ name: String) -> Protocol! {\n        return Protocol.protocolList.filter { $0.name == name }.first\n    }\n}\n"
  },
  {
    "path": "Runtime/RootObject.swift",
    "content": "//\n//  RootObject.swift\n//  Runtime\n//\n//  Created by Tanner on 10/19/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\n/// New classes are defined as static instances within an extension on Class itself.\n/// Methods, ivars, properties, etc for these new classes are defined as below.\npublic struct RootObject {\n    static let `class` = Class(\n        isa: RootObject_meta.class,\n        superclass: nil,\n        name: \"Object\",\n        ivars: [(\"isa\", .pointer(.class(\"self\"))), (\"_retainCount\", .integer)],\n        methods: [_init, retain, retainCount]\n    )\n\n    static var _init = Method(\"init\", returns: .object(\"self\")) { this, _cmd, args in\n        func init$(_ this: id, _ _cmd: SEL) -> id {\n            print(\"\\(this|.getClass).init(): \\(this)\")\n            return this\n        }\n\n        return init$(this, _cmd)\n    }\n\n    static var retain = Method(\"retain\", returns: .object(\"self\")) { this, _cmd, args in\n        func retain$(_ this: id, _ _cmd: SEL) -> id {\n            let newCount: Int = (this|\"_retainCount\") + 1\n            this |= (newCount, \"_retainCount\")\n            return this\n        }\n\n        return retain$(this, _cmd)\n    }\n\n    static var release = Method(\"release\") { this, _cmd, args in\n        func release$(_ this: id, _ _cmd: SEL) {\n            let newCount: Int = (this|\"_retainCount\") - 1\n            this |= (newCount, \"_retainCount\")\n            if newCount < 1 {\n                if newCount < 0 {\n                    fatalError(\"Over-released object at \\(this.raw.debugDescription)\")\n                }\n                \n                this.free()\n            }\n        }\n\n        release$(this, _cmd)\n        return ()\n    }\n\n    static var retainCount = Method(\"retainCount\", returns: .integer) { this, _cmd, args in\n        func retainCount$(_ this: id, _ _cmd: SEL) {\n            return this|\"_retainCount\"\n        }\n\n        retainCount$(this, _cmd)\n        return ()\n    }\n}\n\npublic struct RootObject_meta {\n    static let `class` = Class(\n        isa: nil,\n        superclass: nil,\n        name: \"Object.meta\"\n    )\n}\n"
  },
  {
    "path": "Runtime/Runtime.swift",
    "content": "//\n//  Runtime.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic typealias id = Pointer<Object>\npublic typealias SEL = String\npublic typealias IMP = (_ self: id, _ _cmd: SEL, _ args: Any) -> Any\n\n@inline(__always) func prepareMsg(_ target: id, _ _cmd: SEL, super: Bool) -> IMP {\n    let isClass = Class.isClass(target)\n    var cls: Class!\n    if isClass {\n        cls = `super` ? target|.isa.superclass! : target|.isa\n    } else {\n        cls = `super` ? target|.getClass.superclass! : target|.getClass\n    }\n\n    var imp: IMP!\n    repeat {\n        imp = cls.getMethodIMP(_cmd)\n        cls = cls.superclass\n    } while imp == nil && cls != nil\n    \n    guard imp != nil else {\n        let isClass = Class.isClass(target)\n        let invocation = (isClass ? \"+\" : \"-\") + \"[\\(target|.getClass.name) \\(_cmd)]\"\n        fatalError(\"Unrecognized selector sent to instance \\(target.raw): \" + invocation)\n    }\n\n    return imp\n}\n\n/// Dynamically calls a method on a `Foo` instance given a method name (like objc_msgSend)\npublic func msgSend<T>(super: Bool = false, _ target: id, _ _cmd: SEL, _ args: Any = ()) -> T {\n    let imp = prepareMsg(target, _cmd, super: `super`)\n    return imp(target, _cmd, args) as! T\n}\n\n/// Convenience for `Void` or discardable results\npublic func _msgSend(super: Bool = false, _ target: id, _ _cmd: SEL, _ args: Any = ()) {\n    let imp = prepareMsg(target, _cmd, super: `super`)\n    _ = imp(target, _cmd, args)\n}\n"
  },
  {
    "path": "Runtime/Struct.swift",
    "content": "//\n//  Struct.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\n/// As of now, purely for metadata purposes.\n/// Provides no way to create and use structs.\n/// It may make more sense just to use standard Swift structs\n/// alongside instances of `Struct` for reflection purposes.\npublic class Struct {\n    let name: String\n    let instanceSize: Int\n\n    let ivars: [Ivar]\n    let methods: [Method]\n    let properties: [Property]\n\n    public init(name: String, instanceSize: Int, ivars: [Ivar.Stub] = [], methods: [Method] = [], properties: [Property] = []) {\n        self.name = name\n        self.instanceSize = instanceSize\n        self.ivars = Ivar.make(from: ivars, 0)\n        self.methods = methods\n        self.properties = properties\n    }\n}\n\npublic extension Struct {\n    static var structList: [Struct] = []\n\n    public static func named(_ name: String) -> Struct! {\n        return Struct.structList.filter { $0.name == name }.first\n    }\n}\n\npublic extension Struct {\n    public var describedAsTuple: String {\n        return \"(\" + self.ivars.map({ ivar in\n            if !ivar.name.isEmpty {\n                return ivar.name + \": \" + ivar.type.description\n            } else {\n                return ivar.type.description\n            }\n        }).joined(separator: \", \")\n    }\n\n    public var typeEncoding: String {\n        return \"\"\n    }\n}\n"
  },
  {
    "path": "Runtime/Types.swift",
    "content": "//\n//  Types.swift\n//  Runtime\n//\n//  Created by Tanner on 10/18/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport Foundation\n\npublic indirect enum Type {\n    case void\n    case pointer(Type)\n    case integer\n    case float\n    case bool\n    case string\n    case tuple(String)\n    case optional(Type)\n    case object(String)\n    case `struct`(String)\n    case `class`(String)\n\n    public var description: String {\n        switch self {\n        case .void:\n            return \"Void\"\n        case .pointer(let type):\n            return \"Pointer<\\(type)>\"\n        case .integer:\n            return \"Integer\"\n        case .float:\n            return \"Float\"\n        case .bool:\n            return \"Bool\"\n        case .string:\n            return \"String\"\n        case .tuple(let structName):\n            return structName // TDOO: struct.describedAsTuple\n        case .optional(let type):\n            return type.description + \"?\"\n        case .object(let name):\n            return name\n        case .struct(let name):\n            return name\n        case .class(let name):\n            return name\n        }\n    }\n\n    public var encoding: String {\n        switch self {\n        case .void:\n            return \"v\"\n        case .pointer(let type):\n            return \"^\\(type.encoding)\"\n        case .integer:\n            return Platform.is64Bit ? \"q\" : \"i\"\n        case .float:\n            return Platform.is64Bit ? \"d\" : \"f\"\n        case .bool:\n            return \"C\"\n        case .string:\n            return \"{11_StringCore}\"\n        case .tuple(let structName):\n            return Type.struct(structName).encoding\n        case .optional(let type):\n            return \"?\\(type.description.count)\\(type.description)\"\n        case .object(_):\n            return \"@\"\n        case .struct(let name):\n            return \"{\\(name.count)\" + name + \"}\"\n        case .class(_):\n            return \"#\"\n        }\n    }\n\n    public var size: Int {\n        switch self {\n        case .void:\n            return 0\n        case .pointer(_): fallthrough\n        case .integer:\n            return MemoryLayout<Int>.size\n        case .float:\n            return Platform.is64Bit ? MemoryLayout<Float64>.size : MemoryLayout<Float32>.size\n        case .bool:\n            return MemoryLayout<Bool>.size\n        case .string:\n            return MemoryLayout<String>.size\n        case .tuple(let structName):\n            return Type.struct(structName).size\n        case .optional(let type):\n            switch type {\n            case .pointer(let ptrType):\n                return ptrType.size\n            default:\n                return type.size + 1\n            }\n        case .object(let className):\n            return Class.named(className).instanceSize\n        case .struct(let name):\n            return Struct.named(name).instanceSize\n        case .class(_):\n            return 0 // You'll never need to know the size of a class in practice\n        }\n    }\n}\n"
  },
  {
    "path": "Runtime.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 48;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\tC35AEBBE1F987493008F2988 /* RuntimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35AEBBD1F987493008F2988 /* RuntimeTests.swift */; };\n\t\tC35AEBC01F987493008F2988 /* libRuntime.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C3F59BC81F981B41002494E4 /* libRuntime.a */; };\n\t\tC37F4B741F9B279E000732E0 /* DebugDescriptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C37F4B731F9B279E000732E0 /* DebugDescriptions.swift */; };\n\t\tC3BEFCC11F994C7F005AD638 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3BEFCC01F994C7F005AD638 /* Person.swift */; };\n\t\tC3BEFCC31F994CB9005AD638 /* RootObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3BEFCC21F994CB9005AD638 /* RootObject.swift */; };\n\t\tC3D55DF81F9C4535006DE12F /* ClassBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D55DF71F9C4535006DE12F /* ClassBuilder.swift */; };\n\t\tC3D55DFA1F9E4642006DE12F /* OrderedSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D55DF91F9E4642006DE12F /* OrderedSet.swift */; };\n\t\tC3F59BD51F981B8D002494E4 /* Class.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BD41F981B8D002494E4 /* Class.swift */; };\n\t\tC3F59BD91F981C20002494E4 /* Pointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BD81F981C20002494E4 /* Pointer.swift */; };\n\t\tC3F59BDB1F981C4D002494E4 /* Object.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BDA1F981C4D002494E4 /* Object.swift */; };\n\t\tC3F59BDD1F981D8D002494E4 /* Ivar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BDC1F981D8D002494E4 /* Ivar.swift */; };\n\t\tC3F59BDF1F981D93002494E4 /* Method.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BDE1F981D93002494E4 /* Method.swift */; };\n\t\tC3F59BE11F981D9C002494E4 /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BE01F981D9C002494E4 /* Property.swift */; };\n\t\tC3F59BE31F981DAD002494E4 /* Protocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BE21F981DAD002494E4 /* Protocol.swift */; };\n\t\tC3F59BE51F981E6F002494E4 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BE41F981E6F002494E4 /* Types.swift */; };\n\t\tC3F59BE71F98229C002494E4 /* Struct.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BE61F98229C002494E4 /* Struct.swift */; };\n\t\tC3F59BE91F9827BD002494E4 /* Platform.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BE81F9827BD002494E4 /* Platform.swift */; };\n\t\tC3F59BEB1F982B80002494E4 /* Runtime.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F59BEA1F982B80002494E4 /* Runtime.swift */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\tC35AEBC11F987493008F2988 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = C3F59BC01F981B41002494E4 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = C3F59BC71F981B41002494E4;\n\t\t\tremoteInfo = Runtime;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\tC3F59BC61F981B41002494E4 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"include/$(PRODUCT_NAME)\";\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\tC35AEBBB1F987493008F2988 /* RuntimeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RuntimeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\tC35AEBBD1F987493008F2988 /* RuntimeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeTests.swift; sourceTree = \"<group>\"; };\n\t\tC35AEBBF1F987493008F2988 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\tC37F4B731F9B279E000732E0 /* DebugDescriptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugDescriptions.swift; sourceTree = \"<group>\"; };\n\t\tC3BEFCC01F994C7F005AD638 /* Person.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = \"<group>\"; };\n\t\tC3BEFCC21F994CB9005AD638 /* RootObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootObject.swift; sourceTree = \"<group>\"; };\n\t\tC3D55DF71F9C4535006DE12F /* ClassBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassBuilder.swift; sourceTree = \"<group>\"; };\n\t\tC3D55DF91F9E4642006DE12F /* OrderedSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderedSet.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BC81F981B41002494E4 /* libRuntime.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRuntime.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\tC3F59BD41F981B8D002494E4 /* Class.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Class.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BD81F981C20002494E4 /* Pointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pointer.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BDA1F981C4D002494E4 /* Object.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Object.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BDC1F981D8D002494E4 /* Ivar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Ivar.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BDE1F981D93002494E4 /* Method.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Method.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BE01F981D9C002494E4 /* Property.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Property.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BE21F981DAD002494E4 /* Protocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Protocol.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BE41F981E6F002494E4 /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BE61F98229C002494E4 /* Struct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Struct.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BE81F9827BD002494E4 /* Platform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Platform.swift; sourceTree = \"<group>\"; };\n\t\tC3F59BEA1F982B80002494E4 /* Runtime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Runtime.swift; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\tC35AEBB81F987493008F2988 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tC35AEBC01F987493008F2988 /* libRuntime.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\tC3F59BC51F981B41002494E4 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\tC35AEBBC1F987493008F2988 /* RuntimeTests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC35AEBBD1F987493008F2988 /* RuntimeTests.swift */,\n\t\t\t\tC35AEBBF1F987493008F2988 /* Info.plist */,\n\t\t\t\tC3BEFCC01F994C7F005AD638 /* Person.swift */,\n\t\t\t);\n\t\t\tpath = RuntimeTests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC3F59BBF1F981B41002494E4 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC3F59BCA1F981B41002494E4 /* Runtime */,\n\t\t\t\tC35AEBBC1F987493008F2988 /* RuntimeTests */,\n\t\t\t\tC3F59BC91F981B41002494E4 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC3F59BC91F981B41002494E4 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC3F59BC81F981B41002494E4 /* libRuntime.a */,\n\t\t\t\tC35AEBBB1F987493008F2988 /* RuntimeTests.xctest */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC3F59BCA1F981B41002494E4 /* Runtime */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC3F59BEA1F982B80002494E4 /* Runtime.swift */,\n\t\t\t\tC3F59BE81F9827BD002494E4 /* Platform.swift */,\n\t\t\t\tC3F59BE41F981E6F002494E4 /* Types.swift */,\n\t\t\t\tC3F59BD81F981C20002494E4 /* Pointer.swift */,\n\t\t\t\tC3F59BD41F981B8D002494E4 /* Class.swift */,\n\t\t\t\tC3D55DF71F9C4535006DE12F /* ClassBuilder.swift */,\n\t\t\t\tC3F59BE61F98229C002494E4 /* Struct.swift */,\n\t\t\t\tC3F59BDC1F981D8D002494E4 /* Ivar.swift */,\n\t\t\t\tC3F59BDE1F981D93002494E4 /* Method.swift */,\n\t\t\t\tC3F59BE01F981D9C002494E4 /* Property.swift */,\n\t\t\t\tC3F59BE21F981DAD002494E4 /* Protocol.swift */,\n\t\t\t\tC3F59BDA1F981C4D002494E4 /* Object.swift */,\n\t\t\t\tC3BEFCC21F994CB9005AD638 /* RootObject.swift */,\n\t\t\t\tC37F4B731F9B279E000732E0 /* DebugDescriptions.swift */,\n\t\t\t\tC3D55DF91F9E4642006DE12F /* OrderedSet.swift */,\n\t\t\t);\n\t\t\tpath = Runtime;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\tC35AEBBA1F987493008F2988 /* RuntimeTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = C35AEBC51F987493008F2988 /* Build configuration list for PBXNativeTarget \"RuntimeTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\tC35AEBB71F987493008F2988 /* Sources */,\n\t\t\t\tC35AEBB81F987493008F2988 /* Frameworks */,\n\t\t\t\tC35AEBB91F987493008F2988 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\tC35AEBC21F987493008F2988 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = RuntimeTests;\n\t\t\tproductName = RuntimeTests;\n\t\t\tproductReference = C35AEBBB1F987493008F2988 /* RuntimeTests.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\tC3F59BC71F981B41002494E4 /* Runtime */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = C3F59BD11F981B41002494E4 /* Build configuration list for PBXNativeTarget \"Runtime\" */;\n\t\t\tbuildPhases = (\n\t\t\t\tC3F59BC41F981B41002494E4 /* Sources */,\n\t\t\t\tC3F59BC51F981B41002494E4 /* Frameworks */,\n\t\t\t\tC3F59BC61F981B41002494E4 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = Runtime;\n\t\t\tproductName = Runtime;\n\t\t\tproductReference = C3F59BC81F981B41002494E4 /* libRuntime.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\tC3F59BC01F981B41002494E4 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastSwiftUpdateCheck = 0900;\n\t\t\t\tLastUpgradeCheck = 0910;\n\t\t\t\tORGANIZATIONNAME = \"Tanner Bennett\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\tC35AEBBA1F987493008F2988 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 9.0;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t\tC3F59BC71F981B41002494E4 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 9.0;\n\t\t\t\t\t\tLastSwiftMigration = 0900;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = C3F59BC31F981B41002494E4 /* Build configuration list for PBXProject \"Runtime\" */;\n\t\t\tcompatibilityVersion = \"Xcode 8.0\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = C3F59BBF1F981B41002494E4;\n\t\t\tproductRefGroup = C3F59BC91F981B41002494E4 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\tC3F59BC71F981B41002494E4 /* Runtime */,\n\t\t\t\tC35AEBBA1F987493008F2988 /* RuntimeTests */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\tC35AEBB91F987493008F2988 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\tC35AEBB71F987493008F2988 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tC3BEFCC11F994C7F005AD638 /* Person.swift in Sources */,\n\t\t\t\tC35AEBBE1F987493008F2988 /* RuntimeTests.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\tC3F59BC41F981B41002494E4 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tC3F59BE91F9827BD002494E4 /* Platform.swift in Sources */,\n\t\t\t\tC3F59BE11F981D9C002494E4 /* Property.swift in Sources */,\n\t\t\t\tC3BEFCC31F994CB9005AD638 /* RootObject.swift in Sources */,\n\t\t\t\tC3F59BDF1F981D93002494E4 /* Method.swift in Sources */,\n\t\t\t\tC37F4B741F9B279E000732E0 /* DebugDescriptions.swift in Sources */,\n\t\t\t\tC3F59BD51F981B8D002494E4 /* Class.swift in Sources */,\n\t\t\t\tC3F59BE71F98229C002494E4 /* Struct.swift in Sources */,\n\t\t\t\tC3F59BE51F981E6F002494E4 /* Types.swift in Sources */,\n\t\t\t\tC3F59BEB1F982B80002494E4 /* Runtime.swift in Sources */,\n\t\t\t\tC3D55DFA1F9E4642006DE12F /* OrderedSet.swift in Sources */,\n\t\t\t\tC3F59BE31F981DAD002494E4 /* Protocol.swift in Sources */,\n\t\t\t\tC3D55DF81F9C4535006DE12F /* ClassBuilder.swift in Sources */,\n\t\t\t\tC3F59BDB1F981C4D002494E4 /* Object.swift in Sources */,\n\t\t\t\tC3F59BD91F981C20002494E4 /* Pointer.swift in Sources */,\n\t\t\t\tC3F59BDD1F981D8D002494E4 /* Ivar.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\tC35AEBC21F987493008F2988 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = C3F59BC71F981B41002494E4 /* Runtime */;\n\t\t\ttargetProxy = C35AEBC11F987493008F2988 /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\tC35AEBC31F987493008F2988 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = S6N2F22V2Z;\n\t\t\t\tINFOPLIST_FILE = RuntimeTests/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.nsexceptional.RuntimeTests;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tC35AEBC41F987493008F2988 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = S6N2F22V2Z;\n\t\t\t\tINFOPLIST_FILE = RuntimeTests/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.nsexceptional.RuntimeTests;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\tC3F59BCF1F981B41002494E4 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 11.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tC3F59BD01F981B41002494E4 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 11.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\tC3F59BD21F981B41002494E4 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = S6N2F22V2Z;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tC3F59BD31F981B41002494E4 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = S6N2F22V2Z;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\tC35AEBC51F987493008F2988 /* Build configuration list for PBXNativeTarget \"RuntimeTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tC35AEBC31F987493008F2988 /* Debug */,\n\t\t\t\tC35AEBC41F987493008F2988 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\tC3F59BC31F981B41002494E4 /* Build configuration list for PBXProject \"Runtime\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tC3F59BCF1F981B41002494E4 /* Debug */,\n\t\t\t\tC3F59BD01F981B41002494E4 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\tC3F59BD11F981B41002494E4 /* Build configuration list for PBXNativeTarget \"Runtime\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tC3F59BD21F981B41002494E4 /* Debug */,\n\t\t\t\tC3F59BD31F981B41002494E4 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = C3F59BC01F981B41002494E4 /* Project object */;\n}\n"
  },
  {
    "path": "Runtime.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:Runtime.xcodeproj\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "RuntimeTests/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>$(DEVELOPMENT_LANGUAGE)</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>BNDL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "RuntimeTests/Person.swift",
    "content": "//\n//  Person.swift\n//  RuntimeTests\n//\n//  Created by Tanner on 10/19/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\n@testable import Runtime\n\ninfix operator |=\ninfix operator |\n\n/// Example subclass of RootObject.\nstruct Person {\n    static let `class` = Class(\n        isa: Person_meta.class,\n        superclass: RootObject.class,\n        name: \"Person\",\n        ivars: [\n            (name: \"_name\", type: .string),\n            (name: \"_age\", type: .integer)\n        ],\n        methods: [_init, name, setName_, age, setAge_, description],\n        properties: [\n            Property(name: \"name\", getter: name, setter: setName_),\n            Property(name: \"age\", getter: age, setter: setAge_),\n        ],\n        protocols: []\n    )\n\n    static var _init = Method(\"init\", returns: .object(\"self\")) { this, _cmd, args in\n        func init$(_ this: id, _ _cmd: SEL) -> id {\n            _msgSend(this, \"setName_\", (\"Bob\"))\n            _msgSend(this, \"setAge_\", (18))\n            print(\"init override: \\(this)\")\n\n            return msgSend(super: true, this, _cmd)\n        }\n\n        return init$(this, _cmd)\n    }\n\n    static var name = Method(\"name\", returns: .string) { this, _cmd, args in\n        func name$(_ this: id, _ _cmd: SEL) -> String {\n            return this|\"_name\"\n        }\n\n        return name$(this, _cmd)\n    }\n\n    static var setName_ = Method(\"setName_\", args: [.string]) { this, _cmd, args in\n        func setName$(_ this: id, _ _cmd: SEL, _ name: String) {\n            this |= (name, \"_name\")\n        }\n\n        let args = (args as! (String))\n        setName$(this, _cmd, args)\n        return ()\n    }\n\n    static var age = Method(\"age\", returns: .string) { this, _cmd, args in\n        func age$(_ this: id, _ _cmd: SEL) -> Int {\n            return this|\"_age\"\n        }\n\n        return age$(this, _cmd)\n    }\n\n    static var setAge_ = Method(\"setAge_\", args: [.string]) { this, _cmd, args in\n        func setName$(_ this: id, _ _cmd: SEL, _ age: Int) {\n            this |= (age, \"_age\")\n        }\n\n        let args = (args as! (Int))\n        setName$(this, _cmd, args)\n        return ()\n    }\n\n    static var description = Method(\"description\", returns: .string) { this, _cmd, args in\n        func description$(_ this: id, _ _cmd: SEL) -> String {\n            let name: String = msgSend(this, \"name\")\n            let age: Int = msgSend(this, \"age\")\n            return \"\"\"\n                   <\\(this|.getClass) \\(this.raw.debugDescription)> {\n                       name: \\(name),\n                       age: \\(age)\n                   }\n                   \"\"\"\n        }\n\n        return description$(this, _cmd)\n    }\n}\n\nprivate struct Person_meta {\n    static let `class` = Class(\n        isa: nil,\n        superclass: nil,\n        name: \"Person.meta\",\n        ivars: [],\n        methods: [],\n        properties: [],\n        protocols: []\n    )\n}\n\n/// For debugging purposes\n/// unsafeBitCast(this, to: UnsafePointer<person_>.self).pointee\nstruct person_ {\n    let isa: Class\n    let _retainCount: Int\n    let _name: String\n    let _age: Int\n}\n"
  },
  {
    "path": "RuntimeTests/RuntimeTests.swift",
    "content": "//\n//  RuntimeTests.swift\n//  RuntimeTests\n//\n//  Created by Tanner on 10/19/17.\n//  Copyright © 2017 Tanner Bennett. All rights reserved.\n//\n\nimport XCTest\n@testable import Runtime\n\nclass Tests: XCTestCase {\n    typealias id = Runtime.id\n\n    override func setUp() {\n        // Runtime initialization\n        _ = RootObject.class\n        _ = Person.class\n    }\n\n    func testPerson() {\n        let bob: id = msgSend(Person.class.createInstance(), \"init\")\n        let name: String = msgSend(bob, \"name\")\n        let age: Int = msgSend(bob, \"age\")\n        let description: String = msgSend(bob, \"description\")\n        XCTAssertEqual(\"Bob\", name)\n        XCTAssertEqual(18, age)\n        XCTAssert(description.hasPrefix(\"\\(bob)\"))\n    }\n\n    func testPointerAssumptions() {\n        class Foo {\n            struct Layout {\n                let magic: (isa: Int, refCount: Int)\n                let count: Int\n            }\n            let count = 0x72656E6E6174\n            public init() {}\n        }\n\n        var instance = Foo()\n        let bitcast = unsafeBitCast(instance, to: Pointer<Foo.Layout>.self)\n        let unsafe = withUnsafePointer(to: &instance, { $0 })\n\n        XCTAssertEqual(bitcast|.count, unsafe.pointee.count)\n    }\n\n    func testClassObjectReferencing() {\n        var cls = Class.named(\"Object\")!\n        XCTAssert(cls === RootObject.class)\n\n        let ptr: Pointer<Class> = |cls\n        let unsafePtr = withUnsafePointer(to: &cls, { $0 })\n\n        XCTAssertEqual(cls.name, ptr|.name)\n        XCTAssertEqual(ptr.raw.debugDescription, unsafePtr.debugDescription)\n\n        var asObject: id = ~cls\n        asObject += 16\n        XCTAssertEqual(cls.name, ptr|.name)\n\n        let ref = cls.ref\n        XCTAssertEqual(asObject, ref)\n        XCTAssert(ref|.isa === RootObject_meta.class)\n    }\n\n    func testCreateClass() {\n        XCTAssertNil(Class.named(\"Foo\"))\n        var counter = 0\n\n        let builder = ClassBuilder(name: \"Foo\")!\n        let initializer = Method(\"init\", returns: .object(\"self\")) { this, _cmd, args in\n            func init$(_ this: id, _ _cmd: SEL) -> id {\n                let this: id = msgSend(super: true, this, _cmd)\n                counter += 1\n                return this\n            }\n\n            return init$(this, _cmd)\n        }\n        let method = Method(\"getClassName\", returns: .string) { this, _cmd, args in\n            func getClassName$(_ this: id, _ _cmd: SEL) -> String {\n                return this|.getClass.name\n            }\n\n            return getClassName$(this, _cmd)\n        }\n        builder.add([initializer, method])\n\n        let classMethod = Method(\"instanceCount\", returns: .integer) { this, _cmd, args in\n            func instanceCount$(_ this: id, _ _cmd: SEL) -> Int {\n                return counter\n            }\n\n            return instanceCount$(this, _cmd)\n        }\n        builder.add([classMethod], toClass: true)\n        let created = builder.finalize()\n        let asObject = created.ref // TODO: Make this not necessary\n\n        XCTAssert(created === Class.named(\"Foo\"))\n        XCTAssertEqual(0, msgSend(asObject, \"instanceCount\"))\n\n        _msgSend(created.createInstance(), \"init\")\n        XCTAssertEqual(1, msgSend(asObject, \"instanceCount\"))\n    }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n"
  }
]