aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe <me@christine.website>2022-12-31 14:43:42 -0500
committerXe <me@christine.website>2022-12-31 14:43:42 -0500
commit4970fdc51f8c83dcd38bbdd25606fe030c0c26d2 (patch)
tree36d9d32f5b2b6aca843952fb9eb0d75e11f86697 /cmd
parent2fe527950512b97a544d2d59539026514ad59544 (diff)
downloadx-4970fdc51f8c83dcd38bbdd25606fe030c0c26d2.tar.xz
x-4970fdc51f8c83dcd38bbdd25606fe030c0c26d2.zip
nice
Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hlang/http.go11
-rw-r--r--cmd/hlang/nguh/compile.go1
2 files changed, 5 insertions, 7 deletions
diff --git a/cmd/hlang/http.go b/cmd/hlang/http.go
index d4b9aba..4a7f9df 100644
--- a/cmd/hlang/http.go
+++ b/cmd/hlang/http.go
@@ -298,9 +298,6 @@ const faqTemplate = `<html>
-o string
if specified, write the webassembly binary created
by -p here
- -o-wat string
- if specified, write the uncompiled webassembly
- created by -p here
-p string
h program to compile/run
-port string
@@ -375,9 +372,9 @@ const playgroundTemplate = `<html>
<code><pre id="output"></pre></code>
- <h4>WebAssembly Text Format</h4>
+ <h4>AST</h4>
- <code><pre id="wat_box"></pre></code>
+ <code><pre id="ast_box"></pre></code>
<p>Gas used: <span id="gas_used"></span></p>
<p>Execution time (nanoseconds): <span id="exec_time"></span></p>
@@ -386,7 +383,7 @@ const playgroundTemplate = `<html>
function runProgram() {
const programData = document.getElementById("program").value;
const output = document.getElementById("output");
- const watBox = document.getElementById("wat_box");
+ const astBox = document.getElementById("ast_box");
const gasUsed = document.getElementById("gas_used");
const execTime = document.getElementById("exec_time");
const status = document.getElementById("status");
@@ -401,7 +398,7 @@ const playgroundTemplate = `<html>
}
status.innerHTML = "success";
- watBox.innerHTML = data.prog.wat;
+ astBox.innerHTML = data.prog.ast;
output.innerHTML = data.res.out;
gasUsed.innerHTML = data.res.gas;
execTime.innerHTML = data.res.exec_duration;
diff --git a/cmd/hlang/nguh/compile.go b/cmd/hlang/nguh/compile.go
index d268d77..72fb6aa 100644
--- a/cmd/hlang/nguh/compile.go
+++ b/cmd/hlang/nguh/compile.go
@@ -135,6 +135,7 @@ func Compile(tree *peg.Node) ([]byte, error) {
funcBuf.Write([]byte{
0x20, 0x00, // local.get 0
0x10, 0x00, // call 0
+ 0x01, 0x01, // two padding NOPs to get a single `h` binary to be 69 bytes.
0x0b, // end of function
})