tom-writes-code / rpgle-repl

A green-screen REPL style workspace to assist with RPGLE development
MIT License
26 stars 3 forks source link

Long variable names prevent compilation #20

Closed tom-writes-code closed 2 years ago

tom-writes-code commented 2 years ago

REPL does not create **FREE objects, and so the source can run off the page, preventing compilation. The following example fails to compile:

dcl-ds legal_individual_details qualified;                   
  full_name_for_correspondence_purposes char(50);  
end-ds;                                            

legal_individual_details.                          
  full_name_for_correspondence_purposes = 'Mr Tom';

The generated source clearly shows generated procedure dcl-proc replResult_MAIN_LEGAL_INDIVIDUAL_DETAILS_FULL_NAME_FOR_CORRESP running way beyond 80 characters.

REPLVARS has a unique variable ID per variable - we should be able to use this instead of the name, and then we never need to worry about long variable names again.

tom-writes-code commented 2 years ago

Kicked the tyres with the following tests:

line code                                                                    result       
0001 dcl-s a ind;                                                                         
0002 dcl-s b char(3);                                                                     
0003 dcl-s c char(3) dim(2);                                                              
0004 dcl-ds d qualified;                                                                  
0005   d1 char(1);                                                                        
0006 end-ds;                                                                              
0007 dcl-ds e;                                                                            
0008   e1 char(1);                                                                        
0009 end-ds;                                                                              
0010 dcl-ds t_f qualified template;                                                       
0011   f1 char(1);                                                                        
0012   f2 char(2) dim(2);                                                                 
0013 end-ds;                                                                              
0014 dcl-ds f likeds(t_f) dim(2);                                                         
0015                                                                                      
0016 a = *on;                                                                A = true     
0017 b = 'B';                                                                B = 'B'      
0018 c(1) = 'C';                                                             c(1) = 'C'   
0019 c = c;                                                                  1: C(1) = 'C'
 +                                                                           2: C(2) = '' 
0020 d.d1 = 'D';                                                             D.D1 = 'D'   
0021 e1 = 'E';                                                               E1 = 'E'     
0022 f(1).f1 = 'F';                                                          f(1).f1 = 'F'      
0023 f(1).f2(1) = 'F';                                                       f(1).f2(1) = 'F'   
0024 f(2) = f(1);                                                            1: f(2).F1 = 'F'   
 +                                                                           2: f(2).F2(1) = 'F'
 +                                                                           3: f(2).F2(2) = '' 
0025 f(2).f2 = f(2).f2;                                                      1: f(2).f2(1) = 'F'
 +                                                                           2: f(2).f2(2) = ''