Phase 6A: .aji layer 5 (linear values, own, regions, outcome matches, or trap)
- 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
This commit is contained in:
1 parent
eca30f817a
commit
bdcf871e5d
28 files changed
+882
-78
No files matched your search
@@ -0,0 +1,27 @@
|
||||
module demo.allocerror
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, heap, ownership, resources]
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
entry:
|
||||
%c_1 = const.usize 64
|
||||
%c_2 = const.u64 0
|
||||
own.array %c_1, %c_2, %heap, ok -> @ok_3, err -> @err_5
|
||||
ok_3(%ok_4: own_array<u64>):
|
||||
own.free %ok_4
|
||||
%c_7 = const.u64 1
|
||||
br @endmatch_14(%c_7)
|
||||
err_5(%err_6: alloc_error):
|
||||
enum.switch alloc_error %err_6, budget_exceeded -> @case_budget_exceeded_8, out_of_memory -> @case_out_of_memory_9
|
||||
case_budget_exceeded_8:
|
||||
%c_10 = const.u64 2
|
||||
br @endmatch_12(%c_10)
|
||||
case_out_of_memory_9:
|
||||
%c_11 = const.u64 3
|
||||
br @endmatch_12(%c_11)
|
||||
endmatch_12(%match_13: u64):
|
||||
br @endmatch_14(%match_13)
|
||||
endmatch_14(%match_15: u64):
|
||||
ret %match_15
|
||||
Reference in new issue
Block a user