arithmetic/language/frontend.lisp
The remembered answer of arithmetic-expression-quantity-checked-p.
Unbound until the question is first asked of this expression. See the :AROUND method on that generic function for why the memory is needed and what makes it sound.
A source expression with semantic meaning but no chosen machine form.
A lexical alias binding one function argument inside an application.
A value conditional shared by every arithmetic realization.
Return the source name denoted by reference target.
Whether semantic checking is active at reference target.
Return target's homogeneous quantity specification, or NIL.
Return target's packed quantity layout, or NIL.
Whether semantic quantity checking is active at expression.
Answer once per expression and remember it.
A parsed expression is a directed acyclic graph, not a tree: one binding referenced three times is one object with three references to it, and an inlined function call shares its argument expressions with the call site. The methods below recurse through operands, through a reference's target binding, and through a function call's result, so a plain recursive walk visits every path rather than every node -- which is exponential in the depth of the sharing, not linear in the size of the graph. A shader with a few nested distance-field helpers is enough to make the difference minutes.
The memory is sound because the graph is immutable once built: an expression's operands, a binding's expression, and a call's result are all read-only after construction, and every child is fully constructed before the parent that refers to it. So the answer for a given object can never change, and asking early during parsing gives the same answer as asking at the end.
Reconstruct the compact source form of expression.
Return expression's immediate source operands.
The shared source identity of a reusable expression-language function.
A checked arithmetic source definition awaiting an execution backend.
One inspectable application of shared function source to checked values.
A truth-valued expression over the index and the carried state, tested before each iteration; when it holds the fold stops early with the state it has. NIL means the fold always runs to COUNT.
A bounded value-producing fold over an index and one carried state.
The binding list is (INDEX COUNT STATE INITIAL), optionally followed by :UNTIL TEST, whose TEST sees INDEX and STATE and ends the fold early.
Return the live arithmetic definition named by name, or NIL.
Notify loaded realizations that reusable arithmetic source changed.
Return definition's expression graph in source order without duplicates.
Whether operator belongs to the compiled arithmetic language.
Admit name to the open arithmetic vocabulary through an EQL method.
Parse one arithmetic call into an inspectable expression.
A truth-valued combination of tests. Like a comparison it carries no quantity, and unlike an arithmetic call it never infers one from operands, so checked comparisons and raw flags may combine freely.
Whether expression is a literal construction source.
Destructure a COUNTED-FOLD form into (VALUES INDEX-NAME COUNT-FORM
STATE-NAME INITIAL-FORM UPDATE-FORM UNTIL-FORM), or return NIL when the
shape is not (COUNTED-FOLD (INDEX COUNT STATE INITIAL [:UNTIL TEST]) UPDATE).
Parse a call by specializing shared function source to its actual values.
Parse one backend-neutral arithmetic function definition.
Define one inspectable arithmetic function through an EQL method.
((source-form reason) &body body)A source expression with semantic meaning but no chosen machine form.
The semantic meaning of a value, separate from its machine representation.
Semantic quantities packed into disjoint positions of one representation.
(expression)Whether semantic quantity checking is active at EXPRESSION.
(declaration)Return DECLARATION's backend or Common Lisp representation type, or NIL.
(declaration)Return DECLARATION's homogeneous quantity specification, or NIL.
(declaration)Return DECLARATION's heterogeneous quantity layout, or NIL.
(declaration)Return the source form which established DECLARATION.
A lexical alias binding one function argument inside an application.
A value conditional shared by every arithmetic realization.
(target)Return the source name denoted by reference TARGET.
(target)Whether semantic checking is active at reference TARGET.
(target)Return TARGET's homogeneous quantity specification, or NIL.
(target)Return TARGET's packed quantity layout, or NIL.
Logical disjunction of tests and raw truth values.
((call tool-call) stream)The shared source identity of a reusable expression-language function.
A checked arithmetic source definition awaiting an execution backend.
One inspectable application of shared function source to checked values.
One top-level defining form of a source file.
A bounded value-producing fold over an index and one carried state. The binding list is (INDEX COUNT STATE INITIAL), optionally followed by :UNTIL TEST, whose TEST sees INDEX and STATE and ends the fold early.
Logical conjunction of tests and raw truth values.
(name)Return the live arithmetic definition named by NAME, or NIL.
(name)Notify loaded realizations that reusable arithmetic source changed.
(definition)((name symbol) (type (eql 'arithmetic-operator)))Headings, paragraphs, figures and their IDs, mentions, marks.
(operator)Whether OPERATOR belongs to the compiled arithmetic language.
(name &optional documentation)Addition over compatible quantities.
Subtraction or unary negation.
Multiplication and scalar scaling.
Division of two represented quantities.
The non-negative remainder of integer division.
The inner product of two vectors.
The minimum of compatible quantities.
The maximum of compatible quantities.
The componentwise absolute value of a raw value.
The componentwise square root of a raw value.
Constrain a quantity between compatible bounds.
Interpolate compatible quantities by a scalar amount.
Produce dimensionless progress across compatible edges.
Compare compatible quantities and produce dimensionless values.
Normalize a dimensionless vector.
Raise a dimensionless value to a dimensionless power.
Test whether one compatible scalar is less than another.
Test whether one compatible scalar is at most another.
Test whether one compatible scalar is greater than another.
Test whether one compatible scalar is at least another.
Test whether two compatible scalars are equal.
Construct a meaningful literal.
State external meaning for a raw value.
Name a compatible derived quantity.
Expose a quantity's raw representation.
Convert a quantity to a compatible unit.
Logical negation of one test or raw truth value.
(name environment source-form)(name environment source-form)(options source-form &key (default-tensor-order 0))(options &key (default-tensor-order 0))Parse one source declaration plist into a quantity specification. Return NIL when OPTIONS contains no quantity attributes. This is the common source seam used by arithmetic parameters, shader interfaces, and semantic storage declarations; callers retain ownership of their source-specific error conditions and…
(operator operands source-form)(operator &rest operands)Derive the semantic result of applying OPERATOR to quantity OPERANDS.
(operator form environment)Parse one arithmetic call into an inspectable expression.
(form environment)A truth-valued combination of tests. Like a comparison it carries no quantity, and unlike an arithmetic call it never infers one from operands, so checked comparisons and raw flags may combine freely.
(operator form environment)(expression)Whether EXPRESSION is a literal construction source.
(class form environment &key constant-only-p)(derived interpretation)Give a compatible anonymous DERIVED specification an explicit meaning. This is a semantic interpretation, never a numerical unit conversion. An already named quantity may only retain its name; anonymous derived results may acquire one when their dimension, exact unit, and tensor order agree with INTERPRETATION. …
(source target-unit)Return SOURCE expressed in TARGET-UNIT and its required numeric factor. The operation preserves semantic name, dimension, tensor order, and affine character. It is a linear unit conversion, not a semantic interpretation.
(left right)(left right)(left right)(form)Destructure a COUNTED-FOLD FORM into (VALUES INDEX-NAME COUNT-FORM STATE-NAME INITIAL-FORM UPDATE-FORM UNTIL-FORM), or return NIL when the shape is not (COUNTED-FOLD (INDEX COUNT STATE INITIAL [:UNTIL TEST]) UPDATE).
(form environment)(body environment)(form environment)(form environment)(definition form environment)(name &key (dimension nil dimension-supplied-p) unit
(tensor-order 0)
(affine-p nil affine-p-supplied-p)
(character nil character-supplied-p))(parameter argument source-form)(name parameter-forms body)(name parameters &body body)
Backend-neutral compiled arithmetic definitions and expression graphs.
This is the shared source/semantic frontend. It deliberately does not choose single versus double floats, a vector representation, an execution strategy, or a lowering backend. A realization consumes these inspectable objects after quantity checking and chooses those machine details itself.