gijit / gi

gijit is a just-in-time trace-compiled golang REPL. Standing on the shoulders of giants (GopherJS and LuaJIT).
Other
320 stars 17 forks source link

pointers in structs don't work yet #16

Closed glycerine closed 6 years ago

glycerine commented 6 years ago

or really anywhere; we haven't implemented them yet.

gi> type S struct {                                                                                 
        ptr *S                                                                                  
}                                                                                               

gi> var s S                                                                                     
var s Serror from Lua vm.LoadString(): supplied lua with: 's = __reg:NewInstance("S",{["ptr"]=ptrType.nil});'                                                                     
lua stack:     
========== begin DumpLuaStack: top = 1                                                          
DumpLuaStack: i=1, t= 4                                                                         
 String :       [string "..."]:1: '<name>' expected near 'nil'                                  
========= end of DumpLuaStack                                                                   

gi>
glycerine commented 6 years ago

In v0.9.1, pointers in structs work.

gi> type S struct {                                                                             \

        ptr *S                                                                                   
}                                                                                                

elapsed: '100.456µs'                                                                             
gi> var s S                                                                                      

elapsed: '36.626µs'                                                                              
gi> s                                                                                            
self.__typename: S; table: 0x04d249a0 {                                                          
    ptr:        table: 0x04d24560,                                                               
}                                                                                                

elapsed: '122.167µs'                                                                             
gi>   

cf tests 120-123 struct_test.go