about summary refs log tree commit diff stats
path: root/src/task.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-05 22:03:11 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-03-05 22:38:00 -0800
commitf2d29c22f86a88bfa0d0cbd9141e6ae60f840cb0 (patch)
tree4506091c47f15df46d8a86a3b34a1388e36626c3 /src/task.lua
parent52ae23784b5474298c6ada6252f5a785fc5e8c19 (diff)
downloadteliva-f2d29c22f86a88bfa0d0cbd9141e6ae60f840cb0.tar.gz
a simple hack to make caller apparent
Teliva isn't yet smart enough to know the caller of an indirect function
where the function being called goes through a local variable.

I'd expected fixing this to be a long death march. However, there's a
shockingly easy fix: just make every indirect call go through an
additional direct function call.

My policy for zet.tlv was that function 'main' could open any file. This
stopped working since I introduced spawn_main. But with this commit it's
working again.

I can also drop all my special-casing of 'main' since it's now a regular
Lua call.

We still can't rely on the caller of an indirect call. That affects
start_reading and start_writing, which really need to be part of the
framework.
Diffstat (limited to 'src/task.lua')
-rw-r--r--src/task.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/task.lua b/src/task.lua
index 3b00ef6..dbe788f 100644
--- a/src/task.lua
+++ b/src/task.lua
@@ -382,7 +382,7 @@ _M.NOP       = NOP
 
 -- Specific to Teliva
 function spawn_main()
-  task.spawn(main)
+  task.spawn(call_main)
   task.scheduler()
   assert(false, "Teliva's scheduler ran out of work; this shouldn't happen.\n"..
                 "Either a channel is blocked forever or you're reading past\n"..
@@ -391,6 +391,12 @@ function spawn_main()
   curses.getch()
 end
 
+-- This function exists only to make the call to 'main' visible to Teliva.
+-- Teliva can't yet recognize the caller of indirect calls.
+function call_main()
+  main()
+end
+
 ----------------------------------------------------------------------------
 ----------------------------------------------------------------------------
 -- Tests