Project

General

Profile

4350_fuzzy_matching_changes_20220524a.patch

Greg Shah, 05/24/2022 01:27 PM

Download (580 KB)

View differences:

new/rules/annotations/annotations_prep.xml 2022-05-12 15:05:03 +0000
8 8
**
9 9
** Copyright (c) 2018-2022, Golden Code Development Corporation.
10 10
**
11
** _#_ _I_ __Date__ ________________________________Description_________________________________
11
** _#_ _I_ __Date__ ______________________________________Description_______________________________________
12 12
** 001 GES 20181209 First version.
13 13
**     CA  20181213 Automatically register all builtin skeleton classes, in the 
14 14
**                  com.goldencode.p2j.oo package followed by the legacy package without the 
......
26 26
** 005 CA  20200412 Added incremental conversion support.
27 27
** 006 CA  20200508 Track the USING specs for each program - needed to solve cases when the imported
28 28
**                  class name is the same name as the program with the import statement.
29
** 007 RFB 20200930 Check for a dynamic-function without an "IN", and create an "IN THIS-PROCEDURE". Ref #4861
29
** 007 RFB 20200930 Check for a dynamic-function without an "IN", and create an "IN THIS-PROCEDURE". Refs
30
**                  #4861.
30 31
**     RFB 20201001 Backed out #4861 updates.
31 32
**     RFB 20201004 Reintroduced changes, with additional safeguards and new annotation. Also made it more
32 33
**                  robust, handling nested dynamic-functions. Ref #4861
33 34
**     CA  20220310 Fixed 'dynfunc_in_this_procedure, the oldtype must be explicitly set, and not hard-coded.
34 35
**     CA  20220426 If the same simple class name exists in more than one explicit import, then only the first
35 36
**                  import using this simple class name must be emitted. 
37
**     GES 20220427 Removed the unused variable mode and renamed convert_member_name to convert_method_name.
38
**                  Rewrote convert_method_name to delegate most of the work to ClassDefinition.
36 39
*/
37 40
 -->
38 41
 
......
117 120
   <variable name="clsName"          type="java.lang.String" />
118 121
   <variable name="clsPkg"           type="java.lang.String" />
119 122
   <variable name="mkey"             type="java.lang.String" />
120
   <variable name="cclass"           type="com.goldencode.p2j.uast.ConvertedClassName" />
123
   <variable name="clsdef"           type="com.goldencode.p2j.uast.ClassDefinition" />
121 124

  
122 125
   <!-- pipeline of rule-sets to process -->
123 126
   
124 127
   <func-library access="public">
125
      <function name="convert_member_name">
128
      <function name="convert_method_name">
126 129
         <parameter name="mname"       type="java.lang.String" />
127
         <parameter name="cclass"      type="com.goldencode.p2j.uast.ConvertedClassName" />
128
         <parameter name="mtype"       type="java.lang.Integer" />
130
         <parameter name="clsdef"      type="com.goldencode.p2j.uast.ClassDefinition" />
129 131
         <parameter name="mAst"        type="com.goldencode.ast.Aast" />
130 132
         
131 133
         <return    name="javaname"    type="java.lang.String" />
132 134
         
133
         <variable  name="idx"            type="java.lang.Integer" />
134
         
135 135
         <rule>ovrdNames.containsKey(mname.toLowerCase())
136 136
            <action>mname = ovrdNames.get(mname.toLowerCase())</action>
137 137
         </rule>
138 138
         
139
         <!-- the ConvertedClassName manages our namespaces and has separate behavior for
140
              each case; as other types are added the logic must be expanded below; the result
141
              is cleaner for the caller while adding a small amount of extra code here; the
142
              trade-off is worth it -->
143
         
144
         <rule>mtype == names.variable
145
            <action>javaname = cclass.getVariable(mname)</action>
146
           
147
           <!-- do not track method names -->
148
           <action on="false">javaname = null</action>
149
         </rule>
150
         
151
         <rule>mtype == names.method and mAst != null
152
            <action>javaname = cclass.getConvertedMethodName(mname, mAst)</action>
153
         </rule>
154
         
155
         <!-- if not already in the legacy map, then we have a new javaname to calculate -->
156
         <rule>javaname == null
157
            <action>javaname = names.convert(mname, mtype)</action>
158

  
159
            <rule>conflicts.contains(javaname)
160
               <action>javaname = sprintf("%s_", javaname)</action>
161
            </rule>
162
            
163
            <!-- make sure we don't have collisions (the legacy names can't collide but the
164
                 converted javaname could -->
165
            <rule>
166
               (mtype == names.variable and cclass.isVariableNameConflict(javaname)) or
167
               (mtype == names.method   and cclass.isMethodNameConflict(javaname, mAst))
168
               
169
               <action>idx = 0</action>
170
               
171
               <!-- compute an index such that this name is unique across all method names -->
172
               <while>
173
                  (mtype == names.variable and cclass.isVariableNameConflict(javaname)) or
174
                  (mtype == names.method   and cclass.isMethodNameConflict(javaname, mAst))
175
               
176
                  <action>idx = idx + 1</action>
177
                  <action>javaname = sprintf("%s_%d", javaname, idx)</action>
178
               </while>
179
            </rule>
180
            
181
            <rule>mtype == names.variable
182
               <action>cclass.addVariable(mname, javaname)</action>
183
            </rule>
184
            <rule>mtype == names.method
185
               <action>cclass.addMethod(mname, javaname, mAst)</action>
186
            </rule>
187
         </rule>
139
         <rule>javaname = clsdef.getConvertedMethodName(mname, mAst)</rule>
188 140
      </function>
189 141

  
190 142
   </func-library>
new/rules/annotations/method_defs.rules 2022-05-22 12:43:27 +0000
39 39
**                  and the javaname must be changed).
40 40
**     CA  20220516 For extent OO properties, we need both indexed and bulk setters, plus bulk getters, 
41 41
**                  regardless if there are explicit indexed setters/getters at the property definition.
42
**     GES 20220522 Reworked to properly separate and handle the method names for the extent property bulk
43
**                  getter, bulk setter and "all" setter. 
42 44
*/
43 45
-->
44 46

  
......
149 151
   <variable name="childref"     type="com.goldencode.ast.Aast" />
150 152
   
151 153
   <func-library access="private">
154
   
155
      <!-- called with copy as KW_GET or KW_SET -->
152 156
      <function name="process_getter_setter">
153
         <parameter name="mref"    type="com.goldencode.ast.Aast" />
154
         <parameter name="tref"    type="com.goldencode.ast.Aast" />
155
         <parameter name="indexed" type="java.lang.Boolean" />
157
         <parameter name="mref"     type="com.goldencode.ast.Aast" />
158
         <parameter name="tref"     type="com.goldencode.ast.Aast" />
159
         <parameter name="indexed"  type="java.lang.Boolean" />
160
         <variable  name="javaname" type="java.lang.String" />
156 161
         
157 162
         <rule>true
158 163
            <rule>isAbstract
......
233 238
            </rule>
234 239
            
235 240
            <rule>extent != null and extent != 0
236
               <!-- emit the bulk setter and getter, single-value setter -->
241
               <!-- emit the bulk setter, "all" setter and bulk getter -->
237 242
               <rule>indexed
238 243
                  <action>tref = mref.graftCopyTo(mref.parent, null)</action>
239 244
                  <action on="false">tref = mref</action>
......
242 247
               <rule>type == prog.kw_get
243 248
                  <!-- bulk getter -->
244 249
                  
250
                  <!-- lookup and copy the bulk getter javaname (was deferred from naming.rules) -->
251
                  <rule>copy.parent.isAnnotation("bulk-get-javaname")
252
                     <action>javaname = copy.parent.getAnnotation("bulk-get-javaname")</action>
253
                     <action on="false">javaname = "method_defs.rules_FIXME1"</action>
254
                  </rule>
255
                  <action>tref.putAnnotation("javaname", javaname)</action>
256
                  
245 257
                  <!-- remove the parameter and set the extent for the return type -->
246 258
                  <rule>indexed
247 259
                     <action>eref = tref.getImmediateChild(prog.lparens, null)</action>
......
284 296
               <rule>type == prog.kw_set
285 297
                  <!-- bulk setter -->
286 298
                  
299
                  <!-- lookup and copy the bulk setter javaname (was deferred from naming.rules) -->
300
                  <rule>copy.parent.isAnnotation("bulk-set-javaname")
301
                     <action>javaname = copy.parent.getAnnotation("bulk-set-javaname")</action>
302
                     <action on="false">javaname = "method_defs.rules_FIXME2"</action>
303
                  </rule>
304
                  <action>tref.putAnnotation("javaname", javaname)</action>
305
                  
287 306
                  <!-- remove the index parameter and set the extent -->
288 307
                  <rule>indexed
289 308
                     <action>eref = tref.getImmediateChild(prog.lparens, null)</action>
......
328 347
                     <action>eref.putAnnotation("refid", vref.id)</action>
329 348
                  </rule>
330 349

  
331
                  <!-- single-value setter -->
350
                  <!-- "all" setter (single element parameter is assigned to all elements)  -->
332 351
                  <action>tref = mref.graftCopyTo(mref.parent, null)</action>
333 352

  
353
                  <!-- lookup and copy the bulk getter javaname (was deferred from naming.rules) -->
354
                  <rule>copy.parent.isAnnotation("set-all-javaname")
355
                     <action>javaname = copy.parent.getAnnotation("set-all-javaname")</action>
356
                     <action on="false">javaname = "method_defs.rules_FIXME3"</action>
357
                  </rule>
358
                  <action>tref.putAnnotation("javaname", javaname)</action>
359
                  
334 360
                  <!-- remove the index parameter and don't set the extent -->
335 361
                  <rule>indexed
336 362
                     <action>eref = tref.getImmediateChild(prog.lparens, null)</action>
......
572 598
            <action on="false">putNote("classname", "void")</action>
573 599
         </rule>
574 600
         
575
         <!-- conversion of javaname was already done during annotations_prep -->
601
         <!-- conversion of javaname was already done during parsing -->
576 602
         <action>pname = getNoteString("name")</action>
577 603
         <action>javaname = getNoteString("javaname")</action>
578 604
         
new/rules/annotations/naming.rules 2022-05-22 12:23:43 +0000
7 7
**
8 8
** Copyright (c) 2005-2022, Golden Code Development Corporation.
9 9
**
10
** _#_ _I_ __Date__ __JPRM__ ___________________________________Description___________________________________
10
** _#_ _I_ __Date__ __JPRM__ __________________________________Description__________________________________
11 11
** 001 SIY 20051103   @23186 Initial implementation.
12 12
** 002 GES 20060124   @24051 Rewrote to enhance the annotations to provide
13 13
**                           a more correct name mapping calculation.
......
47 47
**     CA  20200508          Track the USING specs for each program - needed to solve cases when 
48 48
**                           the imported class name is the same name as the program with the 
49 49
**                           import statement.
50
**     CA  20210609          Fixed extent property used as output/input-output argument.
50
** 021 CA  20210609          Fixed extent property used as output/input-output argument.
51 51
**     ME  20211022          Send the AST node as input to loadConvertedClass call.
52 52
**     OM  20211111          Added transaction support for finally blocks.
53 53
**     CA  20220427          Constructors names must be aware of overload suffixes (as their Java signature
......
55 55
**     CA  20220428          Non-persistent programs are emitted only at the (Sub)AppObject service.
56 56
**     CA  20220516          For explicit setter or getter for OO properties, force the index to be int64.
57 57
**                           Fixed 'override' for OO properties.
58
**     GES 20220501          Reworked convert_member_name to be convert_method_name. Rewrote usage of
59
**                           ConvertedClassName to use ClassDefinition instead. Reworked method naming for
60
**                           properties with extents.
58 61
*/
59 62
 -->
60 63
 
......
144 147
   <variable name="mname"       type="java.lang.String" />
145 148
   <variable name="pname"       type="java.lang.String" />
146 149
   <variable name="ename"       type="java.lang.String" />
150
   <variable name="propkey"     type="java.lang.String" />
147 151
   <variable name="pkgbase"     type="java.lang.String" />
148 152
   <variable name="conflicts"   type="java.util.Set" />
149 153
   <variable name="iter"        type="java.util.Iterator" />
150
   <variable name="cclass"      type="com.goldencode.p2j.uast.ConvertedClassName" />
154
   <variable name="clsdef"      type="com.goldencode.p2j.uast.ClassDefinition" />
151 155
   <variable name="mAst"        type="com.goldencode.ast.Aast" />
152 156
   <variable name="ref"         type="com.goldencode.ast.Aast" />
153 157
   <variable name="ref2"        type="com.goldencode.ast.Aast" />
......
321 325
         <!-- this needs to be done first -->
322 326
         <action>setConvertedClassName(file, ooname, fullpkg, classname)</action>
323 327
         <!-- map the source file name to the converted class naming info -->
324
         <action>cclass = loadConvertedClass(file, true, this)</action>
328
         <action>clsdef = loadConvertedClass(file, true, this)</action>
325 329

  
326 330
         <!-- save the converted default constructor name at the root node -->
327
         <action>mname = cclass.getLegacySimpleName()</action>
328
         <action>
329
            javaname = execLib("convert_member_name", mname, cclass, names.method, null)
330
         </action>
331
         <action>javaname = clsdef.getSimpleJavaName()</action>
332
         <!-- TODO: do we need to register a method for this?  A better approach would be to calculate
333
                    this at parse time -->
331 334
         <rule>pkgbase.isEmpty()
332 335
            <action>javaname = sprintf("__%s_constructor__", javaname)</action>
333 336
            <action on="false">javaname = sprintf("__%s_%s_constructor__", pkgbase, javaname)</action>
......
339 342
      <rule>relativePath("METHOD_DEF/KW_METHOD/SYMBOL")
340 343
         <action>mname = text</action>
341 344
         <action>
342
            javaname = execLib("convert_member_name", mname, cclass, names.method, copy.parent.parent)
345
            javaname = execLib("convert_method_name", mname, clsdef, copy.parent.parent)
343 346
         </action>
344 347
         <action>copy.parent.putAnnotation("javaname", javaname)</action>
345 348
      </rule>
......
347 350
      <rule>relativePath("CONSTRUCTOR/KW_CONSTRUC")
348 351
         <!-- to resolve constructor overload clash on object parameters, disambiguate here -->
349 352
         <action>mname = getNoteString("name")</action>
353
         <!-- TODO: do we need to register a method for this?  A better approach would be to calculate
354
                    this at parse time -->
350 355
         <action>
351
            javaname = execLib("convert_member_name", mname, cclass, names.method, copy.parent)
356
            javaname = execLib("convert_method_name", mname, clsdef, copy.parent)
352 357
         </action>
353 358
         <rule>pkgbase.isEmpty()
354 359
            <action>javaname = sprintf("__%s_constructor__", javaname)</action>
......
364 369
         relativePath("DEFINE_PROPERTY/KW_GET")    or
365 370
         relativePath("DEFINE_PROPERTY/KW_SET")
366 371
         
367
         <!-- getter and setter method names are converted here -->
372
         <!-- simple getter and setter method names already exist and are copied here; bulk getter and
373
              bulk/all setters don't yet exist but their names are already converted; since there is no
374
              method def yet for those we will defer lookup/copy of those until they exist (see the
375
              process_getter_setter function in method_defs.rules) -->
368 376
         <action>pname = copy.parent.getAnnotation("name")</action>
369 377
         <action>putNote("name", pname)</action>
370 378

  
......
377 385
         </rule>
378 386
            
379 387
         <rule>type == prog.kw_get
388
         
389
            <!-- only the simple scalar/single element getter can be handled here -->
390
            <action>pname = sprintf("get-%s", pname)</action>
391
            <action>propkey = "get-javaname"</action>
392
            
380 393
            <rule>downPath("LPARENS/PARAMETER") and parent.downPath("KW_EXTENT")  
381 394
               <!-- force the index parameter's data type to be int64 -->
382 395
               <action>ref2 = copy.getImmediateChild(prog.lparens, null)</action>
383 396
               <action>ref2 = ref2.getImmediateChild(prog.parameter, null)</action>
384 397
               <action>ref2.putAnnotation("classname", "int64")</action>
385 398
            </rule>
386
         
387
            <action>pname = cclass.disambiguateLegacyPropertyName("get", pname)</action>
388 399
            <action>
389 400
               mAst.putAnnotation("return_type", #(long) parent.getAnnotation("type"))
390 401
            </action>
......
401 412
               </rule>
402 413

  
403 414
               <action>mAst.putAnnotation("return_type", #(long) prog.kw_void)</action>
404
               <action>pname = cclass.disambiguateLegacyPropertyName("set", pname)</action>
415
               
416
               <!-- only the simple scalar/single element setter can be handled here -->
417
               <action>pname = sprintf("set-%s", pname)</action>
418
               <action>propkey = "set-javaname"</action>
405 419

  
406 420
               <action>ref = createProgressAst(prog.parameter, ref)</action>
407 421
               <action>ref.putAnnotation("type", #(long) parent.getAnnotation("type"))</action>
......
425 439
               <action>mAst.setHidden(true)</action>
426 440
            </rule>
427 441
         </rule>
428
         <action>
429
            javaname = execLib("convert_member_name", pname, cclass, names.method, mAst)
430
         </action>
442
         <rule>copy.parent.isAnnotation(propkey)
443
            <action>javaname = copy.parent.getAnnotation(propkey)</action>
444
            <action on="false">javaname = "naming.rules_FIXME1"</action>
445
         </rule>
431 446
         <action>
432 447
            mAst.putAnnotation("access-mode", #(long) parent.getAnnotation("access-mode"))
433 448
         </action>
......
448 463
            <action>pname = getNoteString("name")</action>
449 464
            
450 465
            <!-- - extent(property) will be like a function named length-of-property() -->
451
            <action>ename = cclass.disambiguateLegacyPropertyName("length-of", pname)</action>
466
            <action>ename = sprintf("length-of-%s", pname)</action>
467
            <action>propkey = "length-of-javaname"</action>
452 468
            <!-- we temporary attach, to build the AST - will delete once done -->
453 469
            <action>mAst = createProgressAst(prog.kw_method, copy)</action>
454 470
            <action>ref = createProgressAst(prog.lparens, mAst)</action>
......
458 474
            <action>ref = createProgressAst(prog.kw_as, ref)</action>
459 475
            <action>ref = createProgressAst(prog.kw_int64, ref)</action>
460 476
            <action>mAst.setHidden(true)</action>
461
            <action>
462
               javaname = execLib("convert_member_name", ename, cclass, names.method, mAst)
463
            </action>
477
            <rule>copy.isAnnotation(propkey)
478
               <action>javaname = copy.getAnnotation(propkey)</action>
479
               <action on="false">javaname = "naming.rules_FIXME2"</action>
480
            </rule>
464 481
            <action>mAst.putAnnotation("name", ename)</action>
465 482
            <action>mAst.putAnnotation("javaname", javaname)</action>
466 483
            <action>mAst.putAnnotation("oo-data-store", "METHOD")</action>
......
469 486
            <action>putNote("extent-length-javaname", javaname)</action>
470 487
            
471 488
            <!-- extent(property) = size will be like a function named resize-property() -->
472
            <action>ename = cclass.disambiguateLegacyPropertyName("resize", pname)</action>
489
            <action>ename = sprintf("resize-%s", pname)</action>
490
            <action>propkey = "resize-javaname"</action>
473 491
            <action>mAst = createProgressAst(prog.kw_method, copy)</action>
474 492
            <action>ref = createProgressAst(prog.lparens, mAst)</action>
475 493
            <action>mAst.setHidden(true)</action>
476
            <action>
477
               javaname = execLib("convert_member_name", ename, cclass, names.method, mAst)
478
            </action>
494
            <rule>copy.isAnnotation(propkey)
495
               <action>javaname = copy.getAnnotation(propkey)</action>
496
               <action on="false">javaname = "naming.rules_FIXME3"</action>
497
            </rule>
479 498
            <action>mAst.putAnnotation("name", ename)</action>
480 499
            <action>mAst.putAnnotation("javaname", javaname)</action>
481 500
            <action>mAst.putAnnotation("oo-data-store", "METHOD")</action>
......
484 503
            <action>putNote("extent-resize-javaname", javaname)</action>
485 504
         </rule>
486 505
      </rule>
487
      
488
      <rule>this.type == prog.define_variable and upPath("CLASS_DEF/BLOCK/STATEMENT")
489
         <action>
490
            cclass.addVariable(getNoteString("name"), 
491
                               getNoteString("javaname"), 
492
                               getNoteLong("extent"))
493
         </action>
494
      </rule>
495 506
   </walk-rules>
496 507

  
497 508
   <post-rules>
new/rules/annotations/oo_references.rules 2022-05-23 19:34:04 +0000
43 43
**     CA  20220426 Always wrap the DYNAMIC-PROPERTY's property name and index, when they are literals.
44 44
**                  Fixed a problem when accessing a builtin OO property from a getter/setter.
45 45
**     CA  20220516 Fixed ASSIGN EXTENT(property) = size.
46
**     GES 20220501 Rewrote usage of ConvertedClassName to use ClassDefinition instead. This required
47
**                  parse time name conversion for the methods we emit for properties.
46 48
*/
47 49
 -->
48 50
 
......
108 110
   <worker class="com.goldencode.p2j.pattern.FileOperationsWorker"       namespace="fileWorker" />
109 111

  
110 112
   <!-- variables -->
111
   <variable name="nameinfo"  type="com.goldencode.p2j.uast.ConvertedClassName" />
113
   <variable name="clsdef"    type="com.goldencode.p2j.uast.ClassDefinition" />
112 114
   <variable name="fname"     type="java.lang.String" />
113 115
   <variable name="pname"     type="java.lang.String" />
114 116
   <variable name="oname"     type="java.lang.String" />
115 117
   <variable name="sname"     type="java.lang.String" />
118
   <variable name="propkey"   type="java.lang.String" />
116 119
   <variable name="javaname"  type="java.lang.String" />
117 120
   <variable name="usingPkg"  type="java.lang.String" />
118 121
   <variable name="pkgroot"   type="java.lang.String" />
......
143 146
   <variable name="pidx"      type="java.lang.Long" />
144 147
   <variable name="refid"     type="java.lang.Long" />
145 148
   <variable name="access"    type="java.lang.Long" />
149
   <variable name="isStatic"     type="java.lang.Boolean" />
150
   <variable name="isExtent"     type="java.lang.Boolean" />
151
   <variable name="accessMode"   type="java.lang.Long" />
152
   <variable name="extent"       type="java.lang.Long" />
146 153
   <variable name="usingClasses" type="java.util.Set" />
147 154
   
148 155
   <init-rules>
......
247 254
               </rule>
248 255
               
249 256
               <rule on="false">true
250
                  <!-- explicit class import -->
257
                  <!-- non-Java, explicit class import -->
251 258
                  <action>fname = getNoteString("source-file")</action>
252
                  <action>nameinfo = loadConvertedClass(fname, false, this)</action>
253
                  <rule>nameinfo != null
254
                     <action>putNote("legacy-import", nameinfo.getQualifiedName())</action>
259
                  <action>clsdef = loadConvertedClass(fname, false, this)</action>
260
                  <rule>clsdef != null
261
                     <action>putNote("legacy-import", clsdef.getQualifiedJavaName())</action>
255 262
                  </rule>
256 263
               </rule>
257 264
            </rule>
......
288 295
            isNote("qualified") and isNote("source-file")
289 296

  
290 297
         <action>fname = getNoteString("source-file")</action>
291
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
298
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
292 299
         
293
         <rule>nameinfo != null
294
            <action>oname = nameinfo.getQualifiedName()</action>
300
         <rule>clsdef != null
301
            <action>oname = clsdef.getQualifiedJavaName()</action>
295 302
            <rule>oname.endsWith("_BaseObject_") and parent.type == prog.kw_inherits
296 303
               <action>oname = "com.goldencode.p2j.oo.lang.BaseObject"</action>
297 304
               <action>sname = "BaseObject"</action>
298 305
               
299
               <action on="false">sname = nameinfo.getClassName()</action>
306
               <action on="false">sname = clsdef.getSimpleJavaName()</action>
300 307
            </rule>
301 308

  
302 309
            <action>putNote("full-java-class", oname)</action>
303 310
            <action>putNote("simple-java-class", sname)</action>
304
            <action>putNote("containing-package", nameinfo.getPackage())</action>
311
            <action>putNote("containing-package", clsdef.getJavaPackage())</action>
305 312
            <rule>not usingClasses.contains(oname)
306 313
               <action>putNote("qualified-reference", true)</action>
307 314
            </rule>
......
321 328
         <action>copy.parent.putAnnotation("source-file", getNoteString("source-file"))</action>
322 329

  
323 330
         <action>fname = getNoteString("source-file")</action>
324
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
331
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
325 332
         
326
         <rule>nameinfo != null
327
            <action>copy.parent.putAnnotation("full-java-class", nameinfo.getQualifiedName())</action>
328
            <action>copy.parent.putAnnotation("simple-java-class", nameinfo.getClassName())</action>
329
            <action>copy.parent.putAnnotation("containing-package", nameinfo.getPackage())</action>
330
            <rule>not usingClasses.contains(nameinfo.getQualifiedName())
333
         <rule>clsdef != null
334
            <action>copy.parent.putAnnotation("full-java-class", clsdef.getQualifiedJavaName())</action>
335
            <action>copy.parent.putAnnotation("simple-java-class", clsdef.getSimpleJavaName())</action>
336
            <action>copy.parent.putAnnotation("containing-package", clsdef.getJavaPackage())</action>
337
            <rule>not usingClasses.contains(clsdef.getQualifiedJavaName())
331 338
               <action>copy.parent.putAnnotation("qualified-reference", true)</action>
332 339
            </rule>
333 340
            <action on="false">
......
341 348
      
342 349
      <rule>this.type == prog.enum_value
343 350
         <action>fname = getNoteString("source-file")</action>
344
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
351
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
345 352
         
346
         <rule>nameinfo != null
347
            <action>copy.putAnnotation("full-java-class", nameinfo.getQualifiedName())</action>
348
            <action>copy.putAnnotation("simple-java-class", nameinfo.getClassName())</action>
349
            <action>copy.putAnnotation("containing-package", nameinfo.getPackage())</action>
350
            <rule>not usingClasses.contains(nameinfo.getQualifiedName())
353
         <rule>clsdef != null
354
            <action>copy.putAnnotation("full-java-class", clsdef.getQualifiedJavaName())</action>
355
            <action>copy.putAnnotation("simple-java-class", clsdef.getSimpleJavaName())</action>
356
            <action>copy.putAnnotation("containing-package", clsdef.getJavaPackage())</action>
357
            <rule>not usingClasses.contains(clsdef.getQualifiedJavaName())
351 358
               <action>copy.putAnnotation("qualified-reference", true)</action>
352 359
            </rule>
353 360
            <action on="false">
......
479 486
            
480 487
            <rule on="false">true
481 488
               <action>fname = getNoteString("found-in-source-file")</action>
482
               <action>nameinfo = loadConvertedClass(fname, false, this)</action>
483
               <rule>nameinfo != null
489
               <action>clsdef = loadConvertedClass(fname, false, this)</action>
490
               <rule>clsdef != null
484 491
                  <rule>isNote("refid")
485 492
                     <!-- use the javaname at the refid, and not what we thing we should convert to -->
486 493
                     <action>ref = execLib("get_var", this)</action>
......
488 495
                        putNote("javaname", #(java.lang.String) ref.getAnnotation("javaname"))
489 496
                     </action>
490 497
                     
498
                     <!-- TODO: it is not clear the exact case which depends upon this code; the previous
499
                          code just did a lookup using only the legacy method name (not the signature) so the
500
                          getConvertedMethodName() seems like a better approach but we need to watch this -->
491 501
                     <rule on="false">!isNote("javaname")
492
                        <action>putNote("javaname", nameinfo.getMethod(this.text))</action>
502
                        <action>putNote("javaname", clsdef.getConvertedMethodName(this.text, copy))</action>
493 503
                     </rule>
494 504
                  </rule>
495 505
                  
496
                  <action>putNote("found-in-full-java-class", nameinfo.getQualifiedName())</action>
506
                  <action>putNote("found-in-full-java-class", clsdef.getQualifiedJavaName())</action>
497 507
                  <rule>!evalLib("is_java_cls", this)
498 508
                     <action>putNote("wrap", true)</action>
499 509
                  </rule>
......
592 602
      <rule>this.type == prog.class_event
593 603
         <!-- annotate the event name -->
594 604
         <action>fname = getNoteString("found-in-source-file")</action>
595
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
605
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
596 606
         <action>refid = getNoteLong("refid")</action>
597 607
         
598 608
         <rule>refid == null
599 609
            <action>propref = null</action>
600
            <action>printfln("MISSING_REFID for property %s", copy.dumpTree())</action>
610
            <action>printfln("MISSING_REFID for event %s", copy.dumpTree())</action>
601 611
            
602 612
            <action on="false">propref = getAst(refid)</action>
603 613
         </rule>
......
607 617
            <action>javaname = propref.getAnnotation("javaname")</action>
608 618
         </rule>
609 619
         <rule>javaname == null
610
            <action>javaname = nameinfo.getVariable(this.text)</action>
620
            <action>isStatic = isNote("static") and getNoteBoolean("static")</action>
621
            <rule>isNote("access-mode")
622
               <action>accessMode = getNoteLong("access-mode")</action>
623
               <action on="false">accessMode = prog.kw_public</action>
624
            </rule>
625
            <action>javaname = clsdef.lookupVariableJavaName(this.text, accessMode, isStatic)</action>
611 626
         </rule>
612 627
         
613 628
         <action>putNote("javaname", javaname)</action>
......
627 642
          (copy.parent.type == prog.object_invocation and evalLib("input_argument", copy.parent)))
628 643
            
629 644
         <action>fname = getNoteString("cls-container")</action>
630
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
645
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
631 646
         <action>refid = getNoteLong("refid")</action>
647
         <action>isExtent = false</action>
632 648
         
633 649
         <rule>refid == null
634 650
            <action>propref = null</action>
635
            <action>printfln("MISSING_REFID for property %s", copy.dumpTree())</action>
651
            <action>printfln("MISSING_REFID for property %s", copy.dumpTree(true))</action>
652
            <action>extent = copy.getAnnotation("extent")</action>
653
            <action>isExtent = (extent != null and (extent == -1 or extent &gt; 0))</action>
636 654
            
637 655
            <action on="false">propref = getAst(refid)</action>
656
            <action on="false">extent = propref.getAnnotation("extent")</action>
657
            <action on="false">isExtent = (extent != null and (extent == -1 or extent &gt; 0))</action>
638 658
         </rule>
639 659
         
640 660
         <!-- TODO: each of the object_invocation cases below does not consider if the
......
653 673
            
654 674
            <rule>setter == null or setter.id != refid or propref == null
655 675
               
656
               <!-- normal usage through the setter method -->
657
               <rule>propref != null
658
                  <action>
659
                     javaname = nameinfo.getConvertedMethodName(
660
                                  getReferenceNoteString(propref.id, "set-legacysignature"),
661
                                  getReferenceNoteString(propref.id, "set-javasignature"))
662
                  </action>
663
               </rule>
664
               <rule>javaname == null
665
                  <action>
666
                     javaname = nameinfo.getMethodForProperty("set", this.text)
667
                  </action>
668
               </rule>
669
               
670 676
               <!-- rewrite the tree -->
671 677
               <rule>parent.type == prog.assign
672 678
                  <action>attref = copy.parent</action>
......
693 699
               </rule>
694 700
               <action>subref = copy.getImmediateChild(prog.lbracket, null)</action>
695 701
               <rule>subref != null
702
                  <!-- normal indexed setter for an extent property -->
696 703
                  <action>idxref = subref.getChildAt(0)</action>
697 704
                  <action>subref.remove()</action>
698 705
                  <action>eref = createProgressAst(prog.expression, copy, 1)</action>
......
705 712
               </rule>
706 713
               <action>execLib("rewrite_prop_to_method", copy)</action>
707 714
               
715
               <rule>!isExtent or subref != null
716
                  <!-- normal usage through the setter method (it is not an extent prop or the lvalue
717
                       has a subscript which means it is assigning a single element)-->
718
                  <action>propkey = "set-javaname"</action>
719
                  
720
                  <!-- one of the special extent setters -->
721
                  <rule on="false">evalLib("is_unsubscripted_extent", childref)
722
                     <!-- replace the reference itself -->
723
                     <action>propkey = "bulk-set-javaname"</action>
724
                     
725
                     <!-- assign multi -->
726
                     <action on="false">propkey = "set-all-javaname"</action>
727
                  </rule>
728
               </rule>
729
               
730
               <rule>propref != null
731
                  <action>javaname = propref.getAnnotation(propkey)</action>
732
                  <action on="false">javaname = "oo_references.rules_FIXME1"</action>
733
               </rule>               
734
               
708 735
               <!-- direct reference, no rewriting -->
709 736
               <action on="false">javaname = setter.getAnnotation("javaname")</action>
710 737
               <action on="false">putNote("direct-property-access", true)</action>
......
720 747
            
721 748
            <action>putNote("property-access-type", "length-of")</action>
722 749
            <rule>propref != null
723
               <action>
724
                  javaname = nameinfo.getConvertedMethodName(
725
                               getReferenceNoteString(propref.id, "length-of-legacysignature"),
726
                               getReferenceNoteString(propref.id, "length-of-javasignature"))
727
               </action>
728
            </rule>
729
            <rule>javaname == null
730
               <action>
731
                  javaname = nameinfo.getMethodForProperty("length-of", this.text)
732
               </action>
750
               <action>javaname = propref.getAnnotation("length-of-javaname")</action>
751
               <action on="false">javaname = "oo_references.rules_FIXME2"</action>
733 752
            </rule>
734 753
            
735 754
            <!-- rewrite the tree -->
......
751 770
         
752 771
         <!-- EXTENT(property) = size (indeterminate extent resize) -->
753 772
         <rule>
754
            (upPath("STATEMENT/ASSIGN/KW_EXTENT/OBJECT_INVOCATION")           and parent.indexPos == 0) or
755
            (upPath("STATEMENT/KW_ASSIGN/ASSIGN/KW_EXTENT/OBJECT_INVOCATION") and parent.indexPos == 0) or
756
            (upPath("STATEMENT/ASSIGN/KW_EXTENT")                             and copy.indexPos == 0)   or
757
            (upPath("STATEMENT/KW_ASSIGN/ASSIGN/KW_EXTENT")                   and copy.indexPos == 0)
773
            (upPath("STATEMENT/ASSIGN/KW_EXTENT/OBJECT_INVOCATION")           and parent.parent.indexPos == 0) or
774
            (upPath("STATEMENT/KW_ASSIGN/ASSIGN/KW_EXTENT/OBJECT_INVOCATION") and parent.parent.indexPos == 0) or
775
            (upPath("STATEMENT/ASSIGN/KW_EXTENT")                             and parent.indexPos == 0)        or
776
            (upPath("STATEMENT/KW_ASSIGN/ASSIGN/KW_EXTENT")                   and parent.indexPos == 0)
758 777
            
759 778
            <action>putNote("property-access-type", "resize")</action>
760 779
            <rule>propref != null
761
               <action>
762
                  javaname = nameinfo.getConvertedMethodName(
763
                               getReferenceNoteString(propref.id, "resize-legacysignature"),
764
                               getReferenceNoteString(propref.id, "resize-javasignature"))
765
               </action>
766
            </rule>
767

  
768
            <rule>javaname == null
769
               <action>
770
                  javaname = nameinfo.getMethodForProperty("resize", this.text)
771
               </action>
780
               <action>javaname = propref.getAnnotation("resize-javaname")</action>
781
               <action on="false">javaname = "oo_references.rules_FIXME3"</action>
772 782
            </rule>
773 783
            
774 784
            <!-- rewrite the tree -->
......
797 807
         <!-- getter -->
798 808
         <rule>javaname == null
799 809
            <action>putNote("property-access-type", "getter")</action>
800
         
810
            
801 811
            <rule>getter == null or getter.id != refid or propref == null
802
               
803
               <!-- normal usage through the getter method -->
804
               <rule>propref != null
805
                  <action>
806
                     javaname = nameinfo.getConvertedMethodName(
807
                                  getReferenceNoteString(propref.id, "get-legacysignature"),
808
                                  getReferenceNoteString(propref.id, "get-javasignature"))
809
                  </action>
810
               </rule>
811
               
812
               <rule>javaname == null
813
                  <action>
814
                     javaname = nameinfo.getMethodForProperty("get", this.text)
815
                  </action>
816
               </rule>
817 812

  
818 813
               <!-- rewrite the tree -->
819 814
               <action>subref = copy.getImmediateChild(prog.lbracket, null)</action>
......
825 820
               <action>execLib("rewrite_prop_to_method", copy)</action>
826 821
               <action>putNote("wrap", true)</action>
827 822
               
823
               <rule>!isExtent or subref != null
824
                  <!-- normal usage through the getter method (scalar/non-extent or return a single
825
                       element) -->
826
                  <action>propkey = "get-javaname"</action>
827
                  
828
                  <!-- the special extent getter that obtains the reference to the array -->
829
                  <action on="false">propkey = "bulk-get-javaname"</action>
830
               </rule>
831
               
832
               <rule>propref != null
833
                  <action>javaname = propref.getAnnotation(propkey)</action>
834
                  <action on="false">javaname = "oo_references.rules_FIXME4"</action>
835
               </rule>
836
               
828 837
               <!-- direct reference -->
829 838
               <action on="false">javaname = getter.getAnnotation("javaname")</action>
830 839
               <action on="false">putNote("direct-property-access", true)</action>
......
834 843
         <rule>javaname != null
835 844
            <action>putNote("javaname", javaname)</action>
836 845
            <action on="false">
837
               printfln("WARNING: non-local property javaname lookup failure! %s",
838
                        copy.dumpTree())
846
               printfln("WARNING: non-local property javaname (%s) lookup failure! %s",
847
                        propkey,
848
                        copy.dumpTree(true))
839 849
            </action>
840 850
         </rule>
841 851
         
......
847 857
               
848 858
               <!-- save the setter name, so assignment_style_stmt_rewriting can use it -->
849 859
               <rule>propref != null
850
                  <action>
851
                     javaname = nameinfo.getConvertedMethodName(
852
                                  getReferenceNoteString(propref.id, "set-legacysignature"),
853
                                  getReferenceNoteString(propref.id, "set-javasignature"))
854
                  </action>
855
               </rule>
856
               
857
               <rule>javaname == null
858
                  <action>
859
                     javaname = nameinfo.getMethodForProperty("set", this.text)
860
                  </action>
860
                  <action>javaname = propref.getAnnotation("set-javaname")</action>
861
                  <action on="false">javaname = "oo_references.rules_FIXME5"</action>
861 862
               </rule>
862 863

  
863 864
               <!-- direct reference -->
......
887 888
            !(isNote("cls-property") or getNoteBoolean("cls-property"))
888 889
            
889 890
         <action>fname = getNoteString("found-in-source-file")</action>
890
         <action>nameinfo = loadConvertedClass(fname, false, this)</action>
891
         <action>clsdef = loadConvertedClass(fname, false, this)</action>
891 892
         
892 893
         <!-- member vars -->
893 894
         <rule>!isNote("refid") and (!isNote("cls-property") or !getNoteBoolean("cls-property"))
894
            <action>putNote("javaname", nameinfo.getVariable(this.text))</action>
895
            <rule>nameinfo.getVariableExtent(this.text) != null
896
               <action>putNote("extent", nameinfo.getVariableExtent(this.text))</action>
895
            <action>isStatic = isNote("static") and getNoteBoolean("static")</action>
896
            <rule>isNote("access-mode")
897
               <action>accessMode = getNoteLong("access-mode")</action>
898
               <action on="false">accessMode = prog.kw_public</action>
899
            </rule>
900
            <action>
901
               putNote("javaname", clsdef.lookupVariableJavaName(this.text, accessMode, isStatic))
902
            </action>
903
            <action>extent = clsdef.lookupVariableExtent(this.text, accessMode, isStatic)</action>
904
            <rule>extent != 0
905
               <action>putNote("extent", extent)</action>
897 906
            </rule>
898 907
            
899 908
            <rule on="false">isNote("refid")
......
904 913
            </rule>
905 914
         </rule>
906 915
         
907
         <action>putNote("found-in-full-java-class", nameinfo.getQualifiedName())</action>
916
         <action>putNote("found-in-full-java-class", clsdef.getQualifiedJavaName())</action>
908 917
      </rule>
909 918
   </walk-rules>
910 919
   
new/rules/annotations/output_parameters.rules 2022-05-20 11:57:12 +0000
128 128
   <variable name="idx"            type="java.lang.Integer" />
129 129
   <variable name="ptype"          type="java.lang.Integer" />
130 130
   <variable name="refid"          type="java.lang.Long" />
131
   <variable name="deftype"        type="java.lang.String" />
132
   <variable name="calltype"       type="java.lang.String" />
131 133
   <variable name="assign_back"    type="java.lang.Boolean" />
132 134
   <variable name="needs_value"    type="java.lang.Boolean" />
133 135
   
......
274 276
            </rule>
275 277
         </rule>
276 278
         
279
         <!-- lref will only be non-null for extent cases -->
277 280
         <rule>lref != null and 
278 281
               (lref.type == prog.kw_in_out or 
279 282
                lref.type == prog.kw_output or 
......
282 285
            <action>putNote("extent", #(long) ref.getAnnotation("extent"))</action>
283 286
            <action>ref.putAnnotation("force_extent_mutable", true)</action>
284 287
            
288
            <action>calltype = null</action>
289
            
285 290
            <rule>!evalLib("fieldtype", type)
286 291
               <rule>isNote("full-java-class")
287 292
                  <action>
288
                     putNote("outputExtentType", 
289
                             sprintf("object&lt;? extends %s&gt;", 
290
                                     ref.getAnnotation("full-java-class")))
293
                     deftype = sprintf("object&lt;? extends %s&gt;", ref.getAnnotation("full-java-class"))
291 294
                  </action>
292 295

  
293
                  <action on="false">
294
                     putNote("outputExtentType", #(java.lang.String) ref.getAnnotation("classname"))
295
                  </action>
296
                  <!-- override type to match definition signature -->
297
                  <rule on="false">isNote("classname")
298
                     <action>deftype = getNoteString("classname")</action>
299
                     <action>calltype = getNoteString("calltype")</action>
300
                     <action on="false">deftype = #(java.lang.String) ref.getAnnotation("classname")</action>
301
                     <action on="false">calltype = #(java.lang.String) ref.getAnnotation("calltype")</action>
302
                  </rule>
296 303
               </rule>
297 304
               
298
               <action on="false">
299
                  putNote("outputExtentType", 
300
                          #(java.lang.String) execLib("wrapper_name_for_field_type", type))
301
               </action>
305
               <rule on="false">ref.isAnnotation("classname")
306
                  <!-- override type to match definition signature -->
307
                  <action>
308
                     deftype = #(java.lang.String) ref.getAnnotation("classname")
309
                  </action>
310
                  <action on="false">
311
                     calltype = #(java.lang.String) ref.getAnnotation("calltype")
312
                  </action>
313
                  
314
                  <!-- use the field type -->
315
                  <action on="false">
316
                     deftype = #(java.lang.String) execLib("wrapper_name_for_field_type", type)
317
                  </action>
318
               </rule>
319
            </rule>
320
            <action>putNote("outputExtentType", deftype)</action>
321
            <rule>calltype != null
322
               <action>putNote("calltype", calltype)</action>
302 323
            </rule>
303 324

  
304 325
            <rule>lref.id != this.id
new/rules/annotations/record_scoping_prep.rules 2022-05-20 12:08:20 +0000
6 6
**
7 7
** Copyright (c) 2005-2022, Golden Code Development Corporation.
8 8
**
9
** _#_ _I_ __Date__ __JPRM__ ___________________________________Description___________________________________
9
** _#_ _I_ __Date__ __JPRM__ __________________________________Description__________________________________
10 10
** 001 GES 20050919   @22810 Preparation for record scoping analysis. In
11 11
**                           particular, all database references are
12 12
**                           classified into the type (weak, strong,
......
112 112
**     CA  20220225          A 'DEFINE BUFFER book FOR book' statement (where the buffer name is the same as 
113 113
**                           the table name) inside an internal top-level block will be dropped if there is a
114 114
**                           reference for this buffer, appearing somewhere before this statement.
115
*     CA  20220425           Refactored to eliminate the dependency on '-1' reference ID for resolving a  
115
**     CA  20220425           Refactored to eliminate the dependency on '-1' reference ID for resolving a  
116 116
**                           buffer's reference scope - the default buffer will be referenced instead, and a 
117 117
**                           special annotation possible_needs_buffer will be used to track the previous 
118 118
**                           requirements of '-1' refid.
119
**    CA  20220516           'b4temporary' is a boolean, not string, annotation.
119
**     CA  20220516          'b4temporary' is a boolean, not string, annotation.
120
**     GES 20210506          Use TableParameter subclasses when needed.
120 121
*/
121 122
-->
122 123

  
......
199 200
   <variable name="extra"            type="java.lang.String" />
200 201
   <variable name="pextra"           type="java.lang.String" />
201 202
   <variable name="bufRefKey"        type="java.lang.String" />
203
   <variable name="tabParmType"      type="java.lang.String" />
202 204
   <variable name="ref"              type="com.goldencode.ast.Aast" />
203 205
   <variable name="master"           type="com.goldencode.p2j.convert.BufferList" />
204 206
   <variable name="ref2"             type="com.goldencode.ast.Aast" />
......
287 289
                  
288 290
                  <!-- lookup and store the DMO class/package names -->
289 291
                  <rule>bref.parent.type == prog.kw_table
290
                     <action>bref.putAnnotation("bufclassname", "TableParameter")</action>
292
                  
293
                     <!-- lookup the TableParameter subclass that should be used, default to the base class
294
                          if no jtype annotation exists -->
295
                     <action>
296
                        tabParmType = #(java.lang.String) execLib("read_jtype",
297
                                                                  bref.parent,
298
                                                                  "TableParameter",
299
                                                                  "record_scoping_prep")
300
                     </action>
301
                  
302
                     <!-- record the proper TableParameter or TableParameter subclass -->
303
                     <action>
304
                        bref.putAnnotation("bufclassname", tabParmType)
305
                     </action>
291 306
                     
292 307
                     <rule>bref.type == prog.buffer
293 308
                        <action>refid = lookupDictionaryLong("buf_ids", bufName)</action>
new/rules/convert/buffer_definitions.rules 2022-05-12 15:24:44 +0000
4 4
** Module   : buffer_definitions.rules
5 5
** Abstract : converts implicit and explicit buffer definitions
6 6
**
7
** Copyright (c) 2004-2021, Golden Code Development Corporation.
7
** Copyright (c) 2004-2022, Golden Code Development Corporation.
8 8
**
9 9
** _#_ _I_ __Date__ __JPRM__ ____________________________Description_____________________________
10 10
** 001 GES 20051005   @22993 First version which converts Progress
......
179 179
**     CA  20220208          External programs can have buffer parameters, but only for permanent tables, and
180 180
**                           these need to be promoted.
181 181
**     CA  20220426          Added RCODE-INFO:TABLE-LIST conversion support.
182
**     GES 20220502          Reworked TableParameter to use subclasses.
182 183
*/
183 184
-->
184 185

  
......
304 305
   <variable name="dbAliases"     type="java.util.Set" />
305 306
   <variable name="tableList"     type="java.util.Set" />
306 307
   <variable name="iter"          type="java.util.Iterator" />
308
   <variable name="usesSubclass"     type="java.lang.Boolean" />
307 309
   
308 310
   <!-- functions "depot_stub" and "buffer_open_scope_anchor" moved to common-convert.rules. -->
309 311
   <include name="convert/common-convert" />
......
518 520
                        <action>bufjname = sprintf("%s.get()", bufjname)</action>
519 521
                     </rule>
520 522
                     
521
                     <rule>parent.parent.type == prog.define_parameter
522
                        <action>parmtype = #(long) parent.parent.getChildAt(0).type</action>
523
                        <action on="false">
524
                           parmtype = #(long) parent.parent.getAnnotation("parmtype")
525
                        </action>
526
                     </rule>
527
                     
528
                     <rule>parmtype == prog.kw_input or parmtype == prog.kw_in_out
529
                        <action>parmin = "BOOL_TRUE"</action>
530
                        <action on="false">parmin = "BOOL_FALSE"</action>
531
                     </rule>
532
                     
533
                     <rule>parmtype == prog.kw_output or parmtype == prog.kw_in_out
534
                        <action>parmout = "BOOL_TRUE"</action>
535
                        <action on="false">parmout = "BOOL_FALSE"</action>
523
                     <!-- functions and procedures use the base class TableParameter, OO methods use
524
                          a TableParameter subclass; the subclass cases use simpler forms below -->
525
                     <action>
526
                        usesSubclass = (parent.parent.type == prog.parameter    and
527
                                        parent.parent.isAnnotation("isOO")      and
528
                                        #(java.lang.Boolean) parent.parent.getAnnotation("isOO"))
529
                     </action>
530
                     
531
                     <rule>!usesSubclass
532
                        <rule>parent.parent.type == prog.define_parameter
533
                           <action>parmtype = #(long) parent.parent.getChildAt(0).type</action>
534
                           <action on="false">
535
                              parmtype = #(long) parent.parent.getAnnotation("parmtype")
536
                           </action>
537
                        </rule>
538
                        <rule>parmtype == prog.kw_input or parmtype == prog.kw_in_out
539
                           <action>parmin = "BOOL_TRUE"</action>
540
                           <action on="false">parmin = "BOOL_FALSE"</action>
541
                        </rule>
542
                        <rule>parmtype == prog.kw_output or parmtype == prog.kw_in_out
543
                           <action>parmout = "BOOL_TRUE"</action>
544
                           <action on="false">parmout = "BOOL_FALSE"</action>
545
                        </rule>
536 546
                     </rule>
537 547
                     <!-- the second argument to TemporaryBuffer.associate is the destination DMO;
538 548
                          if it has the same name as the first argument (the table parameter),
......
540 550
                     <rule>getNoteBoolean("qualify-outer")
541 551
                        <action>bufjname = sprintf("%s.this.%s", baseClass, bufjname)</action>
542 552
                     </rule>
543
                     <action>
544
                        lastthparam = tw.graft("associate_temp_tables", null, promid,
545
                                               "javaname1", javaname,
546
                                               "javaname2", bufjname,
547
                                               "input",     parmin,
548
                                               "output",    parmout)
549
                     </action>
553
                     
554
                     <rule>usesSubclass
555
                        <action>
556
                           lastthparam = tw.graft("associate_temp_tables", null, promid,
557
                                                  "javaname1", javaname,
558
                                                  "javaname2", bufjname)
559
                        </action>
560
                        <action on="false">
561
                           lastthparam = tw.graft("associate_temp_tables_full", null, promid,
562
                                                  "javaname1", javaname,
563
                                                  "javaname2", bufjname,
564
                                                  "input",     parmin,
565
                                                  "output",    parmout)
566
                        </action>
567
                     </rule>
550 568
                     <action>evalLib("setPassingModes", copy.parent.parent, lastthparam)</action>
551 569
                     
552 570
                     <rule on="false">true
......
1120 1138
               javaname = #(java.lang.String) parent.getAnnotation("javaname")
1121 1139
            </action>
1122 1140
         </rule>
1141

  
1142
         <!-- functions and procedures use the base class TableParameter, OO methods use
1143
              a TableParameter subclass; the subclass cases use simpler forms below -->
1144
         <action>
1145
            usesSubclass = (parent.type == prog.parameter    and
1146
                            parent.isAnnotation("isOO")      and
1147
                            #(java.lang.Boolean) parent.getAnnotation("isOO"))
1148
         </action>
1123 1149
         
1124
         <rule>parent.type == prog.define_parameter
1125
            <action>parmtype = #(long) parent.getChildAt(0).type</action>
1126
            <action on="false">parmtype = #(long) parent.getAnnotation("parmtype")</action>
1127
         </rule>
1128
         <rule>parmtype == prog.kw_input or parmtype == prog.kw_in_out
1129
            <action>parmin = "BOOL_TRUE"</action>
1130
            <action on="false">parmin = "BOOL_FALSE"</action>
1131
         </rule>
1132
         <rule>parmtype == prog.kw_output or parmtype == prog.kw_in_out
1133
            <action>parmout = "BOOL_TRUE"</action>
1134
            <action on="false">parmout = "BOOL_FALSE"</action>
1150
         <rule>!usesSubclass         
1151
            <rule>parent.type == prog.define_parameter
1152
               <action>parmtype = #(long) parent.getChildAt(0).type</action>
1153
               <action on="false">parmtype = #(long) parent.getAnnotation("parmtype")</action>
1154
            </rule>
1155
            <rule>parmtype == prog.kw_input or parmtype == prog.kw_in_out
1156
               <action>parmin = "BOOL_TRUE"</action>
1157
               <action on="false">parmin = "BOOL_FALSE"</action>
1158
            </rule>
1159
            <rule>parmtype == prog.kw_output or parmtype == prog.kw_in_out
1160
               <action>parmout = "BOOL_TRUE"</action>
1161
               <action on="false">parmout = "BOOL_FALSE"</action>
1162
            </rule>
1135 1163
         </rule>
1136 1164
         <rule>lastthparam == null
1137 1165
            <action>ref2 = getAst(promid)</action>
......
1140 1168
            <action on="false">ref2 = lastthparam.parent</action>
1141 1169
            <action on="false">idx = lastthparam.indexPos + 1</action>
1142 1170
         </rule>
1143
         <action>
1144
            lastthparam = tw.graftAt("create_dynamic_tt", null, ref2, idx,
1145
                                     "javaname1", sprintf("_%s", javaname),
1146
                                     "javaname2", javaname,
1147
                                     "input", parmin,
1148
                                     "output", parmout)
1149
         </action>
1171
         
1172
         <rule>usesSubclass
1173
            <action>
1174
               lastthparam = tw.graftAt("create_dynamic_tt", null, ref2, idx,
1175
                                        "javaname1", sprintf("_%s", javaname),
1176
                                        "javaname2", javaname)
1177
            </action>
1178
            <action on="false">
1179
               lastthparam = tw.graftAt("create_dynamic_tt_full", null, ref2, idx,
1180
                                        "javaname1", sprintf("_%s", javaname),
1181
                                        "javaname2", javaname,
1182
                                        "input", parmin,
1183
                                        "output", parmout)
1184
            </action>
1185
         </rule>
1186
         
1150 1187
         <action>evalLib("setPassingModes", copy.parent, lastthparam)</action>
1151 1188
         
1152 1189
         <action>createImport("com.goldencode.p2j.persist.*")</action>
new/rules/convert/common-convert.rules 2022-05-12 15:03:49 +0000
5 5
** Module   : common-convert.rules
6 6
** Abstract : library of callable specific functions/rules in the code conversion iteration.
7 7
**
8
** Copyright (c) 2005-2020, Golden Code Development Corporation.
8
** Copyright (c) 2005-2021, Golden Code Development Corporation.
9 9
**
10
** _#_ _I_ __Date__ ________________________________ Description _________________________________
10
** _#_ _I_ __Date__ _____________________________________ Description ______________________________________
11 11
** 001 OM  20131128 Initial commit.
12 12
** 002 VIG 20160624 Added function "collect_ui_strings".
13 13
** 003 GES 20181217 Added a comment.
14 14
** 004 OM  20190403 Moved in buffer_open_scope_anchor from buffer_definitions.rules.
15 15
** 005 OM  20190523 Added setPassingModes() and add_bool_param() functions.
16 16
** 006 CA  20200412 Added incremental conversion support.
17
** 007 CA  20200503 ParameterOption enums are qualified and not imported, as it collides 
18
**                  character.valueOf with.
17
** 007 CA  20200503 ParameterOption enums are qualified and not imported, as it collides with
18
**                  character.valueOf.
19
** 008 GES 20210430 Moved append flag from an unconditional boolean flag to a ParameterOption enum.
19 20
*/
20 21
-->
21 22

  
......
220 221
      </function>
221 222
      
222 223
      <!-- optionally adds parameter passing mode for complex data types to target JAST method
223
           call node: APPEND as a boolean, BY-VALUE, BY-REFERENCE and BIND as excluding enum.
224
           call node: APPEND, BY-VALUE, BY-REFERENCE or BIND as mutually exclusive enum;
224 225
           can't import static, as enum's valueOf conflicts with character valueOf -->
225 226
      <function name="setPassingModes">
226 227
         <parameter name="source"  type="com.goldencode.ast.Aast" />
......
237 238
         <rule>isBind = source.isAnnotation("tt_ds_bind")</rule>
238 239
         
239 240
         <rule>isAppend or isByVal or isBind or isByRef
240
            <!-- add APPEND flag regardless of other flags -->
241
            <action>evalLib("add_bool_param", target, isAppend)</action>
242
            
241
            <!-- add APPEND flag -->
242
            <rule>isAppend
243
               <action>createJavaAst(java.reference, "ParameterOption.APPEND", target)</action>
244
            </rule>            
243 245
            <!-- add BY-VALUE flag -->
244 246
            <rule>isByVal
245 247
               <action>createJavaAst(java.reference, "ParameterOption.BY_VALUE", target)</action>
new/rules/convert/database_references.rules 2022-05-20 12:08:38 +0000
183 183
**     CA  20220514          Added 'dynamic_set_parameter_last_argument' - this is required to properly
184 184
**                           distinguish the parameter in a ParameterList:setParameter, as this OO method call
185 185
**                           can have the INPUT/OUTPUT/INPUT-OUTPUT modes set.
186
**     GES 20210519          Reworked table parameters to use subclasses of TableParameter.
186 187
*/
187 188
-->
188 189

  
......
279 280
   </func-library>
280 281
   
281 282
   <!-- variables -->
282
   <variable name="casttype"    type="java.lang.String" />
283
   <variable name="javaname"    type="java.lang.String" />
284
   <variable name="clsname"     type="java.lang.String" />
285
   <variable name="txt"         type="java.lang.String" />
286
   <variable name="methodtxt"   type="java.lang.String" />
287
   <variable name="bufname"     type="java.lang.String" />
288
   <variable name="wrapimp"     type="java.lang.Boolean" />
289
   <variable name="finaltxt"    type="java.lang.String" />
290
   <variable name="fieldtype"   type="java.lang.String" />
291
   <variable name="partype"     type="java.lang.String" />
292
   <variable name="methodtype"  type="java.lang.Integer" />
293
   <variable name="idx"         type="java.lang.Integer" />
294
   <variable name="astid"       type="java.lang.Long" />
295
   <variable name="lastid"      type="java.lang.Long" />
296
   <variable name="origid"      type="java.lang.Long" />
297
   <variable name="deferid"     type="java.lang.Long" />
298
   <variable name="paridx"      type="java.lang.Long" />
299
   <variable name="builtin"     type="java.lang.Boolean" />
300
   <variable name="inmsg"       type="java.lang.Boolean" />
301
   <variable name="insetp"      type="java.lang.Boolean" />
302
   <variable name="special"     type="java.lang.Boolean" />
303
   <variable name="suppress"    type="java.lang.Boolean" />
304
   <variable name="accessor"    type="java.lang.Boolean" />
305
   <variable name="assign_back" type="java.lang.Boolean" />
306
   <variable name="needs_value" type="java.lang.Boolean" />
307
   <variable name="fieldrefimp" type="java.lang.Boolean" />
308
   <variable name="inline"      type="java.lang.Boolean" />
309
   <variable name="isAccum"     type="java.lang.Boolean" />
310
   <variable name="ref"         type="com.goldencode.ast.Aast" />
311
   <variable name="ref2"        type="com.goldencode.ast.Aast" />
312
   <variable name="lref"        type="com.goldencode.ast.Aast" />
313
   <variable name="lref2"       type="com.goldencode.ast.Aast" />
314
   <variable name="parref"      type="com.goldencode.ast.Aast" />
315
   <variable name="scopeRef"    type="com.goldencode.ast.Aast" />
316
   <variable name="usedByExprs" type="java.util.Set" />
317
   <variable name="is_extent"   type="java.lang.Boolean" />
318
   <variable name="isTableHandle" type="java.lang.Boolean" />
283
   <variable name="casttype"                    type="java.lang.String" />
284
   <variable name="javaname"                    type="java.lang.String" />
285
   <variable name="tabParmType"                 type="java.lang.String" />
286
   <variable name="clsname"                     type="java.lang.String" />
287
   <variable name="txt"                         type="java.lang.String" />
288
   <variable name="methodtxt"                   type="java.lang.String" />
289
   <variable name="bufname"                     type="java.lang.String" />
290
   <variable name="wrapimp"                     type="java.lang.Boolean" />
291
   <variable name="finaltxt"                    type="java.lang.String" />
292
   <variable name="fieldtype"                   type="java.lang.String" />
293
   <variable name="partype"                     type="java.lang.String" />
294
   <variable name="methodtype"                  type="java.lang.Integer" />
295
   <variable name="idx"                         type="java.lang.Integer" />
296
   <variable name="astid"                       type="java.lang.Long" />
297
   <variable name="lastid"                      type="java.lang.Long" />
298
   <variable name="origid"                      type="java.lang.Long" />
299
   <variable name="deferid"                     type="java.lang.Long" />
300
   <variable name="paridx"                      type="java.lang.Long" />
301
   <variable name="builtin"                     type="java.lang.Boolean" />
302
   <variable name="inmsg"                       type="java.lang.Boolean" />
303
   <variable name="insetp"                      type="java.lang.Boolean" />
304
   <variable name="special"                     type="java.lang.Boolean" />
305
   <variable name="suppress"                    type="java.lang.Boolean" />
306
   <variable name="accessor"                    type="java.lang.Boolean" />
307
   <variable name="assign_back"                 type="java.lang.Boolean" />
308
   <variable name="needs_value"                 type="java.lang.Boolean" />
309
   <variable name="fieldrefimp"                 type="java.lang.Boolean" />
310
   <variable name="inline"                      type="java.lang.Boolean" />
311
   <variable name="isAccum"                     type="java.lang.Boolean" />
312
   <variable name="ref"                         type="com.goldencode.ast.Aast" />
313
   <variable name="ref2"                        type="com.goldencode.ast.Aast" />
314
   <variable name="lref"                        type="com.goldencode.ast.Aast" />
315
   <variable name="lref2"                       type="com.goldencode.ast.Aast" />
316
   <variable name="parref"                      type="com.goldencode.ast.Aast" />
317
   <variable name="scopeRef"                    type="com.goldencode.ast.Aast" />
318
   <variable name="usedByExprs"                 type="java.util.Set" />
319
   <variable name="is_extent"                   type="java.lang.Boolean" />
320
   <variable name="isTableHandle"               type="java.lang.Boolean" />
319 321
   <variable name="lval_of_embedded_assignment" type="java.lang.Boolean" />
320 322
   
321 323
   <!-- main processing (once per tree) -->
......
372 374
         <!-- dereference the Java name for the buffer -->
373 375
         <action>javaname = execLib("get_javaname", copy)</action>
374 376
         
377
         <!-- lookup the TableParameter subclass that should be used, default to the base class if no
378
              jtype annotation exists -->
379
         <action>
380
            tabParmType = execLib("read_jtype", copy, "TableParameter", "database_references 1")
381
         </action>
382
         
375 383
         <action>isTableHandle = false</action>
376 384
         <action>parref = parent.parent</action>
377 385
         <rule>(relativePath("COLON/KW_TEMP_TAB/TEMP_TABLE") or
......
387 395
         </rule>
388 396

  
389 397
         <!-- emit the buffer reference (or TableParameter if we pass a TABLE parameter to
390
              procedure/function) -->
398
              procedure/function, or TableParameter subclass if passed to an OO method) -->
391 399
         <rule>(relativePath("KW_TABLE/TEMP_TABLE") or
392 400
                relativePath("KW_TABLE/BUFFER")     or
393 401
                isTableHandle) and
......
412 420
                  <action>partype = parref.getAnnotation("typelist", paridx)</action>
413 421
                  <rule>partype == "TABLE-HANDLE"
414 422
                     <action>lref = getAst(closestPeerId)</action>
415
                     <action>
416
                        lref2 = createJavaAst(java.constructor, "TableParameter", lref.parent, lref.indexPos)
423
                     <!-- lookup the TableParameter subclass that should be used, default to the base class
424
                          if no jtype annotation exists -->
425
                     <action>
426
                        tabParmType = #(java.lang.String) execLib("read_jtype",
427
                                                                  ref2,
428
                                                                  "TableParameter",
429
                                                                  "database_references 2")
430
                     </action>
431
                     <action>
432
                        lref2 = createJavaAst(java.constructor,
433
                                              tabParmType,
434
                                              lref.parent,
435
                                              lref.indexPos)
417 436
                     </action>
418 437
                     <action>lref.move(lref2, 0)</action>
419 438
                     <action>lastid = lref.id</action>
......
432 451
               <rule on="false">
433 452
                  ref.isAnnotation("static") and getReferenceNoteBoolean(ref.id, "static")
434 453
                  <action>
435
                     ref = tw.graft("table_param_static", copy, closestPeerId, "javaname", javaname)
454
                     ref = tw.graft("table_param_static", copy, closestPeerId,
455
                                    "tab-parm-type", tabParmType,
456
                                    "javaname", javaname)
436 457
                  </action>
437 458
                  <action on="false">
438
                     ref = tw.graft("table_param", copy, closestPeerId, "javaname", javaname)
459
                     ref = tw.graft("table_param", copy, closestPeerId,
460
                                    "tab-parm-type", tabParmType,
461
                                    "javaname", javaname)
439 462
                  </action>
440 463
               </rule>
441 464
            </rule>
......
1001 1024
                  
1002 1025
                  <!-- for wrapped fields we need to pass in the datatype class as 3rd param -->
1003 1026
                  <rule>assign_back
1004
                     <rule>isNote("classname")
1005
                        <!-- some cases for OO method arg requires classname override -->
1006
                        <action>fieldtype = getNoteString("classname")</action>
1027
                     <!-- OO fields use generics and that can be directly emitted as a class -->
1028
                     <rule>type == prog.field_class
1029
                        <!-- no cast to Class<object<? extends _BaseObject_>> is needed here to compile the
1030
                             result; if the cast is attempted it won't compile -->
1031
                        <action>fieldtype = "object"</action>
1007 1032
                     </rule>
1008 1033
                     
1009 1034
                     <action>
new/rules/convert/datasets.rules 2022-05-12 15:28:21 +0000
6 6
**
7 7
** Copyright (c) 2019-2022, Golden Code Development Corporation.
8 8
**
9
** _#_ _I_ __Date__ _________________________________Description_________________________________
9
** _#_ _I_ __Date__ _______________________________________Description_______________________________________
10 10
** 001 OM  20190327 First commit.
11 11
** 002 OM  20190305 Fixed DataSetParameter/dataset-handle issue.
12 12
** 003 CA  20190514 Fixed conversion of DATASET and DATA-SOURCE class members (access-mode and
......
20 20
**                  APIs, as these modes are optional for function or OO method definitions.
21 21
** 006 CA  20200503 ParameterOption enums are qualified and not imported, as it collides 
22 22
**                  character.valueOf with.
23
** 067 CA  20220426 Fixed conversion of DATASET arguments at NEW or DYNAMIC-NEW.
23
** 007 GES 20210506 Reworked emit of parameters/arguments to use subclasses of DataSetParameter. Removed
24
**                  unnecessary boolean parameters to associate() and createDynamicDataSet().
25
**     CA  20220426 Fixed conversion of DATASET arguments at NEW or DYNAMIC-NEW.
24 26
*/
25 27
-->
26 28

  
......
99 101
   <variable name="parmtype"      type="java.lang.Long" />
100 102
   <variable name="javaName"      type="java.lang.String" />
101 103
   <variable name="thisName"      type="java.lang.String" />
104
   <variable name="dsetParmType"  type="java.lang.String" />
102 105
   <variable name="toplvlref"     type="com.goldencode.ast.Aast" />
103 106
   <variable name="dsref"         type="com.goldencode.ast.Aast" />
104 107
   <variable name="ref"           type="com.goldencode.ast.Aast" />
......
135 138
               <action>lastid = #(long) execLib("get_parmroot", copy.getAncestor(2))</action>
136 139
               <action on="false">lastid = closestPeerId</action>
137 140
            </rule>
141
            
142
            <!-- lookup the DataSetParameter subclass that should be used, use the base class for
143
                 functions or procedures (but we must use a subclass for OO methods) -->
138 144
            <action>
139
               lastid = createJavaAst(java.reference_def, "DataSetParameter", lastid))
145
               dsetParmType = execLib("read_jtype",
146
                                      copy.parent.parent,
147
                                      "DataSetParameter",
148
                                      "datasets 1")
140 149
            </action>
150
            
151
            <action>lastid = createJavaAst(java.reference_def, dsetParmType, lastid))</action>
141 152
            <action>ref = getAst(lastid)</action>
142 153
            <action>ref.putAnnotation("name", getNoteString("javaname"))</action>
143 154
            <action>ref.putAnnotation("final", true)</action>
......
167 178
                  createJavaAst(java.reference, sprintf("%s.this", thisName), lastid)
168 179
               </action>
169 180
            </rule>
170
            
181

  
171 182
            <action>ref2 = copy.parent.parent</action>
183
            
184
            <!-- procedures use the base class so we need the extra booleans -->
172 185
            <rule>ref2.type == prog.define_parameter
173 186
               <!-- add input flag -->
174 187
               <action>
......
183 196
                          ref2.getImmediateChild(prog.kw_output, null) != null)
184 197
               </action>
185 198
            </rule>
186
            
187
            <rule>ref2.type == prog.parameter
199
               
200
            <!-- functions use the base class so they also need the extra boolean parms but we must avoid
201
                 the OO cases -->
202
            <rule>
203
               ref2.type == prog.parameter   and
204
               ref2.isAnnotation("isOO")     and
205
               !(#(java.lang.Boolean) ref2.getAnnotation("isOO"))
206
               
188 207
               <action>parmtype = #(long) ref2.getAnnotation("parmtype")</action>
189 208
               
190 209
               <!-- add input flag -->
......
247 266
         </action>
248 267
         <action>createPeerAst(java.reference, sprintf("_%s", javaName), ref)</action>
249 268
         <action>createPeerAst(java.reference, javaName, ref)</action>
250
         
269

  
270
         <!-- procedures use the base class so we need the extra booleans -->
251 271
         <rule>parent.type == prog.define_parameter
252 272
            <!-- add input flag -->
253 273
            <action>
......
263 283
            </action>
264 284
         </rule>
265 285
         
266
         <rule>parent.type == prog.parameter
286
         <!-- functions use the base class so they also need the extra boolean parms but we must avoid
287
              the OO cases -->
288
         <rule>
289
            parent.type == prog.parameter   and
290
            parent.isAnnotation("isOO")     and
291
            !(#(java.lang.Boolean) parent.getAnnotation("isOO"))
292
            
267 293
            <action>parmtype = #(long) parent.getAnnotation("parmtype")</action>
268 294

  
269 295
            <!-- add input flag -->
......
295 321
                copy.parent.type &lt; prog.end_oo_meth))                or
296 322
              (parent.type == prog.parameter and 
297 323
               evalLib("type_pair", parent.parent.parent, prog.func_class, prog.kw_new))
298
            <action>createPeerAst(java.constructor, "DataSetParameter", closestPeerId)</action>
324
               
325
            <!-- lookup the DataSetParameter subclass that should be used, use the base class for
326
                 functions or procedures (but we must use a subclass for OO methods) -->
327
            <action>
328
               dsetParmType = execLib("read_jtype",
329
                                      copy,
330
                                      "DataSetParameter",
331
                                      "datasets 2")
332
            </action>
333
            
334
            <action>createPeerAst(java.constructor, dsetParmType, closestPeerId)</action>
299 335
            <action>importPersist = true</action>
300 336
         </rule>
301 337
      </rule>
new/rules/convert/java_templates.tpl 2022-05-20 01:25:33 +0000
7 7
**
8 8
** Copyright (c) 2004-2022, Golden Code Development Corporation.
9 9
**
10
** _#_ _I_ __Date__ __JPRM__ ___________________________________Description___________________________________
10
** _#_ _I_ __Date__ __JPRM__ _________________________________ Description__________________________________
11 11
** 001 GES 20050721   @21760 Good working version which provides many
12 12
**                           templates for processing variable references,
13 13
**                           variable definitions, method calls,
......
292 292
**     CA  20220202          alias_buffer_def is no longer deprecated.
293 293
**     CA  20220426          Changed 'class_proxy_client_definition', to allow any kind of procedure, 
294 294
**                           persistent or not.
295
**     GES 20220519          Added templates with fewer boolean parameters for temp-table associate() and 
296
**                           table-handle createDynamicTable(). Reworked TableParameter templates to allow
297
**                           subclasses. Reworked OutputExtentParameter inner class to allow narrowing of
298
**                           types.
295 299
*/
296 300
 -->
297 301
 
......
1018 1022
      </ast>
1019 1023
   </ast-root>
1020 1024
   
1025
   <!-- inner subclass of an output extent parameter class - in case of variables set as parameter -->
1026
   <ast-root name="output_extent_var_expr_morph" terse="true" ast_class="com.goldencode.p2j.uast.JavaAst" >
... This diff was truncated because it exceeds the maximum size that can be displayed.