diff --git a/libs/llvm/jit_compiler.cr b/libs/llvm/jit_compiler.cr index 248e900b9853d9663667890702aae626e6682dea..a46de43ebb14c1d55aa997592409c678fd10b9a4 100644 --- a/libs/llvm/jit_compiler.cr +++ b/libs/llvm/jit_compiler.cr @@ -1,7 +1,7 @@ class LLVM::JITCompiler def initialize(mod) - if LibLLVM.create_jit_compiler_for_module(out @jit, mod.llvm_module, 3, out error) != 0 - # if LibLLVM.create_mc_jit_compiler_for_module(out @jit, mod.llvm_module, nil, 0_u32, out error) != 0 + # if LibLLVM.create_jit_compiler_for_module(out @jit, mod.llvm_module, 3, out error) != 0 + if LibLLVM.create_mc_jit_compiler_for_module(out @jit, mod.llvm_module, nil, 0_u32, out error) != 0 raise String.new(error) end end diff --git a/libs/llvm/llvm.cr b/libs/llvm/llvm.cr index 8b46f10884fd79c85754f3520b6e489dedbae78f..954a7f23395d1bdd560d57e0c33aef8d881fd77e 100644 --- a/libs/llvm/llvm.cr +++ b/libs/llvm/llvm.cr @@ -6,8 +6,8 @@ module LLVM LibLLVM.initialize_x86_target LibLLVM.initialize_x86_target_mc LibLLVM.initialize_x86_asm_printer - LibLLVM.link_in_jit - # LibLLVM.link_in_mc_jit + # LibLLVM.link_in_jit + LibLLVM.link_in_mc_jit end def self.dump(value) diff --git a/spec/compiler/codegen/fun_spec.cr b/spec/compiler/codegen/fun_spec.cr index ae4a8eb5f6e97ec52b600942c725ad6eb284c623..3e373e61d6d1fc433b45fb17fc82df9d7790f474 100644 --- a/spec/compiler/codegen/fun_spec.cr +++ b/spec/compiler/codegen/fun_spec.cr @@ -25,16 +25,14 @@ describe "Code gen: fun" do ").to_i.should eq(3) end - pending "call fun pointer of instance method" do - run(" - require "prelude" + it "call fun pointer of instance method" do + run(%( class Foo def initialize @x = 1 end def coco - puts "Hola" @x end end @@ -42,7 +40,7 @@ describe "Code gen: fun" do foo = Foo.new f = ->foo.coco f.call - ").to_i.should eq(1) + )).to_i.should eq(1) end it "codegens fun with another var" do diff --git a/src/compiler/crystal/codegen.cr b/src/compiler/crystal/codegen.cr index d700f3b8470189183c70a0c88ba6d2003c9cb86e..4e46fb0fc7552a0f55edafad867935c66f5e34cc 100644 --- a/src/compiler/crystal/codegen.cr +++ b/src/compiler/crystal/codegen.cr @@ -34,7 +34,7 @@ module Crystal engine.run_function llvm_mod.functions[MAIN_NAME], [argc, argv] end - def build(node, single_module = false, llvm_mod = LLVM::Module.new("main")) + def build(node, single_module = false, llvm_mod = LLVM::Module.new("main_module")) visitor = CodeGenVisitor.new(self, node, llvm_mod, single_module) begin node.accept visitor