diff --git a/build/ludus.jimage b/build/ludus.jimage index b8f27dc..d81d9b4 100644 Binary files a/build/ludus.jimage and b/build/ludus.jimage differ diff --git a/build/ludus.mjs b/build/ludus.mjs index ddd35cc..1fb3001 100644 --- a/build/ludus.mjs +++ b/build/ludus.mjs @@ -10,6 +10,7 @@ export function run (source) { code = source const output = mod.ludus(source).value res = JSON.parse(output) + console.log(res) return res } @@ -134,7 +135,8 @@ function command_to_state (prev_state, curr_command) { return {...prev_state, heading: heading} } case "loadstate": { - const [_, x, y, heading, visible, pendown, penwidth, pencolor] = curr_command + console.log("LOADSTATE: ", curr_command) + const [_, [x, y], heading, visible, pendown, penwidth, pencolor] = curr_command return {position: [x, y], heading, visible, pendown, penwidth, pencolor} } case "show": { @@ -276,12 +278,14 @@ function svg_render_turtle (state) { } export function svg (commands) { + console.log(commands) const states = [turtle_init] commands.reduce((prev_state, command) => { const new_state = command_to_state(prev_state, command) states.push(new_state) return new_state }, turtle_init) + console.log(states) const {maxX, maxY, minX, minY} = states.reduce((accum, {position: [x, y]}) => { accum.maxX = Math.max(accum.maxX, x) accum.maxY = Math.max(accum.maxY, y) diff --git a/build/out.mjs b/build/out.mjs index 6db76f1..e026112 100644 --- a/build/out.mjs +++ b/build/out.mjs @@ -6489,7 +6489,7 @@ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports[' var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])(); var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1); var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5); -var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1820168; +var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1819972; function invoke_i(index) { var sp = stackSave(); try { diff --git a/build/out.wasm b/build/out.wasm index 12f69a9..fb581fb 100755 Binary files a/build/out.wasm and b/build/out.wasm differ diff --git a/build/svg_test.mjs b/build/svg_test.mjs index 1594d67..d44883c 100644 --- a/build/svg_test.mjs +++ b/build/svg_test.mjs @@ -4,8 +4,6 @@ const code = ` let home = unbox (turtle_state) -fd! (100) -rt! (0.25) fd! (100) loadstate! (home) diff --git a/build/svg_test.svg b/build/svg_test.svg index ee87a49..6568bf4 100644 --- a/build/svg_test.svg +++ b/build/svg_test.svg @@ -1,5 +1,5 @@ - + @@ -7,14 +7,12 @@ - - - + - + - + @@ -28,7 +26,7 @@ fd! (100) rt! (0.25) fd! (100) -loadstate! (home) +& loadstate! (home) rt! (0.25) fd! (100) diff --git a/prelude.ld b/prelude.ld index 683fe67..76c50c9 100644 --- a/prelude.ld +++ b/prelude.ld @@ -1227,8 +1227,8 @@ fn hideturtle! { fn loadstate! { "Sets the turtle state to a previously saved state." (state) -> { - let #{:position (x, y), heading, pendown?, pencolor, penwidth, visible?} = state - add_command! ((:loadstate, x, y, heading, visible?, pendown?, penwidth, pencolor)) + let #{position, heading, pendown?, pencolor, penwidth, visible?} = state + add_command! ((:loadstate, position, heading, visible?, pendown?, penwidth, pencolor)) } }