diff --git a/README.md b/README.md index 3450233..b793813 100644 --- a/README.md +++ b/README.md @@ -527,9 +527,9 @@ The code has been updated to support compiler: ```bash $ moon version --all -moon 0.1.20240914 (e22cb71 2024-09-14) ~/.moon/bin/moon -moonc v0.1.20240914+b541585d3 ~/.moon/bin/moonc -moonrun 0.1.20240914 (e22cb71 2024-09-14) ~/.moon/bin/moonrun +moon 0.1.20241011 (ca50f51 2024-10-11) ~/.moon/bin/moon +moonc v0.1.20241011+9ea637707 ~/.moon/bin/moonc +moonrun 0.1.20241011 (ca50f51 2024-10-11) ~/.moon/bin/moonrun ``` Use `moonup` to manage `moon` compiler versions: diff --git a/examples/arrays/strings.mbt b/examples/arrays/strings.mbt index e65dbb4..c08bffa 100644 --- a/examples/arrays/strings.mbt +++ b/examples/arrays/strings.mbt @@ -4,7 +4,7 @@ pub fn process_strings(strings : Array[String]) -> Array[String] { strings.eachi( fn(index, value) { parts.push(value) - strings[index] = parts.join("|") + strings[index] = String::concat(parts, separator="|") }, ) strings diff --git a/moon.mod.json b/moon.mod.json index 303d072..90a9735 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -1,6 +1,6 @@ { "name": "extism/moonbit-pdk", - "version": "0.40.0", + "version": "0.41.0", "deps": {}, "readme": "README.md", "repository": "https://github.com/extism/moonbit-pdk", diff --git a/pdk/host/memory.mbt b/pdk/host/memory.mbt index ac84ecc..9bf55e7 100644 --- a/pdk/host/memory.mbt +++ b/pdk/host/memory.mbt @@ -61,9 +61,9 @@ pub fn to_string(self : Memory) -> String { pub fn to_int(self : Memory) -> Int { let bytes = self.to_bytes() bytes[0].to_int() + - bytes[1].to_int().lsl(8) + - bytes[2].to_int().lsl(16) + - bytes[3].to_int().lsl(24) + (bytes[1].to_int() << 8) + + (bytes[2].to_int() << 16) + + (bytes[3].to_int() << 24) } /// `to_bytes` reads the (unprocessed) bytes residing in the host memory diff --git a/pdk/string.mbt b/pdk/string.mbt index b3fb437..f9cbe87 100644 --- a/pdk/string.mbt +++ b/pdk/string.mbt @@ -33,7 +33,7 @@ pub impl ToUtf16 for Bytes with to_utf16(b : Bytes) -> String { // For now, support ASCII. // https://github.com/moonbitlang/core/issues/484 let length = b.length() - let buf = Buffer::new(size_hint=2 * length) + let buf = @buffer.new(size_hint=2 * length) for i = 0; i < length; i = i + 1 { let byte = b[i].to_int() let char = Char::from_int(byte) diff --git a/pdk/var/var.mbt b/pdk/var/var.mbt index f190cc3..7a17f1f 100644 --- a/pdk/var/var.mbt +++ b/pdk/var/var.mbt @@ -56,9 +56,9 @@ pub fn set_int(key : String, value : Int) -> Unit { let key_mem = @host.allocate_string(key) let bytes = Bytes::new(4) bytes[0] = value.land(255).to_byte() - bytes[1] = value.lsr(8).land(255).to_byte() - bytes[2] = value.lsr(16).land(255).to_byte() - bytes[3] = value.lsr(24).land(255).to_byte() + bytes[1] = (value >> 8).land(255).to_byte() + bytes[2] = (value >> 16).land(255).to_byte() + bytes[3] = (value >> 24).land(255).to_byte() let val_mem = @host.allocate_bytes(bytes) @extism.var_set(key_mem.offset, val_mem.offset) key_mem.free()