From 98051b970ce1862cb6bd9759416012dd47da5f4f Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 15 Nov 2024 15:41:10 +0100 Subject: [PATCH 1/3] more documentation on Roto types --- src/runtime/mod.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index f37c12f2..8c6970ac 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -554,7 +554,19 @@ impl Runtime { rt.register_copy_type::(int_docs!(i16))?; rt.register_copy_type::(int_docs!(i32))?; rt.register_copy_type::(int_docs!(i64))?; - rt.register_copy_type::("An ASN: an Autonomous System Number")?; + rt.register_copy_type::( + "An ASN: an Autonomous System Number\n\ + \n\ + An AS number can contain a number of 32-bits and is therefore similar to a [`u32`](u32). \ + However, AS numbers cannot be manipulated with arithmetic operations. An AS number \ + is constructed with the `AS` prefix followed by a number.\n\ + \n\ + ```roto\n\ + AS0\n\ + AS1010\n\ + AS4294967295\n\ + ```\n\ + ")?; rt.register_copy_type::( "An IP address\n\nCan be either IPv4 or IPv6.\n\ \n\ @@ -572,9 +584,10 @@ impl Runtime { ", )?; rt.register_copy_type::( - "An IP address prefix: an IP address and a prefix length\n\n\ + "An IP address prefix: the combination of an IP address and a prefix length\n\n\ A prefix can be constructed with the `/` operator or with the \ - `Prefix.new` function.\n\ + [`Prefix.new`](Prefix.new) function. This operator takes an [`IpAddr`](IpAddr) \ + and a [`u8`](u8) as operands.\n \n\ ```roto\n\ 1.1.1.0 / 8\n\ @@ -585,10 +598,13 @@ impl Runtime { /// Construct a new prefix /// - /// A prefix can also be constructed with a prefix literal. + /// A prefix can also be constructed with the `/` operator. /// /// ```roto - /// Prefix.new(192.169.0.0) + /// Prefix.new(192.169.0.0, 16) + /// + /// # or equivalently + /// 192.169.0.0 / 16 /// ``` #[roto_static_method(rt, Prefix, new)] fn prefix_new(ip: *mut IpAddr, len: u8) -> Prefix { From 671096da6b5eddb40d59bbab695bae227a06c898 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 15 Nov 2024 15:41:24 +0100 Subject: [PATCH 2/3] fix clippy lint --- src/codegen/mod.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index b4da46bd..f4fe5cd8 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -778,20 +778,17 @@ impl<'c> FuncGen<'c> { let (dest, _) = self.operand(to); let (src, _) = self.operand(from); - match clone { - Some(clone) => { - let pointer_ty = self.module.isa.pointer_type(); - let clone = self.ins().iconst( - pointer_ty, - *clone as *mut u8 as usize as i64, - ); - self.builder.ins().call_indirect( - self.clone_signature, - clone, - &[src, dest], - ); - } - None => {} + if let Some(clone) = clone { + let pointer_ty = self.module.isa.pointer_type(); + let clone = self.ins().iconst( + pointer_ty, + *clone as *mut u8 as usize as i64, + ); + self.builder.ins().call_indirect( + self.clone_signature, + clone, + &[src, dest], + ); } self.builder.emit_small_memory_copy( self.module.isa.frontend_config(), From 3ff25c1d60b954185a5f38ecac7847576bcae320 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 15 Nov 2024 15:47:32 +0100 Subject: [PATCH 3/3] update ariadne --- Cargo.toml | 2 +- src/pipeline.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8f41dcca..03d24f36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ categories = ["network-programming"] # ariadne is set to git because of some unpublished contributions made on # Aug 5 2024. It should revert to crates.io when a version later than 4.1.0 # is released -ariadne = { version = "0.4.0", git = "https://github.com/zesterer/ariadne.git", rev = "4e5987cd55d954858da4a4130255eca1bf0bee5f" } +ariadne = "0.5.0" clap = { version = "4.4.6", features = ["derive"] } env_logger = "0.10" log = "0.4" diff --git a/src/pipeline.rs b/src/pipeline.rs index 486dacaf..6d895bc9 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -133,8 +133,7 @@ impl std::fmt::Display for RotoReport { let report = Report::build( ReportKind::Error, - file, - error.location.start, + (file, error.location.start..error.location.end), ) .with_message(format!("Parse error: {}", error)) .with_label(label) @@ -158,10 +157,10 @@ impl std::fmt::Display for RotoReport { let file = self.filename(self.spans.get(error.location)); + let span = self.spans.get(error.location); let report = Report::build( ReportKind::Error, - file, - self.spans.get(error.location).start, + (file, span.start..span.end), ) .with_message(format!( "Type error: {}",