-
Notifications
You must be signed in to change notification settings - Fork 7
feat(ops): abstract op groups with TOML-driven concrete instances #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jellllly420
wants to merge
32
commits into
RPL-Toolchain:master
Choose a base branch
from
jellllly420:feature/abstract-ops
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c30a32c
feat(parser): add ops block grammar rules
jellllly420 2bf6646
refactor(parser): address code review on ops grammar (rename, layout,…
jellllly420 53b8906
feat(parser): add OpRef rule for $group::$op call targets
jellllly420 d4118a9
fix(context, meta): update MirFnOperand match sites for OpRef arm
jellllly420 f5b9526
feat(context): add OpsBlock, OpGroup, OpSignature AST types
jellllly420 21ee842
refactor(context): use derive_more::Debug for ops AST consistency
jellllly420 30c9dfd
feat(context): add Operand::OpRef variant + parser lowering
jellllly420 6c02f25
fix(context): strip $ in Operand::OpRef lowering for resolver lookup
jellllly420 b34487d
feat(context): lower ops block into Pattern.ops_block
jellllly420 7e6e2a2
fix(context): align OpsMetaLookup indices and clarify R1 preconditions
jellllly420 e5ad9d6
feat(resolve): well-formedness checks R1-R3 for ops blocks
jellllly420 7a7a9f6
feat(resolve): op-ref resolution R4-R6 + groups_used
jellllly420 c8fd07f
feat(config): RawOpInstance + RplConfig.ops field
jellllly420 4868b39
feat(context): substitution + validation for op instances
jellllly420 a3109a4
feat(driver): thread OpsConfig through the matcher pipeline
jellllly420 0f5d054
feat(driver): cartesian-product iteration over op instances
jellllly420 6f2f959
feat(match): resolve OpRef and op-typed params via bindings
jellllly420 25358cf
test(ops): add lock_unlock end-to-end UI test
jellllly420 998e2f5
test(ops): folding, partial-bad, set-op composition, two-groups
jellllly420 00c599c
test(ops): CVE-2025-68260 POC — abstract intrusive-list-under-lock pa…
jellllly420 82fb981
style(ops): apply cargo fmt across new abstract-ops code
jellllly420 af1c727
fix(context): replace UB `&PatternItem` -> `*mut` cast with OnceCell
jellllly420 0825e48
refactor(context): use FxHashMap for deterministic ops ordering; drop…
jellllly420 82e63b0
test(ops): align black_box paths, uniform -Zinline-mir, drop broken s…
jellllly420 eab7bfc
fix(ops): silence clippy lints (collapsible_match, needless_borrow, u…
jellllly420 4fe893a
style(ops): re-fmt after if-let collapse (rustfmt was missed before p…
jellllly420 687638b
fix(config): treat empty resolved pattern paths as no-RPL_PATS
jellllly420 20d9fa4
fix(driver): respect outer pat_op bindings in nested RustItems cartesian
jellllly420 a131d92
fix(context): wire R6 (ops meta-vars must not leak into patt bodies)
jellllly420 afbf30d
refactor(rpl.toml): adopt design-intended $T::method op-binding syntax
jellllly420 62effef
revert(toolchain): drop rust-analyzer component (not needed for CI)
jellllly420 2f10724
refactor(tests): share static arena + mctx helpers across ops integra…
jellllly420 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| use std::collections::BTreeMap; | ||
|
|
||
| use serde::Deserialize; | ||
|
|
||
| /// One instance of an op-group as declared in `rpl.toml`. | ||
| /// | ||
| /// All values are stored as raw strings; substitution happens later in `rpl_context`. | ||
| #[derive(Debug, Clone)] | ||
| pub struct RawOpInstance { | ||
| /// Existential type-placeholder names declared via `type = [...]`. | ||
| pub free: Vec<String>, | ||
| /// Every other key/value pair (op-level meta-var bindings + op-name bindings). | ||
| pub bindings: BTreeMap<String, String>, | ||
| } | ||
|
|
||
| impl<'de> Deserialize<'de> for RawOpInstance { | ||
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
| where | ||
| D: serde::Deserializer<'de>, | ||
| { | ||
| let mut raw: BTreeMap<String, toml::Value> = BTreeMap::deserialize(deserializer)?; | ||
|
|
||
| let free = match raw.remove("type") { | ||
| None => Vec::new(), | ||
| Some(toml::Value::Array(arr)) => arr | ||
| .into_iter() | ||
| .map(|v| match v { | ||
| toml::Value::String(s) => Ok(s), | ||
| other => Err(serde::de::Error::custom(format!( | ||
| "ops 'type' entries must be strings, got {other:?}" | ||
| ))), | ||
| }) | ||
| .collect::<Result<Vec<_>, D::Error>>()?, | ||
| Some(other) => { | ||
| return Err(serde::de::Error::custom(format!( | ||
| "ops 'type' must be an array of strings, got {other:?}" | ||
| ))); | ||
| }, | ||
| }; | ||
|
|
||
| let mut bindings = BTreeMap::new(); | ||
| for (k, v) in raw { | ||
| match v { | ||
| toml::Value::String(s) => { | ||
| bindings.insert(k, s); | ||
| }, | ||
| other => { | ||
| return Err(serde::de::Error::custom(format!( | ||
| "ops binding '{k}' must be a string, got {other:?}" | ||
| ))); | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| Ok(RawOpInstance { free, bindings }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| use rpl_config::{RawOpInstance, RplConfig}; | ||
|
|
||
| const TOML: &str = r#" | ||
| [[patterns.local]] | ||
| name = "g" | ||
| path = ["patterns/foo.rpl"] | ||
|
|
||
| [[ops.sync]] | ||
| type = ["$1"] | ||
| T = "std::sync::Mutex<$1>" | ||
| U = "std::sync::MutexGuard<$1>" | ||
| lock = "$T::lock" | ||
| unlock = "$U::drop" | ||
|
|
||
| [[ops.sync]] | ||
| type = ["$1"] | ||
| T = "parking_lot::Mutex<$1>" | ||
| U = "parking_lot::MutexGuard<$1>" | ||
| lock = "$T::lock" | ||
| unlock = "$U::drop" | ||
| "#; | ||
|
|
||
| #[test] | ||
| fn loads_two_sync_instances() { | ||
| let cfg: RplConfig = toml::from_str(TOML).expect("parse"); | ||
| let sync_instances = cfg.ops.get("sync").expect("sync key present"); | ||
| assert_eq!(sync_instances.len(), 2); | ||
| let i0: &RawOpInstance = &sync_instances[0]; | ||
| assert_eq!(i0.free, vec!["$1".to_string()]); | ||
| assert_eq!(i0.bindings.get("T").unwrap(), "std::sync::Mutex<$1>"); | ||
| assert_eq!(i0.bindings.get("lock").unwrap(), "$T::lock"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn type_key_is_not_in_bindings() { | ||
| let cfg: RplConfig = toml::from_str(TOML).expect("parse"); | ||
| let i0 = &cfg.ops["sync"][0]; | ||
| assert!(!i0.bindings.contains_key("type")); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.