Commit graph

26 commits

Author SHA1 Message Date
Andrea Corallo
4e1e0b9dec Have `comp-cstr-intersection-no-mem' intersect pos neg value sets
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-intersection-no-mem):
	intersect pos and neg value sets
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add two tests and fix some
	test number.
2021-04-27 22:58:41 +02:00
Andrea Corallo
edf42af2cc Rework where `comp-ctxt' is defined.
* test/lisp/emacs-lisp/comp-cstr-tests.el (comp-ctxt): Remove
	`comp-ctxt' definition.
	* lisp/emacs-lisp/comp.el (comp-ctxt): Likewise.
	* lisp/emacs-lisp/comp-cstr.el (comp-ctxt): Define it here.
2021-04-26 23:01:39 +02:00
Andrea Corallo
a390a4965f * Fix comp-cstr tests for vanilla build (bug#48021)
* test/lisp/emacs-lisp/comp-cstr-tests.el (comp-ctxt): Fix tests
	for vanilla build (bug#48021)
2021-04-26 16:52:10 +02:00
Glenn Morris
b7c22fab7d ; Add 2021 to copyright years 2021-04-25 17:24:48 -07:00
Andrea Corallo
2d23f19e7d * Fix two comp-cstr tests
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Fix test 53 70.
2021-04-13 12:05:33 +02:00
Andrea Corallo
d6227f6edc * Fix union constraint for mixed pos/neg constraints
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Fix neg
	type shadowing pos values.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add testcase.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Fix testcase.
2021-02-22 13:59:56 +01:00
Andrea Corallo
ad0d553e8f * Add a type specifier test
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add testcase.
2021-01-07 23:08:48 +01:00
Andrea Corallo
7293c23d14 * Fix a type specifier test
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Fix a testcase.
2021-01-04 22:31:40 +01:00
Andrea Corallo
5074447ef4 Fix type inference for bug#45635
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Fix
	missing mixed pos neg handling.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a test.
	* test/src/comp-tests.el (45635): New testcase.
	* test/src/comp-test-funcs.el (comp-test-45635-f): New function.
2021-01-04 22:31:40 +01:00
Andrea Corallo
672988e961 Symplify (not t) => nil and (not nil) => t
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-negation): Symplify (not
	t) => nil and (not nil) => t.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add two tests.
2020-12-24 15:36:46 +01:00
Andrea Corallo
9bbe6eab6c Fix native compiler tests when they are bytecompiled
* test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-test-ts)
	(comp-cstr-typespec-test, comp-cstr-typespec-tests-alist): Eval
	also at compile time.
	* test/src/comp-tests.el (comp-tests-type-spec-tests)
	(comp-tests-define-type-spec-test): Likewise.
2020-12-21 20:22:03 +01:00
Andrea Corallo
e0f20da6ec Simplify correctly (or (integer 1 1) (not (integer 1 1))) as t
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Logic
	update.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a test.
2020-12-21 20:22:03 +01:00
Andrea Corallo
8e816b0ad5 Symplify type specifier (not t) as nil
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-intersection-no-mem):
	Add logic.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add two tests.
2020-12-21 20:22:03 +01:00
Andrea Corallo
7074988d13 * Add a type specifier test to comp-cstr-tests.el
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a test.
2020-12-21 20:22:02 +01:00
Andrea Corallo
a0c0daf7a1 * Fix a number of type specifier simplification tests
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Fix a number of tests.
2020-12-21 19:01:22 +01:00
Andrea Corallo
0ded37fdad * Add initial negated non-negegated intersection support
* lisp/emacs-lisp/comp-cstr.el (comp-range-intersection): Cosmetic.
	(comp-cstr-intersection-homogeneous): Rename from
	`comp-cstr-intersection'.
	(comp-cstr-intersection): New function.
2020-12-13 00:58:12 +01:00
Andrea Corallo
6286945396 Normalize cstrs for cache hint effectiveness and test stability
* lisp/emacs-lisp/comp-cstr.el (comp-normalize-valset)
	(comp-union-valsets, comp-intersection-valsets)
	(comp-normalize-typeset): New functions.
	(comp-union-typesets, comp-intersect-typesets)
	(comp-cstr-union-homogeneous-no-range, comp-cstr-union-1-no-mem):
	Update to return normalized results.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Normalize expected type specifiers.
2020-12-12 16:30:16 +01:00
Andrea Corallo
725c7e1416 * Enumerate type specifier tests to ease debugging
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Enumerate tests.

Acked-by: Andrea Corallo <akrl@sdf.org>
2020-12-12 16:30:16 +01:00
Andrea Corallo
ac40a60696 Couple of `comp-cstr-union-1-no-mem' improvements for mixed neg pos union
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem):
	Generalize disjoint pos types vs neg values conditions.
	(comp-cstr-union-1-no-mem): Do not propagate ranges when we are
	already returning integer as generic type.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add corresponding tests.
2020-12-06 18:02:18 +01:00
Andrea Corallo
2eb41ec137 More improvements to `comp-cstr-union-1' for mixed positive/negative cases
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1): Better handle
	mixed positive/negated cases.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a number of tests.
2020-12-05 19:01:04 +01:00
Andrea Corallo
726e40fb7c Fix union of homogeneously negated input constraints
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1): Fix logic.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a couple of tests.
2020-12-05 19:01:03 +01:00
Andrea Corallo
7c1d90a41d Initial support for union of negated constraints
* lisp/emacs-lisp/comp-cstr.el (comp-range-negation): New
	function.
	(comp-cstr-union-homogeneous-no-range): Rename from
	`comp-cstr-union-no-range'.
	(comp-cstr-union-homogeneous): Rename from `comp-cstr-union'.
	(comp-cstr-union-1): New function.
	(comp-cstr-union-no-range, comp-cstr-union): Rewrite in function
	of `comp-cstr-union-1'.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a bunch of tests.
2020-12-05 19:01:03 +01:00
Andrea Corallo
9b85ae6aa5 Initial constraint negation support
* lisp/emacs-lisp/comp-cstr.el (comp-cstr): Add `neg' slot.
	(comp-range-negation, comp-cstr-negation)
	(comp-cstr-negation-make): New functions.
	(comp-type-spec-to-cstr): Enable `not` in type specifiers.
	(comp-cstr-to-type-spec): Update logic to handle negation.
	* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add a test.
2020-12-05 19:01:03 +01:00
Andrea Corallo
2e0256e0a0 Add intersection support into comp-cstr.el 2020-11-27 23:30:02 +01:00
Andrea Corallo
949b49cf77 Move some tests from comp-tests.el to comp-cstr-tests.el
* test/lisp/emacs-lisp/comp-cstr-tests.el
	(comp-cstr-typespec-tests-alist): Add tests covering what was in:
	`range-simple-union', `union-types', `destructure-type-spec'.
	* test/src/comp-tests.el (range-simple-intersection, union-types)
	(destructure-type-spec): Remove tests.
2020-11-26 22:03:22 +01:00
Andrea Corallo
23c082638e Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.

This commit improve the conversion type
specifier -> constraint for generality.

Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.

	* lisp/emacs-lisp/comp-cstr.el: New file.
	(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
	(comp-cstr, comp-cstr-f): Same + rename.
	(comp-cstr-ctxt): New struct.
	(comp-supertypes, comp-common-supertype-2)
	(comp-common-supertype, comp-subtype-p, comp-union-typesets)
	(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
	(comp-range-intersection): Move from comp.el.
	(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
	rename.
	(comp-cstr-union-make): New function.
	(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
	comp.el, rename it and rework it.

	* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
	(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
	(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
	renamed.
	(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
	`comp-cstr-union'.
	(comp-ret-type-spec): Use `comp-cstr-union' and rework.

	* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
	(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
	(comp-cstr-typespec-tests-alist): New defconst to generate tests
	on.
	(comp-cstr-generate-tests): New macro.

	* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
	(ret-type-spec): Initialize constraint context.
2020-11-26 22:02:30 +01:00