Removes UnaryOp
It was no longer used.
This commit is contained in:
parent
44b95af4ba
commit
bee0c845a8
1
TODO.md
1
TODO.md
@ -29,7 +29,6 @@
|
||||
- Implemented Bounded: https://hackage.haskell.org/package/base-4.21.0.0/docs/Prelude.html#t:Bounded
|
||||
- Try to implement the min and max functions using select
|
||||
- Filter out methods that aren't used; other the other way around (easier?) only add __ methods when needed
|
||||
- Move UnaryOp.operator into type class methods
|
||||
- Move foldr into type class methods
|
||||
- PrimitiveType is just the type, nothing primitive about it (change the name). u32 are still basic types or something.
|
||||
- Clean up Subscript implementation - it's half implemented in the compiler. Makes more sense to move more parts to stdlib_types.
|
||||
|
||||
@ -75,9 +75,6 @@ def expression(inp: ourlang.Expression) -> str:
|
||||
if isinstance(inp, ourlang.VariableReference):
|
||||
return str(inp.variable.name)
|
||||
|
||||
if isinstance(inp, ourlang.UnaryOp):
|
||||
return f'{inp.operator}{expression(inp.right)}'
|
||||
|
||||
if isinstance(inp, ourlang.BinaryOp):
|
||||
return f'{expression(inp.left)} {inp.operator.name} {expression(inp.right)}'
|
||||
|
||||
|
||||
@ -479,13 +479,6 @@ def expression(wgn: WasmGenerator, inp: ourlang.Expression) -> None:
|
||||
|
||||
raise NotImplementedError(inp.operator, instance_key)
|
||||
|
||||
if isinstance(inp, ourlang.UnaryOp):
|
||||
expression(wgn, inp.right)
|
||||
|
||||
assert isinstance(inp.type3, type3types.Type3), type3placeholders.TYPE3_ASSERTION_ERROR
|
||||
|
||||
raise NotImplementedError(expression, inp.type3, inp.operator)
|
||||
|
||||
if isinstance(inp, ourlang.FunctionCall):
|
||||
for arg in inp.arguments:
|
||||
expression(wgn, arg)
|
||||
|
||||
@ -127,21 +127,6 @@ class VariableReference(Expression):
|
||||
super().__init__()
|
||||
self.variable = variable
|
||||
|
||||
class UnaryOp(Expression):
|
||||
"""
|
||||
A unary operator expression within a statement
|
||||
"""
|
||||
__slots__ = ('operator', 'right', )
|
||||
|
||||
operator: str
|
||||
right: Expression
|
||||
|
||||
def __init__(self, operator: str, right: Expression) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.operator = operator
|
||||
self.right = right
|
||||
|
||||
class BinaryOp(Expression):
|
||||
"""
|
||||
A binary operator expression within a statement
|
||||
|
||||
@ -29,7 +29,6 @@ from .ourlang import (
|
||||
StructDefinition,
|
||||
Subscript,
|
||||
TupleInstantiation,
|
||||
UnaryOp,
|
||||
VariableReference,
|
||||
)
|
||||
from .prelude import PRELUDE_METHODS, PRELUDE_OPERATORS, PRELUDE_TYPES
|
||||
@ -389,19 +388,6 @@ class OurVisitor:
|
||||
self.visit_Module_FunctionDef_expr(module, function, our_locals, node.right),
|
||||
)
|
||||
|
||||
if isinstance(node, ast.UnaryOp):
|
||||
if isinstance(node.op, ast.UAdd):
|
||||
operator = '+'
|
||||
elif isinstance(node.op, ast.USub):
|
||||
operator = '-'
|
||||
else:
|
||||
raise NotImplementedError(f'Operator {node.op}')
|
||||
|
||||
return UnaryOp(
|
||||
operator,
|
||||
self.visit_Module_FunctionDef_expr(module, function, our_locals, node.operand),
|
||||
)
|
||||
|
||||
if isinstance(node, ast.Compare):
|
||||
if 1 < len(node.ops):
|
||||
raise NotImplementedError('Multiple operators')
|
||||
@ -476,7 +462,7 @@ class OurVisitor:
|
||||
|
||||
raise NotImplementedError(f'{node} as expr in FunctionDef')
|
||||
|
||||
def visit_Module_FunctionDef_Call(self, module: Module, function: Function, our_locals: OurLocals, node: ast.Call) -> Union[Fold, FunctionCall, UnaryOp]:
|
||||
def visit_Module_FunctionDef_Call(self, module: Module, function: Function, our_locals: OurLocals, node: ast.Call) -> Union[Fold, FunctionCall]:
|
||||
if node.keywords:
|
||||
_raise_static_error(node, 'Keyword calling not supported') # Yet?
|
||||
|
||||
|
||||
@ -48,9 +48,6 @@ def expression(ctx: Context, inp: ourlang.Expression) -> ConstraintGenerator:
|
||||
comment=f'typeOf("{inp.variable.name}") == typeOf({inp.variable.name})')
|
||||
return
|
||||
|
||||
if isinstance(inp, ourlang.UnaryOp):
|
||||
raise NotImplementedError(expression, inp, inp.operator)
|
||||
|
||||
if isinstance(inp, ourlang.BinaryOp) or isinstance(inp, ourlang.FunctionCall):
|
||||
signature = inp.operator.signature if isinstance(inp, ourlang.BinaryOp) else inp.function.signature
|
||||
arguments = [inp.left, inp.right] if isinstance(inp, ourlang.BinaryOp) else inp.arguments
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user