-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from OpShin/feat/allow_empty_lists
Feat/allow empty lists
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import re | ||
from copy import copy | ||
from typing import Optional | ||
from enum import Enum | ||
|
||
from ..util import CompilingNodeTransformer | ||
from ..typed_ast import * | ||
|
||
""" | ||
Replaces empty lists with UPLC constants of empty lists | ||
""" | ||
|
||
|
||
class RewriteEmptyLists(CompilingNodeTransformer): | ||
step = "Rewrite empty lists to uplc empty lists" | ||
|
||
def visit_List(self, node: TypedList): | ||
if node.elts: | ||
return node | ||
return RawPlutoExpr(typ=node.typ, expr=empty_list(node.typ.typ.typ)) | ||
|
||
def visit_Constant(self, node: TypedConstant): | ||
if node.value != []: | ||
return node | ||
return RawPlutoExpr(typ=node.typ, expr=empty_list(node.typ.typ.typ)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters