expredit::ExprCompiler

Compiles an expression through eval into a CompiledExpression that carries a Program.

Declared in src/libs/libexpredit/expredit/ExprCompiler.hpp
Group expredit

Detailed description

compile() does these steps:

  1. It finds the names that the expression reads, with a lexical pass against the CompileContext.
  2. It declares each name as an eval::Graph input, with the type that the input universe gives.
  3. It changes default.<id> to <id> for the eval parser.
  4. It compiles the graph and keeps the eval::Program that results.

setCompileContext() sets the input universe and the type hints. lowerToGlsl() gives the GLSL text of one expression instead of a Program.

Member function documentation

lowerToGlsl

expredit::ExprCompiler::Lowered ExprCompiler::lowerToGlsl(const QString &expressionText, const QHash<QString, QString> &bindings)

Lowers expressionText to GLSL and binds each name it reads to the text that bindings gives for that name.

This is construct-component-parity §CPF-A4.2. The expression language is already GLSL (expression-system-consolidation), so this is a lowering and not a translation. It applies the same default. strip and the same whole-reference renaming as compile(), and it replaces each dependency with its binding in parentheses. compile() runs on the same text first. Thus glslang has validated the text, and the CPU value and the GLSL come from one source.

The result is refused, with a reason, for a text that does not compile, a string value, a function definition, time or anim.* (a seal is not animated), and a name that bindings does not cover. The caller binds math.* to literals, because the constants are in libconstruct.

Returns the GLSL text, its result type and its dependencies, or an error that gives the reason for the refusal.

In this section