File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 'InvalidLoopError' ,
1919 'InvalidCONSTexpr' ,
2020 'InvalidBuiltinFunctionError' ,
21- 'InternalError'
21+ 'InternalError' ,
22+ 'TempAlreadyFreedError'
2223]
2324
2425
@@ -52,6 +53,14 @@ def __init__(self, fname):
5253 self .msg = "Invalid BUILTIN function '%s'" % fname
5354
5455
55- class InternalError :
56+ class InternalError ( Error ) :
5657 def __init__ (self , msg ):
5758 self .msg = msg
59+
60+
61+ class TempAlreadyFreedError (InternalError ):
62+ """ Raised when a TEMP label has been already freed.
63+ """
64+ def __init__ (self , label ):
65+ super ().__init__ (f"Label '{ label } ' already freed" )
66+ self .label = label
Original file line number Diff line number Diff line change 33# vim ts=4:et:sw=4:ai
44
55import math
6- from .errors import TempAlreadyFreedError
6+
7+ from typing import List
8+ from typing import Set
9+
10+ import src .api .errors
11+
712
813MEMORY = [] # Must be initialized by with init()
914
1217
1318# Counter for generated tmp labels (__TMP0, __TMP1, __TMPN)
1419TMP_COUNTER = 0
15- TMP_STORAGES = []
20+ TMP_STORAGES : List [ str ] = []
1621
1722# Set containing REQUIRED libraries
18- REQUIRES = set () # Set of required libraries (included once)
23+ REQUIRES : Set [ str ] = set () # Set of required libraries (included once)
1924
2025# Set containing automatic on start called routines
21- INITS = set () # Set of INIT routines
26+ INITS : Set [ str ] = set () # Set of INIT routines
2227
2328# CONSTANT LN(2)
2429__LN2 = math .log (2 )
2530
2631# GENERATED labels __LABELXX
27- TMP_LABELS = set ()
32+ TMP_LABELS : Set [ str ] = set ()
2833
2934
3035def init ():
@@ -83,9 +88,9 @@ def tmp_temp() -> str:
8388 return result
8489
8590
86- def tmp_remove (label ):
91+ def tmp_remove (label : str ):
8792 if label not in TMP_STORAGES :
88- raise TempAlreadyFreedError (label )
93+ raise src . api . errors . TempAlreadyFreedError (label )
8994
9095 TMP_STORAGES .pop (TMP_STORAGES .index (label ))
9196
Original file line number Diff line number Diff line change 77__all__ = ['GenericError' ,
88 'InvalidICError' ,
99 'NoMoreRegistersError' ,
10- 'UnsupportedError' ,
11- 'TempAlreadyFreedError' ]
10+ 'UnsupportedError' ]
1211
1312
1413class GenericError (Error ):
@@ -52,14 +51,6 @@ def __init__(self, feat):
5251 self .feature = feat
5352
5453
55- class TempAlreadyFreedError (GenericError ):
56- """ Raised when a TEMP label has been already freed.
57- """
58- def __init__ (self , label ):
59- GenericError .__init__ (self , "Label '%s' already freed" % label )
60- self .label = label
61-
62-
6354# -----------------------------------------------------------------------------
6455# Functions for throwing errors
6556# -----------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments