Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | af147882bb4018964e907b4012b0b49acf63f569 (tree) |
---|---|
Zeit | 2024-05-12 21:32:36 |
Autor | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
TESTDOUBLES::sieveCastle solved mypy, by using (new) 'VoidCall' -- thanks mypy
@@ -22,33 +22,33 @@ | ||
22 | 22 | Sieve = ComponentImplementation('Sieve', |
23 | 23 | interface=components.SieveMoat, |
24 | 24 | parameters=(), |
25 | - body=aigr.Body()) # Body in filed below | |
25 | + body=aigr.Body()) # Body filled-in below | |
26 | + | |
27 | +assert isinstance(Sieve.body, aigr.Body) # This make mypy happy to fill-in the Body | |
28 | + | |
26 | 29 | |
27 | 30 | # init(int:onPrime) // `init` is (typically) part of the construction of a element. |
28 | 31 | # { |
29 | 32 | # super.init(); // `super` acts as port to the base-class |
30 | 33 | # .myPrime := onPrime; |
31 | 34 | # } |
32 | - | |
33 | 35 | init_method = Method(ID('init'), |
34 | 36 | returns=None, |
35 | 37 | parameters=(aigr.TypedParameter(name=ID('onPrime'), type=int),), |
36 | 38 | body=aigr.Body(statements=[ |
37 | - aigr.Call( | |
38 | - callable=aigr.Part( | |
39 | - base=aigr.Call(callable=ID('super')), attribute=ID('init')), | |
40 | - arguments=()), | |
39 | + aigr.VoidCall( | |
40 | + aigr.Call( | |
41 | + callable=aigr.Part( | |
42 | + base=aigr.Call(callable=ID('super')), attribute=ID('init')), | |
43 | + arguments=())), | |
41 | 44 | aigr.Become( |
42 | 45 | targets=(aigr.Part(base=ID('self'), attribute=ID('myPrime', context=aigr.Set())),), |
43 | 46 | values=(ID('onPrime', context=aigr.Ref()),))])) |
44 | 47 | |
45 | -assert isinstance(Sieve.body, aigr.Body) # This make mypy happy for the next line :-) | |
48 | + | |
46 | 49 | Sieve.body.expand(init_method) |
47 | 50 | |
48 | 51 | |
49 | - | |
50 | - | |
51 | - | |
52 | 52 | # SimpleSieve.input(try) on .try |
53 | 53 | # { |
54 | 54 | # if ( (try % .myPrime) !=0 ) { |
@@ -8,14 +8,14 @@ | ||
8 | 8 | from castle import aigr |
9 | 9 | |
10 | 10 | |
11 | -def find_name_in_body(name, body) -> PTH.Optional[aigr.statements.callables._Named_callable]: | |
11 | +def find_name_in_body(name, body) -> PTH.Optional[aigr.NamedNode]: | |
12 | 12 | logger.info("find_name_in_body(name=%s, body=%s", name, body) |
13 | 13 | for s in body.statements: |
14 | 14 | logger.debug("\t: %s", s) |
15 | 15 | if isinstance(s, aigr.NamedNode): |
16 | 16 | logger.debug("\t: name=%s in %s", s.name, s) |
17 | 17 | if s.name == name: |
18 | - logger.debug("\t: FOUND name=%s in %s", s.name, s) | |
18 | + logger.debug("\t: FOUND name=%s: %s", s.name, s) | |
19 | 19 | return s |
20 | 20 | logger.debug("NOT FOUND: %s", name) |
21 | 21 | return None |