Qore Programming Language  1.12.0
lvalue_ref.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  lvalue_ref.h
4 
5  POSIX thread library for Qore
6 
7  Qore Programming Language
8 
9  Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
10 
11  Permission is hereby granted, free of charge, to any person obtaining a
12  copy of this software and associated documentation files (the "Software"),
13  to deal in the Software without restriction, including without limitation
14  the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  and/or sell copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following conditions:
17 
18  The above copyright notice and this permission notice shall be included in
19  all copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  DEALINGS IN THE SOFTWARE.
28 
29  Note that the Qore library is released under a choice of three open-source
30  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31  information.
32 */
33 
34 #ifndef _QORE_INTERN_LVALUE_REF_H
35 #define _QORE_INTERN_LVALUE_REF_H
36 
37 class RSetHelper;
38 
39 class lvalue_ref {
40 public:
41  QoreValue vexp;
42  const QoreTypeInfo* typeInfo;
43  QoreObject* self;
44  QoreProgram* pgm;
45  const void* lvalue_id;
46  const qore_class_private* cls;
47 
48  DLLLOCAL lvalue_ref(QoreValue lvexp, const QoreTypeInfo* typeInfo, QoreObject* self, const void* lvid, const qore_class_private* cls);
49 
50  DLLLOCAL lvalue_ref(const lvalue_ref& old);
51 
52  DLLLOCAL ~lvalue_ref() {
53  //printd(5, "lvalue_ref::~lvalue_ref() this: %p vexp: %p self: %p pgm: %p\n", this, vexp, self, pgm);
54  if (self)
55  self->tDeref();
56  vexp.discard(nullptr);
57  }
58 
59  DLLLOCAL void del(ExceptionSink* xsink) {
60  //printd(5, "lvalue_ref::del() this: %p vexp: %p self: %p pgm: %p\n", this, vexp, self, pgm);
61  if (vexp) {
62  vexp.discard(nullptr);
63  vexp = QoreValue();
64  }
65  }
66 
67  DLLLOCAL const QoreTypeInfo* getLValueTypeInfo() const {
68  return QoreTypeInfo::getUniqueReturnComplexReference(typeInfo);
69  }
70 
71  // returns true if a lock error has occurred and the transaction should be aborted or restarted; the rsection lock is held when this function is called
72  DLLLOCAL bool scanReference(RSetHelper& rsh);
73 
74  // returns true if the object needs to be scanned for recursive references (ie could contain an object or closure or a container containing one of those)
75  DLLLOCAL bool needsScan();
76 
77  DLLLOCAL static lvalue_ref* get(const ReferenceNode* r) {
78  return r->priv;
79  }
80 
81  DLLLOCAL static bool scanNode(RSetHelper& rsh, QoreValue vexp);
82 };
83 
84 #endif
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:127
parse type: reference to a lvalue expression
Definition: ReferenceNode.h:45
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275
DLLEXPORT void discard(ExceptionSink *xsink)
dereferences any contained AbstractQoreNode pointer and sets to 0; does not modify other values