Commit graph

7 commits

Author SHA1 Message Date
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
cbbdb4e199 * Add `with-comp-cstr-accessors' macro.
* lisp/emacs-lisp/comp-cstr.el (with-comp-cstr-accessors): New macro.
	(comp-cstr-union-1): Make use of `with-comp-cstr-accessors'.
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
1fb249f6db * lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-no-range): Cosmetic. 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
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