![]() |
Spicy
|
#include <operator.h>
Public Types | |
| template<typename T > | |
| using | Result = ::hilti::Result< T > |
Public Member Functions | |
| Operator (Meta meta=Meta(), bool builtin=true) | |
| virtual | ~Operator () |
| Operator (const Operator &other)=delete | |
| Operator (Operator &&other)=delete | |
| Operator & | operator= (const Operator &other)=delete |
| Operator & | operator= (Operator &&other)=delete |
| auto | isInitialized () const |
| auto | hasOperands () const |
| const auto & | signature () const |
| auto | kind () const |
| auto | isBuiltIn () const |
| auto | operands () const |
| auto | op0 () const |
| auto | op1 () const |
| auto | op2 () const |
| const auto & | meta () const |
| const auto & | doc () const |
| auto | typename_ () const |
| virtual QualifiedType * | result (Builder *builder, const Expressions &operands, const Meta &meta) const |
| virtual std::optional< operator_::Operands > | filter (Builder *builder, const Expressions &operands) const |
| virtual void | validate (expression::ResolvedOperator *n) const |
| virtual Result< expression::ResolvedOperator * > | instantiate (Builder *builder, Expressions operands, Meta meta) const =0 |
| virtual std::string | name () const =0 |
| virtual std::string | print () const |
| virtual std::string | dump () const |
Protected Member Functions | |
| bool | init (Builder *builder, Node *scope_root=nullptr) |
| virtual operator_::Signature | signature (Builder *builder) const =0 |
| virtual std::string | _typename () const |
Static Protected Member Functions | |
| static operator_::Operand * | operandForType (Builder *builder, parameter::Kind kind, UnqualifiedType *t, std::string doc="") |
| static operator_::Operand * | operandForExpression (Builder *builder, parameter::Kind kind, const Expressions &e, size_t i) |
Friends | |
| class | operator_::Registry |
Class representing available HILTI operators.
Operators aren't AST nodes themselves, but they define an operator that's available for instantiation as an AST expression node. Given an operator, one can instantiate a corresponding AST node by passing the concrete operands to the instantiate() method.
Constructor.
| meta | meta data associated with the operator |
| builtin | true if the operator is predefined statically by the compiler; false if it's generated from user code (like functions and methods) |
|
inlinevirtual |
Destructor.
|
inlineprotectedvirtual |
Backend for typename_(). Must be overridden by derived classes.
|
inline |
Returns the operator's documentation string.
|
virtual |
Dumps out the operator's operands in their AST node representation.
|
inlinevirtual |
Refines the operator's signature based on the given operands. This can be used to change the signature to more specific types given concreate operands. To not change anything, return an mepty optional
|
inline |
Returns true if operator's signature has operands defined. If that's not the case, the operator can be instantiated only manually, not through the resolver.
Initializes the operator. To be called only from the registry.
|
pure virtual |
Instantiates the operator as an AST node, given specific operand expressions.
Implemented in hilti::struct_::MemberCall, hilti::generic::CastedCoercion, and hilti::function::Call.
|
inline |
Returns if the operator is predefined statically by the compiler, rather than created through user code (like functions or methods).
|
inline |
Returns true if init() has run and returned success.
|
inline |
Returns the operator's kind.
|
inline |
Returns the operator's meta information.
|
pure virtual |
Returns a readable name describing the operator. Must be provided by derived classes.
Implemented in hilti::struct_::MemberCall, hilti::generic::CastedCoercion, and hilti::function::Call.
|
inline |
Returns the operator's first operand.
|
inline |
Returns the operator's second operand.
|
inline |
Returns the operator's third operand.
|
inlinestaticprotected |
Helper to create an signature operand matching the type of a given expression.
| kind | kind of the operand specifying passing style |
| e | expression whose type to use |
|
staticprotected |
Helper to create an signature operand matching a given type.
| kind | kind of the operand specifying passing style |
| t | type of the operand |
|
inline |
Returns the operator's operands.
|
virtual |
Prints the operator in a human-readable format.
Reimplemented in hilti::BuiltInMemberCall.
|
virtual |
Returns the operator's result type, given specific operand expressions. Must be implemented by operators if the signature does not define a static result type.
Reimplemented in hilti::generic::CastedCoercion.
|
inline |
Returns the operator's signature.
|
protectedpure virtual |
Returns the operator's signature. Must be overridden by derived classes.
Implemented in hilti::struct_::MemberCall, hilti::generic::CastedCoercion, and hilti::function::Call.
|
inline |
Returns the C++-level name of the operator's class. Should be used only for debugging purposes.
|
inlinevirtual |
Performs semantics validation of an instantiated operator. To record any errors, add them to the given AST node.