Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | cf689514c152fa862deb4b94422f2a1468d9bb13 (tree) |
---|---|
Zeit | 2023-09-23 03:02:58 |
Autor | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
ASIS
@@ -0,0 +1,5 @@ | ||
1 | +# (C) Albert Mietus, 2023. Part of Castle/CCastle project | |
2 | + | |
3 | + | |
4 | + | |
5 | + |
@@ -0,0 +1,16 @@ | ||
1 | +# (C) Albert Mietus, 2023. Part of Castle/CCastle project | |
2 | + | |
3 | +from dataclasses import dataclass, KW_ONLY | |
4 | + | |
5 | +from castle.auxiliary import AIGR | |
6 | + | |
7 | +@dataclass # pragma: no mutate | |
8 | +class Event(AIGR): | |
9 | + """An event is like a (remote) function-call | |
10 | + | |
11 | + It has a name, a return-type (can be void), and a sequence of typed parameters.""" | |
12 | + | |
13 | + name: str | |
14 | + _: KW_ONLY # The field below must be passed as keywords, when initialising | |
15 | + return_type: type=None | |
16 | + typedParameters: Sequence[CC_TypedParameter]=() ## A tuple `()` is inmutable |
@@ -0,0 +1,7 @@ | ||
1 | +"XXX DocMe" | |
2 | + | |
3 | +class AIGR: # Abstract Intermediate Graph Representation | |
4 | + def __new__(cls, *args, **kwargs): | |
5 | + if cls == AIGR: | |
6 | + raise NotImplementedError(f"Instantiate a subclass of {cls}, not the `Abstract Intermediate Graph Representation`` itself") | |
7 | + return super().__new__(cls) |
@@ -0,0 +1,17 @@ | ||
1 | +# (C) Albert Mietus, 2023. Part of Castle/CCastle project | |
2 | + | |
3 | +from castle.auxiliary import AIGR | |
4 | + | |
5 | +class Demo(AIGR): | |
6 | + pass | |
7 | + | |
8 | +def test_noAIGR(): | |
9 | + try: | |
10 | + AIGR() | |
11 | + assert False , "shouldn't be able to initiate an AIGR directly" | |
12 | + except NotImplementedError: | |
13 | + pass | |
14 | + | |
15 | +def test_AIGR_sub(): | |
16 | + d = Demo() | |
17 | + assert isinstance(d, AIGR) |