Skip to content

Commit

Permalink
Merge pull request #775 from powdr-labs/remove_degree
Browse files Browse the repository at this point in the history
Remove degree as property of symbol.
  • Loading branch information
lvella authored Nov 17, 2023
2 parents 4eb3be8 + 716b7ba commit aa3aedb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
10 changes: 5 additions & 5 deletions ast/src/analyzed/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use super::*;

impl<T: Display> Display for Analyzed<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
let degree = self.degree.unwrap_or_default();
let mut current_namespace = "Global".to_string();
let mut update_namespace = |name: &str, degree: DegreeType, f: &mut Formatter<'_>| {
let mut update_namespace = |name: &str, f: &mut Formatter<'_>| {
let new_name = if let Some(dot) = name.find('.') {
if name[..dot] != current_namespace {
current_namespace = name[..dot].to_string();
Expand All @@ -29,7 +30,7 @@ impl<T: Display> Display for Analyzed<T> {
match statement {
StatementIdentifier::Definition(name) => {
if let Some((symbol, definition)) = self.definitions.get(name) {
let (name, is_local) = update_namespace(name, symbol.degree, f)?;
let (name, is_local) = update_namespace(name, f)?;
match symbol.kind {
SymbolKind::Poly(poly_type) => {
let kind = match &poly_type {
Expand Down Expand Up @@ -64,7 +65,7 @@ impl<T: Display> Display for Analyzed<T> {
}
}
} else if let Some((symbol, definition)) = self.intermediate_columns.get(name) {
let (name, _) = update_namespace(name, symbol.degree, f)?;
let (name, _) = update_namespace(name, f)?;
assert_eq!(symbol.kind, SymbolKind::Poly(PolynomialType::Intermediate));
writeln!(f, " col {name} = {definition};")?;
} else {
Expand All @@ -73,8 +74,7 @@ impl<T: Display> Display for Analyzed<T> {
}
StatementIdentifier::PublicDeclaration(name) => {
let decl = &self.public_declarations[name];
// TODO we do not know the degree of the namespace here.
let (name, _) = update_namespace(&decl.name, 0, f)?;
let (name, _) = update_namespace(&decl.name, f)?;
writeln!(
f,
" public {name} = {}{}({});",
Expand Down
1 change: 0 additions & 1 deletion ast/src/analyzed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ pub struct Symbol {
pub source: SourceRef,
pub absolute_name: String,
pub kind: SymbolKind,
pub degree: DegreeType,
pub length: Option<DegreeType>,
}

Expand Down
4 changes: 2 additions & 2 deletions backend/src/pilstark/json_exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<'a, T: FieldElement> Exporter<'a, T> {
polType: None,
type_: symbol_kind_to_json_string(symbol.kind).to_string(),
id: id as usize,
polDeg: symbol.degree as usize,
polDeg: self.analyzed.degree() as usize,
isArray: symbol.is_array(),
elementType: None,
len: symbol.length.map(|l| l as usize),
Expand All @@ -219,7 +219,7 @@ impl<'a, T: FieldElement> Exporter<'a, T> {
polType: None,
type_: symbol_kind_to_json_string(symbol.kind).to_string(),
id: id as usize,
polDeg: symbol.degree as usize,
polDeg: self.analyzed.degree() as usize,
isArray: symbol.is_array(),
elementType: None,
len: symbol.length.map(|l| l as usize),
Expand Down
3 changes: 1 addition & 2 deletions executor/src/constant_evaluator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ pub fn generate<T: FieldElement>(analyzed: &Analyzed<T>) -> Vec<(&str, Vec<T>)>
let mut other_constants = HashMap::new();
for (poly, value) in analyzed.constant_polys_in_source_order() {
if let Some(value) = value {
assert!(analyzed.degree() == poly.degree);
let values = generate_values(analyzed, poly.degree, value, &other_constants);
let values = generate_values(analyzed, analyzed.degree(), value, &other_constants);
other_constants.insert(&poly.absolute_name, values);
}
}
Expand Down
4 changes: 0 additions & 4 deletions pil_analyzer/src/pil_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,6 @@ impl<T: FieldElement> PILAnalyzer<T> {
id,
source,
absolute_name,
degree: self.polynomial_degree.unwrap_or_else(|| {
assert!(matches!(symbol_kind, SymbolKind::Constant()));
0
}),
kind: symbol_kind,
length,
};
Expand Down

0 comments on commit aa3aedb

Please sign in to comment.