@@ -45,7 +45,7 @@ public class Context: ContextRef {
4545 }
4646
4747 /// Get the diagnostic handler of current context.
48- public var getContextDiagnosticHandler : DiagnosticHandler ? {
48+ public var getDiagnosticHandler : DiagnosticHandler ? {
4949 if let handler = LLVMContextGetDiagnosticHandler ( contextRef) {
5050 return unsafeBitCast ( handler, to: DiagnosticHandler . self)
5151 } else {
@@ -54,10 +54,22 @@ public class Context: ContextRef {
5454 }
5555
5656 /// Set the diagnostic handler for current context.
57- public func setContextDiagnosticHandler ( handler: LLVMDiagnosticHandler ? , diagnosticContext: UnsafeMutableRawPointer ? ) {
57+ public func setDiagnosticHandler ( handler: LLVMDiagnosticHandler ? , diagnosticContext: UnsafeMutableRawPointer ? ) {
5858 LLVMContextSetDiagnosticHandler ( contextRef, handler, diagnosticContext)
5959 }
6060
61+ /// Retrieve whether the given context is set to discard all value names.
62+ public func shouldDiscardValueNames( ) -> Bool {
63+ return LLVMContextShouldDiscardValueNames ( llvm) != 0
64+ }
65+
66+ /// Set whether the given context discards all value names.
67+ /// If true, only the names of GlobalValue objects will be available in the IR.
68+ /// This can be used to save memory and runtime, especially in release mode.
69+ public func setDiscardValueNames( discard: Bool ) {
70+ LLVMContextSetDiscardValueNames ( llvm, discard. llvm)
71+ }
72+
6173 /// Returns whether the given context is set to discard all value names.
6274 ///
6375 /// If true, only the names of GlobalValue objects will be available in
@@ -66,15 +78,138 @@ public class Context: ContextRef {
6678 public var discardValueNames : Bool {
6779 get {
6880 // Retrieve whether the given context is set to discard all value names.
69- return LLVMContextShouldDiscardValueNames ( llvm ) != 0
81+ return shouldDiscardValueNames ( )
7082 }
7183 set {
7284 // Set whether the given context discards all value names.
73- LLVMContextSetDiscardValueNames ( llvm , newValue. llvm )
85+ setDiscardValueNames ( discard : newValue)
7486 }
7587 }
7688
89+ //=========
90+ /// Get the diagnostic context of this context.
91+ public func getDiagnosticContext( ) {
92+ // void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
93+ }
94+
95+ /// Set the yield callback function for this context.
96+ public func setYieldCallback( ) {
97+ // void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
98+ }
99+
100+ /// Return a string representation of the DiagnosticInfo. Use
101+ /// LLVMDisposeMessage to free the string.
102+ public func getDiagInfoDescription( ) {
103+ // char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
104+ }
105+
106+ /// Return an enum LLVMDiagnosticSeverity.
107+ public func getDiagInfoSeverity( ) {
108+ // LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
109+ }
110+
111+ public func getMDKindIDInContext( ) {
112+ // unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
113+ }
114+
115+ public func getMDKindID( ) {
116+ // unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
117+ }
118+
119+ /// Return an unique id given the name of a enum attribute,
120+ /// or 0 if no attribute by that name exists.
121+ ///
122+ /// See http://llvm.org/docs/LangRef.html#parameter-attributes
123+ /// and http://llvm.org/docs/LangRef.html#function-attributes
124+ /// for the list of available attributes.
125+ ///
126+ /// NB: Attribute names and/or id are subject to change without
127+ /// going through the C API deprecation cycle.
128+ public func getEnumAttributeKindForName( ) {
129+ // unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
130+
131+ }
132+
133+ public func getLastEnumAttributeKind ( ) {
134+ // unsigned LLVMGetLastEnumAttributeKind(void);
135+ }
136+
137+ public func
138+ public func
139+ public func
140+ public func
141+ public func
142+ public func
143+ public func
144+ public func
145+ public func
146+ public func
147+ public func
148+
149+ //========================================
150+ /**
151+ * Create an enum attribute.
152+ */
153+ LLVMAttributeRef LLVMCreateEnumAttribute( LLVMContextRef C, unsigned KindID,
154+ uint64 _t Val) ;
155+
156+ /**
157+ * Get the unique id corresponding to the enum attribute
158+ * passed as argument.
159+ */
160+ unsigned LLVMGetEnumAttributeKind( LLVMAttributeRef A) ;
161+
162+ /**
163+ * Get the enum attribute's value. 0 is returned if none exists.
164+ */
165+ uint64 _t LLVMGetEnumAttributeValue( LLVMAttributeRef A) ;
166+
167+ /**
168+ * Create a type attribute
169+ */
170+ LLVMAttributeRef LLVMCreateTypeAttribute( LLVMContextRef C, unsigned KindID,
171+ LLVMTypeRef type_ref) ;
172+
173+ /**
174+ * Get the type attribute's value.
175+ */
176+ LLVMTypeRef LLVMGetTypeAttributeValue( LLVMAttributeRef A) ;
177+
178+ /**
179+ * Create a string attribute.
180+ */
181+ LLVMAttributeRef LLVMCreateStringAttribute( LLVMContextRef C,
182+ const char * K, unsigned KLength,
183+ const char * V, unsigned VLength) ;
184+
185+ /**
186+ * Get the string attribute's kind.
187+ */
188+ const char * LLVMGetStringAttributeKind( LLVMAttributeRef A, unsigned * Length) ;
189+
190+ /**
191+ * Get the string attribute's value.
192+ */
193+ const char * LLVMGetStringAttributeValue( LLVMAttributeRef A, unsigned * Length) ;
194+
195+ /**
196+ * Check for the different types of attributes.
197+ */
198+ LLVMBool LLVMIsEnumAttribute( LLVMAttributeRef A) ;
199+ LLVMBool LLVMIsStringAttribute( LLVMAttributeRef A) ;
200+ LLVMBool LLVMIsTypeAttribute( LLVMAttributeRef A) ;
201+
202+ /**
203+ * Obtain a Type from a context by its registered name.
204+ */
205+ LLVMTypeRef LLVMGetTypeByName2 ( LLVMContextRef C, const char * Name) ;
206+
207+
77208 /// Deinitialize this value and dispose of its resources.
209+ ///
210+ /// Destroy a context instance.
211+ /// This should be called for every call to LLVMContextCreate() or memory
212+ /// will be leaked.
78213 deinit {
79214 LLVMContextDispose( llvm)
80215 }
0 commit comments