-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create wildcards.js and implement basic type detections * Remove isUnit from isConstantExpression wildcard isUnit would never be encountered because units are stored as a part of ConstantNodes. * Add matching for the new wildcard rules * Add tests for the new wildcard rules * Remove comment regarding Unit * Seperate wildcard import into individual imports * Update comments at top and change '*i' to '*d' * Seperate Unit Tests * Update simplify documentation comment * Add unit test for #1406 * Update imports for new build system * Update simplify test with new rules syntax * Fix small documentation errors * Update simplify rules to use new wildcards * Add tests for rules updated with new wildcards * Remove duplicated comment information Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
- Loading branch information
1 parent
c921121
commit 77f94c4
Showing
4 changed files
with
236 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { isConstantNode, isFunctionNode, isOperatorNode, isParenthesisNode } from '../../../utils/is.js' | ||
export { isConstantNode, isSymbolNode as isVariableNode } from '../../../utils/is.js' | ||
|
||
export function isNumericNode (x) { | ||
return isConstantNode(x) || (isOperatorNode(x) && x.isUnary() && isConstantNode(x.args[0])) | ||
} | ||
|
||
export function isConstantExpression (x) { | ||
if (isConstantNode(x)) { // Basic Constant types | ||
return true | ||
} | ||
if ((isFunctionNode(x) || isOperatorNode(x)) && x.args.every(isConstantExpression)) { // Can be constant depending on arguments | ||
return true | ||
} | ||
if (isParenthesisNode(x) && isConstantExpression(x.content)) { // Parenthesis are transparent | ||
return true | ||
} | ||
return false // Probably missing some edge cases | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters