From e18c96fcd0265867757e2d1a09dab608aaa5fab8 Mon Sep 17 00:00:00 2001 From: Marion Date: Wed, 04 Sep 2013 09:32:17 +0000 Subject: fix exporting the 'store in' and 'box' blocks - Use proper ast.Subscript objects to represent `BOX['my box']` - Enable type guessing for these ASTs --- (limited to 'TurtleArt/tatype.py') diff --git a/TurtleArt/tatype.py b/TurtleArt/tatype.py index 86119b6..0fcd74c 100644 --- a/TurtleArt/tatype.py +++ b/TurtleArt/tatype.py @@ -77,6 +77,9 @@ TYPE_STRING = Type('string', 9) # TODO add list types +BOX_AST = ast.Name(id='BOX', ctx=ast.Load) +ACTION_AST = ast.Name(id='ACTION', ctx=ast.Load) + def get_type(x): """ Return the most specific type in the type hierarchy that applies to x and a boolean indicating whether x is an AST. If the type cannot be @@ -113,6 +116,12 @@ def get_type(x): return (TYPE_OBJECT, True) else: return (get_type(value)[0], True) + elif isinstance(x, ast.Subscript): + if x.value == BOX_AST: + return (TypeDisjunction((TYPE_OBJECT, TYPE_STRING, TYPE_NUMBER, + TYPE_FLOAT, TYPE_INT, TYPE_NUMERIC_STRING, TYPE_CHAR, + TYPE_COLOR)), True) + # TODO elif x.value == ACTION_AST: elif isinstance(x, ast.Call): if isinstance(x.func, ast.Name): if x.func.id == 'float': -- cgit v0.9.1