Skip to content

Commit e0f37df

Browse files
author
Martin Ruefenacht
committed
Initial work on exposing constants
1 parent 9cf7f01 commit e0f37df

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/pympistandard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66

7-
__all__ = ["PROCEDURES", "KINDS", "CALLBACKS", "PREDEFINED_FUNCTIONS"]
7+
__all__ = ["PROCEDURES", "KINDS", "CALLBACKS", "PREDEFINED_FUNCTIONS", "CONSTANTS"]
88
__author__ = "Martin Ruefenacht"
99
__version__ = "0.1"
1010

src/pympistandard/constant.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
"""
3+
4+
5+
from typing import Mapping
6+
7+
8+
class ConstantExpression:
9+
def __init__(self, parseset) -> None:
10+
self._parseset = parseset
11+
12+
13+
class Constant:
14+
"""
15+
Constant is the class which represents a defined global constantwithin the
16+
MPI Standard.
17+
"""
18+
19+
def __init__(self, name: str, parseset: Mapping) -> None:
20+
self._name = name
21+
self._parseset = parseset
22+
23+
@property
24+
def name(self) -> str:
25+
"""Get the Constant name."""
26+
27+
return self._name
28+
29+
@property
30+
def express(self) -> ConstantExpression:
31+
"""Get expressions of this Constant."""
32+
33+
return ConstantExpression(self._parseset)

src/pympistandard/storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
CALLBACKS = NamespaceDict()
1818
PREDEFINED_FUNCTIONS = NamespaceDict()
1919

20-
CONSTANTS = NamespaceDict()
20+
CONSTANTS: MutableMapping[str, "Constant"] = NamespaceDict()
2121
# to support this the Python DSL in the MPI Standard needs to be extended
2222
# and all the constants need to be encoded (name, type, value if given)
2323

24+
2425
def clear_storage():
2526
KINDS.clear()
2627
PROCEDURES.clear()

0 commit comments

Comments
 (0)