LLVMModule.st
changeset 35 fd459b38f324
parent 33 feabf14b6c1d
child 37 0933f973bc22
--- a/LLVMModule.st	Wed Sep 02 21:46:58 2015 +0100
+++ b/LLVMModule.st	Thu Sep 03 07:41:41 2015 +0100
@@ -42,6 +42,12 @@
 
 !LLVMModule class methodsFor:'instance creation'!
 
+new
+    ^ self newWithName: 'm'
+
+    "Created: / 03-09-2015 / 06:41:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 newWithName: name
     ^ LLVM ModuleCreateWithName: name
 
@@ -60,6 +66,42 @@
     ^ LLVMDIBuilder newForModule: self
 
     "Created: / 13-08-2015 / 06:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+getFunctionNamed: name 
+    | function |
+
+    self assertIsString: name.  
+    function := LLVM GetNamedFunction: self  _: name.
+    function notNil ifTrue:[ 
+        "/ TODO: Certainly a hack. must find a better way to do this.
+        function changeClassTo: LLVMFunction.
+    ].
+    ^ function
+
+    "Created: / 02-09-2015 / 22:27:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+getIntrinsicNamed: name 
+    ^ self getIntrinsicNamed: name types: #().
+
+    "Created: / 14-08-2015 / 14:10:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-09-2015 / 06:35:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+getIntrinsicNamed: name types: types
+    | intrinsic |    
+    self assertIsString: name.  
+    self assertIsTypeArray: types.
+    intrinsic := LLVMCEXT GetIntrinsicByName: self _: name _: types size _: types asLLVMObjectArray.
+    intrinsic notNil ifTrue:[
+        "/ TODO: Certainly a hack. must find a better way to do this.
+        intrinsic changeClassTo: LLVMFunction.
+    ]. 
+    ^ intrinsic
+
+    "Created: / 10-08-2015 / 17:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-09-2015 / 06:32:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !LLVMModule methodsFor:'adding & removing'!
@@ -124,30 +166,6 @@
     ^ LLVM AddMethod: self _: name _: type.
 
     "Created: / 11-07-2015 / 09:37:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-getIntrinsicNamed: name 
-    | function |
-
-    function := self getIntrinsicNamed: name types: #().
-    "/ TODO: Certainly a hack. must find a better way to do this.
-    function changeClassTo: LLVMFunction.
-    ^ function
-
-    "Created: / 14-08-2015 / 14:10:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-getIntrinsicNamed: name types: types
-    | intrinsic |    
-    self assertIsString: name.  
-    self assertIsTypeArray: types.
-    intrinsic := LLVMCEXT GetIntrinsicByName: self _: name _: types size _: types asLLVMObjectArray.
-    "/ TODO: Certainly a hack. must find a better way to do this.
-    intrinsic changeClassTo: LLVMFunction.
-    ^ intrinsic
-
-    "Created: / 10-08-2015 / 17:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 17-08-2015 / 07:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !LLVMModule methodsFor:'debugging'!