Merge pull request #775 from powdr-labs/remove_degree

Remove degree as property of symbol.
This commit is contained in:
Lucas Clemente Vella
2023-11-17 15:45:17 +00:00
committed by GitHub
5 changed files with 8 additions and 14 deletions

View File

@@ -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();
@@ -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 {
@@ -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 {
@@ -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} = {}{}({});",

View File

@@ -301,7 +301,6 @@ pub struct Symbol {
pub source: SourceRef,
pub absolute_name: String,
pub kind: SymbolKind,
pub degree: DegreeType,
pub length: Option<DegreeType>,
}

View File

@@ -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),
@@ -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),

View File

@@ -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);
}
}

View File

@@ -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,
};