"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNever = exports.isAny = exports.IntegerTypes = exports.Int32 = exports.UInt32 = exports.Int16 = exports.UInt16 = exports.Int8 = exports.UInt8 = exports.WeakMap = exports.RegExp = exports.Symbol = exports.Void = exports.Undefined = exports.Never = exports.Any = exports.Null = exports.Object = exports.Type = exports.Function = exports.Class = exports.Set = exports.Map = exports.Array = exports.Integer = exports.Number = exports.String = exports.Boolean = void 0;
const combineExpressions_1 = __importDefault(require("./analysis/combineExpressions"));
const ast_1 = require("./ast");
const Reference_1 = __importDefault(require("./ast/Reference"));
const pathFunctions_1 = require("./pathFunctions");
function ref(name) {
    return new Reference_1.default({ name, path: pathFunctions_1.getGlobalPath(name) });
}
function number(type, min, max) {
    return combineExpressions_1.default([
        new ast_1.BinaryExpression({ left: new ast_1.DotExpression({}), operator: "is", right: type }),
        new ast_1.BinaryExpression({ left: new ast_1.DotExpression({}), operator: ">=", right: new ast_1.Literal({ value: min }) }),
        new ast_1.BinaryExpression({ left: new ast_1.DotExpression({}), operator: "<=", right: new ast_1.Literal({ value: max }) }),
    ]);
}
exports.Boolean = ref("Boolean");
exports.String = ref("String");
exports.Number = ref("Number");
exports.Integer = ref("Integer");
exports.Array = ref("Array");
exports.Map = ref("Map");
exports.Set = ref("Set");
exports.Class = ref("Class");
exports.Function = ref("Function");
exports.Type = ref("Type");
exports.Object = ref("Object");
exports.Null = ref("Null");
exports.Any = ref("Any");
exports.Never = ref("Never");
exports.Undefined = ref("Undefined");
exports.Void = ref("Void");
exports.Symbol = ref("Symbol");
exports.RegExp = ref("RegExp");
exports.WeakMap = ref("WeakMap");
exports.UInt8 = number(exports.Integer, 0, 255);
exports.Int8 = number(exports.Integer, -128, 127);
exports.UInt16 = number(exports.Integer, 0, 65535);
exports.Int16 = number(exports.Integer, -32768, 32767);
exports.UInt32 = number(exports.Integer, 0, 4294967295);
exports.Int32 = number(exports.Integer, -2147483648, 2147483647);
exports.IntegerTypes = { UInt8: exports.UInt8, Int8: exports.Int8, UInt16: exports.UInt16, Int16: exports.Int16, UInt32: exports.UInt32, Int32: exports.Int32 };
// export const EmptyLocation = new Location({ start: new Position(0, 0), end: new Position(0, 0), filename: "inferType.empty" })
function equals(a, b) {
    return a === b || Reference_1.default.is(a) && a.name === b.name;
}
function isAny(node) {
    return equals(node, exports.Any);
}
exports.isAny = isAny;
function isNever(node) {
    return equals(node, exports.Never);
}
exports.isNever = isNever;
