Skip to content

Commit a33c770

Browse files
committed
Add Label class
1 parent e14b626 commit a33c770

17 files changed

Lines changed: 181 additions & 30 deletions

File tree

rust/.generated.list

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

rust/.gitattributes

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

rust/extractor/src/generated/top.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ impl TrapEntry for DbLocation {
4141
}
4242
}
4343

44+
#[derive(Debug)]
45+
pub struct Label {
46+
pub id: TrapId,
47+
pub location: Option<trap::Label>,
48+
pub name: String,
49+
}
50+
51+
impl TrapEntry for Label {
52+
fn extract_id(&mut self) -> TrapId {
53+
std::mem::replace(&mut self.id, TrapId::Star)
54+
}
55+
56+
fn emit(self, id: trap::Label, out: &mut trap::Writer) {
57+
out.add_tuple("labels", vec![trap::Arg::Label(id), self.name.into()]);
58+
if let Some(v) = self.location {
59+
out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]);
60+
}
61+
}
62+
}
63+
4464
#[derive(Debug)]
4565
pub struct MatchArm {
4666
pub id: TrapId,
@@ -238,7 +258,7 @@ pub struct Break {
238258
pub id: TrapId,
239259
pub location: Option<trap::Label>,
240260
pub expr: Option<trap::Label>,
241-
pub label: Option<String>,
261+
pub label: Option<trap::Label>,
242262
}
243263

244264
impl TrapEntry for Break {
@@ -388,7 +408,7 @@ impl TrapEntry for ConstBlockPat {
388408
pub struct Continue {
389409
pub id: TrapId,
390410
pub location: Option<trap::Label>,
391-
pub label: Option<String>,
411+
pub label: Option<trap::Label>,
392412
}
393413

394414
impl TrapEntry for Continue {
@@ -658,7 +678,7 @@ pub struct Loop {
658678
pub id: TrapId,
659679
pub location: Option<trap::Label>,
660680
pub body: trap::Label,
661-
pub label: Option<String>,
681+
pub label: Option<trap::Label>,
662682
}
663683

664684
impl TrapEntry for Loop {
@@ -1272,7 +1292,7 @@ pub struct Block {
12721292
pub location: Option<trap::Label>,
12731293
pub statements: Vec<trap::Label>,
12741294
pub tail: Option<trap::Label>,
1275-
pub label: Option<String>,
1295+
pub label: Option<trap::Label>,
12761296
}
12771297

12781298
impl TrapEntry for Block {

rust/ql/lib/codeql/rust/elements.qll

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/Label.qll

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

rust/ql/lib/codeql/rust/elements/LabelConstructor.qll

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

rust/ql/lib/codeql/rust/generated/Block.qll

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/generated/Break.qll

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/generated/Continue.qll

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/generated/Label.qll

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

0 commit comments

Comments
 (0)