Compile (but not run) imports

This commit is contained in:
Andrew Morris
2023-03-08 11:12:53 +11:00
parent db2f2d4125
commit 8e44cb2e95
12 changed files with 146 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
export @f1 {}
@f1 = function(%a, %b, %c) {
op* %b %c %_tmp0
op+ %a %_tmp0 %return
}
}

View File

@@ -1,4 +1,6 @@
export void { "f2": @f2 }
@f2 = function() {
op++ %this
}
@f2 = function(%x) {
op++ %x
mov %x %return
}

View File

@@ -1,17 +1,21 @@
export @main {}
@f1 = lazy {
import "./f1.vsm" %return
}
@f2 = lazy {
import_star "./f2.vsm" %return
import* "./f2.vsm" %return
sub %return "f2" %return
}
@util = lazy {
import_star "./util.vsm" %return
import* "./util.vsm" %return
}
@main = function() {
call @f1 [1, 2, 3] %x
apply @f2 %x [] %ignore
call @f2 [%x] %x
subcall @util "dist" [3, 4] %dist
mov [%x, %dist] %return
}
}

View File

@@ -1,18 +1,22 @@
export @main {}
@f1 = lazy {
import "./f1.vsm" %return
}
@f2 = lazy {
import_star "./f2.vsm" %return
import* "./f2.vsm" %return
sub %return "f2" %return
}
@util_dist = lazy {
import_star "./util.vsm" %return
import* "./util.vsm" %return
sub %return "dist" %return
}
@main = function() {
call @f1 [1, 2, 3] %x
apply @f2 %x [] %ignore
call @f2 [%x] %x
call @util_dist [3, 4] %dist
mov [%x, %dist] %return
}
}

View File

@@ -1,7 +1,8 @@
export void { "dist": @dist }
@dist = function(%x, %y) {
op* %x %x %_tmp0
op* %y %y %_tmp1
op+ %_tmp0 %_tmp1 %_tmp1
subcall $Math "sqrt" [%_tmp1] %return
}
}