32 #ifndef _QORE_QORECASTOPERATORNODE_H
34 #define _QORE_QORECASTOPERATORNODE_H
36 class QoreParseCastOperatorNode :
public QoreSingleExpressionOperatorNode<> {
37 friend class QoreCastOperatorNode;
39 DLLLOCAL QoreParseCastOperatorNode(
const QoreProgramLocation* loc, QoreParseTypeInfo* pti,
QoreValue exp)
40 : QoreSingleExpressionOperatorNode<>(loc, exp), pti(pti) {
44 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
48 DLLLOCAL
virtual ~QoreParseCastOperatorNode() {
57 DLLLOCAL
virtual const char* getTypeName()
const {
58 return cast_str.getBuffer();
61 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
68 QoreParseTypeInfo* pti;
75 DLLLOCAL
virtual int parseInitImpl(
QoreValue& val, QoreParseContext& parse_context);
78 class QoreCastOperatorNode :
public QoreSingleExpressionOperatorNode<> {
80 DLLLOCAL QoreCastOperatorNode(
const QoreProgramLocation* loc,
QoreValue exp)
81 : QoreSingleExpressionOperatorNode<>(loc, exp) {
84 DLLLOCAL
virtual ~QoreCastOperatorNode() =
default;
88 return &QoreParseCastOperatorNode::cast_str;
92 str.
concat(&QoreParseCastOperatorNode::cast_str);
97 DLLLOCAL
virtual const char* getTypeName()
const {
98 return QoreParseCastOperatorNode::cast_str.getBuffer();
105 DLLLOCAL
virtual int parseInitImpl(
QoreValue& val, QoreParseContext& parse_context) {
110 class QoreClassCastOperatorNode :
public QoreCastOperatorNode {
112 DLLLOCAL QoreClassCastOperatorNode(
const QoreProgramLocation* loc,
const QoreClass* qc,
QoreValue exp,
114 : QoreCastOperatorNode(loc, exp), qc(qc), or_nothing(or_nothing) {
117 DLLLOCAL
virtual ~QoreClassCastOperatorNode() =
default;
119 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
120 return qc ? qc->getTypeInfo() : objectTypeInfo;
123 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
124 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
127 return new QoreClassCastOperatorNode(loc, qc, n_exp.release(), or_nothing);
140 class QoreHashDeclCastOperatorNode :
public QoreCastOperatorNode {
142 DLLLOCAL QoreHashDeclCastOperatorNode(
const QoreProgramLocation* loc,
const TypedHashDecl* hd,
QoreValue exp,
144 : QoreCastOperatorNode(loc, exp), hd(hd), or_nothing(or_nothing) {
147 DLLLOCAL
virtual ~QoreHashDeclCastOperatorNode() =
default;
149 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
150 return hd ? hd->getTypeInfo() : hashTypeInfo;
153 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
154 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
157 return new QoreHashDeclCastOperatorNode(loc, hd, n_exp.release(), or_nothing);
170 class QoreComplexHashCastOperatorNode :
public QoreCastOperatorNode {
172 DLLLOCAL QoreComplexHashCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
174 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
177 DLLLOCAL
virtual ~QoreComplexHashCastOperatorNode() =
default;
179 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
183 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
184 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
188 return new QoreComplexHashCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
195 const QoreTypeInfo* typeInfo;
201 class QoreComplexListCastOperatorNode :
public QoreCastOperatorNode {
203 DLLLOCAL QoreComplexListCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
205 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
208 DLLLOCAL
virtual ~QoreComplexListCastOperatorNode() =
default;
210 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
214 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink* xsink)
const {
215 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
218 return new QoreComplexListCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
225 const QoreTypeInfo* typeInfo;
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
defines a Qore-language class
Definition: QoreClass.h:249
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
DLLEXPORT void concat(const QoreString *str, ExceptionSink *xsink)
concatenates a string and converts encodings if necessary
typed hash declaration
Definition: TypedHashDecl.h:44
holds an object and dereferences it in the destructor
Definition: QoreValue.h:476
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275