Skip to content

Commit

Permalink
Fix -Infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 9, 2023
1 parent 5d610b9 commit e540b6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/serialize/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ const {createDependency} = require('./records.js'),
{GLOBAL, MODULE, VALUE, GETTER, SETTER, PROTO, EVAL, COMMON_JS} = require('../shared/constants.js'),
{isJsIdentifier, firstMapKey} = require('./utils.js'),
{
GLOBAL_TOP_LEVEL_TYPE,
GLOBAL_MODULE_TYPE,
GLOBAL_PROPERTY_TYPE,
GLOBAL_PROTOTYPE_TYPE,
GLOBAL_GETTER_SETTER_TYPE,
registerSerializer
GLOBAL_TOP_LEVEL_TYPE, GLOBAL_MODULE_TYPE, GLOBAL_PROPERTY_TYPE, GLOBAL_PROTOTYPE_TYPE,
GLOBAL_GETTER_SETTER_TYPE, GLOBAL_MINUS_INFINITY_TYPE, registerSerializer
} = require('./types.js');

// Exports
Expand Down Expand Up @@ -119,13 +115,10 @@ function traceGlobal({type, parent, key}, record) {
}

// Special values
// TODO: Remove this - can be a primitive
/*
if (key === 'minusInfinity') {
createDependency(record, this.traceValue(Infinity));
this.traceDependency(Infinity, undefined, undefined, record);
return GLOBAL_MINUS_INFINITY_TYPE;
}
*/

// TODO: Add other special values
throw new Error('Special types not supported');
Expand Down Expand Up @@ -233,13 +226,11 @@ registerSerializer(GLOBAL_GETTER_SETTER_TYPE, serializeGlobalGetterSetter);
* @param {Object} record - Record
* @returns {Object} - AST node
*/
// TODO: Remove this - can be a primitive
/*
function serializeMinusInfinity(record) {
const infinityNode = this.serializeValue(firstMapKey(record.dependencies));
return t.unaryExpression('-', infinityNode);
}
*/
registerSerializer(GLOBAL_MINUS_INFINITY_TYPE, serializeMinusInfinity);

/**
* Create member AST node.
Expand Down
2 changes: 2 additions & 0 deletions lib/serialize/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const NO_TYPE = 0,
GLOBAL_PROPERTY_TYPE = GLOBAL_TYPE | 2,
GLOBAL_PROTOTYPE_TYPE = GLOBAL_TYPE | 3,
GLOBAL_GETTER_SETTER_TYPE = GLOBAL_TYPE | 4,
GLOBAL_MINUS_INFINITY_TYPE = GLOBAL_TYPE | 5,
EXPORT_JS_TYPE = 1,
EXPORT_COMMONJS_TYPE = 2,
EXPORT_ESM_TYPE = 3,
Expand All @@ -51,6 +52,7 @@ module.exports = {
GLOBAL_PROPERTY_TYPE,
GLOBAL_PROTOTYPE_TYPE,
GLOBAL_GETTER_SETTER_TYPE,
GLOBAL_MINUS_INFINITY_TYPE,
EXPORT_JS_TYPE,
EXPORT_COMMONJS_TYPE,
EXPORT_ESM_TYPE,
Expand Down

0 comments on commit e540b6f

Please sign in to comment.