Posted by
Ben Coman on
Feb 16, 2016; 1:05pm
URL: https://forum.world.st/Compiling-Pharo-to-C-tp4877775p4877873.html
> Unreal assumes that you either write C++ code
> or using their own scripting language "Blueprint".
Not entirely true [1]....
[1]
https://forums.unrealengine.com/showthread.php?3958-Scripting-Language-extensions-via-pluginsOn Tue, Feb 16, 2016 at 5:42 PM, Clément Bera <
[hidden email]> 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 [2], scrolling down to the #include ?
[2]
http://accu.org/index.php/journals/351What 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 [3] seem to lay out a basic structure.
[3]
https://git.io/vg7bnI see interpret() called from:
* platforms/unix/vm/sqUnixMainNoDisplay.c [4] and
* iOS/vm/Common/Classes/sqSqueakMainApplication.m [5]
but can't see where this is implemented.
[4]
https://git.io/vg5fB[5]
https://git.io/vg5JSI guess the new SDL derived headless mode mentioned recently would
help with embedding Pharo in another program?
cheers -ben
> 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
> not.
>
> While compiling to C++, how to you plan your compiler to manage memory ?
>
>
> 2016-02-16 9:52 GMT+01:00 kilon.alios <
[hidden email]>:
>>
>> 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
>> and
>> 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
>> code
>> fragments to C++ code and then much later on even introduce extensions to
>> the pharo language to accommodate for C++ features like templates ,
>> pointers
>> (FFI probably already cover this) , static types etc. Obviously if I can
>> keep the pharo syntax intact would be the ideal option.