class Context; class Type; class VariableReference;
/** * A binary operation.
*/ class BinaryExpression final : public Expression { public: inlinestatic constexpr Kind kIRNodeKind = Kind::kBinary;
BinaryExpression(Position pos, std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right, const Type* type)
: INHERITED(pos, kIRNodeKind, type)
, fLeft(std::move(left))
, fOperator(op)
, fRight(std::move(right)) { // If we are assigning to a VariableReference, ensure that it is set to Write or ReadWrite.
SkASSERT(!op.isAssignment() || CheckRef(*this->left()));
}
// Creates a potentially-simplified form of the expression. Determines the result type // programmatically. Typechecks and coerces input expressions; reports errors via ErrorReporter. static std::unique_ptr<Expression> Convert(const Context& context,
Position pos,
std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right);
// Creates a potentially-simplified form of the expression. Determines the result type // programmatically. Asserts if the expressions do not typecheck or are otherwise invalid. static std::unique_ptr<Expression> Make(const Context& context,
Position pos,
std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right);
// Creates a potentially-simplified form of the expression. Result type is passed in. // Asserts if the expressions do not typecheck or are otherwise invalid. static std::unique_ptr<Expression> Make(const Context& context,
Position pos,
std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right, const Type* resultType);
/** * If the expression is an assignment like `a = 1` or `a += sin(b)`, returns the * VariableReference that will be written to. For other types of expressions, returns null. * Complex expressions that contain inner assignments, like `(a = b) * 2`, will return null.
*/
VariableReference* isAssignmentIntoVariable();
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.