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
+
2
8
from functools import cached_property
3
- from typing import Optional
9
+ from typing import Self
4
10
5
11
import src .api .global_ as gl
6
12
from src .api import check , errmsg
10
16
from src .symbols .id_ import SymbolID
11
17
from src .symbols .typecast import SymbolTYPECAST as TYPECAST
12
18
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
-
20
19
21
20
class SymbolARRAYACCESS (SymbolCALL ):
22
21
"""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):
38
37
self .entry .ref .is_dynamically_accessed = True
39
38
40
39
@property
41
- def entry (self ):
40
+ def entry (self ) -> SymbolID :
42
41
return self .children [0 ]
43
42
44
43
@entry .setter
@@ -54,7 +53,7 @@ def type_(self):
54
53
return self .entry .type_
55
54
56
55
@property
57
- def arglist (self ):
56
+ def arglist (self ) -> SymbolARGLIST :
58
57
return self .children [1 ]
59
58
60
59
@arglist .setter
@@ -98,7 +97,7 @@ def is_constant(self) -> bool:
98
97
return self .offset is None
99
98
100
99
@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 :
102
101
"""Creates an array access. A(x1, x2, ..., xn)"""
103
102
assert isinstance (arglist , SymbolARGLIST )
104
103
variable = gl .SYMBOL_TABLE .access_array (id_ , lineno )
@@ -129,3 +128,7 @@ def make_node(cls, id_: str, arglist: SymbolARGLIST, lineno: int, filename: str)
129
128
130
129
# Returns the variable entry and the node
131
130
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