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
void parseInitImpl(
QoreValue& val, LocalVar* oflag,
int pflag,
int& lvids,
const QoreTypeInfo*& typeInfo);
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
void parseInitImpl(
QoreValue& val, LocalVar* oflag,
int pflag,
int& lvids,
const QoreTypeInfo*& typeInfo) {
106 class QoreClassCastOperatorNode :
public QoreCastOperatorNode {
108 DLLLOCAL QoreClassCastOperatorNode(
const QoreProgramLocation* loc,
const QoreClass* qc,
QoreValue exp,
110 : QoreCastOperatorNode(loc, exp), qc(qc), or_nothing(or_nothing) {
113 DLLLOCAL
virtual ~QoreClassCastOperatorNode() =
default;
115 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
116 return qc ? qc->getTypeInfo() : objectTypeInfo;
119 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
120 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
123 return new QoreClassCastOperatorNode(loc, qc, n_exp.release(), or_nothing);
133 class QoreHashDeclCastOperatorNode :
public QoreCastOperatorNode {
135 DLLLOCAL QoreHashDeclCastOperatorNode(
const QoreProgramLocation* loc,
const TypedHashDecl* hd,
QoreValue exp,
137 : QoreCastOperatorNode(loc, exp), hd(hd), or_nothing(or_nothing) {
140 DLLLOCAL
virtual ~QoreHashDeclCastOperatorNode() =
default;
142 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
143 return hd ? hd->getTypeInfo() : hashTypeInfo;
146 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
147 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
150 return new QoreHashDeclCastOperatorNode(loc, hd, n_exp.release(), or_nothing);
160 class QoreComplexHashCastOperatorNode :
public QoreCastOperatorNode {
162 DLLLOCAL QoreComplexHashCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
164 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
167 DLLLOCAL
virtual ~QoreComplexHashCastOperatorNode() =
default;
169 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
173 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
174 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
178 return new QoreComplexHashCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
182 const QoreTypeInfo* typeInfo;
188 class QoreComplexListCastOperatorNode :
public QoreCastOperatorNode {
190 DLLLOCAL QoreComplexListCastOperatorNode(
const QoreProgramLocation* loc,
const QoreTypeInfo* typeInfo,
192 : QoreCastOperatorNode(loc, exp), typeInfo(typeInfo), or_nothing(or_nothing) {
195 DLLLOCAL
virtual ~QoreComplexListCastOperatorNode() =
default;
197 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
201 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink* xsink)
const {
202 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
205 return new QoreComplexListCastOperatorNode(loc, typeInfo, n_exp.release(), or_nothing);
209 const QoreTypeInfo* typeInfo;