Skip to content

Commit e14b626

Browse files
committed
Add 'BlockBase' class
1 parent ce2fdb3 commit e14b626

16 files changed

Lines changed: 228 additions & 97 deletions

File tree

rust/.generated.list

Lines changed: 11 additions & 8 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: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,6 @@ pub struct AsyncBlock {
12451245
pub location: Option<trap::Label>,
12461246
pub statements: Vec<trap::Label>,
12471247
pub tail: Option<trap::Label>,
1248-
pub label: Option<String>,
12491248
}
12501249

12511250
impl TrapEntry for AsyncBlock {
@@ -1259,10 +1258,38 @@ impl TrapEntry for AsyncBlock {
12591258
out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]);
12601259
}
12611260
for (i, &v) in self.statements.iter().enumerate() {
1262-
out.add_tuple("block_statements", vec![trap::Arg::Label(id), i.into(), v.into()]);
1261+
out.add_tuple("block_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]);
1262+
}
1263+
if let Some(v) = self.tail {
1264+
out.add_tuple("block_base_tails", vec![trap::Arg::Label(id), v.into()]);
1265+
}
1266+
}
1267+
}
1268+
1269+
#[derive(Debug)]
1270+
pub struct Block {
1271+
pub id: TrapId,
1272+
pub location: Option<trap::Label>,
1273+
pub statements: Vec<trap::Label>,
1274+
pub tail: Option<trap::Label>,
1275+
pub label: Option<String>,
1276+
}
1277+
1278+
impl TrapEntry for Block {
1279+
fn extract_id(&mut self) -> TrapId {
1280+
std::mem::replace(&mut self.id, TrapId::Star)
1281+
}
1282+
1283+
fn emit(self, id: trap::Label, out: &mut trap::Writer) {
1284+
out.add_tuple("blocks", vec![trap::Arg::Label(id)]);
1285+
if let Some(v) = self.location {
1286+
out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]);
1287+
}
1288+
for (i, &v) in self.statements.iter().enumerate() {
1289+
out.add_tuple("block_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]);
12631290
}
12641291
if let Some(v) = self.tail {
1265-
out.add_tuple("block_tails", vec![trap::Arg::Label(id), v.into()]);
1292+
out.add_tuple("block_base_tails", vec![trap::Arg::Label(id), v.into()]);
12661293
}
12671294
if let Some(v) = self.label {
12681295
out.add_tuple("block_labels", vec![trap::Arg::Label(id), v.into()]);
@@ -1276,7 +1303,6 @@ pub struct UnsafeBlock {
12761303
pub location: Option<trap::Label>,
12771304
pub statements: Vec<trap::Label>,
12781305
pub tail: Option<trap::Label>,
1279-
pub label: Option<String>,
12801306
}
12811307

12821308
impl TrapEntry for UnsafeBlock {
@@ -1290,13 +1316,10 @@ impl TrapEntry for UnsafeBlock {
12901316
out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]);
12911317
}
12921318
for (i, &v) in self.statements.iter().enumerate() {
1293-
out.add_tuple("block_statements", vec![trap::Arg::Label(id), i.into(), v.into()]);
1319+
out.add_tuple("block_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]);
12941320
}
12951321
if let Some(v) = self.tail {
1296-
out.add_tuple("block_tails", vec![trap::Arg::Label(id), v.into()]);
1297-
}
1298-
if let Some(v) = self.label {
1299-
out.add_tuple("block_labels", vec![trap::Arg::Label(id), v.into()]);
1322+
out.add_tuple("block_base_tails", vec![trap::Arg::Label(id), v.into()]);
13001323
}
13011324
}
13021325
}

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/BlockBase.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/BlockConstructor.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/AsyncBlock.qll

Lines changed: 2 additions & 2 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: 3 additions & 32 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/BlockBase.qll

Lines changed: 55 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)