1- # vim: ts=4:et:sw=4:
1+ # ----------------------------------------------------------------------
2+ # Copyleft (K), Jose M. Rodriguez-Rosa (a.k.a. Boriel)
3+ #
4+ # This program is Free Software and is released under the terms of
5+ # the GNU General License
6+ # ----------------------------------------------------------------------
7+
28from functools import cached_property
3- from typing import Optional
9+ from typing import Self
410
511import src .api .global_ as gl
612from src .api import check , errmsg
1016from src .symbols .id_ import SymbolID
1117from src .symbols .typecast import SymbolTYPECAST as TYPECAST
1218
13- # ----------------------------------------------------------------------
14- # Copyleft (K), Jose M. Rodriguez-Rosa (a.k.a. Boriel)
15- #
16- # This program is Free Software and is released under the terms of
17- # the GNU General License
18- # ----------------------------------------------------------------------
19-
2019
2120class SymbolARRAYACCESS (SymbolCALL ):
2221 """Defines an array access. It's pretty much like a function call
@@ -38,7 +37,7 @@ def __init__(self, entry, arglist: SymbolARGLIST, lineno: int, filename: str):
3837 self .entry .ref .is_dynamically_accessed = True
3938
4039 @property
41- def entry (self ):
40+ def entry (self ) -> SymbolID :
4241 return self .children [0 ]
4342
4443 @entry .setter
@@ -54,7 +53,7 @@ def type_(self):
5453 return self .entry .type_
5554
5655 @property
57- def arglist (self ):
56+ def arglist (self ) -> SymbolARGLIST :
5857 return self .children [1 ]
5958
6059 @arglist .setter
@@ -98,7 +97,7 @@ def is_constant(self) -> bool:
9897 return self .offset is None
9998
10099 @classmethod
101- def make_node (cls , id_ : str , arglist : SymbolARGLIST , lineno : int , filename : str ) -> Optional [ "SymbolARRAYACCESS" ] :
100+ def make_node (cls , id_ : str , arglist : SymbolARGLIST , lineno : int , filename : str ) -> Self | None :
102101 """Creates an array access. A(x1, x2, ..., xn)"""
103102 assert isinstance (arglist , SymbolARGLIST )
104103 variable = gl .SYMBOL_TABLE .access_array (id_ , lineno )
@@ -129,3 +128,7 @@ def make_node(cls, id_: str, arglist: SymbolARGLIST, lineno: int, filename: str)
129128
130129 # Returns the variable entry and the node
131130 return cls (variable , arglist , lineno , filename )
131+
132+ @classmethod
133+ def copy_from (cls , other : Self ) -> Self | None :
134+ return cls (entry = other .entry , arglist = other .arglist , lineno = other .lineno , filename = other .filename )
0 commit comments