loader.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // load all files to run v86 in browser, uncompiled
  2. (function()
  3. {
  4. "use strict";
  5. var CORE_FILES =
  6. "const.js config.js log.js lib.js cpu.js debug.js " +
  7. "io.js main.js ide.js pci.js floppy.js " +
  8. "memory.js dma.js pit.js vga.js ps2.js pic.js rtc.js uart.js acpi.js apic.js ioapic.js hpet.js " +
  9. "ne2k.js state.js virtio.js bus.js elf.js kernel.js";
  10. var BROWSER_FILES = "main.js screen.js keyboard.js mouse.js serial.js lib.js network.js starter.js worker_bus.js print_stats.js filestorage.js";
  11. var LIB_FILES = "";
  12. // jor1k stuff
  13. LIB_FILES += " jor1k.js 9p.js filesystem.js marshall.js utf8.js";
  14. var BUILD_FILES = "capstone-x86.min.js libwabt.js";
  15. var to_load = [];
  16. load_scripts(CORE_FILES, "src/");
  17. load_scripts(BROWSER_FILES, "src/browser/");
  18. load_scripts(LIB_FILES, "lib/");
  19. load_scripts(BUILD_FILES, "build/");
  20. function load_scripts(resp, path)
  21. {
  22. var files = resp.split(" ");
  23. for(var i = 0; i < files.length; i++)
  24. {
  25. if(!files[i])
  26. {
  27. continue;
  28. }
  29. to_load.push(path + files[i]);
  30. }
  31. }
  32. load_next();
  33. function load_next()
  34. {
  35. let s = to_load.shift();
  36. if(!s)
  37. {
  38. return;
  39. }
  40. var script = document.createElement("script");
  41. script.src = s;
  42. script.onload = load_next;
  43. script.onerror = function() {
  44. dbg_log("Warning: trying to ignore script " + s + ", which failed to load");
  45. load_next();
  46. };
  47. document.head.appendChild(script);
  48. }
  49. })();