- explicit move for named linear values; E7003 with suggestion "move x"; move of a copyable value is E7006; moved state left to the verifier - own.new/own.array/region.create/region.new/region.array/cap.narrow.budget as outcome matches or with `or trap`; own.take/own.free/region.reset/ region.destroy as AIR names in AIR operand order - region.new/region.array take an explicit ref/mut region binding (E7005 otherwise); reset/destroy end nothing (verifier E2104) - match kind (enum/outcome/integer) decided by the parser; built-in error enums (alloc_error, cap_error, io_error) matched exhaustively - cap<K> types; linear owners borrowed in place - features header = registry closure of the features used - parameters keep their source names (grants by @main parameter name) - aji lower --stats: mechanical_air_eliminated = 1 - source/AIR bytes - spec 15, grammar, quick reference, plan updated
31 lines
662 B
Plaintext
31 lines
662 B
Plaintext
module demo.ownbasic
|
|
air 0
|
|
lang 0.1
|
|
features [capabilities, effects, heap, ownership, resources]
|
|
|
|
fn @bump(%c: mut<u64>) -> void
|
|
effects []
|
|
entry:
|
|
%v_1 = load %c
|
|
%c_2 = const.u64 1
|
|
%t_3 = add.checked.u64 %v_1, %c_2
|
|
store %c, %t_3
|
|
ret
|
|
|
|
fn @main(%heap: cap<mem.alloc>) -> u64
|
|
effects [mem.alloc]
|
|
entry:
|
|
%c_1 = const.u64 41
|
|
own.new %c_1, %heap, ok -> @ok_2, err -> @err_4
|
|
ok_2(%ok_3: own<u64>):
|
|
%x_6 = borrow.mut %ok_3
|
|
call @bump(%x_6)
|
|
borrow.end %x_6
|
|
%v_7 = own.take %ok_3
|
|
br @endmatch_9(%v_7)
|
|
err_4(%err_5: alloc_error):
|
|
%c_8 = const.u64 0
|
|
br @endmatch_9(%c_8)
|
|
endmatch_9(%match_10: u64):
|
|
ret %match_10
|