diff --git a/projects/shoggoth/BUILD b/projects/shoggoth/BUILD index 0ec38de..d8fe06e 100644 --- a/projects/shoggoth/BUILD +++ b/projects/shoggoth/BUILD @@ -1,6 +1,6 @@ py_project( name = "shoggoth", - main = "src/python/forerunner/repl/__main__.py", + main = "src/python/shoggoth/repl/__main__.py", main_deps = [ py_requirement("prompt_toolkit"), py_requirement("yaspin"), diff --git a/projects/shoggoth/src/python/shoggoth/vm/NOTES.md b/projects/shoggoth/src/python/ichor/NOTES.md similarity index 100% rename from projects/shoggoth/src/python/shoggoth/vm/NOTES.md rename to projects/shoggoth/src/python/ichor/NOTES.md diff --git a/projects/shoggoth/src/python/shoggoth/vm/__init__.py b/projects/shoggoth/src/python/ichor/__init__.py similarity index 100% rename from projects/shoggoth/src/python/shoggoth/vm/__init__.py rename to projects/shoggoth/src/python/ichor/__init__.py diff --git a/projects/shoggoth/src/python/shoggoth/vm/bootstrap.py b/projects/shoggoth/src/python/ichor/bootstrap.py similarity index 97% rename from projects/shoggoth/src/python/shoggoth/vm/bootstrap.py rename to projects/shoggoth/src/python/ichor/bootstrap.py index 9249971..75b9467 100644 --- a/projects/shoggoth/src/python/shoggoth/vm/bootstrap.py +++ b/projects/shoggoth/src/python/ichor/bootstrap.py @@ -6,7 +6,7 @@ Hopefully no "real" interpreter ever uses this code, since it's obviously replac from .isa import Module, Opcode -from shoggoth.types import * +from .typing import ProductExpr, SumExpr BOOTSTRAP = Module() diff --git a/projects/shoggoth/src/python/shoggoth/vm/impl.py b/projects/shoggoth/src/python/ichor/impl.py similarity index 95% rename from projects/shoggoth/src/python/shoggoth/vm/impl.py rename to projects/shoggoth/src/python/ichor/impl.py index eb72a83..6e7a8a8 100644 --- a/projects/shoggoth/src/python/shoggoth/vm/impl.py +++ b/projects/shoggoth/src/python/ichor/impl.py @@ -1,19 +1,11 @@ #!/usr/bin/env python3 -"""The Shogoth VM implementation. +"""The Ichor VM implementation. -The whole point of shoggoth is that program executions are checkpointable and restartable. This requires that rather than +The whole point of Shoggoth is that program executions are checkpointable and restartable. This requires that rather than using a traditional recursive interpreter which is difficult to snapshot, interpretation in shoggoth occur within a context (a virtual machine) which DOES have an easily introspected and serialized representation. -## The Shogoth VM Architecture - - -- NOT [bool] -> [bool] -- IF [then: addr, else: addr, cond: bool] -> [] -- CALL [procedure, n, ...] -> [...] -- RETURN [n, ...] - """ diff --git a/projects/shoggoth/src/python/shoggoth/vm/isa.py b/projects/shoggoth/src/python/ichor/isa.py similarity index 99% rename from projects/shoggoth/src/python/shoggoth/vm/isa.py rename to projects/shoggoth/src/python/ichor/isa.py index f318fef..c2c9998 100644 --- a/projects/shoggoth/src/python/shoggoth/vm/isa.py +++ b/projects/shoggoth/src/python/ichor/isa.py @@ -3,7 +3,7 @@ from typing import NamedTuple -from shoggoth.types import FunctionRef +from .typing import FunctionRef class Opcode: diff --git a/projects/shoggoth/src/python/shoggoth/types/__init__.py b/projects/shoggoth/src/python/ichor/typing.py similarity index 70% rename from projects/shoggoth/src/python/shoggoth/types/__init__.py rename to projects/shoggoth/src/python/ichor/typing.py index 7f40a9a..c9235b7 100644 --- a/projects/shoggoth/src/python/shoggoth/types/__init__.py +++ b/projects/shoggoth/src/python/ichor/typing.py @@ -58,11 +58,28 @@ class Closure(t.NamedTuple): args: t.List[t.Any] -# FIXME (arrdem 2022-05-30): -# Find a better name for this -class Vec(list): - pass +class FunctionSignature(t.NamedTuple): + raw: str + type_params: list + name: str + args: list + ret: list + + @staticmethod + def parse_list(l): + return [e for e in l.split(",") if e] + + @classmethod + def parse(cls, raw: str): + vars, name, args, ret = raw.split(";") + return cls( + raw, + cls.parse_list(vars), + name, + cls.parse_list(args), + cls.parse_list(ret) + ) -class List(list): - pass +class Function(t.NamedTuple): + """The type of a function; a subset of its signature.""" diff --git a/projects/shoggoth/src/python/shoggoth/types/function.py b/projects/shoggoth/src/python/shoggoth/types/function.py deleted file mode 100644 index 04fde96..0000000 --- a/projects/shoggoth/src/python/shoggoth/types/function.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 - -from typing import NamedTuple - - -class FunctionSignature(NamedTuple): - raw: str - type_params: list - name: str - args: list - ret: list - - @staticmethod - def parse_list(l): - return [e for e in l.split(",") if e] - - @classmethod - def parse(cls, raw: str): - vars, name, args, ret = raw.split(";") - return cls( - raw, - cls.parse_list(vars), - name, - cls.parse_list(args), - cls.parse_list(ret) - ) - - -class Function(NamedTuple): - """The type of a function; a subset of its signature.""" diff --git a/projects/shoggoth/src/python/shoggoth/types/keyword.py b/projects/shoggoth/src/python/shoggoth/types/keyword.py deleted file mode 100644 index da154b2..0000000 --- a/projects/shoggoth/src/python/shoggoth/types/keyword.py +++ /dev/null @@ -1,5 +0,0 @@ -from .symbol import Symbol - - -class Keyword(Symbol): - pass diff --git a/projects/shoggoth/src/python/shoggoth/types/symbol.py b/projects/shoggoth/src/python/shoggoth/types/symbol.py deleted file mode 100644 index 13cd9e9..0000000 --- a/projects/shoggoth/src/python/shoggoth/types/symbol.py +++ /dev/null @@ -1,21 +0,0 @@ -import typing as t - - -class Symbol(t.NamedTuple): - name: str - namespace: t.Optional[str] = None - - def qualify(self, ns: str): - return Symbol(self.name, ns) - - def unqualified(self): - if not self.namespace: - return self - else: - return Symbol(self.name) - - def __str__(self): - if self.namespace: - return f"{self.namespace}/{self.name}" - else: - return self.name diff --git a/projects/shoggoth/test/python/shogoth/vm/fixtures.py b/projects/shoggoth/test/python/ichor/fixtures.py similarity index 79% rename from projects/shoggoth/test/python/shogoth/vm/fixtures.py rename to projects/shoggoth/test/python/ichor/fixtures.py index d3937d6..ea04695 100644 --- a/projects/shoggoth/test/python/shogoth/vm/fixtures.py +++ b/projects/shoggoth/test/python/ichor/fixtures.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import pytest -from shoggoth.vm import * +from ichor import * @pytest.fixture diff --git a/projects/shoggoth/test/python/shogoth/vm/test_bootstrap.py b/projects/shoggoth/test/python/ichor/test_bootstrap.py similarity index 98% rename from projects/shoggoth/test/python/shogoth/vm/test_bootstrap.py rename to projects/shoggoth/test/python/ichor/test_bootstrap.py index fb99599..75188a1 100644 --- a/projects/shoggoth/test/python/shogoth/vm/test_bootstrap.py +++ b/projects/shoggoth/test/python/ichor/test_bootstrap.py @@ -3,7 +3,7 @@ from .fixtures import * # noqa import pytest -from shoggoth.vm import * +from ichor import * @pytest.mark.parametrize("stack,ret", [ diff --git a/projects/shoggoth/test/python/shogoth/vm/test_interpreter.py b/projects/shoggoth/test/python/ichor/test_interpreter.py similarity index 98% rename from projects/shoggoth/test/python/shogoth/vm/test_interpreter.py rename to projects/shoggoth/test/python/ichor/test_interpreter.py index 3f1ee9f..2cfcd9b 100644 --- a/projects/shoggoth/test/python/shogoth/vm/test_interpreter.py +++ b/projects/shoggoth/test/python/ichor/test_interpreter.py @@ -5,7 +5,7 @@ Tests coverign the VM interpreter from .fixtures import * # noqa import pytest -from shoggoth.vm import * +from ichor import * def test_true(vm):