Skip to content
Snippets Groups Projects
Commit a19c66b5 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Merge branch 'bauerd/canonicalize' into 'v2.0-dev'

Extend symbol canonicalization

See merge request !451
parents 3b9860fb 2a23ec52
1 merge request!451Extend symbol canonicalization
Pipeline #74226 passed with stages
in 5 minutes and 23 seconds
...@@ -3,7 +3,15 @@ from ..memory import PsSymbol ...@@ -3,7 +3,15 @@ from ..memory import PsSymbol
from ..exceptions import PsInternalCompilerError from ..exceptions import PsInternalCompilerError
from ..ast import PsAstNode from ..ast import PsAstNode
from ..ast.structural import PsDeclaration, PsAssignment, PsLoop, PsConditional, PsBlock from ..ast.structural import (
PsDeclaration,
PsAssignment,
PsLoop,
PsConditional,
PsBlock,
PsStatement,
PsEmptyLeafMixIn,
)
from ..ast.expressions import PsSymbolExpr, PsExpression from ..ast.expressions import PsSymbolExpr, PsExpression
from ...types import constify from ...types import constify
...@@ -117,3 +125,14 @@ class CanonicalizeSymbols: ...@@ -117,3 +125,14 @@ class CanonicalizeSymbols:
case PsBlock(statements): case PsBlock(statements):
for stmt in statements[::-1]: for stmt in statements[::-1]:
self.visit(stmt, cc) self.visit(stmt, cc)
case PsStatement(expr):
self.visit(expr, cc)
case PsEmptyLeafMixIn():
...
case unknown:
raise PsInternalCompilerError(
f"Can't canonicalize symbols in {unknown} ({repr(unknown)})."
)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment