-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
Refactor compile time environment handling #3365
Conversation
Test262 conformance changes
Fixed tests (3):
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3365 +/- ##
==========================================
- Coverage 49.55% 49.49% -0.06%
==========================================
Files 446 446
Lines 43705 43643 -62
==========================================
- Hits 21656 21602 -54
+ Misses 22049 22041 -8
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! @raskad
Besides @jedel1043 comment this looks good to me! :)
boa_engine/src/bytecompiler/mod.rs
Outdated
@@ -1180,7 +1171,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { | |||
} | |||
|
|||
/// Compile a [`Declaration`]. | |||
#[allow(unused_variables)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is showing warnings because block
is not used if the feature annex-b
is disabled. Maybe rename block
to _block
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming to _block
does not seem to work as we get a different lint for usage of _*
named variables. I just added the allow
back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice improvements! Just have some suggestions.
pub(crate) fn is_lex_binding(&self, name: Identifier) -> bool { | ||
/// Get the binding locator for a binding with the given name. | ||
/// Fall back to the global environment if the binding is not found. | ||
pub(crate) fn get_identifier_reference(&self, name: Identifier) -> (BindingLocator, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document that the bool
returned represents the type of binding found? An alternative would be to return an object instead of a tuple:
struct IdentifierReference {
locator: BindingLocator,
lexical: bool
}
impl PartialEq for CompileTimeEnvironment { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.environment_index == other.environment_index | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it seems wrong to allow comparing environments that may only share the same index as equals (e.g. environments from two different script compilations). Maybe we just expose environment_index
and compare that?
let lex_env = if strict { | ||
// a. Let lexEnv be varEnv. | ||
var_env | ||
} else { | ||
// a. Let lexEnv be NewDeclarativeEnvironment(varEnv). | ||
// b. NOTE: Non-strict functions use a separate Environment Record for top-level lexical | ||
// declarations so that a direct eval can determine whether any var scoped declarations | ||
// introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. | ||
// This is not needed for strict functions because a strict direct eval always | ||
// places all declarations into a new Environment Record. | ||
let env_index = self.push_compile_environment(false); | ||
self.emit_with_varying_operand(Opcode::PushDeclarativeEnvironment, env_index); | ||
self.lexical_environment.clone() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really liking this! Makes it very easy to implement things per the spec :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* Refactor compile time environment handling * Apply review * Apply review
This Pull Request changes the following:
ByteCompiler
before theByteCompiler::finish()
.eval
calls.