Qore Programming Language: include/qore/CallReferenceNode.h (6585) Source File

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CallReferenceNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 CallReferenceNode.h
4
5 Qore Programming Language
6
7 Copyright 2003 - 2013 David Nichols
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef _QORE_FUNCTIONREFERENCENODE_H
25
26 #define _QORE_FUNCTIONREFERENCENODE_H
27
29
31 class AbstractCallReferenceNode : public AbstractQoreNode {
32 private:
34
36 DLLLOCAL virtual AbstractQoreNode *realCopy() const;
37
39
41 DLLLOCAL virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
42
44
46 DLLLOCAL virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
47
48 protected:
50
52 DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
53
55
57 DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
58
60
62 DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
63
65
67 DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
68
70
72 DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
73
75
77 DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
78
80 DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval, bool n_there_can_be_only_one, qore_type_t n_type = NT_FUNCREF);
81
82 public:
83 DLLLOCAL AbstractCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
84
85 DLLLOCAL virtual ~AbstractCallReferenceNode();
86
88
90 DLLEXPORT virtual bool getAsBoolImpl() const;
91
93
99 DLLLOCAL virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
100
102
109 DLLLOCAL virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
110
112 DLLLOCAL virtual const char *getTypeName() const;
113
114 DLLLOCAL static const char *getStaticTypeName() {
115 return "call reference";
116 }
117 };
118
120 class ResolvedCallReferenceNode : public AbstractCallReferenceNode {
121 public:
123 DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval = false, qore_type_t n_type = NT_FUNCREF);
124
126
131 DLLLOCAL virtual AbstractQoreNode *exec(const QoreListNode *args, ExceptionSink *xsink) const = 0;
132
133 DLLLOCAL virtual int64 bigIntExec(const QoreListNode *args, ExceptionSink *xsink) const {
134 ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
135 return rv ? rv->getAsBigInt() : 0;
136 }
137
138 DLLLOCAL virtual int intExec(const QoreListNode *args, ExceptionSink *xsink) const {
139 ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
140 return rv ? rv->getAsInt() : 0;
141 }
142
143 DLLLOCAL virtual bool boolExec(const QoreListNode *args, ExceptionSink *xsink) const {
144 ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
145 return rv ? rv->getAsBool() : false;
146 }
147
148 DLLLOCAL virtual double floatExec(const QoreListNode *args, ExceptionSink *xsink) const {
149 ReferenceHolder<AbstractQoreNode> rv(exec(args, xsink), xsink);
150 return rv ? rv->getAsFloat() : 0.0;
151 }
152
154
157 DLLLOCAL virtual QoreProgram *getProgram() const;
158
159 DLLLOCAL virtual class QoreFunction *getFunction() = 0;
160
161 DLLLOCAL ResolvedCallReferenceNode *refRefSelf() const {
162 ref();
163 return const_cast<ResolvedCallReferenceNode *>(this);
164 }
165 };
166
167 #endif
ResolvedCallReferenceNode::getProgram
virtual DLLLOCAL QoreProgram * getProgram() const
returns a pointer to the QoreProgram object associated with this reference (can be 0) ...
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 ...
AbstractQoreNode::getAsBool
DLLEXPORT bool getAsBool() const
returns the boolean value of the object
ResolvedCallReferenceNode::exec
virtual DLLLOCAL AbstractQoreNode * exec(const QoreListNode *args, ExceptionSink *xsink) const =0
pure virtual function for executing the function reference
AbstractCallReferenceNode::getTypeName
virtual DLLLOCAL const char * getTypeName() const
returns the type name as a c string
AbstractQoreNode::getAsFloat
DLLEXPORT double getAsFloat() const
returns the float value of the object
AbstractCallReferenceNode::evalImpl
virtual DLLLOCAL AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
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
NT_FUNCREF
const qore_type_t NT_FUNCREF
type value for AbstractCallReferenceNode
Definition: node_types.h:63
AbstractCallReferenceNode::getAsBoolImpl
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns true ...
AbstractCallReferenceNode
base class for call references, reference-counted, dynamically allocated only
Definition: CallReferenceNode.h:31
AbstractCallReferenceNode::integerEvalImpl
virtual DLLLOCAL int integerEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
AbstractQoreNode::getAsInt
DLLEXPORT int getAsInt() const
returns the integer value of the object
AbstractQoreNode::getAsBigInt
DLLEXPORT int64 getAsBigInt() const
returns the 64-bit integer value of the object
qore_type_t
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:44
ResolvedCallReferenceNode::ResolvedCallReferenceNode
DLLLOCAL ResolvedCallReferenceNode(bool n_needs_eval=false, qore_type_t n_type=NT_FUNCREF)
constructor is not exported outside the library
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:95
AbstractQoreNode::ref
DLLEXPORT void ref() const
increments the reference count
AbstractCallReferenceNode::floatEvalImpl
virtual DLLLOCAL double floatEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:35
ResolvedCallReferenceNode
base class for resolved call references
Definition: CallReferenceNode.h:120
AbstractCallReferenceNode::boolEvalImpl
virtual DLLLOCAL bool boolEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
AbstractCallReferenceNode::bigIntEvalImpl
virtual DLLLOCAL int64 bigIntEvalImpl(ExceptionSink *xsink) const
this function should never be called for function references; this function should never be called di...
ReferenceHolder
a templated class to manage a reference count of an object that can throw a Qore-language exception w...
Definition: ReferenceHolder.h:43