Skip to content

Commit

Permalink
chore: more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmgr committed Nov 26, 2024
1 parent 56d6bea commit f394956
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 214 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
XXX

# Regular expression of note tags to take in consideration.
notes-rgx=
Expand Down
4 changes: 2 additions & 2 deletions nada_dsl/ast_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import hashlib
from typing import Dict, List
from sortedcontainers import SortedDict
from nada_dsl.nada_types import NadaTypeRepr, Party
from nada_dsl.nada_types import DslTypeRepr, Party
from nada_dsl.source_ref import SourceRef

OPERATION_ID_COUNTER = 0
Expand Down Expand Up @@ -41,7 +41,7 @@ class ASTOperation(ABC):

id: int
source_ref: SourceRef
ty: NadaTypeRepr
ty: DslTypeRepr

def child_operations(self) -> List[int]:
"""Returns the list of identifiers of all the child operations of this operation."""
Expand Down
24 changes: 10 additions & 14 deletions nada_dsl/nada_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Nada type definitions."""

from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, TypeAlias, Union, Type
from typing import Dict, TypeAlias, Union, Type
from nada_dsl.source_ref import SourceRef
from abc import abstractmethod


@dataclass
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self, name):
]

""
NadaTypeRepr: TypeAlias = str | Dict[str, Dict]
DslTypeRepr: TypeAlias = str | Dict[str, Dict]
"""Type alias for the NadaType representation.
This representation can be either a string ("SecretInteger")
Expand Down Expand Up @@ -113,8 +113,9 @@ def is_numeric(self) -> bool:
return self in (BaseType.INTEGER, BaseType.UNSIGNED_INTEGER)


# TODO: abstract?
@dataclass
class NadaType:
class DslType:
"""Nada type class.
This is the parent class of all nada types.
Expand Down Expand Up @@ -145,16 +146,7 @@ def __init__(self, child: OperationType):
"""
self.child = child
if self.child is not None:
self.child.store_in_ast(self.metatype().to_mir())

# @classmethod
# def class_to_mir(cls) -> str:
# """Converts a class into a MIR Nada type."""
# name = cls.__name__
# # Rename public variables so they are considered as the same as literals.
# if name.startswith("Public"):
# name = name[len("Public") :].lstrip()
# return name
self.child.store_in_ast(self.type().to_mir())

def __bool__(self):
raise NotImplementedError
Expand All @@ -168,3 +160,7 @@ def is_scalar(cls) -> bool:
def is_literal(cls) -> bool:
"""Returns True if the type is a literal."""
return False

@abstractmethod
def type(self):
"""Returns a meta type for this NadaType."""
Loading

0 comments on commit f394956

Please sign in to comment.