]> gitweb.factorcode.org Git - factor.git/commitdiff
llvm: fix load errors
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 14 Apr 2010 01:43:48 +0000 (18:43 -0700)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 14 Apr 2010 01:43:48 +0000 (18:43 -0700)
extra/llvm/core/core.factor
extra/llvm/engine/engine.factor
extra/llvm/invoker/invoker.factor
extra/llvm/jit/jit.factor
extra/llvm/types/types.factor

index 0ab43c6ab6b51085e0e1573100d0bd56c49cb4f3..5778a00ffb2d3663340fcfbd9db416078a1f0040 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.libraries alien.syntax system sequences combinators kernel alien.c-types ;
+USING: alien alien.libraries alien.syntax system sequences combinators kernel alien.c-types ;
 
 IN: llvm.core
 
index 95e425c4252130405e7db18e73b7f0abc4e13b8a..bb39f86f73319d661ff5b0e27f50382dc74b999c 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.libraries alien.syntax llvm.core ;
+USING: alien.c-types alien.libraries alien.syntax llvm.core ;
 IN: llvm.engine
 
 <<
index cc3480fe49c586b5268eb4ea64a955cce39d2485..27fdeeb618d114a388ed106da3a29d72b2a3148c 100644 (file)
@@ -45,7 +45,7 @@ TUPLE: function name alien return params ;
     ] [ ] make swap function-effect [ define-declared ] with-compilation-unit ;
 
 : install-module ( name -- )
-    thejit get mps>> at [
+    current-jit mps>> at [
         module>> functions [ install-function ] each
     ] [ "no such module" throw ] if* ;
 
index f58851fe6f9c9be44f330996e4b47f515e84d3b1..fc755fd00fa6c93e48909ffc3054b73aae036096 100644 (file)
@@ -5,8 +5,6 @@ kernel llvm.core llvm.engine llvm.wrappers namespaces ;
 
 IN: llvm.jit
 
-SYMBOL: thejit
-
 TUPLE: jit ee mps ;
 
 : empty-engine ( -- engine )
@@ -15,8 +13,11 @@ TUPLE: jit ee mps ;
 : <jit> ( -- jit )
     jit new empty-engine >>ee H{ } clone >>mps ;
 
+: current-jit ( -- jit )
+    \ current-jit global [ drop <jit> ] cache ;
+
 : (remove-functions) ( function -- )
-    thejit get ee>> value>> over LLVMFreeMachineCodeForFunction
+    current-jit ee>> value>> over LLVMFreeMachineCodeForFunction
     LLVMGetNextFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ;
 
 : remove-functions ( module -- )
@@ -24,26 +25,24 @@ TUPLE: jit ee mps ;
     LLVMGetFirstFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ;
 
 : remove-provider ( provider -- )
-    thejit get ee>> value>> swap value>> f <void*> f <void*>
+    current-jit ee>> value>> swap value>> f <void*> f <void*>
     [ LLVMRemoveModuleProvider drop ] 2keep *void* [ llvm-throw ] when*
     *void* module new swap >>value
     [ value>> remove-functions ] with-disposal ;
 
 : remove-module ( name -- )
-    dup thejit get mps>> at [
+    dup current-jit mps>> at [
         remove-provider
-        thejit get mps>> delete-at
+        current-jit mps>> delete-at
     ] [ drop ] if* ;
 
 : add-module ( module name -- )
     [ <provider> ] dip [ remove-module ] keep
-    thejit get ee>> value>> pick
+    current-jit ee>> value>> pick
     [ [ value>> LLVMAddModuleProvider ] [ t >>disposed drop ] bi ] with-disposal
-    thejit get mps>> set-at ;
+    current-jit mps>> set-at ;
 
 : function-pointer ( name -- alien )
-    thejit get ee>> value>> dup
+    current-jit ee>> value>> dup
     rot f <void*> [ LLVMFindFunction drop ] keep
-    *void* LLVMGetPointerToGlobal ;
-
-thejit [ <jit> ] initialize
\ No newline at end of file
+    *void* LLVMGetPointerToGlobal ;
\ No newline at end of file
index e93cf7a44b986bee57556b2145d3a9482fa9993c..c312e7a173669972b7c32e63bc7369fa8e257fec 100644 (file)
@@ -229,7 +229,7 @@ NoFunctionParams = "(" WhiteSpace ")" => [[ drop { } ]]
 VarArgs = WhiteSpace "..." WhiteSpace => [[ drop ... ]]
 ParamListContinued = "," (Type | VarArgs):t => [[ t ]]
 ParamList = "(" Type:t (ParamListContinued*):ts ")" => [[ ts t prefix ]]
-Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts delete ] when t ts >array rot <function> ]]
+Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts remove! drop ] when t ts >array rot <function> ]]
 PackedStructure = "<" WhiteSpace "{" Type:ty (StructureTypesList)*:ts "}" WhiteSpace ">" => [[ ts ty prefix >array t <struct> ]]
 UpReference = "\\" Number:n => [[ n <up-ref> ]]
 Name = '%' ([a-zA-Z][a-zA-Z0-9]*):id => [[ id flatten >string ]]