This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourcedir="$PWD" | |
if [ ! -d $sourcedir/wasi-sdk ]; then | |
wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz | |
tar xfz wasi-sdk.tar.gz | |
mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk | |
fi | |
cd swift | |
utils/build-script --debug --wasm \ | |
--skip-build-benchmarks \ | |
--extra-cmake-options="-DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM -DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 -DSWIFT_OSX_x86_64_ICU_STATICLIB=1" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol View { | |
func body() -> UIView | |
} | |
struct ModifiedView<T: View>: View { | |
let content: T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator |: MultiplicationPrecedence | |
infix operator ∧: MultiplicationPrecedence | |
infix operator ∨: MultiplicationPrecedence | |
infix operator ⊃: MultiplicationPrecedence | |
prefix operator ¬ | |
func |(lhs: Bool, rhs: Bool) -> Bool { | |
switch (lhs, rhs) { | |
case (true, true): return false | |
case (true, false): return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
COMPILE_SERVICE=$SWIFTWASM_SOURCE/swiftwasm-compile-service | |
WASM_SYSROOT=$COMPILE_SERVICE/compiler/wasi-sdk/opt/wasi-sdk/share/sysroot | |
input=$1 | |
object_file=input.o | |
output=$2 | |
$SWIFTWASM_SOURCE/build/Ninja-DebugAssert/swift-linux-x86_64/bin/swiftc \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_PATH="$1" | |
APP_NAME=$(basename $APP_PATH) | |
APP_NAME=${APP_NAME%.*} | |
RESULT=$(mktemp -d) | |
xcrun dyldinfo -bind $APP_PATH/$APP_NAME > $RESULT/$APP_NAME | |
for FRAMEWORK in $(basename $APP_PATH/Frameworks/*.framework) | |
do | |
FW_NAME=$(basename $FRAMEWORK) | |
FW_NAME=${FW_NAME%.*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RelativePointer<Pointee> { | |
let offset: Int32 | |
mutating func advanced() -> UnsafeMutablePointer<Pointee> { | |
withUnsafePointer(to: &self) { [offset] ptr in | |
let raw = UnsafeRawPointer(ptr) | |
let advanced = raw.advanced(by: Int(offset)) | |
let pointer = advanced.assumingMemoryBound(to: Pointee.self) | |
return UnsafeMutablePointer(mutating: pointer) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
indirect enum LinkedList<T> { | |
case element(T, LinkedList<T>) | |
case tail | |
mutating func removeFirst1() -> T? { | |
switch self { | |
case .element(let element, let list): | |
self = list | |
return element | |
default: return nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RelativePointer<Pointee> { | |
var offset: Int32 | |
mutating func advanced() -> UnsafeMutablePointer<Pointee> { | |
return withUnsafePointer(to: &self) { [offset] pointer in | |
let rawPointer = UnsafeRawPointer(pointer) | |
let advanced = rawPointer.advanced(by: Int(offset)) | |
let pointer = advanced.assumingMemoryBound(to: Pointee.self) | |
return UnsafeMutablePointer(mutating: pointer) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ClassMetadata { | |
let isaPointer: Int64 | |
let superClass: Any.Type | |
let objCRuntimeReserve1: Int | |
let objCRuntimeReserve2: Int | |
let rodataPointer: Int | |
let classFlags: Int32 | |
let instanceAddressPoint: Int32 | |
let instanceSize: Int32 | |
let instanceAlignmentMask: Int16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol P1 { | |
associatedtype X | |
} | |
protocol P2 {} | |
struct Box<T1, T2: P1> { | |
struct X {} | |
} | |
extension Box.X: P2 where T2.X == String {} |