CallReferenceNode.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
CallReferenceNode.h
Qore Programming Language
Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_FUNCTIONREFERENCENODE_H
#define _QORE_FUNCTIONREFERENCENODE_H
class AbstractCallReferenceNode : public AbstractQoreNode {
private:
DLLLOCAL virtual AbstractQoreNode* realCopy() const;
DLLLOCAL virtual bool is_equal_soft(const AbstractQoreNode* v, ExceptionSink* xsink) const;
DLLLOCAL virtual bool is_equal_hard(const AbstractQoreNode* v, ExceptionSink* xsink) const;
protected:
DLLLOCAL virtual QoreValue evalImpl(bool& needs_deref, ExceptionSink* xsink) const;
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one,
qore_type_t n_type = NT_FUNCREF);
public:
DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
DLLLOCAL virtual ~AbstractCallReferenceNode();
DLLEXPORT virtual bool getAsBoolImpl() const;
DLLLOCAL virtual int getAsString(QoreString& str, int foff, ExceptionSink* xsink) const;
DLLLOCAL virtual QoreString* getAsString(bool& del, int foff, ExceptionSink* xsink) const;
DLLLOCAL virtual const char* getTypeName() const;
DLLLOCAL static const char* getStaticTypeName() {
return "call reference";
}
};
class QoreFunction;
class ResolvedCallReferenceNode : public AbstractCallReferenceNode {
public:
DLLEXPORT ResolvedCallReferenceNode();
DLLEXPORT virtual ~ResolvedCallReferenceNode();
DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval, qore_type_t n_type = NT_FUNCREF);
DLLLOCAL virtual QoreValue execValue(const QoreListNode* args, ExceptionSink* xsink) const = 0;
DLLEXPORT virtual QoreProgram* getProgram() const;
DLLLOCAL virtual QoreFunction* getFunction() = 0;
DLLLOCAL ResolvedCallReferenceNode* refRefSelf() const {
ref();
return const_cast<ResolvedCallReferenceNode*>(this);
}
DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLEXPORT virtual AbstractQoreNode* realCopy() const;
// must be defined but performs no action
DLLEXPORT virtual int parseInit(QoreValue& val, QoreParseContext& parse_context);
// the following function must be defined, but is never called
DLLEXPORT virtual QoreValue evalImpl(bool& needs_deref, ExceptionSink* xsink) const;
};
#endif
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
AbstractCallReferenceNode::getAsBoolImpl
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns true ...
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
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...
NT_FUNCREF
const qore_type_t NT_FUNCREF
type value for AbstractCallReferenceNode
Definition: node_types.h:68
AbstractCallReferenceNode
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:39
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:93
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
ResolvedCallReferenceNode::getProgram
virtual DLLEXPORT QoreProgram * getProgram() const
returns a pointer to the QoreProgram object associated with this reference (can be nullptr) ...
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::realCopy
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns this with the ref count inmcremented; not a real copy
AbstractCallReferenceNode::getTypeName
virtual DLLLOCAL const char * getTypeName() const
returns the type name as a c string
ResolvedCallReferenceNode::execValue
virtual DLLLOCAL QoreValue execValue(const QoreListNode *args, ExceptionSink *xsink) const =0
pure virtual function for executing the function reference
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:127
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
ResolvedCallReferenceNode::ResolvedCallReferenceNode
DLLEXPORT ResolvedCallReferenceNode()
public exported constructor function
ResolvedCallReferenceNode::~ResolvedCallReferenceNode
virtual DLLEXPORT ~ResolvedCallReferenceNode()
public destructor function
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
AbstractQoreNode::ref
DLLEXPORT void ref() const
increments the reference count
ResolvedCallReferenceNode::getFunction
virtual DLLLOCAL QoreFunction * getFunction()=0
Returns the internal function object, if any; can return nullptr.
ResolvedCallReferenceNode
base class for resolved call references
Definition: CallReferenceNode.h:109
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:70
ResolvedCallReferenceNode::parseInit
virtual DLLEXPORT int parseInit(QoreValue &val, QoreParseContext &parse_context)
for use by parse types to initialize them for execution during stage 1 parsing
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::refRefSelf
DLLLOCAL ResolvedCallReferenceNode * refRefSelf() const
references itself and returns this
Definition: CallReferenceNode.h:138
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