Skip to content

Commit 7dc178d

Browse files
authored
Merge pull request #14 from metaborg/future-env-container
Future env container
2 parents 002f8e8 + 0968a32 commit 7dc178d

File tree

23 files changed

+1011
-352
lines changed

23 files changed

+1011
-352
lines changed

.github/workflows/rust.yml

+32-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,25 @@ jobs:
4141
with:
4242
command: fmt
4343
args: --all -- --check
44-
test:
44+
45+
test-nightly:
46+
name: Test Nightly
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Install nightly toolchain
51+
uses: actions-rs/toolchain@v1
52+
with:
53+
toolchain: nightly
54+
override: true
55+
56+
- name: Run cargo test
57+
uses: actions-rs/cargo@v1
58+
with:
59+
command: test
60+
args: --all-features
61+
62+
test-beta:
4563
name: Test Beta
4664
runs-on: ubuntu-latest
4765
steps:
@@ -58,15 +76,19 @@ jobs:
5876
command: test
5977
args: --all-features
6078

61-
test-miri:
62-
name: Test Miri
79+
test-stable:
80+
name: Test Stable
6381
runs-on: ubuntu-latest
6482
steps:
6583
- uses: actions/checkout@v3
66-
- name: Install Miri
67-
run: |
68-
rustup toolchain install nightly --component miri
69-
rustup override set nightly
70-
cargo miri setup
71-
- name: Test with Miri
72-
run: cargo miri test
84+
- name: Install stable toolchain
85+
uses: actions-rs/toolchain@v1
86+
with:
87+
toolchain: stable
88+
override: true
89+
90+
- name: Run cargo test
91+
uses: actions-rs/cargo@v1
92+
with:
93+
command: test
94+
args: --all-features

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel="beta"
2+
channel = "1.77.2"

scopegraphs-lib/Cargo.toml

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
[package]
22
name = "scopegraphs-lib"
3-
version = "0.1.0"
3+
version = "0.1.2"
44
edition = "2021"
5+
license = "MIT OR Apache-2.0"
6+
authors = [
7+
"Aron Zwaan <[email protected]>",
8+
"Jonathan Dönszelmann <[email protected]>"
9+
]
10+
description = "A port of [scopegraphs](https://pl.ewi.tudelft.nl/research/projects/scope-graphs/) to Rust"
11+
rust-version = "1.77"
12+
513

614
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15+
[features]
16+
default = []
17+
dot = ["dep:dot"]
718

819
[dependencies]
920
log = "0.4.20"
10-
prust-lib = {git="https://github.com/jdonszelmann/prust", branch = "main"}
21+
scopegraphs-prust-lib = { version = "0.1.0" }
1122
syn = { version = "2.0.29", features = ["full", "extra-traits"] }
12-
quote = { version = "1.0.33" , optional = true}
13-
scopegraphs-regular-expressions = {path = "../scopegraphs-regular-expressions"}
14-
scopegraphs-macros = {path = "../scopegraphs-macros"}
23+
quote = { version = "1.0.33", optional = true }
24+
scopegraphs-regular-expressions = { path = "../scopegraphs-regular-expressions", version = "0.1.0" }
25+
scopegraphs-macros = { path = "../scopegraphs-macros", version = "0.1.0" }
26+
futures = "0.3.30"
27+
bumpalo = "3.14.0"
28+
dot = { version = "0.1.4", optional = true }
1529

1630
[dev-dependencies]
17-
scopegraphs = {path = "../scopegraphs"}
31+
scopegraphs = { path = "../scopegraphs" }
1832
env_logger = "0.10.1"
1933
ctor = "0.2.5"

scopegraphs-lib/src/completeness/critical_edge.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use crate::{completeness::Completeness, Scope, ScopeGraph};
2+
use std::cell::RefCell;
23
use std::{collections::HashSet, hash::Hash};
34

5+
#[derive(Debug)]
46
pub(super) struct CriticalEdgeSet<LABEL> {
5-
open_edges: Vec<HashSet<LABEL>>,
7+
open_edges: RefCell<Vec<HashSet<LABEL>>>,
68
}
79

810
impl<LABEL> Default for CriticalEdgeSet<LABEL> {
@@ -14,18 +16,18 @@ impl<LABEL> Default for CriticalEdgeSet<LABEL> {
1416
}
1517

1618
impl<LABEL> CriticalEdgeSet<LABEL> {
17-
pub(super) fn init_scope(&mut self, edges: HashSet<LABEL>) {
18-
self.open_edges.push(edges)
19+
pub(super) fn init_scope(&self, edges: HashSet<LABEL>) {
20+
self.open_edges.borrow_mut().push(edges)
1921
}
2022
}
2123

2224
impl<LABEL: Hash + Eq> CriticalEdgeSet<LABEL> {
2325
pub fn is_open(&self, scope: Scope, lbl: &LABEL) -> bool {
24-
self.open_edges[scope.0].contains(lbl)
26+
self.open_edges.borrow()[scope.0].contains(lbl)
2527
}
2628

27-
pub(super) fn close(&mut self, scope: Scope, lbl: &LABEL) -> bool {
28-
self.open_edges[scope.0].remove(lbl)
29+
pub(super) fn close(&self, scope: Scope, lbl: &LABEL) -> bool {
30+
self.open_edges.borrow_mut()[scope.0].remove(lbl)
2931
}
3032
}
3133

@@ -35,7 +37,7 @@ impl<LABEL: Hash + Eq> CriticalEdgeSet<LABEL> {
3537
///
3638
/// Should not be called externally, but only from utility function on [`super::ScopeGraph`].
3739
pub trait CriticalEdgeBasedCompleteness<LABEL, DATA>: Completeness<LABEL, DATA> {
38-
fn init_scope_with(&mut self, open_edges: HashSet<LABEL>);
40+
fn init_scope_with(&self, open_edges: HashSet<LABEL>);
3941
}
4042

4143
/// Error returned when attempting to add an edge with a label that is already closed in that scope.
@@ -46,15 +48,15 @@ pub struct EdgeClosedError<LABEL> {
4648
}
4749

4850
/// Value returned when a query cannot yet be computed because some edge it depends on is still closed.
49-
#[derive(Debug, Copy, Clone)]
51+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
5052
pub struct Delay<LABEL> {
5153
pub scope: Scope,
5254
pub label: LABEL,
5355
}
5456

5557
pub(crate) type EdgesOrDelay<EDGES, LABEL> = Result<EDGES, Delay<LABEL>>;
5658

57-
impl<LABEL: Hash + Eq, DATA, CMPL> ScopeGraph<LABEL, DATA, CMPL>
59+
impl<'sg, LABEL: Hash + Eq, DATA, CMPL> ScopeGraph<'sg, LABEL, DATA, CMPL>
5860
where
5961
CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,
6062
{
@@ -65,22 +67,19 @@ where
6567
{
6668
let scope = self.inner_scope_graph.add_scope(data);
6769
self.completeness
68-
.borrow_mut()
69-
.init_scope_with(HashSet::from_iter(open_edges));
70+
.init_scope_with(open_edges.into_iter().collect());
7071
scope
7172
}
7273

7374
/// Adds a new scope with no open edges.
7475
pub fn add_scope_closed(&mut self, data: DATA) -> Scope {
7576
let scope = self.inner_scope_graph.add_scope(data);
76-
self.completeness
77-
.borrow_mut()
78-
.init_scope_with(HashSet::new());
77+
self.completeness.init_scope_with(HashSet::new());
7978
scope
8079
}
8180
}
8281

83-
impl<LABEL: Hash + Eq, DATA, CMPL> ScopeGraph<LABEL, DATA, CMPL>
82+
impl<'sg, LABEL: Hash + Eq, DATA, CMPL> ScopeGraph<'sg, LABEL, DATA, CMPL>
8483
where
8584
DATA: Default,
8685
CMPL: CriticalEdgeBasedCompleteness<LABEL, DATA>,

0 commit comments

Comments
 (0)