Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: type checking refactor #15

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ nada_dsl/version.py

*.log
*.out

# IntelliJ IDEA
*.iml
.idea
2 changes: 1 addition & 1 deletion docs/_source/nada_dsl.nada_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nada\_dsl.nada\_types
:show-inheritance:


.. automodule:: nada_dsl.nada_types.types
.. automodule:: nada_dsl.nada_types.scalar_types
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion nada_dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from nada_dsl.audit import *
from nada_dsl.source_ref import *
from nada_dsl.nada_types.types import *
from nada_dsl.nada_types.scalar_types import *
from nada_dsl.nada_types.generics import *
from nada_dsl.nada_types.function import *
from nada_dsl.nada_types.collections import *
Expand Down
2 changes: 1 addition & 1 deletion nada_dsl/compiler_frontend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)

# pylint: disable=wildcard-import,unused-wildcard-import
from nada_dsl.nada_types.types import *
from nada_dsl.nada_types.scalar_types import *
from nada_dsl.circuit_io import Input, Output
from nada_dsl.compiler_frontend import (
nada_dsl_to_nada_mir,
Expand Down
16 changes: 15 additions & 1 deletion nada_dsl/nada_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from enum import Enum
from typing import Dict, TypeAlias, Union, Type
from nada_dsl.source_ref import SourceRef

Expand Down Expand Up @@ -81,6 +82,18 @@ def __init__(self, name):
"""


class Mode(Enum):
CONSTANT = 1
PUBLIC = 2
SECRET = 3


class BaseType(Enum):
BOOLEAN = 1
INTEGER = 2
UNSIGNED_INTEGER = 3


@dataclass
class NadaType:
"""Nada type class.
Expand Down Expand Up @@ -125,9 +138,10 @@ def class_to_type(cls):
name = cls.__name__
# Rename public variables so they are considered as the same as literals.
if name.startswith("Public"):
name = name[len("Public") :].lstrip()
name = name[len("Public"):].lstrip()
return name
return name

def __bool__(self):
raise NotImplementedError

2 changes: 1 addition & 1 deletion nada_dsl/nada_types/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from nada_dsl.nada_types import NadaType

# Wildcard import due to non-zero types
from nada_dsl.nada_types.types import * # pylint: disable=W0614:wildcard-import
from nada_dsl.nada_types.scalar_types import * # pylint: disable=W0614:wildcard-import
from nada_dsl.source_ref import SourceRef
from nada_dsl.errors import NadaNotAllowedException
from nada_dsl.nada_types.function import NadaFunction, nada_fn
Expand Down
Loading
Loading