Skip to content

Commit

Permalink
index access is always evaluated
Browse files Browse the repository at this point in the history
  • Loading branch information
namnc committed Dec 20, 2023
1 parent ab960a7 commit ba14f56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn execute_statement(
execute_statement(ac, runtime, stmt, program_archive);
}
}
// TODO: THIS ACTUALLY WILL NOT HAPPEN IN EXECUTION
Statement::Declaration {
xtype,
name,
Expand All @@ -41,8 +42,8 @@ pub fn execute_statement(
let dim_u32_vec: Vec<u32> = dimensions
.iter()
.map(|dimension| {
let dim_u32_str =
traverse_expression(ac, runtime, name, dimension, program_archive);
let (dim_u32_str, dim_u32_bool) =
execute_expression(ac, runtime, name, dimension, program_archive);
dim_u32_str
.parse::<u32>()
.expect("Failed to parse dimension as u32")
Expand Down Expand Up @@ -78,8 +79,8 @@ pub fn execute_statement(
match a {
Access::ArrayAccess(expr) => {
debug!("Array access found");
let dim_u32_str =
traverse_expression(ac, runtime, var, expr, program_archive);
let (dim_u32_str, dim_u32_bool) =
execute_expression(ac, runtime, var, expr, program_archive);
name_access.push('_');
name_access.push_str(dim_u32_str.as_str());
debug!("Change var name to {}", name_access);
Expand Down Expand Up @@ -172,8 +173,8 @@ pub fn execute_expression(
match a {
Access::ArrayAccess(expr) => {
debug!("Array access found");
let dim_u32_str =
traverse_expression(ac, runtime, var, expr, program_archive);
let (dim_u32_str, dim_u32_bool) =
execute_expression(ac, runtime, var, expr, program_archive);
name_access.push('_');
name_access.push_str(dim_u32_str.as_str());
debug!("Changed var name to {}", name_access);
Expand Down
4 changes: 2 additions & 2 deletions src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub fn traverse_statement(
let dim_u32_vec: Vec<u32> = dimensions
.iter()
.map(|dimension| {
let dim_u32_str =
traverse_expression(ac, runtime, name, dimension, program_archive);
let (dim_u32_str, dim_u32_bool) =
execute_expression(ac, runtime, name, dimension, program_archive);
dim_u32_str
.parse::<u32>()
.expect("Failed to parse dimension")
Expand Down

0 comments on commit ba14f56

Please sign in to comment.