Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/taexportpython.py
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-08-02 10:25:22 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-02 10:25:22 (GMT)
commiteda6a9f2b0fb4fd6f814fb5b39fc5d1293165570 (patch)
tree75af1c37c44414865a22fe2320d320be477ff371 /TurtleArt/taexportpython.py
parent5b4a6a44ed498f01712a6fd8f01150c9b02e8ff8 (diff)
export tool makes exported code use talogo's execution engine
Diffstat (limited to 'TurtleArt/taexportpython.py')
-rw-r--r--TurtleArt/taexportpython.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index b01e9c9..62065ce 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -28,6 +28,7 @@ import util.codegen as codegen
#from ast_pprint import * # only used for debugging, safe to comment out
+from talogo import LogoCode
from taprimitive import (Primitive, PyExportError)
from tautils import (debug_output, find_top_block)
@@ -52,7 +53,8 @@ _SETUP_CODE_END = """\
if __name__ == '__main__':
- start()
+ tw.lc.icall(start)
+ gobject.idle_add(tw.lc.doevalstep)
gtk.main()
@@ -94,6 +96,7 @@ def _action_stack_to_python(block, lc, name="start"):
name -- the name of the action stack (defaults to "start") """
# traverse the block stack and get the AST for every block
ast_list = _walk_action_stack(block, lc)
+ ast_list.append(_ast_yield_true())
action_stack_ast = ast.Module(body=ast_list)
#debug_output(str(action_stack_ast))
@@ -178,8 +181,9 @@ def _walk_action_stack(top_block, lc):
new_arg_asts = _walk_action_stack(conn, lc)
if dock[0] == 'flow':
# body of conditional or loop
+ if prim == LogoCode.loop:
+ new_arg_asts.append(_ast_yield_true())
arg_asts.extend(new_arg_asts)
- #arg_asts.append(ast.List(elts=new_arg_asts, ctx=ast.Load))
else:
# argument block
arg_asts.append(*new_arg_asts)
@@ -218,4 +222,7 @@ def _indent(code, num_levels=1):
new_line_list.append(indentation + line)
return linesep.join(new_line_list)
+def _ast_yield_true():
+ return ast.Yield(value=ast.Name(id='True', ctx=ast.Load))
+