Skip to content

Commit 177d985

Browse files
committed
Regions
1 parent 5df6c4e commit 177d985

File tree

37 files changed

+10230
-9201
lines changed

37 files changed

+10230
-9201
lines changed

Cargo.lock

Lines changed: 32 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rslint_cli/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ fn run_inner(
7171

7272
let mut formatter = formatter.unwrap_or_else(|| config.formatter());
7373

74-
let store = config.rules_store();
74+
let mut store = config.rules_store();
75+
store.load_rules(rslint_core::groups::ddlog());
7576
verify_formatter(&mut formatter);
7677

7778
if walker.files.is_empty() {
@@ -454,7 +455,7 @@ fn start_ddlog_daemon(number_files: usize) -> DaemonOutput {
454455

455456
let (sender, receiver) = mpsc::channel();
456457
let (finished_sender, finished_receiver) = mpsc::channel();
457-
let analyzer = ScopeAnalyzer::new(3).unwrap();
458+
let analyzer = ScopeAnalyzer::new(2).unwrap();
458459

459460
let handle = {
460461
let analyzer = analyzer.clone();

crates/rslint_scope/ddlog/name_in_scope.dl

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import utils
44
import group
55
import inputs
66
import scopes
7+
import config
78
import var_decls
89

9-
/// The origin of a name
10-
// TODO: More variants
11-
typedef NameOrigin =
12-
/// The name came from an implicit global variable
13-
AutoGlobal
14-
/// The name was imported
15-
| Imported
16-
/// The name was defined in the given scope
17-
| UserDefined { scope: ScopeId }
10+
relation NeedsSymbolResolution(file: FileId)
11+
NeedsSymbolResolution(file) :- EnableNoTypeofUndef(file, _).
12+
NeedsSymbolResolution(file) :- EnableNoUndef(file, _).
13+
NeedsSymbolResolution(file) :- EnableNoUseBeforeDef(file, _).
14+
NeedsSymbolResolution(file) :- EnableNoUnusedVars(file, _).
15+
1816

1917
// TODO: Reduce the size of this since there are so many copies of it
2018
typedef NameInScope = NameInScope {
@@ -57,7 +55,9 @@ index Index_VariableInScope(scope: ScopeId, variable: Name)
5755

5856
// Introduce all declared variables where they're used
5957
NameInScope(name, variable_scope, declared) :-
58+
NeedsSymbolResolution(file),
6059
VariableDeclarations(name, scope, declared, _),
60+
declared.file() == Some { file },
6161
var variable_scope = scope.hoisted_scope(),
6262
NameOccursInScope(variable_scope, name).
6363

@@ -69,30 +69,36 @@ NameInScope(name, child, declared) :-
6969
NameInScope(name, parent, declared).
7070

7171

72+
/// The scopes that variable declarations occur in
7273
relation ScopeOfDeclName(name: Name, scope: ScopeId, declared: AnyId)
7374
ScopeOfDeclName(name, scope, declared) :-
74-
VariableDeclarations(name, Unhoistable { scope }, declared, _).
75+
NeedsSymbolResolution(file),
76+
VariableDeclarations(name, Unhoistable { scope @ ScopeId { _, file }}, declared, _).
7577
ScopeOfDeclName(name, scope, declared) :-
76-
VariableDeclarations(name, Hoistable { scope, _ }, declared, _).
78+
NeedsSymbolResolution(file),
79+
VariableDeclarations(name, Hoistable { scope @ ScopeId { _, file }, _ }, declared, _).
7780

7881

7982
/// A record of where variable usages actually happen
8083
relation NameOccursInScope(scope: ScopeId, name: Name)
8184

8285
/// Add all name references
8386
NameOccursInScope(scope, name) :-
84-
NameRef(id, name),
87+
NeedsSymbolResolution(file),
88+
NameRef(id @ ExprId { _, file }, name),
8589
Expression(id, _, scope, _),.
8690

8791
/// Add assignment patterns
8892
NameOccursInScope(scope, name) :-
89-
Assign(id, Some { Left { pattern }}, _, _),
93+
NeedsSymbolResolution(file),
94+
Assign(id @ ExprId { _, file }, Some { Left { pattern }}, _, _),
9095
Expression(id, _, scope, _),
9196
var name = FlatMap(pattern.bound_vars().map(|name| name.data)).
9297

9398
/// Add exports
9499
NameOccursInScope(scope, name) :-
95-
FileExport(NamedExport { export_name, export_alias }, scope),
100+
NeedsSymbolResolution(file),
101+
FileExport(NamedExport { export_name, export_alias }, scope @ ScopeId { _, file }),
96102
Some { Spanned { var name, _ }} = export_alias.or_else(export_name).
97103

98104
/// Recurse to parent scopes

crates/rslint_scope/generated/differential_datalog/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ c_api = []
1313
[dependencies]
1414
#differential-dataflow = "0.11.0"
1515
differential-dataflow = { git = "https://github.com/ddlog-dev/differential-dataflow", branch = "ddlog-2" }
16+
dogsdogsdogs = { git = "https://github.com/ddlog-dev/differential-dataflow", branch = "ddlog-2" }
1617
#timely = "0.11"
1718
timely = { git = "https://github.com/ddlog-dev/timely-dataflow", branch = "ddlog-2" }
1819

@@ -28,7 +29,7 @@ erased-serde = "0.3"
2829
crossbeam-channel = "0.5.0"
2930

3031
[dev-dependencies]
31-
byteorder = "0.4.2"
32-
getopts = "0.2.14"
33-
itertools = "^0.6"
34-
serde_derive = "1.0"
32+
byteorder = "1.4.2"
33+
getopts = "0.2.21"
34+
itertools = "0.10.0"
35+
serde_derive = "1.0.119"

crates/rslint_scope/generated/differential_datalog/src/program/arrange.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use differential_dataflow::{
88
difference::{Diff, Monoid},
99
hashable::Hashable,
1010
lattice::Lattice,
11-
operators::{
12-
arrange::arrangement::{ArrangeBySelf, Arranged},
13-
Consolidate, JoinCore, Reduce,
14-
},
11+
operators::{arrange::arrangement::Arranged, Consolidate, JoinCore, Reduce},
1512
trace::{BatchReader, Cursor, TraceReader},
1613
Collection, Data, ExchangeData,
1714
};
@@ -28,9 +25,11 @@ pub(super) enum ArrangedCollection<S, T1, T2>
2825
where
2926
S: Scope,
3027
S::Timestamp: Lattice + Ord,
28+
3129
T1: TraceReader<Key = DDValue, Val = DDValue, Time = S::Timestamp, R = Weight> + Clone,
3230
T1::Batch: BatchReader<DDValue, DDValue, S::Timestamp, Weight>,
3331
T1::Cursor: Cursor<DDValue, DDValue, S::Timestamp, Weight>,
32+
3433
T2: TraceReader<Key = DDValue, Val = (), Time = S::Timestamp, R = Weight> + Clone,
3534
T2::Batch: BatchReader<DDValue, (), S::Timestamp, Weight>,
3635
T2::Cursor: Cursor<DDValue, (), S::Timestamp, Weight>,
@@ -183,7 +182,7 @@ where
183182
// For each value with weight w != 1, compute an adjustment record with the same value and
184183
// weight (1-w)
185184
&collection
186-
.arrange_by_self()
185+
.map(|x| (x, ()))
187186
.reduce(|_, src, dst| {
188187
// If the input weight is 1, don't produce a surplus record.
189188
if !src[0].1.is_one() {

0 commit comments

Comments
 (0)