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();
102 DLLLOCAL
virtual int parseInitImpl(
QoreValue& val, QoreParseContext& parse_context) {
107 class QoreClassCastOperatorNode :
public QoreCastOperatorNode {
109 DLLLOCAL QoreClassCastOperatorNode(
const QoreProgramLocation* loc,
const QoreClass* qc,
QoreValue exp,
111 : QoreCastOperatorNode(loc, exp), qc(qc), or_nothing(or_nothing) {
114 DLLLOCAL
virtual ~QoreClassCastOperatorNode() =
default;
116 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
117 return qc ? qc->getTypeInfo() : objectTypeInfo;
120 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
121 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
124 return new QoreClassCastOperatorNode(loc, qc, n_exp.release(), or_nothing);
134 class QoreHashDeclCastOperatorNode :
public QoreCastOperatorNode {
136 DLLLOCAL QoreHashDeclCastOperatorNode(
const QoreProgramLocation* loc,
const TypedHashDecl* hd,
QoreValue exp,
138 : QoreCastOperatorNode(loc, exp), hd(hd), or_nothing(or_nothing) {
141 DLLLOCAL
virtual ~QoreHashDeclCastOperatorNode() =
default;
143 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
144 return hd ? hd->getTypeInfo() : hashTypeInfo;
147 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
148 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
151 return new QoreHashDeclCastOperatorNode(loc, hd, n_exp.release(), or_nothing);
161 class QoreComplexHashCastOperatorNode :
public QoreCastOperatorNode {
163 DLLLOCAL QoreComplexHashCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
165 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
168 DLLLOCAL
virtual ~QoreComplexHashCastOperatorNode() =
default;
170 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
174 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
175 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
179 return new QoreComplexHashCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
183 const QoreTypeInfo* typeInfo;
189 class QoreComplexListCastOperatorNode :
public QoreCastOperatorNode {
191 DLLLOCAL QoreComplexListCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
193 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
196 DLLLOCAL
virtual ~QoreComplexListCastOperatorNode() =
default;
198 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
202 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink* xsink)
const {
203 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
206 return new QoreComplexListCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
210 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