32 #ifndef _QORE_QOREOPERATORNODE_H 33 #define _QORE_QOREOPERATORNODE_H 42 class QoreOperatorNode :
public ParseNode {
48 DLLLOCAL
virtual ~QoreOperatorNode() {}
50 DLLLOCAL
virtual void ignoreReturnValueImpl() {}
53 DLLLOCAL QoreOperatorNode(
const QoreProgramLocation* loc,
bool n_ref_rv =
true) : ParseNode(loc,
NT_OPERATOR), in_parentheses(false), ref_rv(n_ref_rv) {
57 DLLLOCAL
virtual const char *getTypeName()
const = 0;
59 DLLLOCAL
void ignoreReturnValue() {
61 ignoreReturnValueImpl();
64 DLLLOCAL
bool getInParentheses()
const {
65 return in_parentheses;
68 DLLLOCAL
void setInParentheses() {
69 in_parentheses =
true;
72 DLLLOCAL
virtual bool hasEffect()
const = 0;
73 DLLLOCAL
virtual bool hasEffectAsRoot()
const = 0;
75 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const = 0;
78 class LValueOperatorNode :
public QoreOperatorNode {
80 DLLLOCAL LValueOperatorNode(
const QoreProgramLocation* loc) : QoreOperatorNode(loc) {
83 DLLLOCAL
virtual bool hasEffect()
const {
87 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
91 DLLLOCAL
int checkLValue(
QoreValue exp,
int pflag,
bool assignment =
true) {
93 if (check_lvalue(exp, assignment)) {
94 parse_error(*loc,
"expecting lvalue for %s, got '%s' instead", getTypeName(), exp.getTypeName());
97 else if ((pflag & PF_BACKGROUND) && exp.getType() ==
NT_VARREF && exp.get<
const VarRefNode>()->getType() == VT_LOCAL) {
98 parse_error(*loc,
"illegal local variable modification with the background operator in %s", getTypeName());
106 template <
class T = QoreOperatorNode>
107 class QoreSingleExpressionOperatorNode :
public T {
111 DLLLOCAL ~QoreSingleExpressionOperatorNode() {
116 DLLLOCAL QoreSingleExpressionOperatorNode(
const QoreProgramLocation* loc,
QoreValue exp) : T(loc), exp(exp) {
130 DLLLOCAL QoreSingleExpressionOperatorNode* makeSpecialization() {
134 O* rv =
new O(this->loc, e);
136 rv->ignoreReturnValue();
140 DLLLOCAL
virtual bool hasEffect()
const {
141 return exp.hasEffect();
144 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
145 return dynamic_cast<const LValueOperatorNode*
>(
this);
149 DLLLOCAL O* copyBackgroundExplicit(
ExceptionSink* xsink)
const {
150 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
153 return new O(this->loc, n_exp.release());
157 template <
class T = QoreOperatorNode>
158 class QoreSingleValueExpressionOperatorNode :
public T {
162 DLLLOCAL ~QoreSingleValueExpressionOperatorNode() {
167 DLLLOCAL QoreSingleValueExpressionOperatorNode(
const QoreProgramLocation* loc,
QoreValue exp) : T(loc), exp(exp) {
181 DLLLOCAL QoreSingleValueExpressionOperatorNode* makeSpecialization() {
185 O* rv =
new O(this->loc, e);
187 rv->ignoreReturnValue();
191 DLLLOCAL
virtual bool hasEffect()
const {
192 return exp.hasEffect();
195 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
196 return dynamic_cast<const LValueOperatorNode*
>(
this);
200 DLLLOCAL O* copyBackgroundExplicit(
ExceptionSink* xsink)
const {
201 ValueHolder n_exp(copy_value_and_resolve_lvar_refs(exp, xsink), xsink);
204 return new O(this->loc, n_exp.release());
208 template <
class T = QoreOperatorNode>
209 class QoreBinaryOperatorNode :
public T {
214 DLLLOCAL QoreBinaryOperatorNode(
const QoreProgramLocation* loc,
QoreValue left,
QoreValue right) : T(loc), left(left), right(right) {
217 DLLLOCAL ~QoreBinaryOperatorNode() {
223 DLLLOCAL QoreBinaryOperatorNode* makeSpecialization() {
227 U* rv =
new U(this->loc, l, r);
229 rv->ignoreReturnValue();
253 DLLLOCAL
virtual bool hasEffect()
const {
254 return left.hasEffect() || right.hasEffect();
257 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
258 return dynamic_cast<const LValueOperatorNode*
>(
this);
262 DLLLOCAL O* copyBackgroundExplicit(
ExceptionSink* xsink)
const {
263 ValueHolder n_left(copy_value_and_resolve_lvar_refs(left, xsink), xsink);
266 ValueHolder n_right(copy_value_and_resolve_lvar_refs(right, xsink), xsink);
269 return new O(this->loc, n_left.release(), n_right.release());
273 class QoreBoolBinaryOperatorNode :
public QoreBinaryOperatorNode<> {
275 DLLLOCAL QoreBoolBinaryOperatorNode(
const QoreProgramLocation* loc,
QoreValue left,
QoreValue right) : QoreBinaryOperatorNode<>(loc, left, right) {
278 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
283 class QoreIntBinaryOperatorNode :
public QoreBinaryOperatorNode<> {
285 DLLLOCAL QoreIntBinaryOperatorNode(
const QoreProgramLocation* loc,
QoreValue left,
QoreValue right) : QoreBinaryOperatorNode<>(loc, left, right) {
288 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
289 return bigIntTypeInfo;
293 #define OP_COMMON protected:\ 294 DLLLOCAL static QoreString op_str;\ 296 DLLLOCAL virtual QoreString* getAsString(bool& del, int foff, ExceptionSink* xsink) const {del = false;return &op_str;}\ 297 DLLLOCAL virtual int getAsString(QoreString& str, int foff, ExceptionSink* xsink) const {str.concat(&op_str);return 0;}\ 298 DLLLOCAL virtual const char* getTypeName() const {return op_str.getBuffer();} 300 template <
unsigned int N,
class T = QoreOperatorNode>
301 class QoreNOperatorNodeBase :
public T {
305 DLLLOCAL
virtual ~QoreNOperatorNodeBase() {
306 for (
unsigned i = 0; i < N; ++i) {
312 DLLLOCAL QoreNOperatorNodeBase(
const QoreProgramLocation* loc,
QoreValue a0, ...) : T(loc) {
316 for (
unsigned int i = 1; i < N; ++i)
317 e[i] = va_arg(ap, QoreSimpleValue);
321 DLLLOCAL
QoreValue get(
unsigned i)
const {
326 DLLLOCAL
virtual bool hasEffect()
const {
327 for (
unsigned int i = 0; i < N; ++i)
328 if (e[i].hasEffect())
333 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
334 return dynamic_cast<const LValueOperatorNode*
>(
this);
339 #include "qore/intern/QoreDeleteOperatorNode.h" 340 #include "qore/intern/QoreRemoveOperatorNode.h" 341 #include "qore/intern/QoreSpliceOperatorNode.h" 342 #include "qore/intern/QoreExtractOperatorNode.h" 343 #include "qore/intern/QoreCastOperatorNode.h" 344 #include "qore/intern/QoreKeysOperatorNode.h" 345 #include "qore/intern/QoreUnaryMinusOperatorNode.h" 346 #include "qore/intern/QoreUnaryPlusOperatorNode.h" 347 #include "qore/intern/QoreLogicalNotOperatorNode.h" 348 #include "qore/intern/QoreDotEvalOperatorNode.h" 349 #include "qore/intern/QoreLogicalEqualsOperatorNode.h" 350 #include "qore/intern/QoreLogicalAbsoluteEqualsOperatorNode.h" 351 #include "qore/intern/QoreLogicalNotEqualsOperatorNode.h" 352 #include "qore/intern/QoreLogicalAbsoluteNotEqualsOperatorNode.h" 353 #include "qore/intern/QoreModuloOperatorNode.h" 354 #include "qore/intern/QoreBinaryAndOperatorNode.h" 355 #include "qore/intern/QoreBinaryOrOperatorNode.h" 356 #include "qore/intern/QoreBinaryXorOperatorNode.h" 357 #include "qore/intern/QoreBinaryNotOperatorNode.h" 358 #include "qore/intern/QoreShiftLeftOperatorNode.h" 359 #include "qore/intern/QoreShiftRightOperatorNode.h" 360 #include "qore/intern/QoreExistsOperatorNode.h" 361 #include "qore/intern/QoreElementsOperatorNode.h" 362 #include "qore/intern/QoreInstanceOfOperatorNode.h" 363 #include "qore/intern/QoreHashObjectDereferenceOperatorNode.h" 364 #include "qore/intern/QoreRegexMatchOperatorNode.h" 365 #include "qore/intern/QoreRegexNMatchOperatorNode.h" 366 #include "qore/intern/QoreRegexExtractOperatorNode.h" 367 #include "qore/intern/QoreRegexSubstOperatorNode.h" 368 #include "qore/intern/QoreTransliterationOperatorNode.h" 369 #include "qore/intern/QoreBinaryLValueOperatorNode.h" 370 #include "qore/intern/QoreAssignmentOperatorNode.h" 371 #include "qore/intern/QoreListAssignmentOperatorNode.h" 372 #include "qore/intern/QorePlusEqualsOperatorNode.h" 373 #include "qore/intern/QoreIntPlusEqualsOperatorNode.h" 374 #include "qore/intern/QoreMinusEqualsOperatorNode.h" 375 #include "qore/intern/QoreIntMinusEqualsOperatorNode.h" 376 #include "qore/intern/QoreOrEqualsOperatorNode.h" 377 #include "qore/intern/QoreAndEqualsOperatorNode.h" 378 #include "qore/intern/QoreModuloEqualsOperatorNode.h" 379 #include "qore/intern/QoreMultiplyEqualsOperatorNode.h" 380 #include "qore/intern/QoreDivideEqualsOperatorNode.h" 381 #include "qore/intern/QoreXorEqualsOperatorNode.h" 382 #include "qore/intern/QoreShiftLeftEqualsOperatorNode.h" 383 #include "qore/intern/QoreShiftRightEqualsOperatorNode.h" 384 #include "qore/intern/QorePostIncrementOperatorNode.h" 385 #include "qore/intern/QoreIntPostIncrementOperatorNode.h" 386 #include "qore/intern/QorePostDecrementOperatorNode.h" 387 #include "qore/intern/QoreIntPostDecrementOperatorNode.h" 388 #include "qore/intern/QorePreIncrementOperatorNode.h" 389 #include "qore/intern/QoreIntPreIncrementOperatorNode.h" 390 #include "qore/intern/QorePreDecrementOperatorNode.h" 391 #include "qore/intern/QoreIntPreDecrementOperatorNode.h" 392 #include "qore/intern/QoreLogicalLessThanOperatorNode.h" 393 #include "qore/intern/QoreLogicalGreaterThanOrEqualsOperatorNode.h" 394 #include "qore/intern/QoreLogicalGreaterThanOperatorNode.h" 395 #include "qore/intern/QoreLogicalLessThanOrEqualsOperatorNode.h" 396 #include "qore/intern/QoreDivisionOperatorNode.h" 397 #include "qore/intern/QoreQuestionMarkOperatorNode.h" 398 #include "qore/intern/QoreMapOperatorNode.h" 399 #include "qore/intern/QoreMapSelectOperatorNode.h" 400 #include "qore/intern/QoreHashMapOperatorNode.h" 401 #include "qore/intern/QoreHashMapSelectOperatorNode.h" 402 #include "qore/intern/QoreFoldlOperatorNode.h" 403 #include "qore/intern/QoreSelectOperatorNode.h" 404 #include "qore/intern/QoreNullCoalescingOperatorNode.h" 405 #include "qore/intern/QoreValueCoalescingOperatorNode.h" 406 #include "qore/intern/QoreChompOperatorNode.h" 407 #include "qore/intern/QoreTrimOperatorNode.h" 408 #include "qore/intern/QoreSquareBracketsOperatorNode.h" 409 #include "qore/intern/QoreShiftOperatorNode.h" 410 #include "qore/intern/QoreUnshiftOperatorNode.h" 411 #include "qore/intern/QorePopOperatorNode.h" 412 #include "qore/intern/QorePushOperatorNode.h" 413 #include "qore/intern/QoreLogicalAndOperatorNode.h" 414 #include "qore/intern/QoreLogicalOrOperatorNode.h" 415 #include "qore/intern/QoreLogicalComparisonOperatorNode.h" 416 #include "qore/intern/QorePlusOperatorNode.h" 417 #include "qore/intern/QoreMinusOperatorNode.h" 418 #include "qore/intern/QoreMultiplicationOperatorNode.h" 419 #include "qore/intern/QoreBackgroundOperatorNode.h" 420 #include "qore/intern/QoreRangeOperatorNode.h" 421 #include "qore/intern/QoreSquareBracketsRangeOperatorNode.h" const qore_type_t NT_VARREF
type value for VarRefNode
Definition: node_types.h:56
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
manages a reference count of a pointer to a class that takes a simple "deref()" call with no argument...
Definition: ReferenceHolder.h:118
const qore_type_t NT_OPERATOR
type value for QoreOperatorNode (private class)
Definition: node_types.h:76
holds an object and dereferences it in the destructor
Definition: QoreValue.h:452
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values ...