git @ Cat's Eye Technologies Decoy / 857cbff
Checkpoint moving to supporting native (JS in this case) modules. Chris Pressey 1 year, 5 months ago
5 changed file(s) with 41 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
+0
-1
lib/list.mjs less more
0 js/list.mjs
+0
-1
lib/maps.mjs less more
0 js/maps.mjs
+0
-1
lib/rux-rolli.mjs less more
0 js/rux-rolli.mjs
+0
-1
lib/stdenv.mjs less more
0 js/stdenv.mjs
163163 --
164164 local imported_module = self.modules[module_name]
165165 if imported_module == nil and self.module_path ~= nil then
166 --
167 -- First, try to load a Lua implementation module.
168 --
169 debug("module", "loading: " .. module_name)
170 local lua_mod_impl_filename = (
171 self.module_path .. "lua/" .. module_name .. ".lua"
172 )
173 local program_text = try_load_file(lua_mod_impl_filename)
174 if program_text ~= nil then
175 local make_module = dofile(lua_mod_impl_filename)
176 self.modules[module_name] = make_module()
166 if self.evaluator ~= nil then
167 --
168 -- We are evaluating.
169 --
170 -- First, try to load a Lua implementation module.
171 --
172 debug("module", "loading: " .. module_name)
173 local lua_mod_impl_filename = (
174 self.module_path .. "lua/" .. module_name .. ".lua"
175 )
176 local program_text = try_load_file(lua_mod_impl_filename)
177 if program_text ~= nil then
178 local make_module = dofile(lua_mod_impl_filename)
179 self.modules[module_name] = make_module()
180 else
181 --
182 -- If that didn't work, load a Decoy implementation module.
183 --
184 self:process_module_file(
185 self.module_path .. "decoy/" .. module_name .. ".scm"
186 )
187 end
177188 else
178189 --
179 -- If that didn't work, try to load a Decoy implementation module.
180 --
181 self:process_module_file(
182 self.module_path .. "decoy/" .. module_name .. ".scm"
190 -- We are compiling.
191 --
192 -- First, try to load a target-language (JS...) implementation module.
193 --
194 debug("module", "loading: " .. module_name)
195 local js_mod_impl_filename = (
196 self.module_path .. "js/" .. module_name .. ".mjs"
183197 )
198 local program_text = try_load_file(js_mod_impl_filename)
199 if program_text ~= nil then
200 -- FIXME: we may need to "register module specially".
201 self.modules[module_name] = program_text -- !!!
202 else
203 --
204 -- If that didn't work, load a Decoy implementation module.
205 --
206 self:process_module_file(
207 self.module_path .. "decoy/" .. module_name .. ".scm"
208 )
209 end
184210 end
185211 imported_module = self.modules[module_name]
186212 elseif self.module_path == nil then