Project

General

Profile

10597b.patch

Stefanel Pezamosca, 01/16/2026 06:19 AM

Download (10.3 KB)

View differences:

new/rules/annotations/frame_scoping.rules 2026-01-16 10:11:59 +0000
5 5
** Module   : frame_scoping.rules
6 6
** Abstract : frame scoping and frame type tracking.
7 7
**
8
** Copyright (c) 2005-2025, Golden Code Development Corporation.
8
** Copyright (c) 2005-2026, Golden Code Development Corporation.
9 9
**
10 10
** _#_ _I_ __Date__ __JPRM__ ___________________________________Description___________________________________
11 11
** 001 SIY 20051014   @23090 Created.
......
486 486
** 211 SP  20250922          Fixed widget search for EXTENT field items.
487 487
** 212 DDF 20251015          Made fnameused into a CaseInsensitiveHasMap because the frame names could
488 488
**                           collide in a case-insensitive file-system (Windows).
489
** 213 SP  20260115          Fixed search for EXTENT fields by resolving extent index when it is a literal.
489 490
*/
490 491
-->
491 492

  
......
713 714
         </rule>
714 715
      </function>
715 716

  
717
      <!-- Resolve extent name when the index is a literal. In case of dynamic extent index
718
           (the array offset is an expression that can be evaluated dynamically only at runtime)
719
           we assume the whole extent item is part of same frame. 
720
           In this case Progress will stop with error 71. -->
721
      <function name="resolve_literal_extent_wname">
722
         <parameter name="name" type="java.lang.String" />
723
         <parameter name="node" type="com.goldencode.ast.Aast" />
724
         <return    name="res"  type="java.lang.String" />
725

  
726
         <variable name="ref" type="com.goldencode.ast.Aast" />
727

  
728
         <rule>true
729
            <action>res = null</action>
730
            <action>ref = node.getFirstChild()</action>
731
            <rule>ref != null and ref.type == prog.lbracket
732
               <action>ref = ref.getFirstChild()</action>
733
               <rule>ref.type == prog.expression
734
                  <action>ref = ref.getFirstChild()</action>
735
               </rule>
736
               <!-- should be a constant numeric literal -->
737
               <rule>ref != null and ref.isAnnotation("is-literal")
738
                  <action>res = execLib("get_extent_wname", name, ref.text)</action>
739
               </rule>
740
            </rule>
741
         </rule>
742
      </function>
743

  
716 744
      <!-- add frame to current scope -->
717 745
      <function name="add_frame">
718 746
         <parameter name="name"  type="java.lang.String" />
......
4136 4164
         <variable name="is_f"  init="false" />
4137 4165
         <variable name="txt1"  type="java.lang.String" />
4138 4166
         <variable name="txt2"  type="java.lang.String" />
4167
         <variable name="ename" type="java.lang.String" />
4139 4168
         <return   name="res"   type="com.goldencode.ast.Aast" />
4140 4169
         
4141 4170
         <rule>true
......
4148 4177
               <rule>txt1 == null
4149 4178
                  <action>txt1 = node.text</action>
4150 4179
               </rule>
4180

  
4181
               <!-- resolve only if index is a literal; helper returns null for dynamic -->
4182
               <action>ename = execLib("resolve_literal_extent_wname", txt1, node)</action>
4183
               <rule>ename != null
4184
                  <action>txt1 = ename</action>
4185
               </rule>
4151 4186
               <action>txt1 = txt1.toLowerCase()</action>
4152 4187
            </rule>
4153 4188
            
......
4183 4218
                     <rule>txt2 == null
4184 4219
                        <action>txt2 = ref.text</action>
4185 4220
                     </rule>
4221

  
4222
                     <!-- resolve only if index is a literal; helper returns null for dynamic -->
4223
                     <action>ename = execLib("resolve_literal_extent_wname", txt2, ref)</action>
4224
                     <rule>ename != null
4225
                        <action>txt2 = ename</action>
4226
                     </rule>
4186 4227
                     <action>txt2 = txt2.toLowerCase()</action>
4187 4228
                     
4188 4229
                     <rule>node.getChildAt(0) != null and 
......
4224 4265
         <variable  name="nm"    type="java.lang.String" />
4225 4266
         <variable  name="fn"    type="java.lang.String" />
4226 4267
         <variable  name="reffn" type="java.lang.String" />
4227
         <variable  name="dyn"   type="java.lang.Boolean"/> <!-- dynamic extent index -->
4228 4268
         <variable  name="txt1"  type="java.lang.String" />
4229 4269
         <variable  name="txt2"  type="java.lang.String" />
4230 4270
         <variable  name="checked_override" type="java.lang.Boolean" init="false" />
4271
         <variable name="ename" type="java.lang.String" />
4231 4272
         <return    name="res"   type="java.util.Map" />
4232 4273
         
4233 4274
         <rule>true
......
4237 4278
                            evalLib("literals", node.type))</action>
4238 4279
            <action>is_f = evalLib("fieldtype", node.type)</action>
4239 4280
            <action>is_w = evalLib("widgettype", node.type)</action>
4240
            <action>dyn = false</action>
4241 4281
            
4242 4282
            <rule>is_w and node.descendant(1, prog.kw_in)
4243 4283
               <action>ref = node.getFirstChild()</action>
......
4254 4294
               <action on="false">txt1 = node.text</action>
4255 4295
            </rule>
4256 4296
            
4257
            <action>ref2 = node.getFirstChild()</action>
4258
            <rule>ref2 != null and ref2.type == prog.lbracket
4259
               <!-- this is an item of an EXTENT field -->
4260
               <action>ref2 = ref2.getFirstChild()</action>
4261
               <rule>ref2.type == prog.expression
4262
                  <action>ref2 = ref2.getFirstChild()</action>
4263
               </rule>
4264
               <rule>ref2 != null <!-- should be a constant numeric literal -->
4265
                  <rule>ref2.isAnnotation("is-literal")
4266
                     <action>txt1 = execLib("get_extent_wname", txt1, ref2.text)</action>
4267
                     
4268
                     <action on="false">dyn = true</action> <!-- dynamic extent index -->
4269
                  </rule>
4270
               </rule>
4297
            <!-- resolve only if index is a literal; helper returns null for dynamic -->
4298
            <action>ename = execLib("resolve_literal_extent_wname", txt1, node)</action>
4299
            <rule>ename != null
4300
               <action>txt1 = ename</action>
4271 4301
            </rule>
4272 4302
            <action>txt1 = txt1.toLowerCase()</action>
4273 4303
            
......
4312 4342
                        <action on="false">txt2 = ref.text</action>
4313 4343
                     </rule>
4314 4344

  
4315
                     <rule>!dyn
4316
                        <!-- in case of dynamic extent index (the array offset is an expression
4317
                             that can be evaluated dynamically only at runtime) we assume the 
4318
                             whole extent item is part of same frame. 
4319
                             In this case Progress will stop with error 71. -->
4320
                        
4321
                        <action>ref2 = ref.getFirstChild()</action>
4322
                        <rule>ref2 != null and ref2.type == prog.lbracket
4323
                           <!-- this is an item of an EXTENT field -->
4324
                           <action>ref2 = ref2.getFirstChild()</action>
4325
                           <rule>ref2.type == prog.expression
4326
                              <action>ref2 = ref2.getFirstChild()</action>
4327
                           </rule>
4328
                           <rule>ref2 != null <!-- should be a constant numeric literal -->
4329
                              <rule>ref2.isAnnotation("is-literal")
4330
                                 <action>txt2 = execLib("get_extent_wname", txt2, ref2.text)</action>
4331
                              </rule>
4332
                           </rule>
4333
                        </rule>
4345
                     <!-- resolve only if index is a literal; helper returns null for dynamic -->
4346
                     <action>ename = execLib("resolve_literal_extent_wname", txt2, ref)</action>
4347
                     <rule>ename != null
4348
                        <action>txt2 = ename</action>
4334 4349
                     </rule>
4335 4350
                     <action>txt2 = txt2.toLowerCase()</action>
4336
                     
4351
                              
4337 4352
                     <rule>node.getChildAt(0) != null and
4338 4353
                           ref.getChildAt(0) != null  and
4339 4354
                           txt1.equals(txt2)          and
......
4345 4360
                           txt1.equals(txt2)
4346 4361
                        <action>res = frame</action>
4347 4362
                     </rule>
4348
                     
4363

  
4349 4364
                     <!-- check item of EXTENT field -->
4350
                     <rule>node.getNumImmediateChildren() == 1 and 
4365
                     <rule>node.getNumImmediateChildren() == 1 and
4351 4366
                           txt1.equals(txt2)
4352 4367
                        <action>res = frame</action>
4353 4368
                     </rule>
......
4535 4550
         <variable name="nm"    type="java.lang.String" />
4536 4551
         <variable name="txt1"  type="java.lang.String" />
4537 4552
         <variable name="txt2"  type="java.lang.String" />
4553
         <variable name="ename" type="java.lang.String" />
4538 4554
         <return   name="res"   type="java.util.Map" />
4539 4555
         
4540 4556
         <rule>true
......
4551 4567
               <rule>txt1 == null
4552 4568
                  <action>txt1 = node.text</action>
4553 4569
               </rule>
4570

  
4571
               <!-- resolve only if index is a literal; helper returns null for dynamic -->
4572
               <action>ename = execLib("resolve_literal_extent_wname", txt1, node)</action>
4573
               <rule>ename != null
4574
                  <action>txt1 = ename</action>
4575
               </rule>
4576

  
4554 4577
               <action>txt1 = txt1.toLowerCase()</action>
4555 4578
            </rule>
4556 4579

  
......
4591 4614
                           <rule>txt2 == null
4592 4615
                              <action>txt2 = ref.text</action>
4593 4616
                           </rule>
4617

  
4618
                           <!-- resolve only if index is a literal; helper returns null for dynamic -->
4619
                           <action>ename = execLib("resolve_literal_extent_wname", txt2, ref)</action>
4620
                           <rule>ename != null
4621
                              <action>txt2 = ename</action>
4622
                           </rule>
4594 4623
                           <action>txt2 = txt2.toLowerCase()</action>
4595
                           
4624

  
4596 4625
                           <rule>node.getChildAt(0) != null and 
4597 4626
                                 ref.getChildAt(0) != null  and
4598 4627
                                 txt1.equals(txt2)          and