loader.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 coverage.js cpu.js debug.js codegen.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";
  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";
  11. //var LIB_FILES = "esprima.js walk.js";
  12. var LIB_FILES = "";
  13. // jor1k stuff
  14. LIB_FILES += " jor1k.js 9p.js filesystem.js marshall.js utf8.js";
  15. var BUILD_FILES = "capstone-x86.min.js libwabt.js";
  16. var to_load = [];
  17. load_scripts(CORE_FILES, "src/");
  18. load_scripts(BROWSER_FILES, "src/browser/");
  19. load_scripts(LIB_FILES, "lib/");
  20. load_scripts(BUILD_FILES, "build/");
  21. function load_scripts(resp, path)
  22. {
  23. var files = resp.split(" ");
  24. for(var i = 0; i < files.length; i++)
  25. {
  26. if(!files[i])
  27. {
  28. continue;
  29. }
  30. to_load.push(path + files[i]);
  31. }
  32. }
  33. load_next();
  34. function load_next()
  35. {
  36. var s = to_load.shift();
  37. if(!s)
  38. {
  39. return;
  40. }
  41. var script = document.createElement("script");
  42. script.src = s;
  43. script.onload = load_next;
  44. document.head.appendChild(script);
  45. }
  46. })();