Skip to content

Commit 603d92e

Browse files
mkanatclaude
andcommitted
Add codegen and runtime support for destroy dimension point syntax
Implement code generation for destroy dimension point statements, completing the feature through the full compiler pipeline. Add destroy_dimension_point() to the runtime Position class, and include integration testdata covering all position reference patterns (local, interface, chained, and self in init). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b80c4da commit 603d92e

43 files changed

Lines changed: 404 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

define/compiler/codegen/literal/python/action_statements.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
{% endif %}
3333
{% elif stmt.kind == StatementKind.CREATE_DIMENSION_POINT %}
3434
{{ pos(stmt.position) }}.create_dimension_point()
35+
{% elif stmt.kind == StatementKind.DESTROY_DIMENSION_POINT %}
36+
{{ pos(stmt.position) }}.destroy_dimension_point()
3537
{% elif stmt.kind == StatementKind.MOVE_DIMENSION_POINT %}
3638
{% if stmt.to_position.chain_elements %}
3739
{{ pos(stmt.position) }}.move_dimension_point_to(

define/compiler/codegen/literal/python/action_statements.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def _build_statement(
5252
position=self._build_position_expr(stmt.target_position),
5353
)
5454
if isinstance(stmt, ast.DestroyDimensionPointStatement):
55-
raise NotImplementedError("destroy dimension point codegen")
55+
return template_context.ActionStatementContext(
56+
kind=template_context.StatementKind.DESTROY_DIMENSION_POINT,
57+
position=self._build_position_expr(stmt.target_position),
58+
)
5659
return template_context.ActionStatementContext(
5760
kind=template_context.StatementKind.MOVE_DIMENSION_POINT,
5861
position=self._build_position_expr(stmt.source_position),

define/compiler/codegen/literal/python/template_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class StatementKind(enum.Enum):
2626
LOCAL_POSITION = enum.auto()
2727
CREATE_DIMENSION_POINT = enum.auto()
2828
MOVE_DIMENSION_POINT = enum.auto()
29+
DESTROY_DIMENSION_POINT = enum.auto()
2930

3031

3132
class ChainAccessor(enum.Enum):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project: {
2+
universe_name: "my.domain.com:my_lib"
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
define the potential action<my.domain.com:my_lib:/act> {
2+
define the position<trigger>.
3+
define the position<chain_src> {
4+
it may only contain dimension points where {
5+
it has the position</mid>.
6+
}
7+
}
8+
it happens when {
9+
the position<trigger> has a dimension point.
10+
} and it does {
11+
destroy the dimension point in position<chain_src>::position</mid>::position</end>.
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
define the potential position<my.domain.com:my_lib:/end>.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Generated by the Define compiler."""
2+
3+
from define.runtime import literal
4+
5+
import local.my_domain_com.my_lib.test
6+
7+
8+
def main():
9+
literal.start(local.my_domain_com.my_lib.test.Test())
10+
11+
12+
if __name__ == "__main__":
13+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Generated by the Define compiler."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Generated by the Define compiler."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Generated by the Define compiler."""

0 commit comments

Comments
 (0)