snapkitty
compilers
javascript
6502-asm
File size: 2,424 Bytes
e870690
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var RuntimeRegistry = {
  RUNTIMES: {
    HOLY_SIM: 'holy-sim',
    SWIFT_WASM: 'swift-wasm',
    WASM: 'wasm',
    WEBLLM: 'webllm',
    OLLAMA: 'ollama'
  },

  current: 'holy-sim',
  swiftAvailable: false,
  webllmAvailable: false,
  ollamaAvailable: false,
  wasmAvailable: false,
  asmAvailable: true,

  adapters: {},

  register: function(name, adapter) {
    this.adapters[name] = adapter;
  },

  get: function(name) {
    return this.adapters[name] || null;
  },

  getCurrent: function() {
    return this.adapters[this.current] || null;
  },

  setSwiftAvailable: function(val) { this.swiftAvailable = val; },
  setWebLLMAvailable: function(val) { this.webllmAvailable = val; },
  setOllamaAvailable: function(val) { this.ollamaAvailable = val; },
  setWasmAvailable: function(val) { this.wasmAvailable = val; },

  initAll: async function() {
    var results = {};
    var sw = this.get('swift-wasm');
    if (sw) results.swift = await sw.init();
    var wl = this.get('webllm');
    if (wl) results.webllm = await wl.init();
    var ol = this.get('ollama');
    if (ol) results.ollama = await ol.init();
    var wa = this.get('wasm');
    if (wa) results.wasm = await wa.init();
    this.swiftAvailable = results.swift || false;
    this.webllmAvailable = results.webllm || false;
    this.ollamaAvailable = results.ollama || false;
    this.wasmAvailable = results.wasm || false;
    return results;
  },

  getRuntimeStatus: function() {
    return {
      holySim: 'SIMULATED',
      swiftWasm: this.swiftAvailable ? 'AVAILABLE' : 'FALLBACK_JS',
      webllm: this.webllmAvailable ? 'AVAILABLE' : 'FALLBACK_JS',
      ollama: this.ollamaAvailable ? 'AVAILABLE' : 'FALLBACK_JS',
      wasm: this.wasmAvailable ? 'AVAILABLE' : 'FALLBACK_JS',
      asm: 'SIMULATED',
      currentCore: this._getCurrentCore(),
      lispMachine: 'ONLINE',
      fontanaFFI: 'SIMULATED',
      assemblyLayer: 'SIMULATED',
      unicodeLayer: 'ONLINE'
    };
  },

  _getCurrentCore: function() {
    if (this.current === 'swift-wasm' && this.swiftAvailable) return 'SWIFT_SIM';
    if (this.current === 'webllm' && this.webllmAvailable) return 'WEBLLM_INFERENCE';
    if (this.current === 'ollama' && this.ollamaAvailable) return 'OLLAMA_BRIDGE';
    if (this.current === 'wasm' && this.wasmAvailable) return 'WASM_NATIVE';
    return 'JS_SIM';
  }
};