Skip to content

Commit 98580c4

Browse files
committed
Added context to LabelType
1 parent 5a0353f commit 98580c4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Sources/LLVM/LabelType.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@ import cllvm
44

55
/// `LabelType` represents code labels.
66
public struct LabelType: IRType {
7+
8+
/// Returns the context associated with this module.
9+
public let context: Context?
10+
711
/// Creates a code label.
8-
public init() {}
12+
///
13+
/// - parameter context: The context to create this type in
14+
/// - SeeAlso: http://llvm.org/docs/ProgrammersManual.html#achieving-isolation-with-llvmcontext
15+
public init(context: Context? = nil) {
16+
self.context = context
17+
}
918

1019
/// Retrieves the underlying LLVM type object.
1120
public func asLLVM() -> LLVMTypeRef {
21+
if let context = context {
22+
return LLVMLabelTypeInContext(context.llvm)
23+
}
1224
return LLVMLabelType()
1325
}
1426
}

0 commit comments

Comments
 (0)