Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
from
|
| 4 |
|
| 5 |
-
|
| 6 |
-
data = load_data_sources()
|
| 7 |
-
result = run_codexbyte(data)
|
| 8 |
-
return result
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from compiler import compile_codexbyte
|
| 3 |
+
from codexbyte_vm import CodexByteVM
|
| 4 |
|
| 5 |
+
vm = CodexByteVM()
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def run_codexbyte(source: str):
|
| 8 |
+
try:
|
| 9 |
+
program = compile_codexbyte(source.strip().splitlines())
|
| 10 |
+
ledger = vm.run(program)
|
| 11 |
+
return {
|
| 12 |
+
"registers": vm.reg,
|
| 13 |
+
"memory": vm.mem,
|
| 14 |
+
"omega_ledger": ledger
|
| 15 |
+
}
|
| 16 |
+
except Exception as e:
|
| 17 |
+
return {"error": str(e)}
|
| 18 |
|
| 19 |
+
gr.Interface(
|
| 20 |
+
fn=run_codexbyte,
|
| 21 |
+
inputs=gr.Textbox(
|
| 22 |
+
lines=16,
|
| 23 |
+
label="CodexByte Program",
|
| 24 |
+
placeholder="LOAD_IMM 0 1000\nLOAD_MEM 1 0x20\nCMP 1 0\nJZ 10\nHALT"
|
| 25 |
+
),
|
| 26 |
+
outputs=gr.JSON(label="Ω-State Proof"),
|
| 27 |
+
title="CodexByte ΩΞ Runtime",
|
| 28 |
+
description="Bytecode execution is enforcement. Execution trace is proof."
|
| 29 |
+
).launch()
|