Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement scope analysis and local variables #3988

Merged
merged 7 commits into from
Sep 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove unnecessary compile time environment clones
raskad committed Sep 13, 2024
commit 56a56ff81692b5a6ca622ac68f0e4321d63c3a02
9 changes: 9 additions & 0 deletions core/engine/src/environments/runtime/declarative/mod.rs
Original file line number Diff line number Diff line change
@@ -68,6 +68,15 @@ impl DeclarativeEnvironment {
&self.kind
}

/// Returns whether this environment is a function environment.
pub(crate) fn is_function(&self) -> bool {
if let DeclarativeEnvironmentKind::Function(_) = self.kind() {
true
} else {
false
}
}

/// Gets the binding value from the environment by index.
///
/// # Panics
11 changes: 6 additions & 5 deletions core/engine/src/environments/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -278,7 +278,7 @@ impl EnvironmentStack {
.filter_map(Environment::as_declarative)
{
env.poison();
if env.compile_env().is_function() {
if env.is_function() {
return;
}
}
@@ -513,8 +513,8 @@ impl Context {
match self.environment_expect(index) {
Environment::Declarative(env) => {
if env.poisoned() {
let compile = env.compile_env();
if compile.is_function() {
if env.is_function() {
let compile = env.compile_env();
if let Some(b) = compile.get_binding(locator.name()) {
locator.set_environment(b.environment());
locator.binding_index = b.binding_index();
@@ -578,8 +578,9 @@ impl Context {
match self.environment_expect(index) {
Environment::Declarative(env) => {
if env.poisoned() {
let compile = env.compile_env();
if compile.is_function() && compile.get_binding(locator.name()).is_some() {
if env.is_function()
&& env.compile_env().get_binding(locator.name()).is_some()
{
break;
}
} else if !env.with() {