-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I wish you can continue the project #1
Comments
Yeah please this is the only good example of using llvmlite with a python lexer/parser , if you want to continue this project i Will be really supportive |
Can you give a example about "import a Module" and use c++ in llvmlite |
I think I'd start the project over from scratch cuz it's a little bit old and I have much more exprience now, you giving me such feedback means alot to me. So @Andrea-Miele what do you think? |
You'd need to convert whatever c++ code to llvm code that way you can easily use it across your code just like:(https://github.com/dabeaz/bitey). |
@keosariel way to create extensions/modules would be really cool , I also suggest you (if it's possible, I don't know if llvm IR has it) to implement Object Oriented Programming concepts |
I hope to implement import statements (similar to python), import modules that have been written (compiled with llvmlite), and even import c libraries. This will make a basically usable programming language. |
"implement Object Oriented Programming concepts" I wish as well. |
May I ask you something, where did you learn how use llvmlite? I cannot found any good documentation or good example (except for this repo but I cannot understand it a lot) |
I cannot find good documentation anywhere too. |
Oh ok |
https://github.com/Lesma-lang/Lesma There are some projects. I think We can improve the example together. |
I think the Int in the project should all Change to the type_map. Why using previous_builder in the function visit_def? |
I found a way to link c in llvmlite.https://stackoverflow.com/questions/36658726/link-c-in-llvmlite |
@streetartist yeah i also found that |
I searched in the llvmlite documentation and I didn't find any reference to Object Oriented Programming concepts |
i realized that to make classes we can simply make stuctures and then make some methods with the first argument of the instance itself |
i made this test import llvmlite.ir as ir
import llvmlite.binding as llvm
import ctypes
module = ir.Module("OOP")
#Let's make a class called Foo, dividing it in a structure and some methods
Foo = module.context.get_identified_type("Foo")
Foo.set_body(
ir.IntType(32)
)
constructor = ir.Function(module,ir.FunctionType(ir.VoidType(), [Foo.as_pointer()]),"Foo_Create_Default")
constructor.attributes.add("nounwind")
constructor.args[0].name="this"
block = constructor.append_basic_block("entry")
builder = ir.IRBuilder(block)
my_ptr = constructor.args[0]
ptr = builder.gep(my_ptr,[ir.Constant(ir.IntType(32),0),ir.Constant(ir.IntType(32),0)], name="1")
builder.store(ir.Constant(ir.IntType(32),0), ptr)
builder.ret_void()
main_typ = ir.FunctionType(ir.IntType(32), [])
main_func = ir.Function(module,main_typ,"main")
main_block = main_func.append_basic_block("entry")
main_builder = ir.IRBuilder(main_block)
foo = main_builder.alloca(Foo,name='foo')
main_builder.call(constructor, [foo])
new_ptr = main_builder.gep(foo, [ir.Constant(ir.IntType(32),0),ir.Constant(ir.IntType(32),0)])
main_builder.store(ir.Constant(ir.IntType(32),20),new_ptr)
myval = main_builder.load(new_ptr)
main_builder.ret(myval)
print(module)
llvm.initialize()
llvm.initialize_native_target()
llvm.initialize_native_asmprinter()
target = llvm.Target.from_default_triple()
target_machine = target.create_target_machine()
backing_mod = llvm.parse_assembly("")
engine = llvm.create_mcjit_compiler(backing_mod, target_machine)
mod = llvm.parse_assembly(str(module))
mod.verify()
engine.add_module(mod)
engine.finalize_object()
ptr = engine.get_function_address("main")
ctype = ctypes.CFUNCTYPE(ctypes.c_int32)(ptr)
print(ctype()) |
wait @streetartist you already implemented classes in your language |
I think we can have a look at the project Lesma,it has already implemented OOP |
OOP isn't implemented in LLVM, though I've found a way around it. |
I just read and tweeked some code I found on github, besides the code wasn't documented at all. However, the llvmlite module has comments in it's code so I just walked my way backwards. |
I broke the Akilang https://github.com/syegulalp/Akilang project to pieces too, to learn to use llvmlite |
The way Lesma implemented OOP is nice and I used the same technique they used. I've actually implemented OOP for this project but I didn't just upload the code cuz I've not really commented/documented the code yet. |
Besides we'd need a todo list
Sweet |
I think I'd create a new Repo and invite you guys, then we'd need to layout the workflow and also create a todo list sort of, just so we are guided and at the same time we get to know what left and whats not while writing the code. Greate?? |
However, I know we all love Python and I don't think we'd stop writing python anytime soon. So I'm thinking we should write a flavour of RPython. Buh instead of converting statically typed Python code to C/C++ we'd convert it to LLVM IR and we'd need to also devise a means to use the language in Python. What do you guys think? |
Yeah, we'll do that |
@keosariel it already exists, it's called Numba, it's a python jit based on llvmlite that can also emit llvm IR code |
Great |
Also I think we'll need a better way to communicate |
I don't know |
And we must write a standard libarary for it(using llvm or C++), and the program must can import from other program written in this language. |
Yeah, we have to make this |
I don't know C++, for me it will be better to make it in llvm |
I know of numba, but I'm talking of a pair just the way c is to c++ sort off |
Yeah sure |
Mad stuff 😄 😄 |
Let's communicate on discord. Would that favour you guys?? |
can you update your code for oop? |
Yes ,for me it's good |
Yeah please do that |
I'd do that as soon as possible |
However, I've just created a new repo and invited you guys already. Please don't mind the repo's name (:hint github suggested it) 😄 😄 I've also sent @Andrea-Miele discord friend request |
Yo guys, the code is so soo messy!!! |
@keosariel we cannot talk on discord |
Sorry I've been having issues with my e-mail, which affected my Github. I still don't understand why my discord was suspended. However, I've written some code for starters and I'd upload it tomorrow. Sorry!!!! |
Any recommendation on a communication platform?? |
I was hacked. |
@streetartist hasn't accepted the repo invite yet |
@Andrea-Miele pls resend your tag |
Andrea Miele#5093 |
@keosariel tell me when you'll send the request |
I've sent it! |
I would love to see what this is it! |
Ohh christ! I'd have to continue this project. |
Of course! |
also @Andrea-Miele are you active on discord now |
Kinda |
No description provided.
The text was updated successfully, but these errors were encountered: