add more code
[nmigen-type-annotations.git] / nmigen / hdl / ast.pyi
index b978956cb793e02972aeedea4359b572186c246f..fbcb478d39a3aac3834a661352f8088a399887b5 100644 (file)
@@ -1,13 +1,12 @@
 from abc import ABCMeta, abstractmethod
-from typing import Union, Tuple, Any, Iterable, Optional, Mapping
+from typing import (Union, Tuple, Any, Iterable, Optional, Mapping, overload,
+                    List)
 from collections.abc import MutableSequence
 
 __all__ = [
-    "Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part",
-    "Slice", "Cat", "Repl", "Array", "ArrayProxy", "Sample", "Past", "Stable",
-    "Rose", "Fell", "Signal", "ClockSignal", "ResetSignal", "Statement",
-    "Assign", "Assert", "Assume", "Switch", "Delay", "Tick", "Passive",
-    "ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict", "SignalSet"
+    "Value", "Const", "C", "Mux", "Cat", "Repl", "Array", "ArrayProxy",
+    "Signal", "ClockSignal", "ResetSignal", "Statement", "Assign", "Assert",
+    "Assume", "Switch", "Delay", "Tick", "Passive"
 ]
 
 ValueOrLiteral = Union[int, bool, 'Value']
@@ -16,7 +15,7 @@ ShapeResult = Tuple[int, bool]
 
 class Value(metaclass=ABCMeta):
     @staticmethod
-    def wrap(obj: Any) -> 'Value':
+    def wrap(obj: ValueOrLiteral) -> 'Value':
         ...
 
     def __invert__(self) -> 'Value':
@@ -112,6 +111,7 @@ class Value(metaclass=ABCMeta):
     def bool(self) -> 'Value':
         ...
 
+    # noinspection PyMethodParameters
     def implies(premise: ValueOrLiteral,
                 conclusion: ValueOrLiteral) -> 'Value':
         ...
@@ -149,6 +149,7 @@ class Const(Value):
 C = Const
 
 
+# noinspection PyPep8Naming
 def Mux(sel: ValueOrLiteral,
         val1: ValueOrLiteral,
         val0: ValueOrLiteral) -> Value:
@@ -175,6 +176,7 @@ class Repl(Value):
         ...
 
 
+# noinspection PyShadowingBuiltins
 class Signal(Value):
     nbits: int
     signed: bool
@@ -272,3 +274,42 @@ class Tick(Statement):
 
 class Passive(Property):
     pass
+
+
+class Array(MutableSequence):
+    def __init__(self, iterable: Iterable = ()):
+        ...
+
+    @overload
+    def __getitem__(self, index: int) -> Any:
+        ...
+
+    @overload
+    def __getitem__(self, index: Value) -> 'ArrayProxy':
+        ...
+
+    def __len__(self) -> int:
+        ...
+
+    def __setitem__(self, index: int, value: Any) -> None:
+        ...
+
+    def __delitem__(self, index: int) -> None:
+        ...
+
+    def insert(self, index: int, value: Any) -> None:
+        ...
+
+
+class ArrayProxy(Value):
+    def __init__(self, elems: Union[Array, List[Any]], index: ValueOrLiteral):
+        ...
+
+    def __getattr__(self, attr: Any) -> Any:
+        ...
+
+    def __getitem__(self, index: Any) -> Any:
+        ...
+
+    def shape(self) -> Tuple[int, bool]:
+        ...