if (isAssignment && (leftType->componentType().isOpaque() || leftType->isOrContainsAtomic())) {
context.fErrors->error(pos, "assignments to opaque type '" + left->type().displayName() + "' are not permitted"); return nullptr;
} if (context.fConfig->strictES2Mode() && !op.isAllowedInStrictES2Mode()) {
context.fErrors->error(pos, "operator '" + std::string(op.tightOperatorName()) + "' is not allowed"); return nullptr;
} if (context.fConfig->strictES2Mode() || op.kind() == OperatorKind::COMMA) { // Most operators are already rejected on arrays, but GLSL ES 1.0 is very explicit that the // *only* operator allowed on arrays is subscripting (and the rules against assignment, // comparison, and even sequence apply to structs containing arrays as well). // WebGL2 also restricts the usage of the sequence operator with arrays (section 5.26, // "Disallowed variants of GLSL ES 3.00 operators"). Since there is very little practical // application for sequenced array expressions, we disallow it in SkSL. const Expression* arrayExpr = leftType->isOrContainsArray() ? left.get() :
rightType->isOrContainsArray() ? right.get() :
nullptr; if (arrayExpr) {
context.fErrors->error(arrayExpr->position(), "operator '" + std::string(op.tightOperatorName()) + "' can not operate on arrays (or structs containing arrays)"); return nullptr;
}
}
left = leftType->coerceExpression(std::move(left), context);
right = rightType->coerceExpression(std::move(right), context); if (!left || !right) { return nullptr;
}
std::unique_ptr<Expression> BinaryExpression::Make(const Context& context,
Position pos,
std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right, const Type* resultType) { // We should have detected non-ES2 compliant behavior in Convert.
SkASSERT(!context.fConfig->strictES2Mode() || op.isAllowedInStrictES2Mode());
SkASSERT(!context.fConfig->strictES2Mode() || !left->type().isOrContainsArray());
// We should have detected non-assignable assignment expressions in Convert.
SkASSERT(!op.isAssignment() || Analysis::IsAssignable(*left));
SkASSERT(!op.isAssignment() || !left->type().componentType().isOpaque());
// For simple assignments, detect and report out-of-range literal values. if (op.kind() == Operator::Kind::EQ) {
left->type().checkForOutOfRangeLiteral(context, *right);
}
// Perform constant-folding on the expression. if (std::unique_ptr<Expression> result = ConstantFolder::Simplify(context, pos, *left,
op, *right, *resultType)) { return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.