[Vm-dev] Re: [Pharo-users] Compiling Pharo to C++
btc at openinworld.com
Tue Feb 16 13:28:54 UTC 2016
> Unreal assumes that you either write C++ code
> or using their own scripting language "Blueprint".
Not entirely true ....
On Tue, Feb 16, 2016 at 5:42 PM, Clément Bera <bera.clement at gmail.com> wrote:
> Are you sure C++ compilation is the best way ? There are a lot of flaws:
> Smalltalk needs to be restrictive or will be compiled to very slow code, you
> will loose debugging features, etc.
> I would try to integrate Pharo the same way lua is integrated in engines
> like Source2 from valve: you run your Unreal engine and have it call Pharo
> as a scripting language to code some features.
Something like , scrolling down to the #include ?
What would be the Cog equivalent of...?
lua_State* L = lua_open();
and what would be a good starting point to look at this?
main() and fakevm() in threadValidate.c  seem to lay out a basic structure.
I see interpret() called from:
* platforms/unix/vm/sqUnixMainNoDisplay.c  and
* iOS/vm/Common/Classes/sqSqueakMainApplication.m 
but can't see where this is implemented.
I guess the new SDL derived headless mode mentioned recently would
help with embedding Pharo in another program?
> In such case, one needs to
> make the VM embeddable in a C++ app, but on the vm-dev mailing list people
> can help you to do so. Then you need to define some APIs based on what exist
> in the interpreter proxy to easily call Pharo methods and share struct /
> objects from C++. Lastly, you may consider adding a few settings in FFI. By
> default the Smalltalk stack and the C stack are separated to to Smalltalk
> specific stack page handling. I guess with some annotation in Pharo API code
> called from C++ you could define the case where the stack could be shared or
> While compiling to C++, how to you plan your compiler to manage memory ?
> 2016-02-16 9:52 GMT+01:00 kilon.alios <kilon.alios at gmail.com>:
>> So doing further research into Unreal , I have reached the conclusion that
>> the best way to integrate Pharo is make a compiler that takes Pharo code
>> compiles it to C++.
>> I have barely scratch such area when I was playing around with Pharo AST
>> nodes. Any advice / ideas how to accomplish this ?
>> Currently my goal is to start super simple, with compiling small pharo
>> fragments to C++ code and then much later on even introduce extensions to
>> the pharo language to accommodate for C++ features like templates ,
>> (FFI probably already cover this) , static types etc. Obviously if I can
>> keep the pharo syntax intact would be the ideal option.
More information about the Vm-dev