Use global module constants in optimization.

This commit is contained in:
Stephen Chung
2022-03-28 12:53:52 +08:00
parent 42b6796200
commit 95753bb9c3
2 changed files with 28 additions and 1 deletions

View File

@@ -1236,6 +1236,16 @@ fn optimize_top_level(
optimization_level,
);
// Add constants from global modules
for (name, value) in engine
.global_modules
.iter()
.rev()
.flat_map(|m| m.iter_var())
{
state.push_var(name, AccessMode::ReadOnly, Some(value.clone()));
}
// Add constants and variables from the scope
for (name, constant, value) in scope.iter() {
if !constant {