www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Converting Lua source to D

reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
I am making an attempt convert Lua to D. This is less about the 
conversion and more about exploring the tooling to make it happen.

I have chosen to do this file by file and attempting to start 
with linint. I wanted to make use of dpp, however I hit a 
segmentation fault and reduced dependency.

https://github.com/JesseKPhillips/lua/blob/dpp/init/linit.d

I wasn't able to get a core dump for debugging. Anyone willing to 
give some advice or solution? I have gone through a number of 
compilers and better.

I have implemented a build pipeline but didn't incorporate the D 
portion at this time.
Mar 04 2020
parent reply AB <a b.c> writes:
On Thursday, 5 March 2020 at 07:44:21 UTC, Jesse Phillips wrote:
 I am making an attempt convert Lua to D. This is less about the 
 conversion and more about exploring the tooling to make it 
 happen.

 I have chosen to do this file by file and attempting to start 
 with linint. I wanted to make use of dpp, however I hit a 
 segmentation fault and reduced dependency.

 https://github.com/JesseKPhillips/lua/blob/dpp/init/linit.d

 I wasn't able to get a core dump for debugging. Anyone willing 
 to give some advice or solution? I have gone through a number 
 of compilers and better.

 I have implemented a build pipeline but didn't incorporate the 
 D portion at this time.
I am only guessing, but I think the problem is line 87. Arrays and slices in D contain a length field and thus do not need to be null terminated. The foreach at line 96 iterates on all valid indices and thus in the last iteration you call luaL_requiref(L, null, null, 1). Try changing static const luaL_Reg[] loadedlibs = [ ... {LUA_DBLIBNAME, &luaopen_debug}, {null, null} ]; to static const luaL_Reg[] loadedlibs = [ ... {LUA_DBLIBNAME, &luaopen_debug} ];
Mar 05 2020
parent reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Thursday, 5 March 2020 at 16:54:35 UTC, AB wrote:
 I am only guessing, but I think the problem is line 87.
 Arrays and slices in D contain a length field and thus do not 
 need to be null terminated.
 The foreach at line 96 iterates on all valid indices and thus 
 in the last iteration you call luaL_requiref(L, null, null, 1).

 Try changing

 static const luaL_Reg[] loadedlibs = [
   ...
   {LUA_DBLIBNAME, &luaopen_debug},
   {null, null}
 ];

 to

 static const luaL_Reg[] loadedlibs = [
   ...
   {LUA_DBLIBNAME, &luaopen_debug}
 ];
I knew I was blind, thank you. Segfault is gone. Now I should look at getting the CI up and Test failure fixed.
Mar 06 2020
parent Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Saturday, 7 March 2020 at 01:14:14 UTC, Jesse Phillips wrote:

 Now I should look at getting the CI up and Test failure fixed.
Test failures were my local system and related to the stack overflow tests. I have the build pipeline up and running but hit a couple of snags. https://github.com/JesseKPhillips/lua/runs/493866555?check_suite_focus=true * Couldn't use dpp in the build because I couldn't install libclang-dev on the runner (ubuntu repository issue) * The compiler couldn't locate libphobos I think I'll be able to make use of dpp locally though.
Mar 08 2020