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

feat: WIP enums implementation #374

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
49 changes: 33 additions & 16 deletions nova_vm/src/ecmascript/syntax_directed_operations/scope_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ impl<'a> VarDeclaredNames<'a> for Statement<'a> {
}
// 4. Return the list-concatenation of names1, names2, and names3.
},
#[cfg(feature = "typescript")]
Statement::TSEnumDeclaration(_) => {},

Statement::WhileStatement(st) => {
// WhileStatement : while ( Expression ) Statement
// 1. Return the VarDeclaredNames of Statement.
Expand All @@ -737,7 +740,8 @@ impl<'a> VarDeclaredNames<'a> for Statement<'a> {
}
}
},
Statement::TSEnumDeclaration(_) |
#[cfg(not(feature = "typescript"))]
Statement::TSEnumDeclaration(_) => unreachable!(),
Statement::TSExportAssignment(_) |
Statement::TSImportEqualsDeclaration(_) |
Statement::TSInterfaceDeclaration(_) |
Expand Down Expand Up @@ -1080,15 +1084,18 @@ impl<'a> TopLevelLexicallyDeclaredNames<'a> for Statement<'a> {
Statement::ImportDeclaration(decl) => decl.bound_names(f),
Statement::ExportNamedDeclaration(decl) => decl.bound_names(f),
#[cfg(feature = "typescript")]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {}
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {}
#[cfg(not(feature = "typescript"))]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {
unreachable!()
}
// Note: No bounds names for export all and export default declarations.
Statement::ExportAllDeclaration(_) | Statement::ExportDefaultDeclaration(_) => {}
Statement::TSEnumDeclaration(_)
| Statement::TSModuleDeclaration(_)
Statement::TSModuleDeclaration(_)
| Statement::TSImportEqualsDeclaration(_)
| Statement::TSExportAssignment(_)
| Statement::TSNamespaceExportDeclaration(_) => unreachable!(),
Expand Down Expand Up @@ -1163,13 +1170,16 @@ impl<'a> TopLevelLexicallyScopedDeclarations<'a> for Statement<'a> {
Statement::ClassDeclaration(decl) => f(LexicallyScopedDeclaration::Class(decl)),
Statement::UsingDeclaration(_) => todo!(),
#[cfg(feature = "typescript")]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {}
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {}
#[cfg(not(feature = "typescript"))]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {
unreachable!()
}
Statement::TSEnumDeclaration(_)
| Statement::TSExportAssignment(_)
Statement::TSExportAssignment(_)
| Statement::TSImportEqualsDeclaration(_)
| Statement::TSModuleDeclaration(_)
| Statement::TSNamespaceExportDeclaration(_) => unreachable!(),
Expand Down Expand Up @@ -1250,13 +1260,16 @@ impl<'a> TopLevelVarDeclaredNames<'a> for Statement<'a> {
| Statement::WhileStatement(_)
| Statement::WithStatement(_) => self.var_declared_names(f),
#[cfg(feature = "typescript")]
Statement::TSEnumDeclaration(_) => self.var_declared_names(f),
#[cfg(feature = "typescript")]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {}
#[cfg(not(feature = "typescript"))]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {
unreachable!()
}
Statement::TSEnumDeclaration(_)
| Statement::TSExportAssignment(_)
Statement::TSExportAssignment(_)
| Statement::TSImportEqualsDeclaration(_)
| Statement::TSModuleDeclaration(_)
| Statement::TSNamespaceExportDeclaration(_) => unreachable!(),
Expand Down Expand Up @@ -1379,14 +1392,18 @@ impl<'a> TopLevelVarScopedDeclarations<'a> for Statement<'a> {
// 2. Return a new empty List.
}
#[cfg(feature = "typescript")]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {}
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {}
#[cfg(not(feature = "typescript"))]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {
unreachable!()
}
Statement::UsingDeclaration(_) => todo!(),
Statement::TSEnumDeclaration(_)
| Statement::TSExportAssignment(_)

Statement::TSExportAssignment(_)
| Statement::TSImportEqualsDeclaration(_)
| Statement::TSModuleDeclaration(_)
| Statement::TSNamespaceExportDeclaration(_) => unreachable!(),
Expand Down
15 changes: 12 additions & 3 deletions nova_vm/src/engine/bytecode/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,12 @@ impl CompileEvaluation for ast::TryStatement<'_> {
}
}

impl CompileEvaluation for ast::TSEnumDeclaration<'_> {
fn compile(&self, _ctx: &mut CompileContext) {
todo!();
}
}

load1n9 marked this conversation as resolved.
Show resolved Hide resolved
impl CompileEvaluation for ast::WhileStatement<'_> {
fn compile(&self, ctx: &mut CompileContext) {
let previous_continue = ctx.current_continue.replace(vec![]);
Expand Down Expand Up @@ -2752,6 +2758,8 @@ impl CompileEvaluation for ast::Statement<'_> {
ast::Statement::ForStatement(x) => x.compile(ctx),
ast::Statement::ThrowStatement(x) => x.compile(ctx),
ast::Statement::TryStatement(x) => x.compile(ctx),
#[cfg(feature = "typescript")]
Statement::TSEnumDeclaration(statement) => statement.compile(ctx),
Statement::BreakStatement(statement) => statement.compile(ctx),
Statement::ContinueStatement(statement) => statement.compile(ctx),
Statement::DebuggerStatement(_) => todo!(),
Expand All @@ -2771,11 +2779,12 @@ impl CompileEvaluation for ast::Statement<'_> {
#[cfg(feature = "typescript")]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {}
#[cfg(not(feature = "typescript"))]
Statement::TSTypeAliasDeclaration(_) | Statement::TSInterfaceDeclaration(_) => {
Statement::TSTypeAliasDeclaration(_)
| Statement::TSInterfaceDeclaration(_)
| Statement::TSEnumDeclaration(_) => {
unreachable!()
}
Statement::TSEnumDeclaration(_)
| Statement::TSExportAssignment(_)
Statement::TSExportAssignment(_)
| Statement::TSImportEqualsDeclaration(_)
| Statement::TSModuleDeclaration(_)
| Statement::TSNamespaceExportDeclaration(_) => unreachable!(),
Expand Down