spec: accept RFC 0005 and integrate Phase 1 memory model (P1-1, P1-2)

- RFC 0005 Accepted (revision 2)
- spec 07 §8.8 types and syntax; spec 07a contracts for features
  ownership and arrays; spec 08 §11-§14 borrows, facts, initialization,
  stage order; spec 03 frame storage, second-class borrows, static
  region generations
- grammar: from-returns, multi-result, new types and opcodes
- feature registry: ownership and arrays published; heap added and
  regions moved to Phase 2; borrow_joins reserved and unscheduled
- codes E2105-E2108, T0008
- Q-009, Q-010 resolved; Phase 1 and Phase 2 plans updated; Own test
  moved to phase 2
This commit is contained in:
dev committed 2026-10-04 13:10:08 +03:00
1 parent 2c84c0c7cf
commit 48bb50724f
15 files changed
+269 -55

No files matched your search

+31 -3
View File
@@ -35,7 +35,7 @@ field = ident ":" type ;
enum_type = "enum" "{" variant { "," variant } [ "," ] "}" ;
variant = ident [ "(" [ type { "," type } ] ")" ] ;
function = "fn" global "(" [ param_list ] ")" "->" type NL
function = "fn" global "(" [ param_list ] ")" "->" type [ "from" local ] NL (* from: feature ownership *)
"effects" "[" [ path_list ] "]" NL
block { block } ;
param_list = param { "," param } ;
@@ -44,7 +44,8 @@ param = local ":" type ;
block = ident [ "(" [ param_list ] ")" ] ":" NL { instruction NL } ;
(* The first block is the entry block and takes no parameters. *)
instruction = [ local "=" ] operation ;
instruction = [ local { "," local } "=" ] operation ;
(* More than one result only for instructions specified with several results (slice.split). *)
operation = "const." int_type int_lit
| "const.bool" ( "true" | "false" )
@@ -56,8 +57,32 @@ operation = "const." int_type int_lit
| "struct.get" global "." ident "," local
| "enum.make" global "." ident "(" [ local_list ] ")"
| "call" global "(" [ local_list ] ")"
| ownership_op
| arrays_op
| terminator ;
(* Feature ownership (spec 07a). *)
ownership_op = "local.alloc" type
| "local.store" local "," local
| "local.zero" local
| "local.load" local
| "borrow.ref" local
| "borrow.mut" local
| "borrow.field" global "." ident "," local
| "borrow.end" local
| "load" local
| "store" local "," local ;
(* Feature arrays (spec 07a). *)
arrays_op = "array.splat" type local
| ( "borrow.index" | "borrow.index.proven" ) local "," local
| "slice.make" local
| "slice.len" local
| "slice.sub" local "," local "," local
| "slice.split" local "," local
| "slice.copy" local "," local
| "guard" local ;
arith_op = ( "add" | "sub" | "mul" ) "." ( "checked" | "wrap" ) "." int_type
| ( "div" | "rem" ) ".checked." int_type
| ( "and" | "or" | "xor" ) "." ( int_type | "bool" )
@@ -76,7 +101,10 @@ terminator = "br" target
enum_arm = ident "->" global ; (* target block receives the variant payload as parameters *)
target = global "(" [ local_list ] ")" ;
type = int_type | "bool" | "void" | "never" | global ;
type = int_type | "bool" | "void" | "never" | global
| ( "local" | "ref" | "mut" ) "<" type ">" (* feature ownership *)
| "[" type ";" int_lit "]" (* feature arrays *)
| ( "slice" | "slice_mut" ) "<" type ">" ; (* feature arrays *)
int_type = "u8" | "u16" | "u32" | "u64" | "u128" | "usize"
| "i8" | "i16" | "i32" | "i64" | "i128" | "isize" ;
(* "f32" and "f64" are reserved; see spec 07 §8.4. "byte" is not an AIR type: frontends lower it to u8. *)