Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-05 22:17:56 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-05 22:17:56 (GMT)
commitb2d7bd1763e761a1286e61c53acdf2d66b17957c (patch)
tree0277908b219b04f0d54a9b02a3b2881bae9a7aca /TurtleArt
parent4711290decf293b0180f509168a94d3a37b647a2 (diff)
fix execution of 'while' and 'until' loops (again)
- Make it possible to apply type converters to un-called Primitives.
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/taprimitive.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index e037db9..4aa09c3 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -29,9 +29,9 @@ from taconstants import (Color, CONSTANTS)
from talogo import (LogoCode, logoerror)
from taturtle import (Turtle, Turtles)
from tatype import (ACTION_AST, BOX_AST, convert, get_call_ast, get_converter,
- get_type, is_bound_instancemethod, is_instancemethod,
- is_staticmethod, TATypeError, Type, TypeDisjunction,
- TYPE_COLOR, TYPE_FLOAT, TYPE_OBJECT)
+ get_type, identity, is_bound_instancemethod,
+ is_instancemethod, is_staticmethod, TATypeError, Type,
+ TypeDisjunction, TYPE_COLOR, TYPE_FLOAT, TYPE_OBJECT)
from tautils import debug_output
from tawindow import (global_objects, TurtleArtWindow)
from util import ast_extensions
@@ -901,18 +901,25 @@ class ArgSlot(object):
wrapped_argument = value_to_ast(wrapped_argument)
# 3. check the type and convert the argument if necessary
- try:
- converted_argument = convert(wrapped_argument,
- new_type, old_type=old_type, converter=converter)
- except TATypeError as error:
- # on failure, try next wrapper/ slot/ func
- bad_value = wrapped_argument
- continue
- else:
- # on success, return the result
- return ConstantArg(converted_argument,
- value_type=new_type,
- call_arg=(slot.call_arg and call_my_args))
+ converted_argument = wrapped_argument
+ if slot.call_arg and call_my_args:
+ try:
+ converted_argument = convert(wrapped_argument,
+ new_type, old_type=old_type,
+ converter=converter)
+ except TATypeError as error:
+ # on failure, try next wrapper/ slot/ func
+ bad_value = wrapped_argument
+ continue
+ elif converter != identity:
+ converted_argument = Primitive(converter,
+ return_type=new_type,
+ arg_descs=[ConstantArg(wrapped_argument,
+ value_type=old_type, call_arg=False)])
+ # on success, return the result
+ return ConstantArg(converted_argument,
+ value_type=new_type,
+ call_arg=(slot.call_arg and call_my_args))
# if we haven't returned anything yet, then all alternatives failed
if error is not None: