wildcards.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isConstantExpression = isConstantExpression;
  6. Object.defineProperty(exports, "isConstantNode", {
  7. enumerable: true,
  8. get: function get() {
  9. return _is.isConstantNode;
  10. }
  11. });
  12. exports.isNumericNode = isNumericNode;
  13. Object.defineProperty(exports, "isVariableNode", {
  14. enumerable: true,
  15. get: function get() {
  16. return _is.isSymbolNode;
  17. }
  18. });
  19. var _is = require("../../../utils/is.js");
  20. function isNumericNode(x) {
  21. return (0, _is.isConstantNode)(x) || (0, _is.isOperatorNode)(x) && x.isUnary() && (0, _is.isConstantNode)(x.args[0]);
  22. }
  23. function isConstantExpression(x) {
  24. if ((0, _is.isConstantNode)(x)) {
  25. // Basic Constant types
  26. return true;
  27. }
  28. if (((0, _is.isFunctionNode)(x) || (0, _is.isOperatorNode)(x)) && x.args.every(isConstantExpression)) {
  29. // Can be constant depending on arguments
  30. return true;
  31. }
  32. if ((0, _is.isParenthesisNode)(x) && isConstantExpression(x.content)) {
  33. // Parenthesis are transparent
  34. return true;
  35. }
  36. return false; // Probably missing some edge cases
  37. }