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-08 14:12:50 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-08 14:12:50 (GMT)
commitdfebf0be36908618c3b23839557dea93810b1198 (patch)
tree1e9e57273127cbc23e3847e6d3df2427201fdfc1 /TurtleArt/tatype.py
parent7fe3c377a730a75e15b5d7c23c7ba2f746e0396c (diff)
Primitives for all constant blocks (add screen dimensions, update colors)
- Use the get() method of the CONSTANTS dict to retrieve the values of constants, but export it as CONSTANTS['key']. - Introduce the new class TypedSubscript for Subscript ASTs with a type.
Diffstat (limited to 'TurtleArt/tatype.py')
-rw-r--r--TurtleArt/tatype.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/TurtleArt/tatype.py b/TurtleArt/tatype.py
index 752f71b..9a8c17d 100644
--- a/TurtleArt/tatype.py
+++ b/TurtleArt/tatype.py
@@ -350,7 +350,17 @@ def convert(x, new_type, old_type=None, converter=None):
return _apply_converter(converter, x)
-class TypedCall(ast.Call):
+class TypedAST(ast.AST):
+
+ @property
+ def return_type(self):
+ if self._return_type is None:
+ return get_type(self.func)[0]
+ else:
+ return self._return_type
+
+
+class TypedCall(ast.Call,TypedAST):
""" Like a Call AST, but with a return type """
def __init__(self, func, args=None, keywords=None, starargs=None,
@@ -366,12 +376,15 @@ class TypedCall(ast.Call):
self._return_type = return_type
- @property
- def return_type(self):
- if self._return_type is None:
- return get_type(self.func)[0]
- else:
- return self._return_type
+
+class TypedSubscript(ast.Subscript,TypedAST):
+ """ Like a Subscript AST, but with a return type """
+
+ def __init__(self, value, slice_, ctx=ast.Load, return_type=None):
+
+ ast.Subscript.__init__(self, value=value, slice=slice_, ctx=ctx)
+
+ self._return_type = return_type
def get_call_ast(func_name, args=None, kwargs=None, return_type=None):