Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-06 09:33:15 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-06 09:33:15 (GMT)
commit40990d2845454b87840ff7c854acb1cd86129f05 (patch)
treec778de5af14b83031f42cd12a4227941dae5c032
parenta6541270404dfac233ce73c3b9976a7659583eb2 (diff)
add Primitive for the 'stop stack' block
-rw-r--r--TurtleArt/tabasics.py7
-rw-r--r--TurtleArt/talogo.py4
-rw-r--r--TurtleArt/taprimitive.py3
3 files changed, 8 insertions, 6 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 84a374d..fe2bfa1 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -927,7 +927,6 @@ boolean operators from Numbers palette'))
self.tw.lc.def_prim('nop', 0,
Primitive(Primitive.do_nothing, export_me=False))
- primitive_dictionary['stopstack'] = self._prim_stopstack
palette.add_block('stopstack',
style='basic-style-tail',
label=_('stop action'),
@@ -935,7 +934,7 @@ boolean operators from Numbers palette'))
logo_command='stop',
help_string=_('stops current action'))
self.tw.lc.def_prim('stopstack', 0,
- lambda self: primitive_dictionary['stopstack']())
+ Primitive(self.tw.lc.prim_stop_stack))
def _blocks_palette(self):
''' The basic Turtle Art blocks palette '''
@@ -1278,10 +1277,6 @@ variable'))
self.tw.lc.ireturn()
yield True
- def _prim_stopstack(self):
- ''' Stop execution of a stack '''
- self.tw.lc.procstop = True
-
def _prim_wait(self, wait_time):
''' Show the turtle while we wait '''
self.tw.turtles.get_active_turtle().show()
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 563adf3..13d40bc 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -698,6 +698,10 @@ class LogoCode:
self.ireturn()
yield True
+ def prim_stop_stack(self):
+ """ Stop execution of a stack """
+ self.procstop = True
+
def prim_if(self, boolean, blklist):
""" If bool, do list """
if boolean:
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 2ec958b..47317b1 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -388,6 +388,9 @@ class Primitive(object):
call_ast = get_call_ast('logo.icall', [stack_func])
return [call_ast, ast_yield_true()]
+ elif self == LogoCode.prim_stop_stack:
+ return ast.Return()
+
# standard operators
elif self.func.__name__ in Primitive.STANDARD_OPERATORS:
op = Primitive.STANDARD_OPERATORS[self.func.__name__]