Skip to content

Commit

Permalink
chore: split NadaType and NadaValue / refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmgr committed Nov 21, 2024
1 parent 5098d7b commit e2635fa
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 200 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test-dependencies:
pip install .'[test]'

test: test-dependencies
pytest
uv run pytest

# Build protocol buffers definitions.
build_proto:
Expand Down
27 changes: 12 additions & 15 deletions nada_dsl/nada_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

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


@dataclass
Expand Down Expand Up @@ -144,20 +145,16 @@ def __init__(self, child: OperationType):
"""
self.child = child
if self.child is not None:
self.child.store_in_ast(self.to_mir())

def to_mir(self):
"""Default implementation for the Conversion of a type into MIR representation."""
return self.__class__.class_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.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

def __bool__(self):
raise NotImplementedError
Expand Down
Loading

0 comments on commit e2635fa

Please sign in to comment.