Qt 4.8
|
Contains functions that applies Function Conversion Rules and other kinds of compile-time type checking tasks. More...
#include <qtypechecker_p.h>
Public Types | |
enum | Option { AutomaticallyConvert = 1, CheckFocus = 2, GeneratePromotion } |
typedef QFlags< Option > | Options |
Static Public Functions | |
static Expression::Ptr | applyFunctionConversion (const Expression::Ptr &operand, const SequenceType::Ptr &reqType, const StaticContext::Ptr &context, const ReportContext::ErrorCode code=ReportContext::XPTY0004, const Options=Options(AutomaticallyConvert|CheckFocus)) |
Builds a pipeline of artificial AST nodes that ensures operand conforms to the type reqType by applying the Function Conversion Rules. More... | |
Private Functions | |
TypeChecker () | |
Static Private Functions | |
static bool | promotionPossible (const ItemType::Ptr &fromType, const ItemType::Ptr &toType, const StaticContext::Ptr &context) |
static Expression::Ptr | typeCheck (Expression *const op, const StaticContext::Ptr &context, const SequenceType::Ptr &reqType) |
static Expression::Ptr | verifyType (const Expression::Ptr &operand, const SequenceType::Ptr &reqSeqType, const StaticContext::Ptr &context, const ReportContext::ErrorCode code, const Options options) |
Implements the type checking and promotion part of the Function Conversion Rules. More... | |
static QString | wrongType (const NamePool::Ptr &np, const ItemType::Ptr &reqType, const ItemType::Ptr &opType) |
Centralizes a message-string to reduce work for translators and increase consistency. More... | |
Contains functions that applies Function Conversion Rules and other kinds of compile-time type checking tasks.
Definition at line 71 of file qtypechecker_p.h.
Definition at line 111 of file qtypechecker_p.h.
Enumerator | |
---|---|
AutomaticallyConvert | When set, the function conversion rules are applied. For instance, this is type promotion and conversions from |
CheckFocus | Whether the focus should be checked or not. Sometimes the focus is unknown at the time applyFunctionConversion() is called, and therefore it is of interest to post pone the check to later on. |
GeneratePromotion | When applyFunctionConversion() is passed AutomaticallyConvert and promotion is required, such as from However, when GeneratePromotion is set, code will be generated that performs this conversion regardless of what any receiver do. This is useful in the case where one Expression only pipes the result of another. The only known case of that as of this writing is when UserFunctionCallsite evaluates its body. |
Definition at line 74 of file qtypechecker_p.h.
|
inlineprivate |
No implementation is provided for this constructor. This class is not supposed to be instantiated.
|
static |
Builds a pipeline of artificial AST nodes that ensures operand
conforms to the type reqType
by applying the Function Conversion Rules.
This new Expression is returned, or, if no conversions were necessary, operand
as it is.
applyFunctionConversion() also performs various checks, such as if operand
needs the focus and that the focus is defined in the context
. These checks are largely guided by operand's
Expression::properties().
Definition at line 67 of file qtypechecker.cpp.
Referenced by QPatternist::Validate::create(), QPatternist::pushVariable(), QPatternist::resolveVariable(), QPatternist::TreatAs::typeCheck(), QPatternist::Path::typeCheck(), QPatternist::Expression::typeCheck(), QPatternist::typeCheckTemplateBody(), and QPatternist::yyparse().
|
staticprivate |
Determines whether type promotion is possible from one type to another. False is returned when a promotion is not possible or if a promotion is not needed(as when the types are identical), since that can be considered to not be type promotion.
true
if fromType
can be promoted to toType
. Definition at line 84 of file qtypechecker.cpp.
Referenced by verifyType().
|
inlinestaticprivate |
Definition at line 116 of file qtypechecker.cpp.
Referenced by verifyType().
|
staticprivate |
Implements the type checking and promotion part of the Function Conversion Rules.
Definition at line 123 of file qtypechecker.cpp.
Referenced by applyFunctionConversion().
|
inlinestaticprivate |
Centralizes a message-string to reduce work for translators and increase consistency.
Definition at line 59 of file qtypechecker.cpp.
Referenced by verifyType().