mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Update assembly concepts to include export line
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export @main {}
|
||||
@main = function() {
|
||||
call @f1 [1, 2, 3] %x
|
||||
apply @f2 %x [] %ignore
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
00: 0b04 0021 0d1c 0906 0106 0206 0300 0222
|
||||
10: 0d2c 0e02 0900 ff01 0e02 0000 0b07 0306
|
||||
20: 0e03 0e04 0504 0e02 0e05 0000 0b03 0002
|
||||
30: 0100
|
||||
00: 0d05 000a 000b 0400 210d 2300 0906 0106
|
||||
10: 0206 0300 0222 0d33 000e 0209 00ff 010e
|
||||
20: 0200 000b 0703 060e 030e 0405 040e 020e
|
||||
30: 0500 000b 0300 0201 00
|
||||
|
||||
---
|
||||
|
||||
// Pointers occupy a single byte in this example because it is so small. The
|
||||
// length of the bytecode implicitly indicates the byte width needed for
|
||||
// Pointers currently occupy two bytes, restricting programs to 64kB.
|
||||
// In future, the length of the bytecode may indicate the byte width needed for
|
||||
// pointers (1, 2, 4, or 8, whichever is smallest and sufficient).
|
||||
|
||||
// export @main {}
|
||||
00: 0d0500 0a00 // Default export is a pointer (0d) to 0500 (position
|
||||
// 5, little endian)
|
||||
// Named exports are an empty object (0a object, 00 end)
|
||||
|
||||
// @main = function() {
|
||||
00: 0b 04 00 // function with 4 registers and 0 parameters
|
||||
05: 0b 04 00 // function with 4 registers and 0 parameters
|
||||
// 0: %return
|
||||
// 1: %this
|
||||
// 2: %x
|
||||
@@ -19,20 +24,20 @@
|
||||
// the byte width for representing registers in this
|
||||
// function
|
||||
|
||||
// call @f1 [ 1, 2, 3 ] %x
|
||||
03: 21 0d1c 09 0601 0602 0603 00 02
|
||||
// call @f1 [ 1, 2, 3 ] %x
|
||||
08: 21 0d2300 09 0601 0602 0603 00 02
|
||||
|
||||
// apply @f2 %x [ ] %ignore
|
||||
0f: 22 0d2c 0e02 09 00 ff
|
||||
// apply @f2 %x [ ] %ignore
|
||||
15: 22 0d3300 0e02 09 00 ff
|
||||
|
||||
// mov %x %return
|
||||
17: 01 0e02 00
|
||||
1e: 01 0e02 00
|
||||
|
||||
// }
|
||||
1b: 00
|
||||
22: 00
|
||||
|
||||
// @f1 = function(%a, %b, %c) {
|
||||
1c: 0b 07 03 // function with 7 registers and 3 parameters
|
||||
23: 0b 07 03 // function with 7 registers and 3 parameters
|
||||
// 0: %return
|
||||
// 1: %this
|
||||
// 2: %a
|
||||
@@ -42,22 +47,22 @@
|
||||
// ff: %ignore
|
||||
|
||||
// op* %b %c %_tmp0
|
||||
1f: 06 0e03 0e04 05
|
||||
26: 06 0e03 0e04 05
|
||||
|
||||
// op+ %a %_tmp0 %return
|
||||
25: 04 0e02 0e05 00
|
||||
2c: 04 0e02 0e05 00
|
||||
|
||||
// }
|
||||
2b: 00
|
||||
|
||||
// @f2 = function() {
|
||||
2c: 0b 03 00 // function with 3 registers and 0 parameters
|
||||
33: 0b 03 00 // function with 3 registers and 0 parameters
|
||||
// 0: %return
|
||||
// 1: %this
|
||||
// ff: %ignore
|
||||
|
||||
// op++ %this
|
||||
2f: 02 01
|
||||
36: 02 01
|
||||
|
||||
// }
|
||||
31: 00
|
||||
38: 00
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export @main {}
|
||||
@main = function() {
|
||||
mov 37 %x
|
||||
bind @foo [%x] %foo
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export @main {}
|
||||
@main = function() {
|
||||
new @Counter [] %counter
|
||||
subcall %counter "inc" [] %ignore
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export @main {}
|
||||
@main = function() {
|
||||
mov @Counter %Counter
|
||||
sub %Counter "prototype" %_tmp0
|
||||
|
||||
@@ -32,6 +32,9 @@ struct Assembler {
|
||||
|
||||
impl Assembler {
|
||||
fn module(&mut self, module: &Module) {
|
||||
self.value(&module.export_default);
|
||||
self.object(&module.export_star);
|
||||
|
||||
for definition in &module.definitions {
|
||||
self.definition(definition);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user