Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tatype.py
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-05 21:15:59 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-05 21:15:59 (GMT)
commit90dad2ec57b9110b1e2ec6f46539edf41cfe2e99 (patch)
tree736d578b99ccec331af3be31ca6cb476ddf8cc0e /TurtleArt/tatype.py
parent42d9ecf455ffd63bb2aa82d6442a470ff265c831 (diff)
simplify and fix export of 'while' and 'until' loops
Diffstat (limited to 'TurtleArt/tatype.py')
-rw-r--r--TurtleArt/tatype.py28
1 files changed, 4 insertions, 24 deletions
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