Skip to content
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

Open
streetartist opened this issue Aug 29, 2021 · 61 comments
Open

I wish you can continue the project #1

streetartist opened this issue Aug 29, 2021 · 61 comments

Comments

@streetartist
Copy link

No description provided.

@Andrea-Miele
Copy link

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

@streetartist
Copy link
Author

Can you give a example about "import a Module" and use c++ in llvmlite

@keosariel
Copy link
Owner

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

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?
Besides sorry for the late reply

@keosariel
Copy link
Owner

Can you give a example about "import a Module" and use c++ in llvmlite

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).
This would be the mechanism that I'd use to build most libraries in this project

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 1, 2021

So @Andrea-Miele what do you think?

@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

@streetartist
Copy link
Author

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.

@streetartist
Copy link
Author

"implement Object Oriented Programming concepts"

I wish as well.

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 2, 2021

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)

@streetartist
Copy link
Author

I cannot find good documentation anywhere too.
I learn it by reading the code of the project gone.

@Andrea-Miele
Copy link

I learn it by reading the code of the project gone.

Oh ok

@streetartist
Copy link
Author

https://github.com/Lesma-lang/Lesma
https://github.com/paivett/gone
https://github.com/syegulalp/Akilang

There are some projects.

I think We can improve the example together.

@streetartist
Copy link
Author

I think the Int in the project should all Change to the type_map.

Why using previous_builder in the function visit_def?

@streetartist
Copy link
Author

I found a way to link c in llvmlite.

https://stackoverflow.com/questions/36658726/link-c-in-llvmlite

@Andrea-Miele
Copy link

@streetartist yeah i also found that

@Andrea-Miele
Copy link

I searched in the llvmlite documentation and I didn't find any reference to Object Oriented Programming concepts

@Andrea-Miele
Copy link

i realized that to make classes we can simply make stuctures and then make some methods with the first argument of the instance itself

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 3, 2021

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())

@Andrea-Miele
Copy link

wait @streetartist you already implemented classes in your language

@streetartist
Copy link
Author

I think we can have a look at the project Lesma,it has already implemented OOP

@keosariel
Copy link
Owner

So @Andrea-Miele what do you think?

@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

OOP isn't implemented in LLVM, though I've found a way around it.

@keosariel
Copy link
Owner

I cannot find good documentation anywhere too. I learn it by reading the code of the project gone.

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 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.

@keosariel
Copy link
Owner

I broke the Akilang https://github.com/syegulalp/Akilang project to pieces too, to learn to use llvmlite

@keosariel
Copy link
Owner

I think we can have a look at the project Lesma,it has already implemented OOP

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.

@keosariel
Copy link
Owner

Besides we'd need a todo list

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())

Sweet

@keosariel
Copy link
Owner

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??

@keosariel
Copy link
Owner

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?

@Andrea-Miele
Copy link

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.

Yeah, we'll do that

@Andrea-Miele
Copy link

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.

@keosariel it already exists, it's called Numba, it's a python jit based on llvmlite that can also emit llvm IR code

@streetartist
Copy link
Author

Great

@Andrea-Miele
Copy link

Also I think we'll need a better way to communicate

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 5, 2021

What way

I don't know

@streetartist
Copy link
Author

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.

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 5, 2021

and the program must can import from other program written in this language.

Yeah, we have to make this

@streetartist
Copy link
Author

alinalihassan/pyLesma#3

@Andrea-Miele
Copy link

And we must write a standard libarary for it(using llvm or C++),

I don't know C++, for me it will be better to make it in llvm

@keosariel
Copy link
Owner

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.

@keosariel it already exists, it's called Numba, it's a python jit based on llvmlite that can also emit llvm IR code

I know of numba, but I'm talking of a pair just the way c is to c++ sort off

@keosariel
Copy link
Owner

and the program must can import from other program written in this language.

Yeah, we have to make this

Yeah sure

@keosariel
Copy link
Owner

Lesma-lang/Lesma#3

Mad stuff 😄 😄

@keosariel
Copy link
Owner

Also I think we'll need a better way to communicate

Let's communicate on discord. Would that favour you guys??

@streetartist
Copy link
Author

can you update your code for oop?
I want to have a look

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 7, 2021

Let's communicate on discord. Would that favour you guys??

Yes ,for me it's good

@Andrea-Miele
Copy link

can you update your code for oop?
I want to have a look

Yeah please do that

@keosariel
Copy link
Owner

can you update your code for oop?
I want to have a look

Yeah please do that

I'd do that as soon as possible

@keosariel
Copy link
Owner

keosariel commented Oct 7, 2021

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
@streetartist pls your discord tag

@keosariel
Copy link
Owner

keosariel commented Oct 7, 2021

can you update your code for oop?
I want to have a look

Yeah please do that

I'd do that as soon as possible

Yo guys, the code is so soo messy!!!
Most of the stuff I did in the code was just proof of concept for a new language I was going to build, which I ended up not building

@Andrea-Miele
Copy link

Andrea-Miele commented Oct 9, 2021

@keosariel we cannot talk on discord
Your account is hacked
Never click links that promise nitro

@keosariel
Copy link
Owner

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.
Besides we'd need to talk on how the syntax would work.

Sorry!!!!

@keosariel
Copy link
Owner

Any recommendation on a communication platform??

@Andrea-Miele
Copy link

Andrea-Miele commented Nov 6, 2021

I still don't understand why my discord was suspended.

Probably because you got hacked
Screenshot_20211106-150623_Discord.jpg

Any recommendation on a communication platform??

I don't know. I used to use discord, but if your account is suspended we need to find an alternative

@keosariel
Copy link
Owner

I was hacked.
I didn't send that message

@keosariel
Copy link
Owner

@streetartist hasn't accepted the repo invite yet

@keosariel
Copy link
Owner

@Andrea-Miele pls resend your tag
I created a new discord account using keosariel_

@Andrea-Miele
Copy link

Andrea Miele#5093

@Andrea-Miele
Copy link

Andrea-Miele commented Nov 6, 2021

@keosariel tell me when you'll send the request

@keosariel
Copy link
Owner

I've sent it!

@OneAvargeCoder193
Copy link

OneAvargeCoder193 commented Sep 12, 2022

I would love to see what this is it!
From what I see here it looks interesting and I would love to see this!
GeraForever#4530

@keosariel
Copy link
Owner

Ohh christ! I'd have to continue this project.
@OneAvargeCoder193 @streetartist @Andrea-Miele I guess you guys are in??

@Andrea-Miele
Copy link

Of course!

@keosariel
Copy link
Owner

also @Andrea-Miele are you active on discord now

@Andrea-Miele
Copy link

Andrea-Miele commented Sep 13, 2022

Kinda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants