Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Mar 14, 2024
1 parent d08c515 commit 3e777ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions napi/parser/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ for (const typeName of [
typesByName[typeName].fields.find(field => field.name === 'rest').skip = false;
}

function mergeVariants(destTypeName, srcTypeName, variantName) {
// Combine nested enums
function flattenEnumVariants(destTypeName, srcTypeName, variantName) {
const destType = typesByName[destTypeName],
srcType = typesByName[srcTypeName],
variantIndex = destType.variants.findIndex(variant => variant.name === variantName);
assert(variantIndex !== -1);
destType.variants.splice(
Expand All @@ -72,10 +72,10 @@ function mergeVariants(destTypeName, srcTypeName, variantName) {
);
}

// Combine `Declaration`'s variants into `Statement`
mergeVariants('Statement', 'Declaration', 'Declaration');
flattenEnumVariants('Statement', 'Declaration', 'Declaration');
typesByName.Declaration.niche = {offset: 0, size: 1, value: 255};
mergeVariants('ExportDefaultDeclarationKind', 'Expression', 'Expression');

flattenEnumVariants('ExportDefaultDeclarationKind', 'Expression', 'Expression');
typesByName.Expression.niche = {offset: 0, size: 1, value: 255};

// Link up types.
Expand Down

0 comments on commit 3e777ba

Please sign in to comment.