From 90dad2ec57b9110b1e2ec6f46539edf41cfe2e99 Mon Sep 17 00:00:00 2001 From: Marion Date: Thu, 05 Sep 2013 21:15:59 +0000 Subject: simplify and fix export of 'while' and 'until' loops --- (limited to 'TurtleArt/tatype.py') diff --git a/TurtleArt/tatype.py b/TurtleArt/tatype.py index add26e3..cf75e44 100644 --- a/TurtleArt/tatype.py +++ b/TurtleArt/tatype.py @@ -49,11 +49,8 @@ class Type(object): class TypeDisjunction(tuple,Type): """ Disjunction of two or more Types (from the type hierarchy) """ - def __init__(self, iterable): self = tuple(iterable) - - def __str__(self): s = ["("] for disj in self: @@ -129,6 +126,9 @@ def get_type(x): return (TYPE_INT, True) elif x.func.id in ('repr', 'str', 'unicode'): return (TYPE_STRING, True) + # unary operands never change the type of their argument + elif isinstance(x, ast.UnaryOp): + return get_type(x.operand) return (TYPE_OBJECT, isinstance(x, ast.AST)) @@ -337,27 +337,7 @@ class TypedCall(ast.Call): @property def return_type(self): if self._return_type is None: - return get_type(self.func) - else: - return self._return_type - - -class TypedLambda(ast.Lambda): - """ Like a Lambda AST, but with a return type """ - - def __init__(self, body=None, args=None, return_type=None): - - if args is None: - args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) - - ast.Lambda.__init__(self, body=body, args=args) - - self._return_type = return_type - - @property - def return_type(self): - if self._return_type is None: - return get_type(self.func) + return get_type(self.func)[0] else: return self._return_type -- cgit v0.9.1