Super basic and a tiny bit hardcoded WAT-like syntax for generating the array of arrays of arrays of arrays wasm implementation in wasm.kp, allowing us to write psudo-WAT in kraken and output binary wasm with 1 function call

This commit is contained in:
Nathan Braswell
2021-07-18 23:42:19 -04:00
parent d3dd37c60e
commit d6d7af0bc1
3 changed files with 63 additions and 20 deletions

View File

@@ -892,8 +892,18 @@ fun main(argc: int, argv: **char): int {
if !params[1].is_int() { return make_pair(null<KPEnv>(), KPResult::Err(kpString(str("Param 2 to idx is not int ") + pr_str(params[1], true)))); }
var index = params[1].get_int()
var size = 0
if params[0].is_array() {
size = params[0].get_array_rc().get().size
} else {
size = params[0].get_string().length()
}
if index < 0 {
index += params[0].get_array_rc().get().size
index += size
}
if index < 0 || index >= size {
return make_pair(null<KPEnv>(), KPResult::Err(kpString(str("idx out of bounds, tried to get index ") + index + " in " + pr_str(params[0], true))))
}
if params[0].is_array() {