Commits

Vincent Fiack committed 0100909

simplification

Comments (0)

Files changed (1)

brainfuck/bfjs.ml

   ast_elem##innerHTML <- js "";
   optim_elem##innerHTML <- js ""
 
-let run () = 
+let run_onclick _ = 
   reset ();
   let module JsInterpreter = Interpreter(JsIo) in
   let source = Js.to_string (source_elem##value) in
   let optim = Optimizer.optimize ast in
   ast_elem##innerHTML <- js (ParseTree.string_of_ast ast);  
   optim_elem##innerHTML <- js (ParseTree.string_of_ast optim);
-  JsInterpreter.exec optim
-
-let set_handlers _ = 
-  run_elem##onclick <- Html.handler (fun _ -> run (); Js._false);
+  JsInterpreter.exec optim;
   Js._false
 
+let onload _ = 
+  run_elem##onclick <- Html.handler run_onclick;
+  run_onclick ()
+
 let _ = 
-  Html.window##onload <- Html.handler set_handlers
+  Html.window##onload <- Html.handler onload