Implement const-generics #360
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#360
Loading…
Reference in New Issue
No description provided.
Delete Branch "feat/const-generics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Const generics are declared using e.g.
T = ConstGeneric("T", int32)
, and const-generic parameters in classes are declared usingclass A(Generic[T])
.The ellipsis change is necessary since currently it causes a compilation error, and functions marked as
extern
are eagerly evaluated.58d457c1f3
to5266e9b48e
v2: Add missing documentation
Implement const-genericsto WIP: Implement const-generics5266e9b48e
to4fb634aaa7
WIP: Implement const-genericsto Implement const-genericsv3: Re-introduced
ConstGeneric
class, implemented codegen for...
4fb634aaa7
to181756fb3c
v4: Remove all references to
Const
181756fb3c
to921aec411b
v5: Implement const generics for nac3artiq, minor cleanup
ARTIQ implementation is tested and working.
Implement const-genericsto WIP: Implement const-genericsMarked as WIP again due to some missing handling for ellipsis, specifically cases where
...
are used in sub-expressions as placeholders, e.g.... + 1
.921aec411b
toe7add9ea0d
v6: Completed codegen refactoring for ellipsis expression - Ellipsis are now treated as the equivalent of
todo!()
of Ruste7add9ea0d
to649874868a
v7: Fixed some cases where codegen fails for ellipsis due to extraneous/missing terminators, removed all references to
NonTypeVar
WIP: Implement const-genericsto Implement const-generics@ -3,3 +3,3 @@
from types import SimpleNamespace
from numpy import int32, int64
from typing import Generic, TypeVar
from typing import Any, Generic, TypeVar
Where is this used?
Was a leftover change from before, removed.
@ -879,1 +880,4 @@
typevar: get_attr_id(typing_mod, "TypeVar"),
const_generic_dummy: id_fn
.call1((
builtins_mod.getattr("globals")
Won't this break if
_ConstGenericDummy
is not in scope of the current module?Also it's not really a "dummy" if it plays such a role.
The intention is that
_ConstGenericDummy
is from the ARTIQ library and used as a marker that theTypeVar
is to be treated as a const generic variable.I know. The two problems above remain.
If I understand correctly: After we implement module support, you could just
import min_artiq
and then this code will break, since it becomesmin_artiq._ConstGenericMarker
and not_ConstGenericMarker
.When we implement module support, we will probably have to refactor this entire logic anyways, because
none
,Option
andvirtual
are all obtained this way. I assume we will do something like this (assuming that themin_artiq
module is imported asmin_artiq_mod
:BTW, this works in the interpreter:
@ -27,3 +27,3 @@
impl fmt::Display for Location {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: line {} column {}", self.file.0, self.row, self.column)
write!(f, "{}:{}:{}", self.file.0, self.row, self.column)
Should be a different PR.
Split this and the builtin-list changes into #361 and #362.
649874868a
to6e26c3abb7
6e26c3abb7
to390b7cc5f4
v8, v9: Split unrelated changes to other MRs, renamed
_ConstGenericDummy
to_ConstGenericMarker
.390b7cc5f4
to20607934a6
v10: Fixed missing
_ConstGenericMarker
changes20607934a6
to983f080ea7
v11: Rebased onto
master
, fixed an incorrect usage ofunreachable!