Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Expose debug symbol start and end for the language server (#289)
Browse files Browse the repository at this point in the history
We have accidentally made the start and end of debug symbol private, so
here's a fix for the language server. Also had to update the halo2 to
the latest version because the language server didn't want to compile
(there was a missing bound on a variable generic inside the halo2
middleware `Expression`, not sure why Chiquito itself compiled
successfully).
  • Loading branch information
alxkzmn authored Aug 27, 2024
1 parent 9c08b6d commit 50ec990
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ authors = ["Leo Lara <[email protected]>"]
# 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"] }
Expand Down
33 changes: 32 additions & 1 deletion src/parser/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ impl PartialEq for DebugSymRef {
}
}

/// Interface of the debug symbol reference to use with the Chiquito language server
pub trait Spanned {
/// Get span start
fn get_start(&self) -> usize;
/// Get span end
fn get_end(&self) -> usize;
}

impl Spanned for DebugSymRef {
fn get_start(&self) -> usize {
self.start
}

fn get_end(&self) -> usize {
self.end
}
}

#[derive(Clone, PartialEq, Eq)]
pub struct Identifier(
/// Name
Expand Down Expand Up @@ -227,7 +245,20 @@ mod test {

use codespan_reporting::files::SimpleFile;

use crate::parser::ast::{DebugSymRef, Identifier};
use crate::parser::ast::{DebugSymRef, Identifier, Spanned};

#[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() {
Expand Down

0 comments on commit 50ec990

Please sign in to comment.