Skip to content

Commit

Permalink
fix decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
sskeirik committed Dec 7, 2024
1 parent 57a9ff5 commit 1c11f3c
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions pykwasm/src/pykwasm/kdist/wasm-semantics/ulm-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ requires "ulm.k"
```

```k
module ULM-WASM-COMMON-SYNTAX
imports WASM-COMMON-SYNTAX
imports BOOL-SYNTAX
imports INT-SYNTAX
module ULM-WASM-SYNTAX
imports WASM
```

Program Encoding
Expand All @@ -18,31 +16,22 @@ The ULM-integrated WASM VM has two possible program encodings:
1. In the local test VM case, a direct encoding is used.

```local
syntax PgmEncoding ::= Stmts
syntax PgmEncoding ::= ModuleDecl
```
2. In the remote ULM-integrated VM case, a byte encoding is used.
```remote
imports BYTES-SYNTAX
syntax PgmEncoding ::= Bytes
```
```k
endmodule
```

```k
module ULM-WASM-SYNTAX
imports ULM-WASM-COMMON-SYNTAX
imports WASM-SYNTAX
endmodule
```

```k
module ULM-WASM
imports ULM-WASM-COMMON-SYNTAX
imports WASM
imports ULM-WASM-SYNTAX
imports ULM
```

Expand All @@ -54,9 +43,9 @@ The WASM VM must decode the input program:
1. In local test VM case, the decoding function is just identity.

```local
syntax Stmts ::= decodePgm(Stmts) [function, total]
// ------------------------------------------------
rule decodePgm(Stmts) => Stmts
syntax ModuleDecl ::= decodePgm(ModuleDecl) [function, total]
// ----------------------------------------------------------
rule decodePgm(Mod) => Mod
```
2. In the remote ULM-integrated VM case, a specialized, hooked byte decoder is used.
Expand Down Expand Up @@ -96,9 +85,7 @@ The embedder loads the module to be executed and then resolves the entrypoint fu
```k
rule <k> PGM:PgmEncoding => #resolveCurModuleFuncExport(FUNCNAME) </k>
<entry> FUNCNAME </entry>
<instrs> .K
=> sequenceStmts(text2abstract(decodePgm(PGM)))
</instrs>
<instrs> .K => decodePgm(PGM) </instrs>
```

Note that entrypoint resolution must occur _after_ the Wasm module has been loaded.
Expand Down

0 comments on commit 1c11f3c

Please sign in to comment.