about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-25 21:26:47 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-25 21:26:47 -0800
commite7dc519c405cb5ab4e9ad9acf3c9b21cc0c58497 (patch)
tree5cf391117be0b5fca7b245a68e7ee4cfec7d6fd0
parent6ae7bf91b1828df915f261c25202ca4dc241bbe9 (diff)
downloadteliva-e7dc519c405cb5ab4e9ad9acf3c9b21cc0c58497.tar.gz
reorg
-rw-r--r--src/teliva.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/teliva.c b/src/teliva.c
index 1129dc3..6ed849e 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -1021,30 +1021,6 @@ static void clear_call_graph(lua_State* L) {
   assert(lua_gettop(L) == oldtop);
 }
 
-char* Image_name = NULL;
-extern void set_args (lua_State *L, char **argv, int n);
-extern void load_tlv(lua_State* L, char* filename);
-int handle_image(lua_State* L, char** argv, int n) {
-  int status;
-  set_args(L, argv, n);
-  /* parse and load file contents (teliva_program array) */
-  Image_name = argv[n];
-  load_tlv(L, Image_name);
-//?   save_tlv(L, Image_name);  // manual test; should always return identical result, modulo key order
-//?   exit(1);
-  status = load_definitions(L);
-  if (status != 0) return 0;
-  status = run_tests(L);
-  if (status != 0) return report_in_developer_mode(L, status);
-  /* clear callgraph stats from running tests */
-  clear_call_graph(L);
-  /* call main() */
-  lua_getglobal(L, "main");
-  status = docall(L, 0, 1);
-  if (status != 0) return report_in_developer_mode(L, status);
-  return 0;
-}
-
 int file_operations_allowed = false;
 int net_operations_allowed = false;
 
@@ -1158,3 +1134,27 @@ void permissions_mode(lua_State* L) {
   execv(Argv[0], Argv);
   /* never returns */
 }
+
+char* Image_name = NULL;
+extern void set_args (lua_State *L, char **argv, int n);
+extern void load_tlv(lua_State* L, char* filename);
+int handle_image(lua_State* L, char** argv, int n) {
+  int status;
+  set_args(L, argv, n);
+  /* parse and load file contents (teliva_program array) */
+  Image_name = argv[n];
+  load_tlv(L, Image_name);
+//?   save_tlv(L, Image_name);  // manual test; should always return identical result, modulo key order
+//?   exit(1);
+  status = load_definitions(L);
+  if (status != 0) return 0;
+  status = run_tests(L);
+  if (status != 0) return report_in_developer_mode(L, status);
+  /* clear callgraph stats from running tests */
+  clear_call_graph(L);
+  /* call main() */
+  lua_getglobal(L, "main");
+  status = docall(L, 0, 1);
+  if (status != 0) return report_in_developer_mode(L, status);
+  return 0;
+}