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-06 09:47:52 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-06 09:47:52 (GMT)
commit20e59359edae3d88b65c08523607050401e38693 (patch)
treede057016e33cf3e760921e0ad81a63218d3cbc7f /TurtleArt/tatype.py
parent40990d2845454b87840ff7c854acb1cd86129f05 (diff)
new special return type for the 'box' block
Diffstat (limited to 'TurtleArt/tatype.py')
-rw-r--r--TurtleArt/tatype.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/TurtleArt/tatype.py b/TurtleArt/tatype.py
index cf7bb03..346eb23 100644
--- a/TurtleArt/tatype.py
+++ b/TurtleArt/tatype.py
@@ -63,6 +63,7 @@ class TypeDisjunction(tuple,Type):
TYPE_OBJECT = Type('object', 0)
TYPE_BOOL = Type('bool', 5)
+TYPE_BOX = Type('box', 8) # special type for the unknown content of a box
TYPE_CHAR = Type('char', 1)
TYPE_COLOR = Type('color', 2)
TYPE_FLOAT = Type('float', 3)
@@ -115,9 +116,7 @@ def get_type(x):
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)
+ return (TYPE_BOX, True)
elif isinstance(x, ast.Call):
if isinstance(x.func, ast.Name):
if x.func.id == 'float':
@@ -172,6 +171,11 @@ TYPE_CONVERTERS = {
# The relation describing the type hierarchy must be transitive, i.e.
# converting A -> C must yield the same result as converting A -> B -> C.
# TYPE_OBJECT is the supertype of everything.
+ TYPE_BOX: {
+ TYPE_FLOAT: float,
+ TYPE_INT: int,
+ TYPE_NUMBER: float,
+ TYPE_STRING: str},
TYPE_CHAR: {
TYPE_INT: ord,
TYPE_STRING: identity},