From de1e45886bf248bdc7ad98ac947e8643dfd1d958 Mon Sep 17 00:00:00 2001 From: Alex Kuzmin Date: Thu, 22 Aug 2024 17:27:26 +0800 Subject: [PATCH 1/2] Expose debug symbol start and end for the language server --- Cargo.toml | 10 +++++----- src/parser/ast/mod.rs | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6371a68e..55b1e9f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,18 +8,18 @@ authors = ["Leo Lara "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [patch.crates-io] -halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "da4983e" } +halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "bc857a7" } [patch."https://github.com/scroll-tech/halo2.git"] -halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "da4983e" } +halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, rev = "bc857a7" } [dependencies] pyo3 = { version = "0.19.1", features = ["extension-module"] } -halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, features = [ "circuit-params", "derive_serde"], rev = "da4983e"} +halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", default-features = false, features = [ "circuit-params", "derive_serde"], rev = "bc857a7"} -halo2_middleware = { git = "https://github.com/privacy-scaling-explorations/halo2.git", rev = "da4983e" } -halo2_backend = { git = "https://github.com/privacy-scaling-explorations/halo2.git", features = ["derive_serde"], rev = "da4983e" } +halo2_middleware = { git = "https://github.com/privacy-scaling-explorations/halo2.git", rev = "bc857a7" } +halo2_backend = { git = "https://github.com/privacy-scaling-explorations/halo2.git", features = ["derive_serde"], rev = "bc857a7" } num-bigint = { version = "0.4", features = ["rand"] } uuid = { version = "1.4.0", features = ["v1", "rng"] } diff --git a/src/parser/ast/mod.rs b/src/parser/ast/mod.rs index c64e2665..1a1ec198 100644 --- a/src/parser/ast/mod.rs +++ b/src/parser/ast/mod.rs @@ -141,6 +141,22 @@ impl PartialEq for DebugSymRef { } } +/// Interface of the debug symbol reference to use with the Chiquito language server +pub trait LanguageServerInterface { + fn get_start(&self) -> usize; + fn get_end(&self) -> usize; +} + +impl LanguageServerInterface for DebugSymRef { + fn get_start(&self) -> usize { + self.start + } + + fn get_end(&self) -> usize { + self.end + } +} + #[derive(Clone, PartialEq, Eq)] pub struct Identifier( /// Name @@ -227,7 +243,20 @@ mod test { use codespan_reporting::files::SimpleFile; - use crate::parser::ast::{DebugSymRef, Identifier}; + use crate::parser::ast::{DebugSymRef, Identifier, LanguageServerInterface}; + + #[test] + fn test_language_server_interface() { + let debug_sym_ref = DebugSymRef { + start: 0, + end: 1, + file: Arc::new(SimpleFile::new("file_path".to_string(), "".to_string())), + virt: false, + }; + + assert_eq!(debug_sym_ref.get_start(), 0); + assert_eq!(debug_sym_ref.get_end(), 1); + } #[test] fn test_from_string() { From 04e6cbfa35a72982bc200fe0ec1ee3359f5b07d9 Mon Sep 17 00:00:00 2001 From: Alex Kuzmin Date: Tue, 27 Aug 2024 16:58:13 +0800 Subject: [PATCH 2/2] Improve trait naming --- src/parser/ast/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/parser/ast/mod.rs b/src/parser/ast/mod.rs index 1a1ec198..a65c683b 100644 --- a/src/parser/ast/mod.rs +++ b/src/parser/ast/mod.rs @@ -142,12 +142,14 @@ impl PartialEq for DebugSymRef { } /// Interface of the debug symbol reference to use with the Chiquito language server -pub trait LanguageServerInterface { +pub trait Spanned { + /// Get span start fn get_start(&self) -> usize; + /// Get span end fn get_end(&self) -> usize; } -impl LanguageServerInterface for DebugSymRef { +impl Spanned for DebugSymRef { fn get_start(&self) -> usize { self.start } @@ -243,7 +245,7 @@ mod test { use codespan_reporting::files::SimpleFile; - use crate::parser::ast::{DebugSymRef, Identifier, LanguageServerInterface}; + use crate::parser::ast::{DebugSymRef, Identifier, Spanned}; #[test] fn test_language_server_interface() {