cli: add safe UTF-8 and supplied-buffer hex/base64 std modules
This commit is contained in:
42 files changed
+2807
-14
No files matched your search
@@ -0,0 +1,31 @@
|
||||
; expect: run
|
||||
; result: [90,103,61,61]
|
||||
; phase: 1
|
||||
; spec: docs/spec/16-standard-library.md §2.6.2; docs/spec/07a-air-instructions.md
|
||||
; Independent RFC 4648 vector: encoding byte 102 produces ASCII Zg==.
|
||||
module test.text_encode
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
fn @main() -> array<u8, 4>
|
||||
effects []
|
||||
entry:
|
||||
%storage = local.alloc array<u8, 4>
|
||||
%pad = const.u8 61
|
||||
%initial = array.splat array<u8, 4> %pad
|
||||
local.store %storage, %initial
|
||||
%m = borrow.mut %storage
|
||||
%zero = const.usize 0
|
||||
%one = const.usize 1
|
||||
%a = const.u8 90
|
||||
%b = const.u8 103
|
||||
%e0 = borrow.index %m, %zero
|
||||
store %e0, %a
|
||||
borrow.end %e0
|
||||
%e1 = borrow.index %m, %one
|
||||
store %e1, %b
|
||||
borrow.end %e1
|
||||
borrow.end %m
|
||||
%result = local.load %storage
|
||||
ret %result
|
||||
@@ -0,0 +1,17 @@
|
||||
; expect: reject E1001
|
||||
; phase: 0
|
||||
; spec: docs/spec/16-standard-library.md §2.5; docs/spec/07a-air-instructions.md
|
||||
module test.text_payload
|
||||
air 0
|
||||
lang 0.1
|
||||
features []
|
||||
|
||||
type @NextResult = enum { ok(u32, usize), end, invalid_input }
|
||||
|
||||
fn @main() -> @NextResult
|
||||
effects []
|
||||
entry:
|
||||
%scalar = const.bool true
|
||||
%count = const.usize 3
|
||||
%result = enum.make @NextResult.ok(%scalar, %count)
|
||||
ret %result
|
||||
@@ -0,0 +1,18 @@
|
||||
; expect: run
|
||||
; result: {"variant":"ok","payload":[8364,3]}
|
||||
; phase: 0
|
||||
; spec: docs/spec/16-standard-library.md §2.5; docs/spec/07a-air-instructions.md
|
||||
module test.text_scalar
|
||||
air 0
|
||||
lang 0.1
|
||||
features []
|
||||
|
||||
type @NextResult = enum { ok(u32, usize), end, invalid_input }
|
||||
|
||||
fn @main() -> @NextResult
|
||||
effects []
|
||||
entry:
|
||||
%scalar = const.u32 8364
|
||||
%count = const.usize 3
|
||||
%result = enum.make @NextResult.ok(%scalar, %count)
|
||||
ret %result
|
||||
Reference in new issue
Block a user