Skip to content

Commit

Permalink
solving bug: error when processing sizes of arrays of variables in fu…
Browse files Browse the repository at this point in the history
…nctions, panic in merger when processing complex expressions
  • Loading branch information
clararod9 committed Nov 28, 2023
1 parent 326981a commit def74e8
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion constraint_generation/src/compute_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ fn treat_statement(stmt: &mut Statement, context: &Context, reports: &mut Report
treat_while(stmt, context, reports, flags, prime)
} else if stmt.is_declaration(){
treat_declaration(stmt, context, reports, flags, prime)
} else {
} else if stmt.is_substitution(){
treat_substitution(stmt, context, reports, flags, prime)
} else{

}
}

Expand All @@ -98,6 +101,9 @@ fn treat_init_block(stmt: &mut Statement, context: &Context, reports: &mut Repor
if init.is_declaration() {
treat_declaration(init, context, reports, flags, prime)
}
if init.is_substitution(){
treat_substitution(init, context, reports, flags, prime)
}
}
} else {
unreachable!()
Expand Down Expand Up @@ -162,6 +168,33 @@ fn treat_declaration(stmt: &mut Statement, context: &Context, reports: &mut Repo
}
}

fn treat_substitution(stmt: &mut Statement, context: &Context, reports: &mut ReportCollection, flags: FlagsExecution, prime: &String) {
use Statement::Substitution;

if let Substitution{rhe, ..} = stmt{
treat_expression(rhe, context, reports, flags, prime);
} else{
unreachable!()
}

}

fn treat_expression(
expr: &mut Expression, context: &Context, reports: &mut ReportCollection, flags: FlagsExecution, prime: &String
){
use Expression::{Number, UniformArray};
if let UniformArray {meta, value, dimension} = expr{
let execution_response = treat_dimension(&dimension, context, reports, flags, prime);
if let Option::Some(v) = execution_response {
**dimension = Number(meta.clone(), BigInt::from(v));
} else {
report_invalid_dimension(meta, reports);
}
treat_expression(value, context, reports, flags, prime)
} else{
}
}

fn treat_dimension(
dim: &Expression,
context: &Context,
Expand Down

0 comments on commit def74e8

Please sign in to comment.