Skip to content

Commit

Permalink
support getter function name in reexports (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Oct 31, 2020
1 parent 20e456d commit 1163d92
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ EXPORTS_DEFINE: `Object` `.` `defineProperty `(` IDENTIFIER_STRING `, {`
(`enumerable: true,`)?
(
`value:` |
`get` `: function`? `()` {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}`
`get` (`: function` IDENTIFIER? )? `()` {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}`
)
`})`
Expand Down
3 changes: 3 additions & 0 deletions lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ function tryParseObjectDefineOrKeys (keys) {
if (ch !== 102/*f*/) break;
if (!source.startsWith('unction', pos + 1)) break;
pos += 8;
let lastPos = pos;
ch = commentWhitespace();
if (ch !== 40 && (lastPos === pos || !identifier())) break;
ch = commentWhitespace();
}
if (ch !== 40/*(*/) break;
Expand Down
3 changes: 3 additions & 0 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ void tryParseObjectDefineOrKeys (bool keys) {
if (ch != 'f') break;
if (!str_eq7(pos + 1, 'u', 'n', 'c', 't', 'i', 'o', 'n')) break;
pos += 8;
uint16_t* lastPos = pos;
ch = commentWhitespace();
if (ch != '(' && (lastPos == pos || !identifier(ch))) break;
ch = commentWhitespace();
}
if (ch != '(') break;
Expand Down
8 changes: 7 additions & 1 deletion test/_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ suite('Lexer', () => {
});
Object.defineProperty(exports, "c", {
get: function () {
get: function get () {
return q['p' ];
}
});
Expand All @@ -70,6 +70,12 @@ suite('Lexer', () => {
return external;
}
});
Object.defineProperty(exports, "f", {
get: functionget () {
return q['p' ];
}
});
`);
assert.equal(exports.length, 4);
assert.equal(exports[0], 'a');
Expand Down

0 comments on commit 1163d92

Please sign in to comment.