Qore Programming Language  0.9.16
CallReferenceNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  CallReferenceNode.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2020 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_FUNCTIONREFERENCENODE_H
33 
34 #define _QORE_FUNCTIONREFERENCENODE_H
35 
37 
40 private:
42 
44  DLLLOCAL virtual AbstractQoreNode* realCopy() const;
45 
47 
49  DLLLOCAL virtual bool is_equal_soft(const AbstractQoreNode* v, ExceptionSink* xsink) const;
50 
52 
54  DLLLOCAL virtual bool is_equal_hard(const AbstractQoreNode* v, ExceptionSink* xsink) const;
55 
56 protected:
58 
60  DLLLOCAL virtual QoreValue evalImpl(bool& needs_deref, ExceptionSink* xsink) const;
61 
63  DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type = NT_FUNCREF);
64 
65 public:
66  DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
67 
68  DLLLOCAL virtual ~AbstractCallReferenceNode();
69 
71 
73  DLLEXPORT virtual bool getAsBoolImpl() const;
74 
76 
82  DLLLOCAL virtual int getAsString(QoreString& str, int foff, ExceptionSink* xsink) const;
83 
85 
92  DLLLOCAL virtual QoreString* getAsString(bool& del, int foff, ExceptionSink* xsink) const;
93 
95  DLLLOCAL virtual const char* getTypeName() const;
96 
97  DLLLOCAL static const char* getStaticTypeName() {
98  return "call reference";
99  }
100 };
101 
102 class QoreFunction;
103 
106 public:
108  DLLEXPORT ResolvedCallReferenceNode();
109 
111  DLLEXPORT virtual ~ResolvedCallReferenceNode();
112 
114  DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval, qore_type_t n_type = NT_FUNCREF);
115 
117 
122  DLLLOCAL virtual QoreValue execValue(const QoreListNode* args, ExceptionSink* xsink) const = 0;
123 
125 
128  DLLEXPORT virtual QoreProgram* getProgram() const;
129 
131  DLLLOCAL virtual QoreFunction* getFunction() = 0;
132 
135  ref();
136  return const_cast<ResolvedCallReferenceNode*>(this);
137  }
138 
140  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
141 
143  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
144 
146  DLLEXPORT virtual AbstractQoreNode* realCopy() const;
147 
148  // must be defined but performs no action
149  DLLEXPORT virtual void parseInit(QoreValue& val, LocalVar *oflag, int pflag, int &lvids,
150  const QoreTypeInfo *&returnTypeInfo);
151 
152  // the following function must be defined, but is never called
153  DLLEXPORT virtual QoreValue evalImpl(bool& needs_deref, ExceptionSink* xsink) const;
154 };
155 
156 #endif
AbstractCallReferenceNode::evalImpl
virtual DLLLOCAL QoreValue evalImpl(bool &needs_deref, ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
ResolvedCallReferenceNode::refRefSelf
DLLLOCAL ResolvedCallReferenceNode * refRefSelf() const
references itself and returns this
Definition: CallReferenceNode.h:134
AbstractCallReferenceNode::getAsString
virtual DLLLOCAL int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const
concatenate the verbose string representation of the value to an existing QoreString
ResolvedCallReferenceNode::is_equal_soft
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
returns true if the other node is the same value
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:126
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
AbstractCallReferenceNode::getTypeName
virtual const DLLLOCAL char * getTypeName() const
returns the type name as a c string
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
NT_FUNCREF
const qore_type_t NT_FUNCREF
type value for AbstractCallReferenceNode
Definition: node_types.h:68
ResolvedCallReferenceNode::parseInit
virtual DLLEXPORT void parseInit(QoreValue &val, LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&returnTypeInfo)
for use by parse types to initialize them for execution during stage 1 parsing; not exported in the l...
AbstractCallReferenceNode::getAsBoolImpl
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns true
ResolvedCallReferenceNode::realCopy
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns this with the ref count inmcremented; not a real copy
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
ResolvedCallReferenceNode::evalImpl
virtual DLLEXPORT QoreValue evalImpl(bool &needs_deref, ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
ResolvedCallReferenceNode::ResolvedCallReferenceNode
DLLEXPORT ResolvedCallReferenceNode()
public exported constructor function
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
ResolvedCallReferenceNode::~ResolvedCallReferenceNode
virtual DLLEXPORT ~ResolvedCallReferenceNode()
public destructor function
ResolvedCallReferenceNode::getProgram
virtual DLLEXPORT QoreProgram * getProgram() const
returns a pointer to the QoreProgram object associated with this reference (can be nullptr)
ResolvedCallReferenceNode::execValue
virtual DLLLOCAL QoreValue execValue(const QoreListNode *args, ExceptionSink *xsink) const =0
pure virtual function for executing the function reference
ResolvedCallReferenceNode::getFunction
virtual DLLLOCAL QoreFunction * getFunction()=0
Returns the internal function object, if any; can return nullptr.
AbstractQoreNode::ref
DLLEXPORT void ref() const
increments the reference count
ResolvedCallReferenceNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
returns true if the other node is the same value
ResolvedCallReferenceNode
base class for resolved call references
Definition: CallReferenceNode.h:105
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
AbstractCallReferenceNode
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
AbstractCallReferenceNode::AbstractCallReferenceNode
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type=NT_FUNCREF)
protected constructor for subclasses that are not reference-counted