diff options
author | Marion <marion.zepf@gmail.com> | 2013-09-04 09:32:17 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-09-04 09:32:17 (GMT) |
commit | e18c96fcd0265867757e2d1a09dab608aaa5fab8 (patch) | |
tree | e6353349557e4c305c3a13d008177b95b6fb0b92 /TurtleArt/tatype.py | |
parent | 6ee1bb7f1a827d2b6e1d898c63d8017fa95d7222 (diff) |
fix exporting the 'store in' and 'box' blocks
- Use proper ast.Subscript objects to represent `BOX['my box']`
- Enable type guessing for these ASTs
Diffstat (limited to 'TurtleArt/tatype.py')
-rw-r--r-- | TurtleArt/tatype.py | 9 |
1 files changed, 9 insertions, 0 deletions
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': |