feat(rfc-cm): baseline P0-P3 compute machine, stdlib and resource slices
Implements the first vertical slices of RFC-CM-0001/0002 on top of a113d89:
- P1: opaque Memory regions (64 KiB pages, budgets, grow-only), byte
read/write, Memory-index place assignment, wire/host-boundary rejection.
- CM-A04/A05: value-semantics List/Map/Text/Table primitives and the
recoverable Result map convention.
- CM-A06: opaque Resource handles, resource.open/read/write/close, stdout
write, granted project-file read and buffered write, strict fail-closed.
- CM-A07 Compat-A: explicit .mq.md format/utf8/io chain matching builtin
print for the covered value types; builtin remains default.
- P2 fixtures: allocators, list/tree/graph/hash, integer codecs, UTF-8
encode/decode, CSV/JSON subsets, table filter/sort/join, bytecode VM.
- ADRs 0022-0027, spec updates, evidence reports and 68 semantic goldens.
Gate: cargo fmt --check, clippy -D warnings, 407 tests passed.
This commit is contained in:
1 parent
a113d89496
commit
92bfbf2568
127 files changed
+11351
-141
No files matched your search
@@ -17,7 +17,7 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use marqdo_expression::{Arg, Expr, Ident, RecordEntry};
|
||||
use marqdo_ir::{BranchArm, Stmt};
|
||||
use marqdo_ir::{BranchArm, PlaceTarget, Stmt};
|
||||
use marqdo_span::Span;
|
||||
use marqdo_value::{codes, Diagnostic};
|
||||
|
||||
@@ -178,9 +178,24 @@ impl<'a> Analyzer<'a> {
|
||||
fn analyze_stmts(&mut self, stmts: &[Stmt], mut state: State) -> State {
|
||||
for stmt in stmts {
|
||||
state = match stmt {
|
||||
Stmt::Assign { name, value, .. } => {
|
||||
self.read_expr(value, &state);
|
||||
self.assign(name, &mut state);
|
||||
Stmt::Assign { target, value, .. } => {
|
||||
match target {
|
||||
PlaceTarget::Local { name, .. } => {
|
||||
// Preserve v1 order: the RHS is read before the
|
||||
// local rebinding makes the name definitely
|
||||
// assigned.
|
||||
self.read_expr(value, &state);
|
||||
self.assign(name, &mut state);
|
||||
}
|
||||
PlaceTarget::Index { base, index, .. } => {
|
||||
// Runtime order for an index place is base, index,
|
||||
// RHS; reads in the place are free reads like any
|
||||
// other.
|
||||
self.read_expr(base, &state);
|
||||
self.read_expr(index, &state);
|
||||
self.read_expr(value, &state);
|
||||
}
|
||||
}
|
||||
state
|
||||
}
|
||||
Stmt::Eval { expr, .. } => {
|
||||
@@ -312,8 +327,10 @@ mod tests {
|
||||
|
||||
fn assign(name: &str, value: &str) -> Stmt {
|
||||
Stmt::Assign {
|
||||
name: name.to_string(),
|
||||
name_span: Span::new(0, 0),
|
||||
target: PlaceTarget::Local {
|
||||
name: name.to_string(),
|
||||
name_span: Span::new(0, 0),
|
||||
},
|
||||
value: parse_expression(value).unwrap(),
|
||||
span: Span::new(0, 0),
|
||||
}
|
||||
@@ -334,6 +351,24 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_assignment_reads_its_base_and_index_without_binding_a_local() {
|
||||
let stmts = vec![
|
||||
Stmt::Assign {
|
||||
target: PlaceTarget::Index {
|
||||
base: parse_expression("m").unwrap(),
|
||||
index: parse_expression("i").unwrap(),
|
||||
span: Span::new(0, 0),
|
||||
},
|
||||
value: parse_expression("9").unwrap(),
|
||||
span: Span::new(0, 0),
|
||||
},
|
||||
ret("m[0]"),
|
||||
];
|
||||
// `m` and `i` are free reads; the place never rebinds `m` as a local.
|
||||
assert_eq!(params(&stmts), vec!["i".to_string(), "m".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infers_free_reads() {
|
||||
// n * 阶乘(n=n-1)
|
||||
|
||||
Reference in new issue
Block a user