@@ -1148,9 +1148,9 @@ def visit_ADDRESS(self, node):
11481148 # Address of an array element.
11491149 if scope == SCOPE .global_ :
11501150 self .ic_aaddr (node .t , node .children [0 ].entry .mangled )
1151- elif scope == ' parameter' :
1151+ elif scope == SCOPE . parameter :
11521152 self .ic_paaddr (node .t , node .children [0 ].entry .offset )
1153- elif scope == ' local' :
1153+ elif scope == SCOPE . local :
11541154 self .ic_paaddr (node .t , - node .children [0 ].entry .offset )
11551155 else : # It's a scalar variable
11561156 if scope == SCOPE .global_ :
@@ -1316,6 +1316,14 @@ def __init__(self, function_list):
13161316 assert isinstance (x , symbols .FUNCTION )
13171317 self .functions = function_list
13181318
1319+ def _local_array_load (self , scope , local_var ):
1320+ t2 = optemps .new_t ()
1321+ if scope == SCOPE .parameter :
1322+ self .ic_pload (gl .PTR_TYPE , t2 , '%i' % (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1323+ elif scope == SCOPE .local :
1324+ self .ic_pload (gl .PTR_TYPE , t2 , '%i' % - (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1325+ self .ic_fparam (gl .PTR_TYPE , t2 )
1326+
13191327 def start (self ):
13201328 while self .functions :
13211329 f = self .functions .pop (0 )
@@ -1388,12 +1396,7 @@ def visit_FUNCTION(self, node):
13881396 self .ic_exchg ()
13891397
13901398 self .ic_param (gl .BOUND_TYPE , local_var .count )
1391- t2 = optemps .new_t ()
1392- if scope == SCOPE .parameter :
1393- self .ic_pload (gl .PTR_TYPE , t2 , '%i' % (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1394- elif scope == SCOPE .local :
1395- self .ic_pload (gl .PTR_TYPE , t2 , '%i' % - (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1396- self .ic_fparam (gl .PTR_TYPE , t2 )
1399+ self ._local_array_load (scope , local_var )
13971400 self .ic_call ('__ARRAYSTR_FREE_MEM' , 0 )
13981401 self .REQUIRES .add ('arraystrfree.asm' )
13991402
@@ -1403,13 +1406,7 @@ def visit_FUNCTION(self, node):
14031406 preserve_hl = True
14041407 self .ic_exchg ()
14051408
1406- t2 = optemps .new_t ()
1407- if scope == SCOPE .parameter :
1408- self .ic_pload (gl .PTR_TYPE , t2 , '%i' % (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1409- elif scope == SCOPE .local :
1410- self .ic_pload (gl .PTR_TYPE , t2 , '%i' % - (local_var .offset - self .TYPE (gl .PTR_TYPE ).size ))
1411-
1412- self .ic_fparam (gl .PTR_TYPE , t2 )
1409+ self ._local_array_load (scope , local_var )
14131410 self .ic_call ('__MEM_FREE' , 0 )
14141411 self .REQUIRES .add ('free.asm' )
14151412
0 commit comments